babylon.d.ts 2.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083
  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. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module BABYLON {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module BABYLON {
  256. /**
  257. * Constant used to convert a value to gamma space
  258. * @ignorenaming
  259. */
  260. export const ToGammaSpace: number;
  261. /**
  262. * Constant used to convert a value to linear space
  263. * @ignorenaming
  264. */
  265. export const ToLinearSpace = 2.2;
  266. /**
  267. * Constant used to define the minimal number value in Babylon.js
  268. * @ignorenaming
  269. */
  270. let Epsilon: number;
  271. /**
  272. * Class used to hold a RBG color
  273. */
  274. export class Color3 {
  275. /**
  276. * Defines the red component (between 0 and 1, default is 0)
  277. */
  278. r: number;
  279. /**
  280. * Defines the green component (between 0 and 1, default is 0)
  281. */
  282. g: number;
  283. /**
  284. * Defines the blue component (between 0 and 1, default is 0)
  285. */
  286. b: number;
  287. /**
  288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  289. * @param r defines the red component (between 0 and 1, default is 0)
  290. * @param g defines the green component (between 0 and 1, default is 0)
  291. * @param b defines the blue component (between 0 and 1, default is 0)
  292. */
  293. constructor(
  294. /**
  295. * Defines the red component (between 0 and 1, default is 0)
  296. */
  297. r?: number,
  298. /**
  299. * Defines the green component (between 0 and 1, default is 0)
  300. */
  301. g?: number,
  302. /**
  303. * Defines the blue component (between 0 and 1, default is 0)
  304. */
  305. b?: number);
  306. /**
  307. * Creates a string with the Color3 current values
  308. * @returns the string representation of the Color3 object
  309. */
  310. toString(): string;
  311. /**
  312. * Returns the string "Color3"
  313. * @returns "Color3"
  314. */
  315. getClassName(): string;
  316. /**
  317. * Compute the Color3 hash code
  318. * @returns an unique number that can be used to hash Color3 objects
  319. */
  320. getHashCode(): number;
  321. /**
  322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  323. * @param array defines the array where to store the r,g,b components
  324. * @param index defines an optional index in the target array to define where to start storing values
  325. * @returns the current Color3 object
  326. */
  327. toArray(array: FloatArray, index?: number): Color3;
  328. /**
  329. * Returns a new Color4 object from the current Color3 and the given alpha
  330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  331. * @returns a new Color4 object
  332. */
  333. toColor4(alpha?: number): Color4;
  334. /**
  335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  336. * @returns the new array
  337. */
  338. asArray(): number[];
  339. /**
  340. * Returns the luminance value
  341. * @returns a float value
  342. */
  343. toLuminance(): number;
  344. /**
  345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  346. * @param otherColor defines the second operand
  347. * @returns the new Color3 object
  348. */
  349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  350. /**
  351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  352. * @param otherColor defines the second operand
  353. * @param result defines the Color3 object where to store the result
  354. * @returns the current Color3
  355. */
  356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  357. /**
  358. * Determines equality between Color3 objects
  359. * @param otherColor defines the second operand
  360. * @returns true if the rgb values are equal to the given ones
  361. */
  362. equals(otherColor: DeepImmutable<Color3>): boolean;
  363. /**
  364. * Determines equality between the current Color3 object and a set of r,b,g values
  365. * @param r defines the red component to check
  366. * @param g defines the green component to check
  367. * @param b defines the blue component to check
  368. * @returns true if the rgb values are equal to the given ones
  369. */
  370. equalsFloats(r: number, g: number, b: number): boolean;
  371. /**
  372. * Multiplies in place each rgb value by scale
  373. * @param scale defines the scaling factor
  374. * @returns the updated Color3
  375. */
  376. scale(scale: number): Color3;
  377. /**
  378. * Multiplies the rgb values by scale and stores the result into "result"
  379. * @param scale defines the scaling factor
  380. * @param result defines the Color3 object where to store the result
  381. * @returns the unmodified current Color3
  382. */
  383. scaleToRef(scale: number, result: Color3): Color3;
  384. /**
  385. * Scale the current Color3 values by a factor and add the result to a given Color3
  386. * @param scale defines the scale factor
  387. * @param result defines color to store the result into
  388. * @returns the unmodified current Color3
  389. */
  390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  391. /**
  392. * Clamps the rgb values by the min and max values and stores the result into "result"
  393. * @param min defines minimum clamping value (default is 0)
  394. * @param max defines maximum clamping value (default is 1)
  395. * @param result defines color to store the result into
  396. * @returns the original Color3
  397. */
  398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  399. /**
  400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  401. * @param otherColor defines the second operand
  402. * @returns the new Color3
  403. */
  404. add(otherColor: DeepImmutable<Color3>): Color3;
  405. /**
  406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  407. * @param otherColor defines the second operand
  408. * @param result defines Color3 object to store the result into
  409. * @returns the unmodified current Color3
  410. */
  411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  412. /**
  413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  414. * @param otherColor defines the second operand
  415. * @returns the new Color3
  416. */
  417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  418. /**
  419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  420. * @param otherColor defines the second operand
  421. * @param result defines Color3 object to store the result into
  422. * @returns the unmodified current Color3
  423. */
  424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  425. /**
  426. * Copy the current object
  427. * @returns a new Color3 copied the current one
  428. */
  429. clone(): Color3;
  430. /**
  431. * Copies the rgb values from the source in the current Color3
  432. * @param source defines the source Color3 object
  433. * @returns the updated Color3 object
  434. */
  435. copyFrom(source: DeepImmutable<Color3>): Color3;
  436. /**
  437. * Updates the Color3 rgb values from the given floats
  438. * @param r defines the red component to read from
  439. * @param g defines the green component to read from
  440. * @param b defines the blue component to read from
  441. * @returns the current Color3 object
  442. */
  443. copyFromFloats(r: number, g: number, b: number): Color3;
  444. /**
  445. * Updates the Color3 rgb values from the given floats
  446. * @param r defines the red component to read from
  447. * @param g defines the green component to read from
  448. * @param b defines the blue component to read from
  449. * @returns the current Color3 object
  450. */
  451. set(r: number, g: number, b: number): Color3;
  452. /**
  453. * Compute the Color3 hexadecimal code as a string
  454. * @returns a string containing the hexadecimal representation of the Color3 object
  455. */
  456. toHexString(): string;
  457. /**
  458. * Computes a new Color3 converted from the current one to linear space
  459. * @returns a new Color3 object
  460. */
  461. toLinearSpace(): Color3;
  462. /**
  463. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  464. * @param convertedColor defines the Color3 object where to store the linear space version
  465. * @returns the unmodified Color3
  466. */
  467. toLinearSpaceToRef(convertedColor: Color3): Color3;
  468. /**
  469. * Computes a new Color3 converted from the current one to gamma space
  470. * @returns a new Color3 object
  471. */
  472. toGammaSpace(): Color3;
  473. /**
  474. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  475. * @param convertedColor defines the Color3 object where to store the gamma space version
  476. * @returns the unmodified Color3
  477. */
  478. toGammaSpaceToRef(convertedColor: Color3): Color3;
  479. private static _BlackReadOnly;
  480. /**
  481. * Creates a new Color3 from the string containing valid hexadecimal values
  482. * @param hex defines a string containing valid hexadecimal values
  483. * @returns a new Color3 object
  484. */
  485. static FromHexString(hex: string): Color3;
  486. /**
  487. * Creates a new Color3 from the starting index of the given array
  488. * @param array defines the source array
  489. * @param offset defines an offset in the source array
  490. * @returns a new Color3 object
  491. */
  492. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  493. /**
  494. * Creates a new Color3 from integer values (< 256)
  495. * @param r defines the red component to read from (value between 0 and 255)
  496. * @param g defines the green component to read from (value between 0 and 255)
  497. * @param b defines the blue component to read from (value between 0 and 255)
  498. * @returns a new Color3 object
  499. */
  500. static FromInts(r: number, g: number, b: number): Color3;
  501. /**
  502. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  503. * @param start defines the start Color3 value
  504. * @param end defines the end Color3 value
  505. * @param amount defines the gradient value between start and end
  506. * @returns a new Color3 object
  507. */
  508. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  509. /**
  510. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  511. * @param left defines the start value
  512. * @param right defines the end value
  513. * @param amount defines the gradient factor
  514. * @param result defines the Color3 object where to store the result
  515. */
  516. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  517. /**
  518. * Returns a Color3 value containing a red color
  519. * @returns a new Color3 object
  520. */
  521. static Red(): Color3;
  522. /**
  523. * Returns a Color3 value containing a green color
  524. * @returns a new Color3 object
  525. */
  526. static Green(): Color3;
  527. /**
  528. * Returns a Color3 value containing a blue color
  529. * @returns a new Color3 object
  530. */
  531. static Blue(): Color3;
  532. /**
  533. * Returns a Color3 value containing a black color
  534. * @returns a new Color3 object
  535. */
  536. static Black(): Color3;
  537. /**
  538. * Gets a Color3 value containing a black color that must not be updated
  539. */
  540. static readonly BlackReadOnly: DeepImmutable<Color3>;
  541. /**
  542. * Returns a Color3 value containing a white color
  543. * @returns a new Color3 object
  544. */
  545. static White(): Color3;
  546. /**
  547. * Returns a Color3 value containing a purple color
  548. * @returns a new Color3 object
  549. */
  550. static Purple(): Color3;
  551. /**
  552. * Returns a Color3 value containing a magenta color
  553. * @returns a new Color3 object
  554. */
  555. static Magenta(): Color3;
  556. /**
  557. * Returns a Color3 value containing a yellow color
  558. * @returns a new Color3 object
  559. */
  560. static Yellow(): Color3;
  561. /**
  562. * Returns a Color3 value containing a gray color
  563. * @returns a new Color3 object
  564. */
  565. static Gray(): Color3;
  566. /**
  567. * Returns a Color3 value containing a teal color
  568. * @returns a new Color3 object
  569. */
  570. static Teal(): Color3;
  571. /**
  572. * Returns a Color3 value containing a random color
  573. * @returns a new Color3 object
  574. */
  575. static Random(): Color3;
  576. }
  577. /**
  578. * Class used to hold a RBGA color
  579. */
  580. export class Color4 {
  581. /**
  582. * Defines the red component (between 0 and 1, default is 0)
  583. */
  584. r: number;
  585. /**
  586. * Defines the green component (between 0 and 1, default is 0)
  587. */
  588. g: number;
  589. /**
  590. * Defines the blue component (between 0 and 1, default is 0)
  591. */
  592. b: number;
  593. /**
  594. * Defines the alpha component (between 0 and 1, default is 1)
  595. */
  596. a: number;
  597. /**
  598. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  599. * @param r defines the red component (between 0 and 1, default is 0)
  600. * @param g defines the green component (between 0 and 1, default is 0)
  601. * @param b defines the blue component (between 0 and 1, default is 0)
  602. * @param a defines the alpha component (between 0 and 1, default is 1)
  603. */
  604. constructor(
  605. /**
  606. * Defines the red component (between 0 and 1, default is 0)
  607. */
  608. r?: number,
  609. /**
  610. * Defines the green component (between 0 and 1, default is 0)
  611. */
  612. g?: number,
  613. /**
  614. * Defines the blue component (between 0 and 1, default is 0)
  615. */
  616. b?: number,
  617. /**
  618. * Defines the alpha component (between 0 and 1, default is 1)
  619. */
  620. a?: number);
  621. /**
  622. * Adds in place the given Color4 values to the current Color4 object
  623. * @param right defines the second operand
  624. * @returns the current updated Color4 object
  625. */
  626. addInPlace(right: DeepImmutable<Color4>): Color4;
  627. /**
  628. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  629. * @returns the new array
  630. */
  631. asArray(): number[];
  632. /**
  633. * Stores from the starting index in the given array the Color4 successive values
  634. * @param array defines the array where to store the r,g,b components
  635. * @param index defines an optional index in the target array to define where to start storing values
  636. * @returns the current Color4 object
  637. */
  638. toArray(array: number[], index?: number): Color4;
  639. /**
  640. * Determines equality between Color4 objects
  641. * @param otherColor defines the second operand
  642. * @returns true if the rgba values are equal to the given ones
  643. */
  644. equals(otherColor: DeepImmutable<Color4>): boolean;
  645. /**
  646. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  647. * @param right defines the second operand
  648. * @returns a new Color4 object
  649. */
  650. add(right: DeepImmutable<Color4>): Color4;
  651. /**
  652. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  653. * @param right defines the second operand
  654. * @returns a new Color4 object
  655. */
  656. subtract(right: DeepImmutable<Color4>): Color4;
  657. /**
  658. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  659. * @param right defines the second operand
  660. * @param result defines the Color4 object where to store the result
  661. * @returns the current Color4 object
  662. */
  663. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  664. /**
  665. * Creates a new Color4 with the current Color4 values multiplied by scale
  666. * @param scale defines the scaling factor to apply
  667. * @returns a new Color4 object
  668. */
  669. scale(scale: number): Color4;
  670. /**
  671. * Multiplies the current Color4 values by scale and stores the result in "result"
  672. * @param scale defines the scaling factor to apply
  673. * @param result defines the Color4 object where to store the result
  674. * @returns the current unmodified Color4
  675. */
  676. scaleToRef(scale: number, result: Color4): Color4;
  677. /**
  678. * Scale the current Color4 values by a factor and add the result to a given Color4
  679. * @param scale defines the scale factor
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the unmodified current Color4
  682. */
  683. scaleAndAddToRef(scale: number, result: Color4): Color4;
  684. /**
  685. * Clamps the rgb values by the min and max values and stores the result into "result"
  686. * @param min defines minimum clamping value (default is 0)
  687. * @param max defines maximum clamping value (default is 1)
  688. * @param result defines color to store the result into.
  689. * @returns the cuurent Color4
  690. */
  691. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  692. /**
  693. * Multipy an Color4 value by another and return a new Color4 object
  694. * @param color defines the Color4 value to multiply by
  695. * @returns a new Color4 object
  696. */
  697. multiply(color: Color4): Color4;
  698. /**
  699. * Multipy a Color4 value by another and push the result in a reference value
  700. * @param color defines the Color4 value to multiply by
  701. * @param result defines the Color4 to fill the result in
  702. * @returns the result Color4
  703. */
  704. multiplyToRef(color: Color4, result: Color4): Color4;
  705. /**
  706. * Creates a string with the Color4 current values
  707. * @returns the string representation of the Color4 object
  708. */
  709. toString(): string;
  710. /**
  711. * Returns the string "Color4"
  712. * @returns "Color4"
  713. */
  714. getClassName(): string;
  715. /**
  716. * Compute the Color4 hash code
  717. * @returns an unique number that can be used to hash Color4 objects
  718. */
  719. getHashCode(): number;
  720. /**
  721. * Creates a new Color4 copied from the current one
  722. * @returns a new Color4 object
  723. */
  724. clone(): Color4;
  725. /**
  726. * Copies the given Color4 values into the current one
  727. * @param source defines the source Color4 object
  728. * @returns the current updated Color4 object
  729. */
  730. copyFrom(source: Color4): Color4;
  731. /**
  732. * Copies the given float values into the current one
  733. * @param r defines the red component to read from
  734. * @param g defines the green component to read from
  735. * @param b defines the blue component to read from
  736. * @param a defines the alpha component to read from
  737. * @returns the current updated Color4 object
  738. */
  739. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  740. /**
  741. * Copies the given float values into the current one
  742. * @param r defines the red component to read from
  743. * @param g defines the green component to read from
  744. * @param b defines the blue component to read from
  745. * @param a defines the alpha component to read from
  746. * @returns the current updated Color4 object
  747. */
  748. set(r: number, g: number, b: number, a: number): Color4;
  749. /**
  750. * Compute the Color4 hexadecimal code as a string
  751. * @returns a string containing the hexadecimal representation of the Color4 object
  752. */
  753. toHexString(): string;
  754. /**
  755. * Computes a new Color4 converted from the current one to linear space
  756. * @returns a new Color4 object
  757. */
  758. toLinearSpace(): Color4;
  759. /**
  760. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  761. * @param convertedColor defines the Color4 object where to store the linear space version
  762. * @returns the unmodified Color4
  763. */
  764. toLinearSpaceToRef(convertedColor: Color4): Color4;
  765. /**
  766. * Computes a new Color4 converted from the current one to gamma space
  767. * @returns a new Color4 object
  768. */
  769. toGammaSpace(): Color4;
  770. /**
  771. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  772. * @param convertedColor defines the Color4 object where to store the gamma space version
  773. * @returns the unmodified Color4
  774. */
  775. toGammaSpaceToRef(convertedColor: Color4): Color4;
  776. /**
  777. * Creates a new Color4 from the string containing valid hexadecimal values
  778. * @param hex defines a string containing valid hexadecimal values
  779. * @returns a new Color4 object
  780. */
  781. static FromHexString(hex: string): Color4;
  782. /**
  783. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  784. * @param left defines the start value
  785. * @param right defines the end value
  786. * @param amount defines the gradient factor
  787. * @returns a new Color4 object
  788. */
  789. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  790. /**
  791. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  792. * @param left defines the start value
  793. * @param right defines the end value
  794. * @param amount defines the gradient factor
  795. * @param result defines the Color4 object where to store data
  796. */
  797. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  798. /**
  799. * Creates a new Color4 from a Color3 and an alpha value
  800. * @param color3 defines the source Color3 to read from
  801. * @param alpha defines the alpha component (1.0 by default)
  802. * @returns a new Color4 object
  803. */
  804. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  805. /**
  806. * Creates a new Color4 from the starting index element of the given array
  807. * @param array defines the source array to read from
  808. * @param offset defines the offset in the source array
  809. * @returns a new Color4 object
  810. */
  811. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  812. /**
  813. * Creates a new Color3 from integer values (< 256)
  814. * @param r defines the red component to read from (value between 0 and 255)
  815. * @param g defines the green component to read from (value between 0 and 255)
  816. * @param b defines the blue component to read from (value between 0 and 255)
  817. * @param a defines the alpha component to read from (value between 0 and 255)
  818. * @returns a new Color3 object
  819. */
  820. static FromInts(r: number, g: number, b: number, a: number): Color4;
  821. /**
  822. * Check the content of a given array and convert it to an array containing RGBA data
  823. * If the original array was already containing count * 4 values then it is returned directly
  824. * @param colors defines the array to check
  825. * @param count defines the number of RGBA data to expect
  826. * @returns an array containing count * 4 values (RGBA)
  827. */
  828. static CheckColors4(colors: number[], count: number): number[];
  829. }
  830. /**
  831. * Class representing a vector containing 2 coordinates
  832. */
  833. export class Vector2 {
  834. /** defines the first coordinate */
  835. x: number;
  836. /** defines the second coordinate */
  837. y: number;
  838. /**
  839. * Creates a new Vector2 from the given x and y coordinates
  840. * @param x defines the first coordinate
  841. * @param y defines the second coordinate
  842. */
  843. constructor(
  844. /** defines the first coordinate */
  845. x?: number,
  846. /** defines the second coordinate */
  847. y?: number);
  848. /**
  849. * Gets a string with the Vector2 coordinates
  850. * @returns a string with the Vector2 coordinates
  851. */
  852. toString(): string;
  853. /**
  854. * Gets class name
  855. * @returns the string "Vector2"
  856. */
  857. getClassName(): string;
  858. /**
  859. * Gets current vector hash code
  860. * @returns the Vector2 hash code as a number
  861. */
  862. getHashCode(): number;
  863. /**
  864. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  865. * @param array defines the source array
  866. * @param index defines the offset in source array
  867. * @returns the current Vector2
  868. */
  869. toArray(array: FloatArray, index?: number): Vector2;
  870. /**
  871. * Copy the current vector to an array
  872. * @returns a new array with 2 elements: the Vector2 coordinates.
  873. */
  874. asArray(): number[];
  875. /**
  876. * Sets the Vector2 coordinates with the given Vector2 coordinates
  877. * @param source defines the source Vector2
  878. * @returns the current updated Vector2
  879. */
  880. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  881. /**
  882. * Sets the Vector2 coordinates with the given floats
  883. * @param x defines the first coordinate
  884. * @param y defines the second coordinate
  885. * @returns the current updated Vector2
  886. */
  887. copyFromFloats(x: number, y: number): Vector2;
  888. /**
  889. * Sets the Vector2 coordinates with the given floats
  890. * @param x defines the first coordinate
  891. * @param y defines the second coordinate
  892. * @returns the current updated Vector2
  893. */
  894. set(x: number, y: number): Vector2;
  895. /**
  896. * Add another vector with the current one
  897. * @param otherVector defines the other vector
  898. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  899. */
  900. add(otherVector: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  903. * @param otherVector defines the other vector
  904. * @param result defines the target vector
  905. * @returns the unmodified current Vector2
  906. */
  907. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  908. /**
  909. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  910. * @param otherVector defines the other vector
  911. * @returns the current updated Vector2
  912. */
  913. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  916. * @param otherVector defines the other vector
  917. * @returns a new Vector2
  918. */
  919. addVector3(otherVector: Vector3): Vector2;
  920. /**
  921. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  922. * @param otherVector defines the other vector
  923. * @returns a new Vector2
  924. */
  925. subtract(otherVector: Vector2): Vector2;
  926. /**
  927. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  928. * @param otherVector defines the other vector
  929. * @param result defines the target vector
  930. * @returns the unmodified current Vector2
  931. */
  932. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  933. /**
  934. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  935. * @param otherVector defines the other vector
  936. * @returns the current updated Vector2
  937. */
  938. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  939. /**
  940. * Multiplies in place the current Vector2 coordinates by the given ones
  941. * @param otherVector defines the other vector
  942. * @returns the current updated Vector2
  943. */
  944. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  945. /**
  946. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  947. * @param otherVector defines the other vector
  948. * @returns a new Vector2
  949. */
  950. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  951. /**
  952. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @param result defines the target vector
  955. * @returns the unmodified current Vector2
  956. */
  957. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  958. /**
  959. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  960. * @param x defines the first coordinate
  961. * @param y defines the second coordinate
  962. * @returns a new Vector2
  963. */
  964. multiplyByFloats(x: number, y: number): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. divide(otherVector: Vector2): Vector2;
  971. /**
  972. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Divides the current Vector2 coordinates by the given ones
  980. * @param otherVector defines the other vector
  981. * @returns the current updated Vector2
  982. */
  983. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  984. /**
  985. * Gets a new Vector2 with current Vector2 negated coordinates
  986. * @returns a new Vector2
  987. */
  988. negate(): Vector2;
  989. /**
  990. * Multiply the Vector2 coordinates by scale
  991. * @param scale defines the scaling factor
  992. * @returns the current updated Vector2
  993. */
  994. scaleInPlace(scale: number): Vector2;
  995. /**
  996. * Returns a new Vector2 scaled by "scale" from the current Vector2
  997. * @param scale defines the scaling factor
  998. * @returns a new Vector2
  999. */
  1000. scale(scale: number): Vector2;
  1001. /**
  1002. * Scale the current Vector2 values by a factor to a given Vector2
  1003. * @param scale defines the scale factor
  1004. * @param result defines the Vector2 object where to store the result
  1005. * @returns the unmodified current Vector2
  1006. */
  1007. scaleToRef(scale: number, result: Vector2): Vector2;
  1008. /**
  1009. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1010. * @param scale defines the scale factor
  1011. * @param result defines the Vector2 object where to store the result
  1012. * @returns the unmodified current Vector2
  1013. */
  1014. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1015. /**
  1016. * Gets a boolean if two vectors are equals
  1017. * @param otherVector defines the other vector
  1018. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1019. */
  1020. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1021. /**
  1022. * Gets a boolean if two vectors are equals (using an epsilon value)
  1023. * @param otherVector defines the other vector
  1024. * @param epsilon defines the minimal distance to consider equality
  1025. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1026. */
  1027. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1028. /**
  1029. * Gets a new Vector2 from current Vector2 floored values
  1030. * @returns a new Vector2
  1031. */
  1032. floor(): Vector2;
  1033. /**
  1034. * Gets a new Vector2 from current Vector2 floored values
  1035. * @returns a new Vector2
  1036. */
  1037. fract(): Vector2;
  1038. /**
  1039. * Gets the length of the vector
  1040. * @returns the vector length (float)
  1041. */
  1042. length(): number;
  1043. /**
  1044. * Gets the vector squared length
  1045. * @returns the vector squared length (float)
  1046. */
  1047. lengthSquared(): number;
  1048. /**
  1049. * Normalize the vector
  1050. * @returns the current updated Vector2
  1051. */
  1052. normalize(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 copied from the Vector2
  1055. * @returns a new Vector2
  1056. */
  1057. clone(): Vector2;
  1058. /**
  1059. * Gets a new Vector2(0, 0)
  1060. * @returns a new Vector2
  1061. */
  1062. static Zero(): Vector2;
  1063. /**
  1064. * Gets a new Vector2(1, 1)
  1065. * @returns a new Vector2
  1066. */
  1067. static One(): Vector2;
  1068. /**
  1069. * Gets a new Vector2 set from the given index element of the given array
  1070. * @param array defines the data source
  1071. * @param offset defines the offset in the data source
  1072. * @returns a new Vector2
  1073. */
  1074. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1075. /**
  1076. * Sets "result" from the given index element of the given array
  1077. * @param array defines the data source
  1078. * @param offset defines the offset in the data source
  1079. * @param result defines the target vector
  1080. */
  1081. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1082. /**
  1083. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1084. * @param value1 defines 1st point of control
  1085. * @param value2 defines 2nd point of control
  1086. * @param value3 defines 3rd point of control
  1087. * @param value4 defines 4th point of control
  1088. * @param amount defines the interpolation factor
  1089. * @returns a new Vector2
  1090. */
  1091. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1092. /**
  1093. * 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".
  1094. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1095. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1096. * @param value defines the value to clamp
  1097. * @param min defines the lower limit
  1098. * @param max defines the upper limit
  1099. * @returns a new Vector2
  1100. */
  1101. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1102. /**
  1103. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1104. * @param value1 defines the 1st control point
  1105. * @param tangent1 defines the outgoing tangent
  1106. * @param value2 defines the 2nd control point
  1107. * @param tangent2 defines the incoming tangent
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1114. * @param start defines the start vector
  1115. * @param end defines the end vector
  1116. * @param amount defines the interpolation factor
  1117. * @returns a new Vector2
  1118. */
  1119. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1120. /**
  1121. * Gets the dot product of the vector "left" and the vector "right"
  1122. * @param left defines first vector
  1123. * @param right defines second vector
  1124. * @returns the dot product (float)
  1125. */
  1126. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1127. /**
  1128. * Returns a new Vector2 equal to the normalized given vector
  1129. * @param vector defines the vector to normalize
  1130. * @returns a new Vector2
  1131. */
  1132. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1133. /**
  1134. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1135. * @param left defines 1st vector
  1136. * @param right defines 2nd vector
  1137. * @returns a new Vector2
  1138. */
  1139. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1140. /**
  1141. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1142. * @param left defines 1st vector
  1143. * @param right defines 2nd vector
  1144. * @returns a new Vector2
  1145. */
  1146. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1147. /**
  1148. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1149. * @param vector defines the vector to transform
  1150. * @param transformation defines the matrix to apply
  1151. * @returns a new Vector2
  1152. */
  1153. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1154. /**
  1155. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1156. * @param vector defines the vector to transform
  1157. * @param transformation defines the matrix to apply
  1158. * @param result defines the target vector
  1159. */
  1160. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1161. /**
  1162. * Determines if a given vector is included in a triangle
  1163. * @param p defines the vector to test
  1164. * @param p0 defines 1st triangle point
  1165. * @param p1 defines 2nd triangle point
  1166. * @param p2 defines 3rd triangle point
  1167. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1168. */
  1169. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1170. /**
  1171. * Gets the distance between the vectors "value1" and "value2"
  1172. * @param value1 defines first vector
  1173. * @param value2 defines second vector
  1174. * @returns the distance between vectors
  1175. */
  1176. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1177. /**
  1178. * Returns the squared distance between the vectors "value1" and "value2"
  1179. * @param value1 defines first vector
  1180. * @param value2 defines second vector
  1181. * @returns the squared distance between vectors
  1182. */
  1183. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1184. /**
  1185. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1186. * @param value1 defines first vector
  1187. * @param value2 defines second vector
  1188. * @returns a new Vector2
  1189. */
  1190. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1191. /**
  1192. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1193. * @param p defines the middle point
  1194. * @param segA defines one point of the segment
  1195. * @param segB defines the other point of the segment
  1196. * @returns the shortest distance
  1197. */
  1198. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1199. }
  1200. /**
  1201. * Classed used to store (x,y,z) vector representation
  1202. * A Vector3 is the main object used in 3D geometry
  1203. * It can represent etiher the coordinates of a point the space, either a direction
  1204. * Reminder: js uses a left handed forward facing system
  1205. */
  1206. export class Vector3 {
  1207. /**
  1208. * Defines the first coordinates (on X axis)
  1209. */
  1210. x: number;
  1211. /**
  1212. * Defines the second coordinates (on Y axis)
  1213. */
  1214. y: number;
  1215. /**
  1216. * Defines the third coordinates (on Z axis)
  1217. */
  1218. z: number;
  1219. private static _UpReadOnly;
  1220. /**
  1221. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1222. * @param x defines the first coordinates (on X axis)
  1223. * @param y defines the second coordinates (on Y axis)
  1224. * @param z defines the third coordinates (on Z axis)
  1225. */
  1226. constructor(
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x?: number,
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y?: number,
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z?: number);
  1239. /**
  1240. * Creates a string representation of the Vector3
  1241. * @returns a string with the Vector3 coordinates.
  1242. */
  1243. toString(): string;
  1244. /**
  1245. * Gets the class name
  1246. * @returns the string "Vector3"
  1247. */
  1248. getClassName(): string;
  1249. /**
  1250. * Creates the Vector3 hash code
  1251. * @returns a number which tends to be unique between Vector3 instances
  1252. */
  1253. getHashCode(): number;
  1254. /**
  1255. * Creates an array containing three elements : the coordinates of the Vector3
  1256. * @returns a new array of numbers
  1257. */
  1258. asArray(): number[];
  1259. /**
  1260. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1261. * @param array defines the destination array
  1262. * @param index defines the offset in the destination array
  1263. * @returns the current Vector3
  1264. */
  1265. toArray(array: FloatArray, index?: number): Vector3;
  1266. /**
  1267. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1268. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1269. */
  1270. toQuaternion(): Quaternion;
  1271. /**
  1272. * Adds the given vector to the current Vector3
  1273. * @param otherVector defines the second operand
  1274. * @returns the current updated Vector3
  1275. */
  1276. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1277. /**
  1278. * Adds the given coordinates to the current Vector3
  1279. * @param x defines the x coordinate of the operand
  1280. * @param y defines the y coordinate of the operand
  1281. * @param z defines the z coordinate of the operand
  1282. * @returns the current updated Vector3
  1283. */
  1284. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1285. /**
  1286. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1287. * @param otherVector defines the second operand
  1288. * @returns the resulting Vector3
  1289. */
  1290. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1291. /**
  1292. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1293. * @param otherVector defines the second operand
  1294. * @param result defines the Vector3 object where to store the result
  1295. * @returns the current Vector3
  1296. */
  1297. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1298. /**
  1299. * Subtract the given vector from the current Vector3
  1300. * @param otherVector defines the second operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1304. /**
  1305. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1312. * @param otherVector defines the second operand
  1313. * @param result defines the Vector3 object where to store the result
  1314. * @returns the current Vector3
  1315. */
  1316. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1319. * @param x defines the x coordinate of the operand
  1320. * @param y defines the y coordinate of the operand
  1321. * @param z defines the z coordinate of the operand
  1322. * @returns the resulting Vector3
  1323. */
  1324. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1325. /**
  1326. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1327. * @param x defines the x coordinate of the operand
  1328. * @param y defines the y coordinate of the operand
  1329. * @param z defines the z coordinate of the operand
  1330. * @param result defines the Vector3 object where to store the result
  1331. * @returns the current Vector3
  1332. */
  1333. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1334. /**
  1335. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1336. * @returns a new Vector3
  1337. */
  1338. negate(): Vector3;
  1339. /**
  1340. * Multiplies the Vector3 coordinates by the float "scale"
  1341. * @param scale defines the multiplier factor
  1342. * @returns the current updated Vector3
  1343. */
  1344. scaleInPlace(scale: number): Vector3;
  1345. /**
  1346. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1347. * @param scale defines the multiplier factor
  1348. * @returns a new Vector3
  1349. */
  1350. scale(scale: number): Vector3;
  1351. /**
  1352. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1353. * @param scale defines the multiplier factor
  1354. * @param result defines the Vector3 object where to store the result
  1355. * @returns the current Vector3
  1356. */
  1357. scaleToRef(scale: number, result: Vector3): Vector3;
  1358. /**
  1359. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1360. * @param scale defines the scale factor
  1361. * @param result defines the Vector3 object where to store the result
  1362. * @returns the unmodified current Vector3
  1363. */
  1364. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1365. /**
  1366. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1367. * @param otherVector defines the second operand
  1368. * @returns true if both vectors are equals
  1369. */
  1370. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1371. /**
  1372. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1373. * @param otherVector defines the second operand
  1374. * @param epsilon defines the minimal distance to define values as equals
  1375. * @returns true if both vectors are distant less than epsilon
  1376. */
  1377. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1378. /**
  1379. * Returns true if the current Vector3 coordinates equals the given floats
  1380. * @param x defines the x coordinate of the operand
  1381. * @param y defines the y coordinate of the operand
  1382. * @param z defines the z coordinate of the operand
  1383. * @returns true if both vectors are equals
  1384. */
  1385. equalsToFloats(x: number, y: number, z: number): boolean;
  1386. /**
  1387. * Multiplies the current Vector3 coordinates by the given ones
  1388. * @param otherVector defines the second operand
  1389. * @returns the current updated Vector3
  1390. */
  1391. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1392. /**
  1393. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1394. * @param otherVector defines the second operand
  1395. * @returns the new Vector3
  1396. */
  1397. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1398. /**
  1399. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1400. * @param otherVector defines the second operand
  1401. * @param result defines the Vector3 object where to store the result
  1402. * @returns the current Vector3
  1403. */
  1404. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1405. /**
  1406. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1407. * @param x defines the x coordinate of the operand
  1408. * @param y defines the y coordinate of the operand
  1409. * @param z defines the z coordinate of the operand
  1410. * @returns the new Vector3
  1411. */
  1412. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1413. /**
  1414. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Divides the current Vector3 coordinates by the given ones.
  1428. * @param otherVector defines the second operand
  1429. * @returns the current updated Vector3
  1430. */
  1431. divideInPlace(otherVector: Vector3): Vector3;
  1432. /**
  1433. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1434. * @param other defines the second operand
  1435. * @returns the current updated Vector3
  1436. */
  1437. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1440. * @param other defines the second operand
  1441. * @returns the current updated Vector3
  1442. */
  1443. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1444. /**
  1445. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1446. * @param x defines the x coordinate of the operand
  1447. * @param y defines the y coordinate of the operand
  1448. * @param z defines the z coordinate of the operand
  1449. * @returns the current updated Vector3
  1450. */
  1451. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1452. /**
  1453. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1454. * @param x defines the x coordinate of the operand
  1455. * @param y defines the y coordinate of the operand
  1456. * @param z defines the z coordinate of the operand
  1457. * @returns the current updated Vector3
  1458. */
  1459. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1460. /**
  1461. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1462. * Check if is non uniform within a certain amount of decimal places to account for this
  1463. * @param epsilon the amount the values can differ
  1464. * @returns if the the vector is non uniform to a certain number of decimal places
  1465. */
  1466. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1467. /**
  1468. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1469. */
  1470. readonly isNonUniform: boolean;
  1471. /**
  1472. * Gets a new Vector3 from current Vector3 floored values
  1473. * @returns a new Vector3
  1474. */
  1475. floor(): Vector3;
  1476. /**
  1477. * Gets a new Vector3 from current Vector3 floored values
  1478. * @returns a new Vector3
  1479. */
  1480. fract(): Vector3;
  1481. /**
  1482. * Gets the length of the Vector3
  1483. * @returns the length of the Vecto3
  1484. */
  1485. length(): number;
  1486. /**
  1487. * Gets the squared length of the Vector3
  1488. * @returns squared length of the Vector3
  1489. */
  1490. lengthSquared(): number;
  1491. /**
  1492. * Normalize the current Vector3.
  1493. * Please note that this is an in place operation.
  1494. * @returns the current updated Vector3
  1495. */
  1496. normalize(): Vector3;
  1497. /**
  1498. * Reorders the x y z properties of the vector in place
  1499. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1500. * @returns the current updated vector
  1501. */
  1502. reorderInPlace(order: string): this;
  1503. /**
  1504. * Rotates the vector around 0,0,0 by a quaternion
  1505. * @param quaternion the rotation quaternion
  1506. * @param result vector to store the result
  1507. * @returns the resulting vector
  1508. */
  1509. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1510. /**
  1511. * Rotates a vector around a given point
  1512. * @param quaternion the rotation quaternion
  1513. * @param point the point to rotate around
  1514. * @param result vector to store the result
  1515. * @returns the resulting vector
  1516. */
  1517. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1518. /**
  1519. * Normalize the current Vector3 with the given input length.
  1520. * Please note that this is an in place operation.
  1521. * @param len the length of the vector
  1522. * @returns the current updated Vector3
  1523. */
  1524. normalizeFromLength(len: number): Vector3;
  1525. /**
  1526. * Normalize the current Vector3 to a new vector
  1527. * @returns the new Vector3
  1528. */
  1529. normalizeToNew(): Vector3;
  1530. /**
  1531. * Normalize the current Vector3 to the reference
  1532. * @param reference define the Vector3 to update
  1533. * @returns the updated Vector3
  1534. */
  1535. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1536. /**
  1537. * Creates a new Vector3 copied from the current Vector3
  1538. * @returns the new Vector3
  1539. */
  1540. clone(): Vector3;
  1541. /**
  1542. * Copies the given vector coordinates to the current Vector3 ones
  1543. * @param source defines the source Vector3
  1544. * @returns the current updated Vector3
  1545. */
  1546. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1547. /**
  1548. * Copies the given floats to the current Vector3 coordinates
  1549. * @param x defines the x coordinate of the operand
  1550. * @param y defines the y coordinate of the operand
  1551. * @param z defines the z coordinate of the operand
  1552. * @returns the current updated Vector3
  1553. */
  1554. copyFromFloats(x: number, y: number, z: number): Vector3;
  1555. /**
  1556. * Copies the given floats to the current Vector3 coordinates
  1557. * @param x defines the x coordinate of the operand
  1558. * @param y defines the y coordinate of the operand
  1559. * @param z defines the z coordinate of the operand
  1560. * @returns the current updated Vector3
  1561. */
  1562. set(x: number, y: number, z: number): Vector3;
  1563. /**
  1564. * Copies the given float to the current Vector3 coordinates
  1565. * @param v defines the x, y and z coordinates of the operand
  1566. * @returns the current updated Vector3
  1567. */
  1568. setAll(v: number): Vector3;
  1569. /**
  1570. * Get the clip factor between two vectors
  1571. * @param vector0 defines the first operand
  1572. * @param vector1 defines the second operand
  1573. * @param axis defines the axis to use
  1574. * @param size defines the size along the axis
  1575. * @returns the clip factor
  1576. */
  1577. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1578. /**
  1579. * Get angle between two vectors
  1580. * @param vector0 angle between vector0 and vector1
  1581. * @param vector1 angle between vector0 and vector1
  1582. * @param normal direction of the normal
  1583. * @return the angle between vector0 and vector1
  1584. */
  1585. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1586. /**
  1587. * Returns a new Vector3 set from the index "offset" of the given array
  1588. * @param array defines the source array
  1589. * @param offset defines the offset in the source array
  1590. * @returns the new Vector3
  1591. */
  1592. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1593. /**
  1594. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1595. * This function is deprecated. Use FromArray instead
  1596. * @param array defines the source array
  1597. * @param offset defines the offset in the source array
  1598. * @returns the new Vector3
  1599. */
  1600. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1601. /**
  1602. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1603. * @param array defines the source array
  1604. * @param offset defines the offset in the source array
  1605. * @param result defines the Vector3 where to store the result
  1606. */
  1607. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1608. /**
  1609. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1610. * This function is deprecated. Use FromArrayToRef instead.
  1611. * @param array defines the source array
  1612. * @param offset defines the offset in the source array
  1613. * @param result defines the Vector3 where to store the result
  1614. */
  1615. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1616. /**
  1617. * Sets the given vector "result" with the given floats.
  1618. * @param x defines the x coordinate of the source
  1619. * @param y defines the y coordinate of the source
  1620. * @param z defines the z coordinate of the source
  1621. * @param result defines the Vector3 where to store the result
  1622. */
  1623. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1624. /**
  1625. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1626. * @returns a new empty Vector3
  1627. */
  1628. static Zero(): Vector3;
  1629. /**
  1630. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1631. * @returns a new unit Vector3
  1632. */
  1633. static One(): Vector3;
  1634. /**
  1635. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1636. * @returns a new up Vector3
  1637. */
  1638. static Up(): Vector3;
  1639. /**
  1640. * Gets a up Vector3 that must not be updated
  1641. */
  1642. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1645. * @returns a new down Vector3
  1646. */
  1647. static Down(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1650. * @returns a new forward Vector3
  1651. */
  1652. static Forward(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1655. * @returns a new forward Vector3
  1656. */
  1657. static Backward(): Vector3;
  1658. /**
  1659. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1660. * @returns a new right Vector3
  1661. */
  1662. static Right(): Vector3;
  1663. /**
  1664. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1665. * @returns a new left Vector3
  1666. */
  1667. static Left(): Vector3;
  1668. /**
  1669. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1670. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1671. * @param vector defines the Vector3 to transform
  1672. * @param transformation defines the transformation matrix
  1673. * @returns the transformed Vector3
  1674. */
  1675. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1676. /**
  1677. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1678. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1679. * @param vector defines the Vector3 to transform
  1680. * @param transformation defines the transformation matrix
  1681. * @param result defines the Vector3 where to store the result
  1682. */
  1683. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1684. /**
  1685. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1686. * This method computes tranformed coordinates only, not transformed direction vectors
  1687. * @param x define the x coordinate of the source vector
  1688. * @param y define the y coordinate of the source vector
  1689. * @param z define the z coordinate of the source vector
  1690. * @param transformation defines the transformation matrix
  1691. * @param result defines the Vector3 where to store the result
  1692. */
  1693. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1694. /**
  1695. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1696. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1697. * @param vector defines the Vector3 to transform
  1698. * @param transformation defines the transformation matrix
  1699. * @returns the new Vector3
  1700. */
  1701. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1702. /**
  1703. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1704. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1705. * @param vector defines the Vector3 to transform
  1706. * @param transformation defines the transformation matrix
  1707. * @param result defines the Vector3 where to store the result
  1708. */
  1709. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1710. /**
  1711. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1712. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1713. * @param x define the x coordinate of the source vector
  1714. * @param y define the y coordinate of the source vector
  1715. * @param z define the z coordinate of the source vector
  1716. * @param transformation defines the transformation matrix
  1717. * @param result defines the Vector3 where to store the result
  1718. */
  1719. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1720. /**
  1721. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1722. * @param value1 defines the first control point
  1723. * @param value2 defines the second control point
  1724. * @param value3 defines the third control point
  1725. * @param value4 defines the fourth control point
  1726. * @param amount defines the amount on the spline to use
  1727. * @returns the new Vector3
  1728. */
  1729. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1730. /**
  1731. * 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"
  1732. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1733. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1734. * @param value defines the current value
  1735. * @param min defines the lower range value
  1736. * @param max defines the upper range value
  1737. * @returns the new Vector3
  1738. */
  1739. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1740. /**
  1741. * 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"
  1742. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1743. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1744. * @param value defines the current value
  1745. * @param min defines the lower range value
  1746. * @param max defines the upper range value
  1747. * @param result defines the Vector3 where to store the result
  1748. */
  1749. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1750. /**
  1751. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1752. * @param value1 defines the first control point
  1753. * @param tangent1 defines the first tangent vector
  1754. * @param value2 defines the second control point
  1755. * @param tangent2 defines the second tangent vector
  1756. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1757. * @returns the new Vector3
  1758. */
  1759. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1760. /**
  1761. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1762. * @param start defines the start value
  1763. * @param end defines the end value
  1764. * @param amount max defines amount between both (between 0 and 1)
  1765. * @returns the new Vector3
  1766. */
  1767. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1768. /**
  1769. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1770. * @param start defines the start value
  1771. * @param end defines the end value
  1772. * @param amount max defines amount between both (between 0 and 1)
  1773. * @param result defines the Vector3 where to store the result
  1774. */
  1775. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1776. /**
  1777. * Returns the dot product (float) between the vectors "left" and "right"
  1778. * @param left defines the left operand
  1779. * @param right defines the right operand
  1780. * @returns the dot product
  1781. */
  1782. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1783. /**
  1784. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1785. * The cross product is then orthogonal to both "left" and "right"
  1786. * @param left defines the left operand
  1787. * @param right defines the right operand
  1788. * @returns the cross product
  1789. */
  1790. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the cross product of "left" and "right"
  1793. * The cross product is then orthogonal to both "left" and "right"
  1794. * @param left defines the left operand
  1795. * @param right defines the right operand
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1799. /**
  1800. * Returns a new Vector3 as the normalization of the given vector
  1801. * @param vector defines the Vector3 to normalize
  1802. * @returns the new Vector3
  1803. */
  1804. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1805. /**
  1806. * Sets the given vector "result" with the normalization of the given first vector
  1807. * @param vector defines the Vector3 to normalize
  1808. * @param result defines the Vector3 where to store the result
  1809. */
  1810. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1811. /**
  1812. * Project a Vector3 onto screen space
  1813. * @param vector defines the Vector3 to project
  1814. * @param world defines the world matrix to use
  1815. * @param transform defines the transform (view x projection) matrix to use
  1816. * @param viewport defines the screen viewport to use
  1817. * @returns the new Vector3
  1818. */
  1819. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1820. /** @hidden */
  1821. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1822. /**
  1823. * Unproject from screen space to object space
  1824. * @param source defines the screen space Vector3 to use
  1825. * @param viewportWidth defines the current width of the viewport
  1826. * @param viewportHeight defines the current height of the viewport
  1827. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1828. * @param transform defines the transform (view x projection) matrix to use
  1829. * @returns the new Vector3
  1830. */
  1831. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1832. /**
  1833. * Unproject from screen space to object space
  1834. * @param source defines the screen space Vector3 to use
  1835. * @param viewportWidth defines the current width of the viewport
  1836. * @param viewportHeight defines the current height of the viewport
  1837. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1838. * @param view defines the view matrix to use
  1839. * @param projection defines the projection matrix to use
  1840. * @returns the new Vector3
  1841. */
  1842. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1843. /**
  1844. * Unproject from screen space to object space
  1845. * @param source defines the screen space Vector3 to use
  1846. * @param viewportWidth defines the current width of the viewport
  1847. * @param viewportHeight defines the current height of the viewport
  1848. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1849. * @param view defines the view matrix to use
  1850. * @param projection defines the projection matrix to use
  1851. * @param result defines the Vector3 where to store the result
  1852. */
  1853. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1854. /**
  1855. * Unproject from screen space to object space
  1856. * @param sourceX defines the screen space x coordinate to use
  1857. * @param sourceY defines the screen space y coordinate to use
  1858. * @param sourceZ defines the screen space z coordinate 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. * @param result defines the Vector3 where to store the result
  1865. */
  1866. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1867. /**
  1868. * Gets the minimal coordinate values between two Vector3
  1869. * @param left defines the first operand
  1870. * @param right defines the second operand
  1871. * @returns the new Vector3
  1872. */
  1873. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1874. /**
  1875. * Gets the maximal coordinate values between two Vector3
  1876. * @param left defines the first operand
  1877. * @param right defines the second operand
  1878. * @returns the new Vector3
  1879. */
  1880. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1881. /**
  1882. * Returns the distance between the vectors "value1" and "value2"
  1883. * @param value1 defines the first operand
  1884. * @param value2 defines the second operand
  1885. * @returns the distance
  1886. */
  1887. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1888. /**
  1889. * Returns the squared distance between the vectors "value1" and "value2"
  1890. * @param value1 defines the first operand
  1891. * @param value2 defines the second operand
  1892. * @returns the squared distance
  1893. */
  1894. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1895. /**
  1896. * Returns a new Vector3 located at the center between "value1" and "value2"
  1897. * @param value1 defines the first operand
  1898. * @param value2 defines the second operand
  1899. * @returns the new Vector3
  1900. */
  1901. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1902. /**
  1903. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1904. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1905. * to something in order to rotate it from its local system to the given target system
  1906. * Note: axis1, axis2 and axis3 are normalized during this operation
  1907. * @param axis1 defines the first axis
  1908. * @param axis2 defines the second axis
  1909. * @param axis3 defines the third axis
  1910. * @returns a new Vector3
  1911. */
  1912. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1913. /**
  1914. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1915. * @param axis1 defines the first axis
  1916. * @param axis2 defines the second axis
  1917. * @param axis3 defines the third axis
  1918. * @param ref defines the Vector3 where to store the result
  1919. */
  1920. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1921. }
  1922. /**
  1923. * Vector4 class created for EulerAngle class conversion to Quaternion
  1924. */
  1925. export class Vector4 {
  1926. /** x value of the vector */
  1927. x: number;
  1928. /** y value of the vector */
  1929. y: number;
  1930. /** z value of the vector */
  1931. z: number;
  1932. /** w value of the vector */
  1933. w: number;
  1934. /**
  1935. * Creates a Vector4 object from the given floats.
  1936. * @param x x value of the vector
  1937. * @param y y value of the vector
  1938. * @param z z value of the vector
  1939. * @param w w value of the vector
  1940. */
  1941. constructor(
  1942. /** x value of the vector */
  1943. x: number,
  1944. /** y value of the vector */
  1945. y: number,
  1946. /** z value of the vector */
  1947. z: number,
  1948. /** w value of the vector */
  1949. w: number);
  1950. /**
  1951. * Returns the string with the Vector4 coordinates.
  1952. * @returns a string containing all the vector values
  1953. */
  1954. toString(): string;
  1955. /**
  1956. * Returns the string "Vector4".
  1957. * @returns "Vector4"
  1958. */
  1959. getClassName(): string;
  1960. /**
  1961. * Returns the Vector4 hash code.
  1962. * @returns a unique hash code
  1963. */
  1964. getHashCode(): number;
  1965. /**
  1966. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1967. * @returns the resulting array
  1968. */
  1969. asArray(): number[];
  1970. /**
  1971. * Populates the given array from the given index with the Vector4 coordinates.
  1972. * @param array array to populate
  1973. * @param index index of the array to start at (default: 0)
  1974. * @returns the Vector4.
  1975. */
  1976. toArray(array: FloatArray, index?: number): Vector4;
  1977. /**
  1978. * Adds the given vector to the current Vector4.
  1979. * @param otherVector the vector to add
  1980. * @returns the updated Vector4.
  1981. */
  1982. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1983. /**
  1984. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1985. * @param otherVector the vector to add
  1986. * @returns the resulting vector
  1987. */
  1988. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1989. /**
  1990. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1991. * @param otherVector the vector to add
  1992. * @param result the vector to store the result
  1993. * @returns the current Vector4.
  1994. */
  1995. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1996. /**
  1997. * Subtract in place the given vector from the current Vector4.
  1998. * @param otherVector the vector to subtract
  1999. * @returns the updated Vector4.
  2000. */
  2001. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2002. /**
  2003. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the new vector with the result
  2006. */
  2007. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2010. * @param otherVector the vector to subtract
  2011. * @param result the vector to store the result
  2012. * @returns the current Vector4.
  2013. */
  2014. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2015. /**
  2016. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2017. */
  2018. /**
  2019. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2020. * @param x value to subtract
  2021. * @param y value to subtract
  2022. * @param z value to subtract
  2023. * @param w value to subtract
  2024. * @returns new vector containing the result
  2025. */
  2026. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2027. /**
  2028. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2029. * @param x value to subtract
  2030. * @param y value to subtract
  2031. * @param z value to subtract
  2032. * @param w value to subtract
  2033. * @param result the vector to store the result in
  2034. * @returns the current Vector4.
  2035. */
  2036. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2037. /**
  2038. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2039. * @returns a new vector with the negated values
  2040. */
  2041. negate(): Vector4;
  2042. /**
  2043. * Multiplies the current Vector4 coordinates by scale (float).
  2044. * @param scale the number to scale with
  2045. * @returns the updated Vector4.
  2046. */
  2047. scaleInPlace(scale: number): Vector4;
  2048. /**
  2049. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2050. * @param scale the number to scale with
  2051. * @returns a new vector with the result
  2052. */
  2053. scale(scale: number): Vector4;
  2054. /**
  2055. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2056. * @param scale the number to scale with
  2057. * @param result a vector to store the result in
  2058. * @returns the current Vector4.
  2059. */
  2060. scaleToRef(scale: number, result: Vector4): Vector4;
  2061. /**
  2062. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2063. * @param scale defines the scale factor
  2064. * @param result defines the Vector4 object where to store the result
  2065. * @returns the unmodified current Vector4
  2066. */
  2067. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2068. /**
  2069. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2070. * @param otherVector the vector to compare against
  2071. * @returns true if they are equal
  2072. */
  2073. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2074. /**
  2075. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2076. * @param otherVector vector to compare against
  2077. * @param epsilon (Default: very small number)
  2078. * @returns true if they are equal
  2079. */
  2080. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2081. /**
  2082. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2083. * @param x x value to compare against
  2084. * @param y y value to compare against
  2085. * @param z z value to compare against
  2086. * @param w w value to compare against
  2087. * @returns true if equal
  2088. */
  2089. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2090. /**
  2091. * Multiplies in place the current Vector4 by the given one.
  2092. * @param otherVector vector to multiple with
  2093. * @returns the updated Vector4.
  2094. */
  2095. multiplyInPlace(otherVector: Vector4): Vector4;
  2096. /**
  2097. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2098. * @param otherVector vector to multiple with
  2099. * @returns resulting new vector
  2100. */
  2101. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2102. /**
  2103. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2104. * @param otherVector vector to multiple with
  2105. * @param result vector to store the result
  2106. * @returns the current Vector4.
  2107. */
  2108. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2109. /**
  2110. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2111. * @param x x value multiply with
  2112. * @param y y value multiply with
  2113. * @param z z value multiply with
  2114. * @param w w value multiply with
  2115. * @returns resulting new vector
  2116. */
  2117. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2118. /**
  2119. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2120. * @param otherVector vector to devide with
  2121. * @returns resulting new vector
  2122. */
  2123. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2124. /**
  2125. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2126. * @param otherVector vector to devide with
  2127. * @param result vector to store the result
  2128. * @returns the current Vector4.
  2129. */
  2130. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2131. /**
  2132. * Divides the current Vector3 coordinates by the given ones.
  2133. * @param otherVector vector to devide with
  2134. * @returns the updated Vector3.
  2135. */
  2136. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2137. /**
  2138. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2139. * @param other defines the second operand
  2140. * @returns the current updated Vector4
  2141. */
  2142. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2143. /**
  2144. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2145. * @param other defines the second operand
  2146. * @returns the current updated Vector4
  2147. */
  2148. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Gets a new Vector4 from current Vector4 floored values
  2151. * @returns a new Vector4
  2152. */
  2153. floor(): Vector4;
  2154. /**
  2155. * Gets a new Vector4 from current Vector3 floored values
  2156. * @returns a new Vector4
  2157. */
  2158. fract(): Vector4;
  2159. /**
  2160. * Returns the Vector4 length (float).
  2161. * @returns the length
  2162. */
  2163. length(): number;
  2164. /**
  2165. * Returns the Vector4 squared length (float).
  2166. * @returns the length squared
  2167. */
  2168. lengthSquared(): number;
  2169. /**
  2170. * Normalizes in place the Vector4.
  2171. * @returns the updated Vector4.
  2172. */
  2173. normalize(): Vector4;
  2174. /**
  2175. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2176. * @returns this converted to a new vector3
  2177. */
  2178. toVector3(): Vector3;
  2179. /**
  2180. * Returns a new Vector4 copied from the current one.
  2181. * @returns the new cloned vector
  2182. */
  2183. clone(): Vector4;
  2184. /**
  2185. * Updates the current Vector4 with the given one coordinates.
  2186. * @param source the source vector to copy from
  2187. * @returns the updated Vector4.
  2188. */
  2189. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2190. /**
  2191. * Updates the current Vector4 coordinates with the given floats.
  2192. * @param x float to copy from
  2193. * @param y float to copy from
  2194. * @param z float to copy from
  2195. * @param w float to copy from
  2196. * @returns the updated Vector4.
  2197. */
  2198. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2199. /**
  2200. * Updates the current Vector4 coordinates with the given floats.
  2201. * @param x float to set from
  2202. * @param y float to set from
  2203. * @param z float to set from
  2204. * @param w float to set from
  2205. * @returns the updated Vector4.
  2206. */
  2207. set(x: number, y: number, z: number, w: number): Vector4;
  2208. /**
  2209. * Copies the given float to the current Vector3 coordinates
  2210. * @param v defines the x, y, z and w coordinates of the operand
  2211. * @returns the current updated Vector3
  2212. */
  2213. setAll(v: number): Vector4;
  2214. /**
  2215. * Returns a new Vector4 set from the starting index of the given array.
  2216. * @param array the array to pull values from
  2217. * @param offset the offset into the array to start at
  2218. * @returns the new vector
  2219. */
  2220. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2221. /**
  2222. * Updates the given vector "result" from the starting index of the given array.
  2223. * @param array the array to pull values from
  2224. * @param offset the offset into the array to start at
  2225. * @param result the vector to store the result in
  2226. */
  2227. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2228. /**
  2229. * Updates the given vector "result" from the starting index of the given Float32Array.
  2230. * @param array the array to pull values from
  2231. * @param offset the offset into the array to start at
  2232. * @param result the vector to store the result in
  2233. */
  2234. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2235. /**
  2236. * Updates the given vector "result" coordinates from the given floats.
  2237. * @param x float to set from
  2238. * @param y float to set from
  2239. * @param z float to set from
  2240. * @param w float to set from
  2241. * @param result the vector to the floats in
  2242. */
  2243. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2244. /**
  2245. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2246. * @returns the new vector
  2247. */
  2248. static Zero(): Vector4;
  2249. /**
  2250. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2251. * @returns the new vector
  2252. */
  2253. static One(): Vector4;
  2254. /**
  2255. * Returns a new normalized Vector4 from the given one.
  2256. * @param vector the vector to normalize
  2257. * @returns the vector
  2258. */
  2259. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2260. /**
  2261. * Updates the given vector "result" from the normalization of the given one.
  2262. * @param vector the vector to normalize
  2263. * @param result the vector to store the result in
  2264. */
  2265. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2266. /**
  2267. * Returns a vector with the minimum values from the left and right vectors
  2268. * @param left left vector to minimize
  2269. * @param right right vector to minimize
  2270. * @returns a new vector with the minimum of the left and right vector values
  2271. */
  2272. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2273. /**
  2274. * Returns a vector with the maximum values from the left and right vectors
  2275. * @param left left vector to maximize
  2276. * @param right right vector to maximize
  2277. * @returns a new vector with the maximum of the left and right vector values
  2278. */
  2279. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2280. /**
  2281. * Returns the distance (float) between the vectors "value1" and "value2".
  2282. * @param value1 value to calulate the distance between
  2283. * @param value2 value to calulate the distance between
  2284. * @return the distance between the two vectors
  2285. */
  2286. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2287. /**
  2288. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2289. * @param value1 value to calulate the distance between
  2290. * @param value2 value to calulate the distance between
  2291. * @return the distance between the two vectors squared
  2292. */
  2293. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2294. /**
  2295. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2296. * @param value1 value to calulate the center between
  2297. * @param value2 value to calulate the center between
  2298. * @return the center between the two vectors
  2299. */
  2300. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2301. /**
  2302. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2303. * This methods computes transformed normalized direction vectors only.
  2304. * @param vector the vector to transform
  2305. * @param transformation the transformation matrix to apply
  2306. * @returns the new vector
  2307. */
  2308. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2309. /**
  2310. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2311. * This methods computes transformed normalized direction vectors only.
  2312. * @param vector the vector to transform
  2313. * @param transformation the transformation matrix to apply
  2314. * @param result the vector to store the result in
  2315. */
  2316. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2317. /**
  2318. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2319. * This methods computes transformed normalized direction vectors only.
  2320. * @param x value to transform
  2321. * @param y value to transform
  2322. * @param z value to transform
  2323. * @param w value to transform
  2324. * @param transformation the transformation matrix to apply
  2325. * @param result the vector to store the results in
  2326. */
  2327. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2328. /**
  2329. * Creates a new Vector4 from a Vector3
  2330. * @param source defines the source data
  2331. * @param w defines the 4th component (default is 0)
  2332. * @returns a new Vector4
  2333. */
  2334. static FromVector3(source: Vector3, w?: number): Vector4;
  2335. }
  2336. /**
  2337. * Interface for the size containing width and height
  2338. */
  2339. export interface ISize {
  2340. /**
  2341. * Width
  2342. */
  2343. width: number;
  2344. /**
  2345. * Heighht
  2346. */
  2347. height: number;
  2348. }
  2349. /**
  2350. * Size containing widht and height
  2351. */
  2352. export class Size implements ISize {
  2353. /**
  2354. * Width
  2355. */
  2356. width: number;
  2357. /**
  2358. * Height
  2359. */
  2360. height: number;
  2361. /**
  2362. * Creates a Size object from the given width and height (floats).
  2363. * @param width width of the new size
  2364. * @param height height of the new size
  2365. */
  2366. constructor(width: number, height: number);
  2367. /**
  2368. * Returns a string with the Size width and height
  2369. * @returns a string with the Size width and height
  2370. */
  2371. toString(): string;
  2372. /**
  2373. * "Size"
  2374. * @returns the string "Size"
  2375. */
  2376. getClassName(): string;
  2377. /**
  2378. * Returns the Size hash code.
  2379. * @returns a hash code for a unique width and height
  2380. */
  2381. getHashCode(): number;
  2382. /**
  2383. * Updates the current size from the given one.
  2384. * @param src the given size
  2385. */
  2386. copyFrom(src: Size): void;
  2387. /**
  2388. * Updates in place the current Size from the given floats.
  2389. * @param width width of the new size
  2390. * @param height height of the new size
  2391. * @returns the updated Size.
  2392. */
  2393. copyFromFloats(width: number, height: number): Size;
  2394. /**
  2395. * Updates in place the current Size from the given floats.
  2396. * @param width width to set
  2397. * @param height height to set
  2398. * @returns the updated Size.
  2399. */
  2400. set(width: number, height: number): Size;
  2401. /**
  2402. * Multiplies the width and height by numbers
  2403. * @param w factor to multiple the width by
  2404. * @param h factor to multiple the height by
  2405. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2406. */
  2407. multiplyByFloats(w: number, h: number): Size;
  2408. /**
  2409. * Clones the size
  2410. * @returns a new Size copied from the given one.
  2411. */
  2412. clone(): Size;
  2413. /**
  2414. * True if the current Size and the given one width and height are strictly equal.
  2415. * @param other the other size to compare against
  2416. * @returns True if the current Size and the given one width and height are strictly equal.
  2417. */
  2418. equals(other: Size): boolean;
  2419. /**
  2420. * The surface of the Size : width * height (float).
  2421. */
  2422. readonly surface: number;
  2423. /**
  2424. * Create a new size of zero
  2425. * @returns a new Size set to (0.0, 0.0)
  2426. */
  2427. static Zero(): Size;
  2428. /**
  2429. * Sums the width and height of two sizes
  2430. * @param otherSize size to add to this size
  2431. * @returns a new Size set as the addition result of the current Size and the given one.
  2432. */
  2433. add(otherSize: Size): Size;
  2434. /**
  2435. * Subtracts the width and height of two
  2436. * @param otherSize size to subtract to this size
  2437. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2438. */
  2439. subtract(otherSize: Size): Size;
  2440. /**
  2441. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2442. * @param start starting size to lerp between
  2443. * @param end end size to lerp between
  2444. * @param amount amount to lerp between the start and end values
  2445. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2446. */
  2447. static Lerp(start: Size, end: Size, amount: number): Size;
  2448. }
  2449. /**
  2450. * Class used to store quaternion data
  2451. * @see https://en.wikipedia.org/wiki/Quaternion
  2452. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2453. */
  2454. export class Quaternion {
  2455. /** defines the first component (0 by default) */
  2456. x: number;
  2457. /** defines the second component (0 by default) */
  2458. y: number;
  2459. /** defines the third component (0 by default) */
  2460. z: number;
  2461. /** defines the fourth component (1.0 by default) */
  2462. w: number;
  2463. /**
  2464. * Creates a new Quaternion from the given floats
  2465. * @param x defines the first component (0 by default)
  2466. * @param y defines the second component (0 by default)
  2467. * @param z defines the third component (0 by default)
  2468. * @param w defines the fourth component (1.0 by default)
  2469. */
  2470. constructor(
  2471. /** defines the first component (0 by default) */
  2472. x?: number,
  2473. /** defines the second component (0 by default) */
  2474. y?: number,
  2475. /** defines the third component (0 by default) */
  2476. z?: number,
  2477. /** defines the fourth component (1.0 by default) */
  2478. w?: number);
  2479. /**
  2480. * Gets a string representation for the current quaternion
  2481. * @returns a string with the Quaternion coordinates
  2482. */
  2483. toString(): string;
  2484. /**
  2485. * Gets the class name of the quaternion
  2486. * @returns the string "Quaternion"
  2487. */
  2488. getClassName(): string;
  2489. /**
  2490. * Gets a hash code for this quaternion
  2491. * @returns the quaternion hash code
  2492. */
  2493. getHashCode(): number;
  2494. /**
  2495. * Copy the quaternion to an array
  2496. * @returns a new array populated with 4 elements from the quaternion coordinates
  2497. */
  2498. asArray(): number[];
  2499. /**
  2500. * Check if two quaternions are equals
  2501. * @param otherQuaternion defines the second operand
  2502. * @return true if the current quaternion and the given one coordinates are strictly equals
  2503. */
  2504. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2505. /**
  2506. * Clone the current quaternion
  2507. * @returns a new quaternion copied from the current one
  2508. */
  2509. clone(): Quaternion;
  2510. /**
  2511. * Copy a quaternion to the current one
  2512. * @param other defines the other quaternion
  2513. * @returns the updated current quaternion
  2514. */
  2515. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2516. /**
  2517. * Updates the current quaternion with the given float coordinates
  2518. * @param x defines the x coordinate
  2519. * @param y defines the y coordinate
  2520. * @param z defines the z coordinate
  2521. * @param w defines the w coordinate
  2522. * @returns the updated current quaternion
  2523. */
  2524. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2525. /**
  2526. * Updates the current quaternion from the given float coordinates
  2527. * @param x defines the x coordinate
  2528. * @param y defines the y coordinate
  2529. * @param z defines the z coordinate
  2530. * @param w defines the w coordinate
  2531. * @returns the updated current quaternion
  2532. */
  2533. set(x: number, y: number, z: number, w: number): Quaternion;
  2534. /**
  2535. * Adds two quaternions
  2536. * @param other defines the second operand
  2537. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2538. */
  2539. add(other: DeepImmutable<Quaternion>): Quaternion;
  2540. /**
  2541. * Add a quaternion to the current one
  2542. * @param other defines the quaternion to add
  2543. * @returns the current quaternion
  2544. */
  2545. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2546. /**
  2547. * Subtract two quaternions
  2548. * @param other defines the second operand
  2549. * @returns a new quaternion as the subtraction result of the given one from the current one
  2550. */
  2551. subtract(other: Quaternion): Quaternion;
  2552. /**
  2553. * Multiplies the current quaternion by a scale factor
  2554. * @param value defines the scale factor
  2555. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2556. */
  2557. scale(value: number): Quaternion;
  2558. /**
  2559. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2560. * @param scale defines the scale factor
  2561. * @param result defines the Quaternion object where to store the result
  2562. * @returns the unmodified current quaternion
  2563. */
  2564. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2565. /**
  2566. * Multiplies in place the current quaternion by a scale factor
  2567. * @param value defines the scale factor
  2568. * @returns the current modified quaternion
  2569. */
  2570. scaleInPlace(value: number): Quaternion;
  2571. /**
  2572. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2573. * @param scale defines the scale factor
  2574. * @param result defines the Quaternion object where to store the result
  2575. * @returns the unmodified current quaternion
  2576. */
  2577. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2578. /**
  2579. * Multiplies two quaternions
  2580. * @param q1 defines the second operand
  2581. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2582. */
  2583. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2584. /**
  2585. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2586. * @param q1 defines the second operand
  2587. * @param result defines the target quaternion
  2588. * @returns the current quaternion
  2589. */
  2590. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2591. /**
  2592. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2593. * @param q1 defines the second operand
  2594. * @returns the currentupdated quaternion
  2595. */
  2596. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2597. /**
  2598. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2599. * @param ref defines the target quaternion
  2600. * @returns the current quaternion
  2601. */
  2602. conjugateToRef(ref: Quaternion): Quaternion;
  2603. /**
  2604. * Conjugates in place (1-q) the current quaternion
  2605. * @returns the current updated quaternion
  2606. */
  2607. conjugateInPlace(): Quaternion;
  2608. /**
  2609. * Conjugates in place (1-q) the current quaternion
  2610. * @returns a new quaternion
  2611. */
  2612. conjugate(): Quaternion;
  2613. /**
  2614. * Gets length of current quaternion
  2615. * @returns the quaternion length (float)
  2616. */
  2617. length(): number;
  2618. /**
  2619. * Normalize in place the current quaternion
  2620. * @returns the current updated quaternion
  2621. */
  2622. normalize(): Quaternion;
  2623. /**
  2624. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2625. * @param order is a reserved parameter and is ignore for now
  2626. * @returns a new Vector3 containing the Euler angles
  2627. */
  2628. toEulerAngles(order?: string): Vector3;
  2629. /**
  2630. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2631. * @param result defines the vector which will be filled with the Euler angles
  2632. * @param order is a reserved parameter and is ignore for now
  2633. * @returns the current unchanged quaternion
  2634. */
  2635. toEulerAnglesToRef(result: Vector3): Quaternion;
  2636. /**
  2637. * Updates the given rotation matrix with the current quaternion values
  2638. * @param result defines the target matrix
  2639. * @returns the current unchanged quaternion
  2640. */
  2641. toRotationMatrix(result: Matrix): Quaternion;
  2642. /**
  2643. * Updates the current quaternion from the given rotation matrix values
  2644. * @param matrix defines the source matrix
  2645. * @returns the current updated quaternion
  2646. */
  2647. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2648. /**
  2649. * Creates a new quaternion from a rotation matrix
  2650. * @param matrix defines the source matrix
  2651. * @returns a new quaternion created from the given rotation matrix values
  2652. */
  2653. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2654. /**
  2655. * Updates the given quaternion with the given rotation matrix values
  2656. * @param matrix defines the source matrix
  2657. * @param result defines the target quaternion
  2658. */
  2659. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2660. /**
  2661. * Returns the dot product (float) between the quaternions "left" and "right"
  2662. * @param left defines the left operand
  2663. * @param right defines the right operand
  2664. * @returns the dot product
  2665. */
  2666. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2667. /**
  2668. * Checks if the two quaternions are close to each other
  2669. * @param quat0 defines the first quaternion to check
  2670. * @param quat1 defines the second quaternion to check
  2671. * @returns true if the two quaternions are close to each other
  2672. */
  2673. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2674. /**
  2675. * Creates an empty quaternion
  2676. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2677. */
  2678. static Zero(): Quaternion;
  2679. /**
  2680. * Inverse a given quaternion
  2681. * @param q defines the source quaternion
  2682. * @returns a new quaternion as the inverted current quaternion
  2683. */
  2684. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2685. /**
  2686. * Inverse a given quaternion
  2687. * @param q defines the source quaternion
  2688. * @param result the quaternion the result will be stored in
  2689. * @returns the result quaternion
  2690. */
  2691. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2692. /**
  2693. * Creates an identity quaternion
  2694. * @returns the identity quaternion
  2695. */
  2696. static Identity(): Quaternion;
  2697. /**
  2698. * Gets a boolean indicating if the given quaternion is identity
  2699. * @param quaternion defines the quaternion to check
  2700. * @returns true if the quaternion is identity
  2701. */
  2702. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2703. /**
  2704. * Creates a quaternion from a rotation around an axis
  2705. * @param axis defines the axis to use
  2706. * @param angle defines the angle to use
  2707. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2708. */
  2709. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2710. /**
  2711. * Creates a rotation around an axis and stores it into the given quaternion
  2712. * @param axis defines the axis to use
  2713. * @param angle defines the angle to use
  2714. * @param result defines the target quaternion
  2715. * @returns the target quaternion
  2716. */
  2717. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2718. /**
  2719. * Creates a new quaternion from data stored into an array
  2720. * @param array defines the data source
  2721. * @param offset defines the offset in the source array where the data starts
  2722. * @returns a new quaternion
  2723. */
  2724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2725. /**
  2726. * Create a quaternion from Euler rotation angles
  2727. * @param x Pitch
  2728. * @param y Yaw
  2729. * @param z Roll
  2730. * @returns the new Quaternion
  2731. */
  2732. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2733. /**
  2734. * Updates a quaternion from Euler rotation angles
  2735. * @param x Pitch
  2736. * @param y Yaw
  2737. * @param z Roll
  2738. * @param result the quaternion to store the result
  2739. * @returns the updated quaternion
  2740. */
  2741. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2742. /**
  2743. * Create a quaternion from Euler rotation vector
  2744. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2745. * @returns the new Quaternion
  2746. */
  2747. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2748. /**
  2749. * Updates a quaternion from Euler rotation vector
  2750. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2751. * @param result the quaternion to store the result
  2752. * @returns the updated quaternion
  2753. */
  2754. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2755. /**
  2756. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2757. * @param yaw defines the rotation around Y axis
  2758. * @param pitch defines the rotation around X axis
  2759. * @param roll defines the rotation around Z axis
  2760. * @returns the new quaternion
  2761. */
  2762. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2763. /**
  2764. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2765. * @param yaw defines the rotation around Y axis
  2766. * @param pitch defines the rotation around X axis
  2767. * @param roll defines the rotation around Z axis
  2768. * @param result defines the target quaternion
  2769. */
  2770. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2771. /**
  2772. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2773. * @param alpha defines the rotation around first axis
  2774. * @param beta defines the rotation around second axis
  2775. * @param gamma defines the rotation around third axis
  2776. * @returns the new quaternion
  2777. */
  2778. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2779. /**
  2780. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2781. * @param alpha defines the rotation around first axis
  2782. * @param beta defines the rotation around second axis
  2783. * @param gamma defines the rotation around third axis
  2784. * @param result defines the target quaternion
  2785. */
  2786. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2787. /**
  2788. * 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)
  2789. * @param axis1 defines the first axis
  2790. * @param axis2 defines the second axis
  2791. * @param axis3 defines the third axis
  2792. * @returns the new quaternion
  2793. */
  2794. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2795. /**
  2796. * 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
  2797. * @param axis1 defines the first axis
  2798. * @param axis2 defines the second axis
  2799. * @param axis3 defines the third axis
  2800. * @param ref defines the target quaternion
  2801. */
  2802. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2803. /**
  2804. * Interpolates between two quaternions
  2805. * @param left defines first quaternion
  2806. * @param right defines second quaternion
  2807. * @param amount defines the gradient to use
  2808. * @returns the new interpolated quaternion
  2809. */
  2810. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2811. /**
  2812. * Interpolates between two quaternions and stores it into a target quaternion
  2813. * @param left defines first quaternion
  2814. * @param right defines second quaternion
  2815. * @param amount defines the gradient to use
  2816. * @param result defines the target quaternion
  2817. */
  2818. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2819. /**
  2820. * Interpolate between two quaternions using Hermite interpolation
  2821. * @param value1 defines first quaternion
  2822. * @param tangent1 defines the incoming tangent
  2823. * @param value2 defines second quaternion
  2824. * @param tangent2 defines the outgoing tangent
  2825. * @param amount defines the target quaternion
  2826. * @returns the new interpolated quaternion
  2827. */
  2828. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2829. }
  2830. /**
  2831. * Class used to store matrix data (4x4)
  2832. */
  2833. export class Matrix {
  2834. private static _updateFlagSeed;
  2835. private static _identityReadOnly;
  2836. private _isIdentity;
  2837. private _isIdentityDirty;
  2838. private _isIdentity3x2;
  2839. private _isIdentity3x2Dirty;
  2840. /**
  2841. * Gets the update flag of the matrix which is an unique number for the matrix.
  2842. * It will be incremented every time the matrix data change.
  2843. * You can use it to speed the comparison between two versions of the same matrix.
  2844. */
  2845. updateFlag: number;
  2846. private readonly _m;
  2847. /**
  2848. * Gets the internal data of the matrix
  2849. */
  2850. readonly m: DeepImmutable<Float32Array>;
  2851. /** @hidden */
  2852. _markAsUpdated(): void;
  2853. /** @hidden */
  2854. private _updateIdentityStatus;
  2855. /**
  2856. * Creates an empty matrix (filled with zeros)
  2857. */
  2858. constructor();
  2859. /**
  2860. * Check if the current matrix is identity
  2861. * @returns true is the matrix is the identity matrix
  2862. */
  2863. isIdentity(): boolean;
  2864. /**
  2865. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2866. * @returns true is the matrix is the identity matrix
  2867. */
  2868. isIdentityAs3x2(): boolean;
  2869. /**
  2870. * Gets the determinant of the matrix
  2871. * @returns the matrix determinant
  2872. */
  2873. determinant(): number;
  2874. /**
  2875. * Returns the matrix as a Float32Array
  2876. * @returns the matrix underlying array
  2877. */
  2878. toArray(): DeepImmutable<Float32Array>;
  2879. /**
  2880. * Returns the matrix as a Float32Array
  2881. * @returns the matrix underlying array.
  2882. */
  2883. asArray(): DeepImmutable<Float32Array>;
  2884. /**
  2885. * Inverts the current matrix in place
  2886. * @returns the current inverted matrix
  2887. */
  2888. invert(): Matrix;
  2889. /**
  2890. * Sets all the matrix elements to zero
  2891. * @returns the current matrix
  2892. */
  2893. reset(): Matrix;
  2894. /**
  2895. * Adds the current matrix with a second one
  2896. * @param other defines the matrix to add
  2897. * @returns a new matrix as the addition of the current matrix and the given one
  2898. */
  2899. add(other: DeepImmutable<Matrix>): Matrix;
  2900. /**
  2901. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2902. * @param other defines the matrix to add
  2903. * @param result defines the target matrix
  2904. * @returns the current matrix
  2905. */
  2906. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2907. /**
  2908. * Adds in place the given matrix to the current matrix
  2909. * @param other defines the second operand
  2910. * @returns the current updated matrix
  2911. */
  2912. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2913. /**
  2914. * Sets the given matrix to the current inverted Matrix
  2915. * @param other defines the target matrix
  2916. * @returns the unmodified current matrix
  2917. */
  2918. invertToRef(other: Matrix): Matrix;
  2919. /**
  2920. * add a value at the specified position in the current Matrix
  2921. * @param index the index of the value within the matrix. between 0 and 15.
  2922. * @param value the value to be added
  2923. * @returns the current updated matrix
  2924. */
  2925. addAtIndex(index: number, value: number): Matrix;
  2926. /**
  2927. * mutiply the specified position in the current Matrix by a value
  2928. * @param index the index of the value within the matrix. between 0 and 15.
  2929. * @param value the value to be added
  2930. * @returns the current updated matrix
  2931. */
  2932. multiplyAtIndex(index: number, value: number): Matrix;
  2933. /**
  2934. * Inserts the translation vector (using 3 floats) in the current matrix
  2935. * @param x defines the 1st component of the translation
  2936. * @param y defines the 2nd component of the translation
  2937. * @param z defines the 3rd component of the translation
  2938. * @returns the current updated matrix
  2939. */
  2940. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2941. /**
  2942. * Adds the translation vector (using 3 floats) in the current matrix
  2943. * @param x defines the 1st component of the translation
  2944. * @param y defines the 2nd component of the translation
  2945. * @param z defines the 3rd component of the translation
  2946. * @returns the current updated matrix
  2947. */
  2948. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2949. /**
  2950. * Inserts the translation vector in the current matrix
  2951. * @param vector3 defines the translation to insert
  2952. * @returns the current updated matrix
  2953. */
  2954. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2955. /**
  2956. * Gets the translation value of the current matrix
  2957. * @returns a new Vector3 as the extracted translation from the matrix
  2958. */
  2959. getTranslation(): Vector3;
  2960. /**
  2961. * Fill a Vector3 with the extracted translation from the matrix
  2962. * @param result defines the Vector3 where to store the translation
  2963. * @returns the current matrix
  2964. */
  2965. getTranslationToRef(result: Vector3): Matrix;
  2966. /**
  2967. * Remove rotation and scaling part from the matrix
  2968. * @returns the updated matrix
  2969. */
  2970. removeRotationAndScaling(): Matrix;
  2971. /**
  2972. * Multiply two matrices
  2973. * @param other defines the second operand
  2974. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2975. */
  2976. multiply(other: DeepImmutable<Matrix>): Matrix;
  2977. /**
  2978. * Copy the current matrix from the given one
  2979. * @param other defines the source matrix
  2980. * @returns the current updated matrix
  2981. */
  2982. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2983. /**
  2984. * Populates the given array from the starting index with the current matrix values
  2985. * @param array defines the target array
  2986. * @param offset defines the offset in the target array where to start storing values
  2987. * @returns the current matrix
  2988. */
  2989. copyToArray(array: Float32Array, offset?: number): Matrix;
  2990. /**
  2991. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the matrix where to store the multiplication
  2994. * @returns the current matrix
  2995. */
  2996. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2997. /**
  2998. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2999. * @param other defines the second operand
  3000. * @param result defines the array where to store the multiplication
  3001. * @param offset defines the offset in the target array where to start storing values
  3002. * @returns the current matrix
  3003. */
  3004. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3005. /**
  3006. * Check equality between this matrix and a second one
  3007. * @param value defines the second matrix to compare
  3008. * @returns true is the current matrix and the given one values are strictly equal
  3009. */
  3010. equals(value: DeepImmutable<Matrix>): boolean;
  3011. /**
  3012. * Clone the current matrix
  3013. * @returns a new matrix from the current matrix
  3014. */
  3015. clone(): Matrix;
  3016. /**
  3017. * Returns the name of the current matrix class
  3018. * @returns the string "Matrix"
  3019. */
  3020. getClassName(): string;
  3021. /**
  3022. * Gets the hash code of the current matrix
  3023. * @returns the hash code
  3024. */
  3025. getHashCode(): number;
  3026. /**
  3027. * Decomposes the current Matrix into a translation, rotation and scaling components
  3028. * @param scale defines the scale vector3 given as a reference to update
  3029. * @param rotation defines the rotation quaternion given as a reference to update
  3030. * @param translation defines the translation vector3 given as a reference to update
  3031. * @returns true if operation was successful
  3032. */
  3033. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3034. /**
  3035. * Gets specific row of the matrix
  3036. * @param index defines the number of the row to get
  3037. * @returns the index-th row of the current matrix as a new Vector4
  3038. */
  3039. getRow(index: number): Nullable<Vector4>;
  3040. /**
  3041. * Sets the index-th row of the current matrix to the vector4 values
  3042. * @param index defines the number of the row to set
  3043. * @param row defines the target vector4
  3044. * @returns the updated current matrix
  3045. */
  3046. setRow(index: number, row: Vector4): Matrix;
  3047. /**
  3048. * Compute the transpose of the matrix
  3049. * @returns the new transposed matrix
  3050. */
  3051. transpose(): Matrix;
  3052. /**
  3053. * Compute the transpose of the matrix and store it in a given matrix
  3054. * @param result defines the target matrix
  3055. * @returns the current matrix
  3056. */
  3057. transposeToRef(result: Matrix): Matrix;
  3058. /**
  3059. * Sets the index-th row of the current matrix with the given 4 x float values
  3060. * @param index defines the row index
  3061. * @param x defines the x component to set
  3062. * @param y defines the y component to set
  3063. * @param z defines the z component to set
  3064. * @param w defines the w component to set
  3065. * @returns the updated current matrix
  3066. */
  3067. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3068. /**
  3069. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3070. * @param scale defines the scale factor
  3071. * @returns a new matrix
  3072. */
  3073. scale(scale: number): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor to a given result matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Scale the current matrix values by a factor and add the result to a given matrix
  3083. * @param scale defines the scale factor
  3084. * @param result defines the Matrix to store the result
  3085. * @returns the current matrix
  3086. */
  3087. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3088. /**
  3089. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3090. * @param ref matrix to store the result
  3091. */
  3092. toNormalMatrix(ref: Matrix): void;
  3093. /**
  3094. * Gets only rotation part of the current matrix
  3095. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3096. */
  3097. getRotationMatrix(): Matrix;
  3098. /**
  3099. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3100. * @param result defines the target matrix to store data to
  3101. * @returns the current matrix
  3102. */
  3103. getRotationMatrixToRef(result: Matrix): Matrix;
  3104. /**
  3105. * Toggles model matrix from being right handed to left handed in place and vice versa
  3106. */
  3107. toggleModelMatrixHandInPlace(): void;
  3108. /**
  3109. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3110. */
  3111. toggleProjectionMatrixHandInPlace(): void;
  3112. /**
  3113. * Creates a matrix from an array
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @returns a new Matrix set from the starting index of the given array
  3117. */
  3118. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3119. /**
  3120. * Copy the content of an array into a given matrix
  3121. * @param array defines the source array
  3122. * @param offset defines an offset in the source array
  3123. * @param result defines the target matrix
  3124. */
  3125. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3126. /**
  3127. * Stores an array into a matrix after having multiplied each component by a given factor
  3128. * @param array defines the source array
  3129. * @param offset defines the offset in the source array
  3130. * @param scale defines the scaling factor
  3131. * @param result defines the target matrix
  3132. */
  3133. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3134. /**
  3135. * Gets an identity matrix that must not be updated
  3136. */
  3137. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3138. /**
  3139. * Stores a list of values (16) inside a given matrix
  3140. * @param initialM11 defines 1st value of 1st row
  3141. * @param initialM12 defines 2nd value of 1st row
  3142. * @param initialM13 defines 3rd value of 1st row
  3143. * @param initialM14 defines 4th value of 1st row
  3144. * @param initialM21 defines 1st value of 2nd row
  3145. * @param initialM22 defines 2nd value of 2nd row
  3146. * @param initialM23 defines 3rd value of 2nd row
  3147. * @param initialM24 defines 4th value of 2nd row
  3148. * @param initialM31 defines 1st value of 3rd row
  3149. * @param initialM32 defines 2nd value of 3rd row
  3150. * @param initialM33 defines 3rd value of 3rd row
  3151. * @param initialM34 defines 4th value of 3rd row
  3152. * @param initialM41 defines 1st value of 4th row
  3153. * @param initialM42 defines 2nd value of 4th row
  3154. * @param initialM43 defines 3rd value of 4th row
  3155. * @param initialM44 defines 4th value of 4th row
  3156. * @param result defines the target matrix
  3157. */
  3158. 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;
  3159. /**
  3160. * Creates new matrix from a list of values (16)
  3161. * @param initialM11 defines 1st value of 1st row
  3162. * @param initialM12 defines 2nd value of 1st row
  3163. * @param initialM13 defines 3rd value of 1st row
  3164. * @param initialM14 defines 4th value of 1st row
  3165. * @param initialM21 defines 1st value of 2nd row
  3166. * @param initialM22 defines 2nd value of 2nd row
  3167. * @param initialM23 defines 3rd value of 2nd row
  3168. * @param initialM24 defines 4th value of 2nd row
  3169. * @param initialM31 defines 1st value of 3rd row
  3170. * @param initialM32 defines 2nd value of 3rd row
  3171. * @param initialM33 defines 3rd value of 3rd row
  3172. * @param initialM34 defines 4th value of 3rd row
  3173. * @param initialM41 defines 1st value of 4th row
  3174. * @param initialM42 defines 2nd value of 4th row
  3175. * @param initialM43 defines 3rd value of 4th row
  3176. * @param initialM44 defines 4th value of 4th row
  3177. * @returns the new matrix
  3178. */
  3179. 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;
  3180. /**
  3181. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3182. * @param scale defines the scale vector3
  3183. * @param rotation defines the rotation quaternion
  3184. * @param translation defines the translation vector3
  3185. * @returns a new matrix
  3186. */
  3187. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3188. /**
  3189. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3190. * @param scale defines the scale vector3
  3191. * @param rotation defines the rotation quaternion
  3192. * @param translation defines the translation vector3
  3193. * @param result defines the target matrix
  3194. */
  3195. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3196. /**
  3197. * Creates a new identity matrix
  3198. * @returns a new identity matrix
  3199. */
  3200. static Identity(): Matrix;
  3201. /**
  3202. * Creates a new identity matrix and stores the result in a given matrix
  3203. * @param result defines the target matrix
  3204. */
  3205. static IdentityToRef(result: Matrix): void;
  3206. /**
  3207. * Creates a new zero matrix
  3208. * @returns a new zero matrix
  3209. */
  3210. static Zero(): Matrix;
  3211. /**
  3212. * Creates a new rotation matrix for "angle" radians around the X axis
  3213. * @param angle defines the angle (in radians) to use
  3214. * @return the new matrix
  3215. */
  3216. static RotationX(angle: number): Matrix;
  3217. /**
  3218. * Creates a new matrix as the invert of a given matrix
  3219. * @param source defines the source matrix
  3220. * @returns the new matrix
  3221. */
  3222. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3223. /**
  3224. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3225. * @param angle defines the angle (in radians) to use
  3226. * @param result defines the target matrix
  3227. */
  3228. static RotationXToRef(angle: number, result: Matrix): void;
  3229. /**
  3230. * Creates a new rotation matrix for "angle" radians around the Y axis
  3231. * @param angle defines the angle (in radians) to use
  3232. * @return the new matrix
  3233. */
  3234. static RotationY(angle: number): Matrix;
  3235. /**
  3236. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3237. * @param angle defines the angle (in radians) to use
  3238. * @param result defines the target matrix
  3239. */
  3240. static RotationYToRef(angle: number, result: Matrix): void;
  3241. /**
  3242. * Creates a new rotation matrix for "angle" radians around the Z axis
  3243. * @param angle defines the angle (in radians) to use
  3244. * @return the new matrix
  3245. */
  3246. static RotationZ(angle: number): Matrix;
  3247. /**
  3248. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3249. * @param angle defines the angle (in radians) to use
  3250. * @param result defines the target matrix
  3251. */
  3252. static RotationZToRef(angle: number, result: Matrix): void;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @return the new matrix
  3258. */
  3259. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3260. /**
  3261. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3262. * @param axis defines the axis to use
  3263. * @param angle defines the angle (in radians) to use
  3264. * @param result defines the target matrix
  3265. */
  3266. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3267. /**
  3268. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3269. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3270. * @param from defines the vector to align
  3271. * @param to defines the vector to align to
  3272. * @param result defines the target matrix
  3273. */
  3274. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3275. /**
  3276. * Creates a rotation matrix
  3277. * @param yaw defines the yaw angle in radians (Y axis)
  3278. * @param pitch defines the pitch angle in radians (X axis)
  3279. * @param roll defines the roll angle in radians (X axis)
  3280. * @returns the new rotation matrix
  3281. */
  3282. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3283. /**
  3284. * Creates a rotation matrix and stores it in a given matrix
  3285. * @param yaw defines the yaw angle in radians (Y axis)
  3286. * @param pitch defines the pitch angle in radians (X axis)
  3287. * @param roll defines the roll angle in radians (X axis)
  3288. * @param result defines the target matrix
  3289. */
  3290. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3291. /**
  3292. * Creates a scaling matrix
  3293. * @param x defines the scale factor on X axis
  3294. * @param y defines the scale factor on Y axis
  3295. * @param z defines the scale factor on Z axis
  3296. * @returns the new matrix
  3297. */
  3298. static Scaling(x: number, y: number, z: number): Matrix;
  3299. /**
  3300. * Creates a scaling matrix and stores it in a given matrix
  3301. * @param x defines the scale factor on X axis
  3302. * @param y defines the scale factor on Y axis
  3303. * @param z defines the scale factor on Z axis
  3304. * @param result defines the target matrix
  3305. */
  3306. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3307. /**
  3308. * Creates a translation matrix
  3309. * @param x defines the translation on X axis
  3310. * @param y defines the translation on Y axis
  3311. * @param z defines the translationon Z axis
  3312. * @returns the new matrix
  3313. */
  3314. static Translation(x: number, y: number, z: number): Matrix;
  3315. /**
  3316. * Creates a translation matrix and stores it in a given matrix
  3317. * @param x defines the translation on X axis
  3318. * @param y defines the translation on Y axis
  3319. * @param z defines the translationon Z axis
  3320. * @param result defines the target matrix
  3321. */
  3322. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3323. /**
  3324. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3325. * @param startValue defines the start value
  3326. * @param endValue defines the end value
  3327. * @param gradient defines the gradient factor
  3328. * @returns the new matrix
  3329. */
  3330. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3331. /**
  3332. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3333. * @param startValue defines the start value
  3334. * @param endValue defines the end value
  3335. * @param gradient defines the gradient factor
  3336. * @param result defines the Matrix object where to store data
  3337. */
  3338. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3339. /**
  3340. * Builds a new matrix whose values are computed by:
  3341. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3342. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3343. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3344. * @param startValue defines the first matrix
  3345. * @param endValue defines the second matrix
  3346. * @param gradient defines the gradient between the two matrices
  3347. * @returns the new matrix
  3348. */
  3349. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3350. /**
  3351. * Update a matrix to values which are computed by:
  3352. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3353. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3354. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3355. * @param startValue defines the first matrix
  3356. * @param endValue defines the second matrix
  3357. * @param gradient defines the gradient between the two matrices
  3358. * @param result defines the target matrix
  3359. */
  3360. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3361. /**
  3362. * 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"
  3363. * This function works in left handed mode
  3364. * @param eye defines the final position of the entity
  3365. * @param target defines where the entity should look at
  3366. * @param up defines the up vector for the entity
  3367. * @returns the new matrix
  3368. */
  3369. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3370. /**
  3371. * 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".
  3372. * This function works in left handed mode
  3373. * @param eye defines the final position of the entity
  3374. * @param target defines where the entity should look at
  3375. * @param up defines the up vector for the entity
  3376. * @param result defines the target matrix
  3377. */
  3378. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3379. /**
  3380. * 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"
  3381. * This function works in right handed mode
  3382. * @param eye defines the final position of the entity
  3383. * @param target defines where the entity should look at
  3384. * @param up defines the up vector for the entity
  3385. * @returns the new matrix
  3386. */
  3387. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3388. /**
  3389. * 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".
  3390. * This function works in right handed mode
  3391. * @param eye defines the final position of the entity
  3392. * @param target defines where the entity should look at
  3393. * @param up defines the up vector for the entity
  3394. * @param result defines the target matrix
  3395. */
  3396. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3397. /**
  3398. * Create a left-handed orthographic projection matrix
  3399. * @param width defines the viewport width
  3400. * @param height defines the viewport height
  3401. * @param znear defines the near clip plane
  3402. * @param zfar defines the far clip plane
  3403. * @returns a new matrix as a left-handed orthographic projection matrix
  3404. */
  3405. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3406. /**
  3407. * Store a left-handed orthographic projection to a given matrix
  3408. * @param width defines the viewport width
  3409. * @param height defines the viewport height
  3410. * @param znear defines the near clip plane
  3411. * @param zfar defines the far clip plane
  3412. * @param result defines the target matrix
  3413. */
  3414. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3415. /**
  3416. * Create a left-handed orthographic projection matrix
  3417. * @param left defines the viewport left coordinate
  3418. * @param right defines the viewport right coordinate
  3419. * @param bottom defines the viewport bottom coordinate
  3420. * @param top defines the viewport top coordinate
  3421. * @param znear defines the near clip plane
  3422. * @param zfar defines the far clip plane
  3423. * @returns a new matrix as a left-handed orthographic projection matrix
  3424. */
  3425. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3426. /**
  3427. * Stores a left-handed orthographic projection into a given matrix
  3428. * @param left defines the viewport left coordinate
  3429. * @param right defines the viewport right coordinate
  3430. * @param bottom defines the viewport bottom coordinate
  3431. * @param top defines the viewport top coordinate
  3432. * @param znear defines the near clip plane
  3433. * @param zfar defines the far clip plane
  3434. * @param result defines the target matrix
  3435. */
  3436. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3437. /**
  3438. * Creates a right-handed orthographic projection matrix
  3439. * @param left defines the viewport left coordinate
  3440. * @param right defines the viewport right coordinate
  3441. * @param bottom defines the viewport bottom coordinate
  3442. * @param top defines the viewport top coordinate
  3443. * @param znear defines the near clip plane
  3444. * @param zfar defines the far clip plane
  3445. * @returns a new matrix as a right-handed orthographic projection matrix
  3446. */
  3447. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3448. /**
  3449. * Stores a right-handed orthographic projection into a given matrix
  3450. * @param left defines the viewport left coordinate
  3451. * @param right defines the viewport right coordinate
  3452. * @param bottom defines the viewport bottom coordinate
  3453. * @param top defines the viewport top coordinate
  3454. * @param znear defines the near clip plane
  3455. * @param zfar defines the far clip plane
  3456. * @param result defines the target matrix
  3457. */
  3458. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3459. /**
  3460. * Creates a left-handed perspective projection matrix
  3461. * @param width defines the viewport width
  3462. * @param height defines the viewport height
  3463. * @param znear defines the near clip plane
  3464. * @param zfar defines the far clip plane
  3465. * @returns a new matrix as a left-handed perspective projection matrix
  3466. */
  3467. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3468. /**
  3469. * Creates a left-handed perspective projection matrix
  3470. * @param fov defines the horizontal field of view
  3471. * @param aspect defines the aspect ratio
  3472. * @param znear defines the near clip plane
  3473. * @param zfar defines the far clip plane
  3474. * @returns a new matrix as a left-handed perspective projection matrix
  3475. */
  3476. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3477. /**
  3478. * Stores a left-handed perspective projection into a given matrix
  3479. * @param fov defines the horizontal field of view
  3480. * @param aspect defines the aspect ratio
  3481. * @param znear defines the near clip plane
  3482. * @param zfar defines the far clip plane
  3483. * @param result defines the target matrix
  3484. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3485. */
  3486. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3487. /**
  3488. * Creates a right-handed perspective projection matrix
  3489. * @param fov defines the horizontal field of view
  3490. * @param aspect defines the aspect ratio
  3491. * @param znear defines the near clip plane
  3492. * @param zfar defines the far clip plane
  3493. * @returns a new matrix as a right-handed perspective projection matrix
  3494. */
  3495. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3496. /**
  3497. * Stores a right-handed perspective projection into a given matrix
  3498. * @param fov defines the horizontal field of view
  3499. * @param aspect defines the aspect ratio
  3500. * @param znear defines the near clip plane
  3501. * @param zfar defines the far clip plane
  3502. * @param result defines the target matrix
  3503. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3504. */
  3505. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3506. /**
  3507. * Stores a perspective projection for WebVR info a given matrix
  3508. * @param fov defines the field of view
  3509. * @param znear defines the near clip plane
  3510. * @param zfar defines the far clip plane
  3511. * @param result defines the target matrix
  3512. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3513. */
  3514. static PerspectiveFovWebVRToRef(fov: {
  3515. upDegrees: number;
  3516. downDegrees: number;
  3517. leftDegrees: number;
  3518. rightDegrees: number;
  3519. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3520. /**
  3521. * Computes a complete transformation matrix
  3522. * @param viewport defines the viewport to use
  3523. * @param world defines the world matrix
  3524. * @param view defines the view matrix
  3525. * @param projection defines the projection matrix
  3526. * @param zmin defines the near clip plane
  3527. * @param zmax defines the far clip plane
  3528. * @returns the transformation matrix
  3529. */
  3530. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3531. /**
  3532. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3533. * @param matrix defines the matrix to use
  3534. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3535. */
  3536. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3537. /**
  3538. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3539. * @param matrix defines the matrix to use
  3540. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3541. */
  3542. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3543. /**
  3544. * Compute the transpose of a given matrix
  3545. * @param matrix defines the matrix to transpose
  3546. * @returns the new matrix
  3547. */
  3548. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3549. /**
  3550. * Compute the transpose of a matrix and store it in a target matrix
  3551. * @param matrix defines the matrix to transpose
  3552. * @param result defines the target matrix
  3553. */
  3554. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3555. /**
  3556. * Computes a reflection matrix from a plane
  3557. * @param plane defines the reflection plane
  3558. * @returns a new matrix
  3559. */
  3560. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3561. /**
  3562. * Computes a reflection matrix from a plane
  3563. * @param plane defines the reflection plane
  3564. * @param result defines the target matrix
  3565. */
  3566. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3567. /**
  3568. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3569. * @param xaxis defines the value of the 1st axis
  3570. * @param yaxis defines the value of the 2nd axis
  3571. * @param zaxis defines the value of the 3rd axis
  3572. * @param result defines the target matrix
  3573. */
  3574. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3575. /**
  3576. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3577. * @param quat defines the quaternion to use
  3578. * @param result defines the target matrix
  3579. */
  3580. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3581. }
  3582. /**
  3583. * Represens a plane by the equation ax + by + cz + d = 0
  3584. */
  3585. export class Plane {
  3586. /**
  3587. * Normal of the plane (a,b,c)
  3588. */
  3589. normal: Vector3;
  3590. /**
  3591. * d component of the plane
  3592. */
  3593. d: number;
  3594. /**
  3595. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3596. * @param a a component of the plane
  3597. * @param b b component of the plane
  3598. * @param c c component of the plane
  3599. * @param d d component of the plane
  3600. */
  3601. constructor(a: number, b: number, c: number, d: number);
  3602. /**
  3603. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3604. */
  3605. asArray(): number[];
  3606. /**
  3607. * @returns a new plane copied from the current Plane.
  3608. */
  3609. clone(): Plane;
  3610. /**
  3611. * @returns the string "Plane".
  3612. */
  3613. getClassName(): string;
  3614. /**
  3615. * @returns the Plane hash code.
  3616. */
  3617. getHashCode(): number;
  3618. /**
  3619. * Normalize the current Plane in place.
  3620. * @returns the updated Plane.
  3621. */
  3622. normalize(): Plane;
  3623. /**
  3624. * Applies a transformation the plane and returns the result
  3625. * @param transformation the transformation matrix to be applied to the plane
  3626. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3627. */
  3628. transform(transformation: DeepImmutable<Matrix>): Plane;
  3629. /**
  3630. * Calcualtte the dot product between the point and the plane normal
  3631. * @param point point to calculate the dot product with
  3632. * @returns the dot product (float) of the point coordinates and the plane normal.
  3633. */
  3634. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3635. /**
  3636. * Updates the current Plane from the plane defined by the three given points.
  3637. * @param point1 one of the points used to contruct the plane
  3638. * @param point2 one of the points used to contruct the plane
  3639. * @param point3 one of the points used to contruct the plane
  3640. * @returns the updated Plane.
  3641. */
  3642. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3643. /**
  3644. * Checks if the plane is facing a given direction
  3645. * @param direction the direction to check if the plane is facing
  3646. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3647. * @returns True is the vector "direction" is the same side than the plane normal.
  3648. */
  3649. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3650. /**
  3651. * Calculates the distance to a point
  3652. * @param point point to calculate distance to
  3653. * @returns the signed distance (float) from the given point to the Plane.
  3654. */
  3655. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3656. /**
  3657. * Creates a plane from an array
  3658. * @param array the array to create a plane from
  3659. * @returns a new Plane from the given array.
  3660. */
  3661. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3662. /**
  3663. * Creates a plane from three points
  3664. * @param point1 point used to create the plane
  3665. * @param point2 point used to create the plane
  3666. * @param point3 point used to create the plane
  3667. * @returns a new Plane defined by the three given points.
  3668. */
  3669. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3670. /**
  3671. * Creates a plane from an origin point and a normal
  3672. * @param origin origin of the plane to be constructed
  3673. * @param normal normal of the plane to be constructed
  3674. * @returns a new Plane the normal vector to this plane at the given origin point.
  3675. * Note : the vector "normal" is updated because normalized.
  3676. */
  3677. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3678. /**
  3679. * Calculates the distance from a plane and a point
  3680. * @param origin origin of the plane to be constructed
  3681. * @param normal normal of the plane to be constructed
  3682. * @param point point to calculate distance to
  3683. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3684. */
  3685. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3686. }
  3687. /**
  3688. * Class used to represent a viewport on screen
  3689. */
  3690. export class Viewport {
  3691. /** viewport left coordinate */
  3692. x: number;
  3693. /** viewport top coordinate */
  3694. y: number;
  3695. /**viewport width */
  3696. width: number;
  3697. /** viewport height */
  3698. height: number;
  3699. /**
  3700. * Creates a Viewport object located at (x, y) and sized (width, height)
  3701. * @param x defines viewport left coordinate
  3702. * @param y defines viewport top coordinate
  3703. * @param width defines the viewport width
  3704. * @param height defines the viewport height
  3705. */
  3706. constructor(
  3707. /** viewport left coordinate */
  3708. x: number,
  3709. /** viewport top coordinate */
  3710. y: number,
  3711. /**viewport width */
  3712. width: number,
  3713. /** viewport height */
  3714. height: number);
  3715. /**
  3716. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3717. * @param renderWidth defines the rendering width
  3718. * @param renderHeight defines the rendering height
  3719. * @returns a new Viewport
  3720. */
  3721. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3722. /**
  3723. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3724. * @param renderWidth defines the rendering width
  3725. * @param renderHeight defines the rendering height
  3726. * @param ref defines the target viewport
  3727. * @returns the current viewport
  3728. */
  3729. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3730. /**
  3731. * Returns a new Viewport copied from the current one
  3732. * @returns a new Viewport
  3733. */
  3734. clone(): Viewport;
  3735. }
  3736. /**
  3737. * Reprasents a camera frustum
  3738. */
  3739. export class Frustum {
  3740. /**
  3741. * Gets the planes representing the frustum
  3742. * @param transform matrix to be applied to the returned planes
  3743. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3744. */
  3745. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3746. /**
  3747. * Gets the near frustum plane transformed by the transform matrix
  3748. * @param transform transformation matrix to be applied to the resulting frustum plane
  3749. * @param frustumPlane the resuling frustum plane
  3750. */
  3751. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3752. /**
  3753. * Gets the far frustum plane transformed by the transform matrix
  3754. * @param transform transformation matrix to be applied to the resulting frustum plane
  3755. * @param frustumPlane the resuling frustum plane
  3756. */
  3757. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3758. /**
  3759. * Gets the left frustum plane transformed by the transform matrix
  3760. * @param transform transformation matrix to be applied to the resulting frustum plane
  3761. * @param frustumPlane the resuling frustum plane
  3762. */
  3763. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3764. /**
  3765. * Gets the right frustum plane transformed by the transform matrix
  3766. * @param transform transformation matrix to be applied to the resulting frustum plane
  3767. * @param frustumPlane the resuling frustum plane
  3768. */
  3769. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3770. /**
  3771. * Gets the top frustum plane transformed by the transform matrix
  3772. * @param transform transformation matrix to be applied to the resulting frustum plane
  3773. * @param frustumPlane the resuling frustum plane
  3774. */
  3775. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3776. /**
  3777. * Gets the bottom frustum plane transformed by the transform matrix
  3778. * @param transform transformation matrix to be applied to the resulting frustum plane
  3779. * @param frustumPlane the resuling frustum plane
  3780. */
  3781. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3782. /**
  3783. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3784. * @param transform transformation matrix to be applied to the resulting frustum planes
  3785. * @param frustumPlanes the resuling frustum planes
  3786. */
  3787. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3788. }
  3789. /** Defines supported spaces */
  3790. export enum Space {
  3791. /** Local (object) space */
  3792. LOCAL = 0,
  3793. /** World space */
  3794. WORLD = 1,
  3795. /** Bone space */
  3796. BONE = 2
  3797. }
  3798. /** Defines the 3 main axes */
  3799. export class Axis {
  3800. /** X axis */
  3801. static X: Vector3;
  3802. /** Y axis */
  3803. static Y: Vector3;
  3804. /** Z axis */
  3805. static Z: Vector3;
  3806. }
  3807. /** Class used to represent a Bezier curve */
  3808. export class BezierCurve {
  3809. /**
  3810. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3811. * @param t defines the time
  3812. * @param x1 defines the left coordinate on X axis
  3813. * @param y1 defines the left coordinate on Y axis
  3814. * @param x2 defines the right coordinate on X axis
  3815. * @param y2 defines the right coordinate on Y axis
  3816. * @returns the interpolated value
  3817. */
  3818. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3819. }
  3820. /**
  3821. * Defines potential orientation for back face culling
  3822. */
  3823. export enum Orientation {
  3824. /**
  3825. * Clockwise
  3826. */
  3827. CW = 0,
  3828. /** Counter clockwise */
  3829. CCW = 1
  3830. }
  3831. /**
  3832. * Defines angle representation
  3833. */
  3834. export class Angle {
  3835. private _radians;
  3836. /**
  3837. * Creates an Angle object of "radians" radians (float).
  3838. * @param radians the angle in radians
  3839. */
  3840. constructor(radians: number);
  3841. /**
  3842. * Get value in degrees
  3843. * @returns the Angle value in degrees (float)
  3844. */
  3845. degrees(): number;
  3846. /**
  3847. * Get value in radians
  3848. * @returns the Angle value in radians (float)
  3849. */
  3850. radians(): number;
  3851. /**
  3852. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3853. * @param a defines first vector
  3854. * @param b defines second vector
  3855. * @returns a new Angle
  3856. */
  3857. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3858. /**
  3859. * Gets a new Angle object from the given float in radians
  3860. * @param radians defines the angle value in radians
  3861. * @returns a new Angle
  3862. */
  3863. static FromRadians(radians: number): Angle;
  3864. /**
  3865. * Gets a new Angle object from the given float in degrees
  3866. * @param degrees defines the angle value in degrees
  3867. * @returns a new Angle
  3868. */
  3869. static FromDegrees(degrees: number): Angle;
  3870. }
  3871. /**
  3872. * This represents an arc in a 2d space.
  3873. */
  3874. export class Arc2 {
  3875. /** Defines the start point of the arc */
  3876. startPoint: Vector2;
  3877. /** Defines the mid point of the arc */
  3878. midPoint: Vector2;
  3879. /** Defines the end point of the arc */
  3880. endPoint: Vector2;
  3881. /**
  3882. * Defines the center point of the arc.
  3883. */
  3884. centerPoint: Vector2;
  3885. /**
  3886. * Defines the radius of the arc.
  3887. */
  3888. radius: number;
  3889. /**
  3890. * Defines the angle of the arc (from mid point to end point).
  3891. */
  3892. angle: Angle;
  3893. /**
  3894. * Defines the start angle of the arc (from start point to middle point).
  3895. */
  3896. startAngle: Angle;
  3897. /**
  3898. * Defines the orientation of the arc (clock wise/counter clock wise).
  3899. */
  3900. orientation: Orientation;
  3901. /**
  3902. * Creates an Arc object from the three given points : start, middle and end.
  3903. * @param startPoint Defines the start point of the arc
  3904. * @param midPoint Defines the midlle point of the arc
  3905. * @param endPoint Defines the end point of the arc
  3906. */
  3907. constructor(
  3908. /** Defines the start point of the arc */
  3909. startPoint: Vector2,
  3910. /** Defines the mid point of the arc */
  3911. midPoint: Vector2,
  3912. /** Defines the end point of the arc */
  3913. endPoint: Vector2);
  3914. }
  3915. /**
  3916. * Represents a 2D path made up of multiple 2D points
  3917. */
  3918. export class Path2 {
  3919. private _points;
  3920. private _length;
  3921. /**
  3922. * If the path start and end point are the same
  3923. */
  3924. closed: boolean;
  3925. /**
  3926. * Creates a Path2 object from the starting 2D coordinates x and y.
  3927. * @param x the starting points x value
  3928. * @param y the starting points y value
  3929. */
  3930. constructor(x: number, y: number);
  3931. /**
  3932. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3933. * @param x the added points x value
  3934. * @param y the added points y value
  3935. * @returns the updated Path2.
  3936. */
  3937. addLineTo(x: number, y: number): Path2;
  3938. /**
  3939. * 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.
  3940. * @param midX middle point x value
  3941. * @param midY middle point y value
  3942. * @param endX end point x value
  3943. * @param endY end point y value
  3944. * @param numberOfSegments (default: 36)
  3945. * @returns the updated Path2.
  3946. */
  3947. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3948. /**
  3949. * Closes the Path2.
  3950. * @returns the Path2.
  3951. */
  3952. close(): Path2;
  3953. /**
  3954. * Gets the sum of the distance between each sequential point in the path
  3955. * @returns the Path2 total length (float).
  3956. */
  3957. length(): number;
  3958. /**
  3959. * Gets the points which construct the path
  3960. * @returns the Path2 internal array of points.
  3961. */
  3962. getPoints(): Vector2[];
  3963. /**
  3964. * Retreives the point at the distance aways from the starting point
  3965. * @param normalizedLengthPosition the length along the path to retreive the point from
  3966. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3967. */
  3968. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3969. /**
  3970. * Creates a new path starting from an x and y position
  3971. * @param x starting x value
  3972. * @param y starting y value
  3973. * @returns a new Path2 starting at the coordinates (x, y).
  3974. */
  3975. static StartingAt(x: number, y: number): Path2;
  3976. }
  3977. /**
  3978. * Represents a 3D path made up of multiple 3D points
  3979. */
  3980. export class Path3D {
  3981. /**
  3982. * an array of Vector3, the curve axis of the Path3D
  3983. */
  3984. path: Vector3[];
  3985. private _curve;
  3986. private _distances;
  3987. private _tangents;
  3988. private _normals;
  3989. private _binormals;
  3990. private _raw;
  3991. /**
  3992. * new Path3D(path, normal, raw)
  3993. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3994. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3995. * @param path an array of Vector3, the curve axis of the Path3D
  3996. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3997. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3998. */
  3999. constructor(
  4000. /**
  4001. * an array of Vector3, the curve axis of the Path3D
  4002. */
  4003. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4004. /**
  4005. * Returns the Path3D array of successive Vector3 designing its curve.
  4006. * @returns the Path3D array of successive Vector3 designing its curve.
  4007. */
  4008. getCurve(): Vector3[];
  4009. /**
  4010. * Returns an array populated with tangent vectors on each Path3D curve point.
  4011. * @returns an array populated with tangent vectors on each Path3D curve point.
  4012. */
  4013. getTangents(): Vector3[];
  4014. /**
  4015. * Returns an array populated with normal vectors on each Path3D curve point.
  4016. * @returns an array populated with normal vectors on each Path3D curve point.
  4017. */
  4018. getNormals(): Vector3[];
  4019. /**
  4020. * Returns an array populated with binormal vectors on each Path3D curve point.
  4021. * @returns an array populated with binormal vectors on each Path3D curve point.
  4022. */
  4023. getBinormals(): Vector3[];
  4024. /**
  4025. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4026. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4027. */
  4028. getDistances(): number[];
  4029. /**
  4030. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4031. * @param path path which all values are copied into the curves points
  4032. * @param firstNormal which should be projected onto the curve
  4033. * @returns the same object updated.
  4034. */
  4035. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4036. private _compute;
  4037. private _getFirstNonNullVector;
  4038. private _getLastNonNullVector;
  4039. private _normalVector;
  4040. }
  4041. /**
  4042. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4043. * A Curve3 is designed from a series of successive Vector3.
  4044. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4045. */
  4046. export class Curve3 {
  4047. private _points;
  4048. private _length;
  4049. /**
  4050. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4051. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4052. * @param v1 (Vector3) the control point
  4053. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4054. * @param nbPoints (integer) the wanted number of points in the curve
  4055. * @returns the created Curve3
  4056. */
  4057. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4058. /**
  4059. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4060. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4061. * @param v1 (Vector3) the first control point
  4062. * @param v2 (Vector3) the second control point
  4063. * @param v3 (Vector3) the end point of the Cubic Bezier
  4064. * @param nbPoints (integer) the wanted number of points in the curve
  4065. * @returns the created Curve3
  4066. */
  4067. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4068. /**
  4069. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4070. * @param p1 (Vector3) the origin point of the Hermite Spline
  4071. * @param t1 (Vector3) the tangent vector at the origin point
  4072. * @param p2 (Vector3) the end point of the Hermite Spline
  4073. * @param t2 (Vector3) the tangent vector at the end point
  4074. * @param nbPoints (integer) the wanted number of points in the curve
  4075. * @returns the created Curve3
  4076. */
  4077. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4078. /**
  4079. * Returns a Curve3 object along a CatmullRom Spline curve :
  4080. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4081. * @param nbPoints (integer) the wanted number of points between each curve control points
  4082. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4083. * @returns the created Curve3
  4084. */
  4085. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4086. /**
  4087. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4088. * A Curve3 is designed from a series of successive Vector3.
  4089. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4090. * @param points points which make up the curve
  4091. */
  4092. constructor(points: Vector3[]);
  4093. /**
  4094. * @returns the Curve3 stored array of successive Vector3
  4095. */
  4096. getPoints(): Vector3[];
  4097. /**
  4098. * @returns the computed length (float) of the curve.
  4099. */
  4100. length(): number;
  4101. /**
  4102. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4103. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4104. * curveA and curveB keep unchanged.
  4105. * @param curve the curve to continue from this curve
  4106. * @returns the newly constructed curve
  4107. */
  4108. continue(curve: DeepImmutable<Curve3>): Curve3;
  4109. private _computeLength;
  4110. }
  4111. /**
  4112. * Contains position and normal vectors for a vertex
  4113. */
  4114. export class PositionNormalVertex {
  4115. /** the position of the vertex (defaut: 0,0,0) */
  4116. position: Vector3;
  4117. /** the normal of the vertex (defaut: 0,1,0) */
  4118. normal: Vector3;
  4119. /**
  4120. * Creates a PositionNormalVertex
  4121. * @param position the position of the vertex (defaut: 0,0,0)
  4122. * @param normal the normal of the vertex (defaut: 0,1,0)
  4123. */
  4124. constructor(
  4125. /** the position of the vertex (defaut: 0,0,0) */
  4126. position?: Vector3,
  4127. /** the normal of the vertex (defaut: 0,1,0) */
  4128. normal?: Vector3);
  4129. /**
  4130. * Clones the PositionNormalVertex
  4131. * @returns the cloned PositionNormalVertex
  4132. */
  4133. clone(): PositionNormalVertex;
  4134. }
  4135. /**
  4136. * Contains position, normal and uv vectors for a vertex
  4137. */
  4138. export class PositionNormalTextureVertex {
  4139. /** the position of the vertex (defaut: 0,0,0) */
  4140. position: Vector3;
  4141. /** the normal of the vertex (defaut: 0,1,0) */
  4142. normal: Vector3;
  4143. /** the uv of the vertex (default: 0,0) */
  4144. uv: Vector2;
  4145. /**
  4146. * Creates a PositionNormalTextureVertex
  4147. * @param position the position of the vertex (defaut: 0,0,0)
  4148. * @param normal the normal of the vertex (defaut: 0,1,0)
  4149. * @param uv the uv of the vertex (default: 0,0)
  4150. */
  4151. constructor(
  4152. /** the position of the vertex (defaut: 0,0,0) */
  4153. position?: Vector3,
  4154. /** the normal of the vertex (defaut: 0,1,0) */
  4155. normal?: Vector3,
  4156. /** the uv of the vertex (default: 0,0) */
  4157. uv?: Vector2);
  4158. /**
  4159. * Clones the PositionNormalTextureVertex
  4160. * @returns the cloned PositionNormalTextureVertex
  4161. */
  4162. clone(): PositionNormalTextureVertex;
  4163. }
  4164. /**
  4165. * @hidden
  4166. */
  4167. export class Tmp {
  4168. static Color3: Color3[];
  4169. static Color4: Color4[];
  4170. static Vector2: Vector2[];
  4171. static Vector3: Vector3[];
  4172. static Vector4: Vector4[];
  4173. static Quaternion: Quaternion[];
  4174. static Matrix: Matrix[];
  4175. }
  4176. }
  4177. declare module BABYLON {
  4178. /**
  4179. * Class used to enable access to offline support
  4180. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4181. */
  4182. export interface IOfflineProvider {
  4183. /**
  4184. * Gets a boolean indicating if scene must be saved in the database
  4185. */
  4186. enableSceneOffline: boolean;
  4187. /**
  4188. * Gets a boolean indicating if textures must be saved in the database
  4189. */
  4190. enableTexturesOffline: boolean;
  4191. /**
  4192. * Open the offline support and make it available
  4193. * @param successCallback defines the callback to call on success
  4194. * @param errorCallback defines the callback to call on error
  4195. */
  4196. open(successCallback: () => void, errorCallback: () => void): void;
  4197. /**
  4198. * Loads an image from the offline support
  4199. * @param url defines the url to load from
  4200. * @param image defines the target DOM image
  4201. */
  4202. loadImage(url: string, image: HTMLImageElement): void;
  4203. /**
  4204. * Loads a file from offline support
  4205. * @param url defines the URL to load from
  4206. * @param sceneLoaded defines a callback to call on success
  4207. * @param progressCallBack defines a callback to call when progress changed
  4208. * @param errorCallback defines a callback to call on error
  4209. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4210. */
  4211. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4212. }
  4213. }
  4214. declare module BABYLON {
  4215. /**
  4216. * A class serves as a medium between the observable and its observers
  4217. */
  4218. export class EventState {
  4219. /**
  4220. * Create a new EventState
  4221. * @param mask defines the mask associated with this state
  4222. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4223. * @param target defines the original target of the state
  4224. * @param currentTarget defines the current target of the state
  4225. */
  4226. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4227. /**
  4228. * Initialize the current event state
  4229. * @param mask defines the mask associated with this state
  4230. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4231. * @param target defines the original target of the state
  4232. * @param currentTarget defines the current target of the state
  4233. * @returns the current event state
  4234. */
  4235. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4236. /**
  4237. * An Observer can set this property to true to prevent subsequent observers of being notified
  4238. */
  4239. skipNextObservers: boolean;
  4240. /**
  4241. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4242. */
  4243. mask: number;
  4244. /**
  4245. * The object that originally notified the event
  4246. */
  4247. target?: any;
  4248. /**
  4249. * The current object in the bubbling phase
  4250. */
  4251. currentTarget?: any;
  4252. /**
  4253. * This will be populated with the return value of the last function that was executed.
  4254. * If it is the first function in the callback chain it will be the event data.
  4255. */
  4256. lastReturnValue?: any;
  4257. }
  4258. /**
  4259. * Represent an Observer registered to a given Observable object.
  4260. */
  4261. export class Observer<T> {
  4262. /**
  4263. * Defines the callback to call when the observer is notified
  4264. */
  4265. callback: (eventData: T, eventState: EventState) => void;
  4266. /**
  4267. * Defines the mask of the observer (used to filter notifications)
  4268. */
  4269. mask: number;
  4270. /**
  4271. * Defines the current scope used to restore the JS context
  4272. */
  4273. scope: any;
  4274. /** @hidden */
  4275. _willBeUnregistered: boolean;
  4276. /**
  4277. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4278. */
  4279. unregisterOnNextCall: boolean;
  4280. /**
  4281. * Creates a new observer
  4282. * @param callback defines the callback to call when the observer is notified
  4283. * @param mask defines the mask of the observer (used to filter notifications)
  4284. * @param scope defines the current scope used to restore the JS context
  4285. */
  4286. constructor(
  4287. /**
  4288. * Defines the callback to call when the observer is notified
  4289. */
  4290. callback: (eventData: T, eventState: EventState) => void,
  4291. /**
  4292. * Defines the mask of the observer (used to filter notifications)
  4293. */
  4294. mask: number,
  4295. /**
  4296. * Defines the current scope used to restore the JS context
  4297. */
  4298. scope?: any);
  4299. }
  4300. /**
  4301. * Represent a list of observers registered to multiple Observables object.
  4302. */
  4303. export class MultiObserver<T> {
  4304. private _observers;
  4305. private _observables;
  4306. /**
  4307. * Release associated resources
  4308. */
  4309. dispose(): void;
  4310. /**
  4311. * Raise a callback when one of the observable will notify
  4312. * @param observables defines a list of observables to watch
  4313. * @param callback defines the callback to call on notification
  4314. * @param mask defines the mask used to filter notifications
  4315. * @param scope defines the current scope used to restore the JS context
  4316. * @returns the new MultiObserver
  4317. */
  4318. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4319. }
  4320. /**
  4321. * The Observable class is a simple implementation of the Observable pattern.
  4322. *
  4323. * 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.
  4324. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4325. * 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).
  4326. * 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.
  4327. */
  4328. export class Observable<T> {
  4329. private _observers;
  4330. private _eventState;
  4331. private _onObserverAdded;
  4332. /**
  4333. * Creates a new observable
  4334. * @param onObserverAdded defines a callback to call when a new observer is added
  4335. */
  4336. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4337. /**
  4338. * Create a new Observer with the specified callback
  4339. * @param callback the callback that will be executed for that Observer
  4340. * @param mask the mask used to filter observers
  4341. * @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.
  4342. * @param scope optional scope for the callback to be called from
  4343. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4344. * @returns the new observer created for the callback
  4345. */
  4346. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4347. /**
  4348. * Create a new Observer with the specified callback and unregisters after the next notification
  4349. * @param callback the callback that will be executed for that Observer
  4350. * @returns the new observer created for the callback
  4351. */
  4352. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4353. /**
  4354. * Remove an Observer from the Observable object
  4355. * @param observer the instance of the Observer to remove
  4356. * @returns false if it doesn't belong to this Observable
  4357. */
  4358. remove(observer: Nullable<Observer<T>>): boolean;
  4359. /**
  4360. * Remove a callback from the Observable object
  4361. * @param callback the callback to remove
  4362. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4363. * @returns false if it doesn't belong to this Observable
  4364. */
  4365. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4366. private _deferUnregister;
  4367. private _remove;
  4368. /**
  4369. * Moves the observable to the top of the observer list making it get called first when notified
  4370. * @param observer the observer to move
  4371. */
  4372. makeObserverTopPriority(observer: Observer<T>): void;
  4373. /**
  4374. * Moves the observable to the bottom of the observer list making it get called last when notified
  4375. * @param observer the observer to move
  4376. */
  4377. makeObserverBottomPriority(observer: Observer<T>): void;
  4378. /**
  4379. * Notify all Observers by calling their respective callback with the given data
  4380. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4381. * @param eventData defines the data to send to all observers
  4382. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4383. * @param target defines the original target of the state
  4384. * @param currentTarget defines the current target of the state
  4385. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4386. */
  4387. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4388. /**
  4389. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4390. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4391. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4392. * and it is crucial that all callbacks will be executed.
  4393. * The order of the callbacks is kept, callbacks are not executed parallel.
  4394. *
  4395. * @param eventData The data to be sent to each callback
  4396. * @param mask is used to filter observers defaults to -1
  4397. * @param target defines the callback target (see EventState)
  4398. * @param currentTarget defines he current object in the bubbling phase
  4399. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4400. */
  4401. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4402. /**
  4403. * Notify a specific observer
  4404. * @param observer defines the observer to notify
  4405. * @param eventData defines the data to be sent to each callback
  4406. * @param mask is used to filter observers defaults to -1
  4407. */
  4408. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4409. /**
  4410. * Gets a boolean indicating if the observable has at least one observer
  4411. * @returns true is the Observable has at least one Observer registered
  4412. */
  4413. hasObservers(): boolean;
  4414. /**
  4415. * Clear the list of observers
  4416. */
  4417. clear(): void;
  4418. /**
  4419. * Clone the current observable
  4420. * @returns a new observable
  4421. */
  4422. clone(): Observable<T>;
  4423. /**
  4424. * Does this observable handles observer registered with a given mask
  4425. * @param mask defines the mask to be tested
  4426. * @return whether or not one observer registered with the given mask is handeled
  4427. **/
  4428. hasSpecificMask(mask?: number): boolean;
  4429. }
  4430. }
  4431. declare module BABYLON {
  4432. /**
  4433. * Class used to help managing file picking and drag'n'drop
  4434. * File Storage
  4435. */
  4436. export class FilesInputStore {
  4437. /**
  4438. * List of files ready to be loaded
  4439. */
  4440. static FilesToLoad: {
  4441. [key: string]: File;
  4442. };
  4443. }
  4444. }
  4445. declare module BABYLON {
  4446. /** Defines the cross module used constants to avoid circular dependncies */
  4447. export class Constants {
  4448. /** Defines that alpha blending is disabled */
  4449. static readonly ALPHA_DISABLE: number;
  4450. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4451. static readonly ALPHA_ADD: number;
  4452. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4453. static readonly ALPHA_COMBINE: number;
  4454. /** Defines that alpha blending to DEST - SRC * DEST */
  4455. static readonly ALPHA_SUBTRACT: number;
  4456. /** Defines that alpha blending to SRC * DEST */
  4457. static readonly ALPHA_MULTIPLY: number;
  4458. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4459. static readonly ALPHA_MAXIMIZED: number;
  4460. /** Defines that alpha blending to SRC + DEST */
  4461. static readonly ALPHA_ONEONE: number;
  4462. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4463. static readonly ALPHA_PREMULTIPLIED: number;
  4464. /**
  4465. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4466. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4467. */
  4468. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4469. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4470. static readonly ALPHA_INTERPOLATE: number;
  4471. /**
  4472. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4473. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4474. */
  4475. static readonly ALPHA_SCREENMODE: number;
  4476. /** Defines that the ressource is not delayed*/
  4477. static readonly DELAYLOADSTATE_NONE: number;
  4478. /** Defines that the ressource was successfully delay loaded */
  4479. static readonly DELAYLOADSTATE_LOADED: number;
  4480. /** Defines that the ressource is currently delay loading */
  4481. static readonly DELAYLOADSTATE_LOADING: number;
  4482. /** Defines that the ressource is delayed and has not started loading */
  4483. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4484. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4485. static readonly NEVER: number;
  4486. /** 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 */
  4487. static readonly ALWAYS: number;
  4488. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4489. static readonly LESS: number;
  4490. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4491. static readonly EQUAL: number;
  4492. /** 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 */
  4493. static readonly LEQUAL: number;
  4494. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4495. static readonly GREATER: number;
  4496. /** 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 */
  4497. static readonly GEQUAL: number;
  4498. /** 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 */
  4499. static readonly NOTEQUAL: number;
  4500. /** Passed to stencilOperation to specify that stencil value must be kept */
  4501. static readonly KEEP: number;
  4502. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4503. static readonly REPLACE: number;
  4504. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4505. static readonly INCR: number;
  4506. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4507. static readonly DECR: number;
  4508. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4509. static readonly INVERT: number;
  4510. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4511. static readonly INCR_WRAP: number;
  4512. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4513. static readonly DECR_WRAP: number;
  4514. /** Texture is not repeating outside of 0..1 UVs */
  4515. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4516. /** Texture is repeating outside of 0..1 UVs */
  4517. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4518. /** Texture is repeating and mirrored */
  4519. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4520. /** ALPHA */
  4521. static readonly TEXTUREFORMAT_ALPHA: number;
  4522. /** LUMINANCE */
  4523. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4524. /** LUMINANCE_ALPHA */
  4525. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4526. /** RGB */
  4527. static readonly TEXTUREFORMAT_RGB: number;
  4528. /** RGBA */
  4529. static readonly TEXTUREFORMAT_RGBA: number;
  4530. /** RED */
  4531. static readonly TEXTUREFORMAT_RED: number;
  4532. /** RED (2nd reference) */
  4533. static readonly TEXTUREFORMAT_R: number;
  4534. /** RG */
  4535. static readonly TEXTUREFORMAT_RG: number;
  4536. /** RED_INTEGER */
  4537. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4538. /** RED_INTEGER (2nd reference) */
  4539. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4540. /** RG_INTEGER */
  4541. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4542. /** RGB_INTEGER */
  4543. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4544. /** RGBA_INTEGER */
  4545. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4546. /** UNSIGNED_BYTE */
  4547. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4548. /** UNSIGNED_BYTE (2nd reference) */
  4549. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4550. /** FLOAT */
  4551. static readonly TEXTURETYPE_FLOAT: number;
  4552. /** HALF_FLOAT */
  4553. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4554. /** BYTE */
  4555. static readonly TEXTURETYPE_BYTE: number;
  4556. /** SHORT */
  4557. static readonly TEXTURETYPE_SHORT: number;
  4558. /** UNSIGNED_SHORT */
  4559. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4560. /** INT */
  4561. static readonly TEXTURETYPE_INT: number;
  4562. /** UNSIGNED_INT */
  4563. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4564. /** UNSIGNED_SHORT_4_4_4_4 */
  4565. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4566. /** UNSIGNED_SHORT_5_5_5_1 */
  4567. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4568. /** UNSIGNED_SHORT_5_6_5 */
  4569. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4570. /** UNSIGNED_INT_2_10_10_10_REV */
  4571. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4572. /** UNSIGNED_INT_24_8 */
  4573. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4574. /** UNSIGNED_INT_10F_11F_11F_REV */
  4575. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4576. /** UNSIGNED_INT_5_9_9_9_REV */
  4577. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4578. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4579. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4580. /** nearest is mag = nearest and min = nearest and mip = linear */
  4581. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4582. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4583. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4584. /** Trilinear is mag = linear and min = linear and mip = linear */
  4585. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4586. /** nearest is mag = nearest and min = nearest and mip = linear */
  4587. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4588. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4589. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4590. /** Trilinear is mag = linear and min = linear and mip = linear */
  4591. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4592. /** mag = nearest and min = nearest and mip = nearest */
  4593. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4594. /** mag = nearest and min = linear and mip = nearest */
  4595. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4596. /** mag = nearest and min = linear and mip = linear */
  4597. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4598. /** mag = nearest and min = linear and mip = none */
  4599. static readonly TEXTURE_NEAREST_LINEAR: number;
  4600. /** mag = nearest and min = nearest and mip = none */
  4601. static readonly TEXTURE_NEAREST_NEAREST: number;
  4602. /** mag = linear and min = nearest and mip = nearest */
  4603. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4604. /** mag = linear and min = nearest and mip = linear */
  4605. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4606. /** mag = linear and min = linear and mip = none */
  4607. static readonly TEXTURE_LINEAR_LINEAR: number;
  4608. /** mag = linear and min = nearest and mip = none */
  4609. static readonly TEXTURE_LINEAR_NEAREST: number;
  4610. /** Explicit coordinates mode */
  4611. static readonly TEXTURE_EXPLICIT_MODE: number;
  4612. /** Spherical coordinates mode */
  4613. static readonly TEXTURE_SPHERICAL_MODE: number;
  4614. /** Planar coordinates mode */
  4615. static readonly TEXTURE_PLANAR_MODE: number;
  4616. /** Cubic coordinates mode */
  4617. static readonly TEXTURE_CUBIC_MODE: number;
  4618. /** Projection coordinates mode */
  4619. static readonly TEXTURE_PROJECTION_MODE: number;
  4620. /** Skybox coordinates mode */
  4621. static readonly TEXTURE_SKYBOX_MODE: number;
  4622. /** Inverse Cubic coordinates mode */
  4623. static readonly TEXTURE_INVCUBIC_MODE: number;
  4624. /** Equirectangular coordinates mode */
  4625. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4626. /** Equirectangular Fixed coordinates mode */
  4627. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4628. /** Equirectangular Fixed Mirrored coordinates mode */
  4629. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4630. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4631. static readonly SCALEMODE_FLOOR: number;
  4632. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4633. static readonly SCALEMODE_NEAREST: number;
  4634. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4635. static readonly SCALEMODE_CEILING: number;
  4636. /**
  4637. * The dirty texture flag value
  4638. */
  4639. static readonly MATERIAL_TextureDirtyFlag: number;
  4640. /**
  4641. * The dirty light flag value
  4642. */
  4643. static readonly MATERIAL_LightDirtyFlag: number;
  4644. /**
  4645. * The dirty fresnel flag value
  4646. */
  4647. static readonly MATERIAL_FresnelDirtyFlag: number;
  4648. /**
  4649. * The dirty attribute flag value
  4650. */
  4651. static readonly MATERIAL_AttributesDirtyFlag: number;
  4652. /**
  4653. * The dirty misc flag value
  4654. */
  4655. static readonly MATERIAL_MiscDirtyFlag: number;
  4656. /**
  4657. * The all dirty flag value
  4658. */
  4659. static readonly MATERIAL_AllDirtyFlag: number;
  4660. /**
  4661. * Returns the triangle fill mode
  4662. */
  4663. static readonly MATERIAL_TriangleFillMode: number;
  4664. /**
  4665. * Returns the wireframe mode
  4666. */
  4667. static readonly MATERIAL_WireFrameFillMode: number;
  4668. /**
  4669. * Returns the point fill mode
  4670. */
  4671. static readonly MATERIAL_PointFillMode: number;
  4672. /**
  4673. * Returns the point list draw mode
  4674. */
  4675. static readonly MATERIAL_PointListDrawMode: number;
  4676. /**
  4677. * Returns the line list draw mode
  4678. */
  4679. static readonly MATERIAL_LineListDrawMode: number;
  4680. /**
  4681. * Returns the line loop draw mode
  4682. */
  4683. static readonly MATERIAL_LineLoopDrawMode: number;
  4684. /**
  4685. * Returns the line strip draw mode
  4686. */
  4687. static readonly MATERIAL_LineStripDrawMode: number;
  4688. /**
  4689. * Returns the triangle strip draw mode
  4690. */
  4691. static readonly MATERIAL_TriangleStripDrawMode: number;
  4692. /**
  4693. * Returns the triangle fan draw mode
  4694. */
  4695. static readonly MATERIAL_TriangleFanDrawMode: number;
  4696. /**
  4697. * Stores the clock-wise side orientation
  4698. */
  4699. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4700. /**
  4701. * Stores the counter clock-wise side orientation
  4702. */
  4703. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4704. /**
  4705. * Nothing
  4706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4707. */
  4708. static readonly ACTION_NothingTrigger: number;
  4709. /**
  4710. * On pick
  4711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4712. */
  4713. static readonly ACTION_OnPickTrigger: number;
  4714. /**
  4715. * On left pick
  4716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4717. */
  4718. static readonly ACTION_OnLeftPickTrigger: number;
  4719. /**
  4720. * On right pick
  4721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4722. */
  4723. static readonly ACTION_OnRightPickTrigger: number;
  4724. /**
  4725. * On center pick
  4726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4727. */
  4728. static readonly ACTION_OnCenterPickTrigger: number;
  4729. /**
  4730. * On pick down
  4731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4732. */
  4733. static readonly ACTION_OnPickDownTrigger: number;
  4734. /**
  4735. * On double pick
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_OnDoublePickTrigger: number;
  4739. /**
  4740. * On pick up
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnPickUpTrigger: number;
  4744. /**
  4745. * On pick out.
  4746. * This trigger will only be raised if you also declared a OnPickDown
  4747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4748. */
  4749. static readonly ACTION_OnPickOutTrigger: number;
  4750. /**
  4751. * On long press
  4752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4753. */
  4754. static readonly ACTION_OnLongPressTrigger: number;
  4755. /**
  4756. * On pointer over
  4757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4758. */
  4759. static readonly ACTION_OnPointerOverTrigger: number;
  4760. /**
  4761. * On pointer out
  4762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4763. */
  4764. static readonly ACTION_OnPointerOutTrigger: number;
  4765. /**
  4766. * On every frame
  4767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4768. */
  4769. static readonly ACTION_OnEveryFrameTrigger: number;
  4770. /**
  4771. * On intersection enter
  4772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4773. */
  4774. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4775. /**
  4776. * On intersection exit
  4777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4778. */
  4779. static readonly ACTION_OnIntersectionExitTrigger: number;
  4780. /**
  4781. * On key down
  4782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4783. */
  4784. static readonly ACTION_OnKeyDownTrigger: number;
  4785. /**
  4786. * On key up
  4787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4788. */
  4789. static readonly ACTION_OnKeyUpTrigger: number;
  4790. /**
  4791. * Billboard mode will only apply to Y axis
  4792. */
  4793. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4794. /**
  4795. * Billboard mode will apply to all axes
  4796. */
  4797. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4798. /**
  4799. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4800. */
  4801. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4802. /**
  4803. * Gets or sets base Assets URL
  4804. */
  4805. static readonly PARTICLES_BaseAssetsUrl: string;
  4806. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4807. * Test order :
  4808. * Is the bounding sphere outside the frustum ?
  4809. * If not, are the bounding box vertices outside the frustum ?
  4810. * It not, then the cullable object is in the frustum.
  4811. */
  4812. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4813. /** Culling strategy : Bounding Sphere Only.
  4814. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4815. * It's also less accurate than the standard because some not visible objects can still be selected.
  4816. * Test : is the bounding sphere outside the frustum ?
  4817. * If not, then the cullable object is in the frustum.
  4818. */
  4819. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4820. /** Culling strategy : Optimistic Inclusion.
  4821. * This in an inclusion test first, then the standard exclusion test.
  4822. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4823. * 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.
  4824. * Anyway, it's as accurate as the standard strategy.
  4825. * Test :
  4826. * Is the cullable object bounding sphere center in the frustum ?
  4827. * If not, apply the default culling strategy.
  4828. */
  4829. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4830. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4831. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4832. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4833. * 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.
  4834. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4835. * Test :
  4836. * Is the cullable object bounding sphere center in the frustum ?
  4837. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4838. */
  4839. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4840. /**
  4841. * No logging while loading
  4842. */
  4843. static readonly SCENELOADER_NO_LOGGING: number;
  4844. /**
  4845. * Minimal logging while loading
  4846. */
  4847. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4848. /**
  4849. * Summary logging while loading
  4850. */
  4851. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4852. /**
  4853. * Detailled logging while loading
  4854. */
  4855. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4856. }
  4857. }
  4858. declare module BABYLON {
  4859. /**
  4860. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4861. * Babylon.js
  4862. */
  4863. export class DomManagement {
  4864. /**
  4865. * Checks if the window object exists
  4866. * @returns true if the window object exists
  4867. */
  4868. static IsWindowObjectExist(): boolean;
  4869. /**
  4870. * Extracts text content from a DOM element hierarchy
  4871. * @param element defines the root element
  4872. * @returns a string
  4873. */
  4874. static GetDOMTextContent(element: HTMLElement): string;
  4875. }
  4876. }
  4877. declare module BABYLON {
  4878. /**
  4879. * Logger used througouht the application to allow configuration of
  4880. * the log level required for the messages.
  4881. */
  4882. export class Logger {
  4883. /**
  4884. * No log
  4885. */
  4886. static readonly NoneLogLevel: number;
  4887. /**
  4888. * Only message logs
  4889. */
  4890. static readonly MessageLogLevel: number;
  4891. /**
  4892. * Only warning logs
  4893. */
  4894. static readonly WarningLogLevel: number;
  4895. /**
  4896. * Only error logs
  4897. */
  4898. static readonly ErrorLogLevel: number;
  4899. /**
  4900. * All logs
  4901. */
  4902. static readonly AllLogLevel: number;
  4903. private static _LogCache;
  4904. /**
  4905. * Gets a value indicating the number of loading errors
  4906. * @ignorenaming
  4907. */
  4908. static errorsCount: number;
  4909. /**
  4910. * Callback called when a new log is added
  4911. */
  4912. static OnNewCacheEntry: (entry: string) => void;
  4913. private static _AddLogEntry;
  4914. private static _FormatMessage;
  4915. private static _LogDisabled;
  4916. private static _LogEnabled;
  4917. private static _WarnDisabled;
  4918. private static _WarnEnabled;
  4919. private static _ErrorDisabled;
  4920. private static _ErrorEnabled;
  4921. /**
  4922. * Log a message to the console
  4923. */
  4924. static Log: (message: string) => void;
  4925. /**
  4926. * Write a warning message to the console
  4927. */
  4928. static Warn: (message: string) => void;
  4929. /**
  4930. * Write an error message to the console
  4931. */
  4932. static Error: (message: string) => void;
  4933. /**
  4934. * Gets current log cache (list of logs)
  4935. */
  4936. static readonly LogCache: string;
  4937. /**
  4938. * Clears the log cache
  4939. */
  4940. static ClearLogCache(): void;
  4941. /**
  4942. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4943. */
  4944. static LogLevels: number;
  4945. }
  4946. }
  4947. declare module BABYLON {
  4948. /** @hidden */
  4949. export class _TypeStore {
  4950. /** @hidden */
  4951. static RegisteredTypes: {
  4952. [key: string]: Object;
  4953. };
  4954. /** @hidden */
  4955. static GetClass(fqdn: string): any;
  4956. }
  4957. }
  4958. declare module BABYLON {
  4959. /**
  4960. * Class containing a set of static utilities functions for deep copy.
  4961. */
  4962. export class DeepCopier {
  4963. /**
  4964. * Tries to copy an object by duplicating every property
  4965. * @param source defines the source object
  4966. * @param destination defines the target object
  4967. * @param doNotCopyList defines a list of properties to avoid
  4968. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4969. */
  4970. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4971. }
  4972. }
  4973. declare module BABYLON {
  4974. /**
  4975. * Class containing a set of static utilities functions for precision date
  4976. */
  4977. export class PrecisionDate {
  4978. /**
  4979. * Gets either window.performance.now() if supported or Date.now() else
  4980. */
  4981. static readonly Now: number;
  4982. }
  4983. }
  4984. declare module BABYLON {
  4985. /** @hidden */
  4986. export class _DevTools {
  4987. static WarnImport(name: string): string;
  4988. }
  4989. }
  4990. declare module BABYLON {
  4991. /**
  4992. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4993. */
  4994. export class WebRequest {
  4995. private _xhr;
  4996. /**
  4997. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4998. * i.e. when loading files, where the server/service expects an Authorization header
  4999. */
  5000. static CustomRequestHeaders: {
  5001. [key: string]: string;
  5002. };
  5003. /**
  5004. * Add callback functions in this array to update all the requests before they get sent to the network
  5005. */
  5006. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5007. private _injectCustomRequestHeaders;
  5008. /**
  5009. * Gets or sets a function to be called when loading progress changes
  5010. */
  5011. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5012. /**
  5013. * Returns client's state
  5014. */
  5015. readonly readyState: number;
  5016. /**
  5017. * Returns client's status
  5018. */
  5019. readonly status: number;
  5020. /**
  5021. * Returns client's status as a text
  5022. */
  5023. readonly statusText: string;
  5024. /**
  5025. * Returns client's response
  5026. */
  5027. readonly response: any;
  5028. /**
  5029. * Returns client's response url
  5030. */
  5031. readonly responseURL: string;
  5032. /**
  5033. * Returns client's response as text
  5034. */
  5035. readonly responseText: string;
  5036. /**
  5037. * Gets or sets the expected response type
  5038. */
  5039. responseType: XMLHttpRequestResponseType;
  5040. /** @hidden */
  5041. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5042. /** @hidden */
  5043. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5044. /**
  5045. * Cancels any network activity
  5046. */
  5047. abort(): void;
  5048. /**
  5049. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5050. * @param body defines an optional request body
  5051. */
  5052. send(body?: Document | BodyInit | null): void;
  5053. /**
  5054. * Sets the request method, request URL
  5055. * @param method defines the method to use (GET, POST, etc..)
  5056. * @param url defines the url to connect with
  5057. */
  5058. open(method: string, url: string): void;
  5059. }
  5060. }
  5061. declare module BABYLON {
  5062. /**
  5063. * Class used to evalaute queries containing `and` and `or` operators
  5064. */
  5065. export class AndOrNotEvaluator {
  5066. /**
  5067. * Evaluate a query
  5068. * @param query defines the query to evaluate
  5069. * @param evaluateCallback defines the callback used to filter result
  5070. * @returns true if the query matches
  5071. */
  5072. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5073. private static _HandleParenthesisContent;
  5074. private static _SimplifyNegation;
  5075. }
  5076. }
  5077. declare module BABYLON {
  5078. /**
  5079. * Class used to store custom tags
  5080. */
  5081. export class Tags {
  5082. /**
  5083. * Adds support for tags on the given object
  5084. * @param obj defines the object to use
  5085. */
  5086. static EnableFor(obj: any): void;
  5087. /**
  5088. * Removes tags support
  5089. * @param obj defines the object to use
  5090. */
  5091. static DisableFor(obj: any): void;
  5092. /**
  5093. * Gets a boolean indicating if the given object has tags
  5094. * @param obj defines the object to use
  5095. * @returns a boolean
  5096. */
  5097. static HasTags(obj: any): boolean;
  5098. /**
  5099. * Gets the tags available on a given object
  5100. * @param obj defines the object to use
  5101. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5102. * @returns the tags
  5103. */
  5104. static GetTags(obj: any, asString?: boolean): any;
  5105. /**
  5106. * Adds tags to an object
  5107. * @param obj defines the object to use
  5108. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5109. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5110. */
  5111. static AddTagsTo(obj: any, tagsString: string): void;
  5112. /**
  5113. * @hidden
  5114. */
  5115. static _AddTagTo(obj: any, tag: string): void;
  5116. /**
  5117. * Removes specific tags from a specific object
  5118. * @param obj defines the object to use
  5119. * @param tagsString defines the tags to remove
  5120. */
  5121. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5122. /**
  5123. * @hidden
  5124. */
  5125. static _RemoveTagFrom(obj: any, tag: string): void;
  5126. /**
  5127. * Defines if tags hosted on an object match a given query
  5128. * @param obj defines the object to use
  5129. * @param tagsQuery defines the tag query
  5130. * @returns a boolean
  5131. */
  5132. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5133. }
  5134. }
  5135. declare module BABYLON {
  5136. /**
  5137. * Manages the defines for the Material
  5138. */
  5139. export class MaterialDefines {
  5140. private _keys;
  5141. private _isDirty;
  5142. /** @hidden */
  5143. _renderId: number;
  5144. /** @hidden */
  5145. _areLightsDirty: boolean;
  5146. /** @hidden */
  5147. _areAttributesDirty: boolean;
  5148. /** @hidden */
  5149. _areTexturesDirty: boolean;
  5150. /** @hidden */
  5151. _areFresnelDirty: boolean;
  5152. /** @hidden */
  5153. _areMiscDirty: boolean;
  5154. /** @hidden */
  5155. _areImageProcessingDirty: boolean;
  5156. /** @hidden */
  5157. _normals: boolean;
  5158. /** @hidden */
  5159. _uvs: boolean;
  5160. /** @hidden */
  5161. _needNormals: boolean;
  5162. /** @hidden */
  5163. _needUVs: boolean;
  5164. /**
  5165. * Specifies if the material needs to be re-calculated
  5166. */
  5167. readonly isDirty: boolean;
  5168. /**
  5169. * Marks the material to indicate that it has been re-calculated
  5170. */
  5171. markAsProcessed(): void;
  5172. /**
  5173. * Marks the material to indicate that it needs to be re-calculated
  5174. */
  5175. markAsUnprocessed(): void;
  5176. /**
  5177. * Marks the material to indicate all of its defines need to be re-calculated
  5178. */
  5179. markAllAsDirty(): void;
  5180. /**
  5181. * Marks the material to indicate that image processing needs to be re-calculated
  5182. */
  5183. markAsImageProcessingDirty(): void;
  5184. /**
  5185. * Marks the material to indicate the lights need to be re-calculated
  5186. */
  5187. markAsLightDirty(): void;
  5188. /**
  5189. * Marks the attribute state as changed
  5190. */
  5191. markAsAttributesDirty(): void;
  5192. /**
  5193. * Marks the texture state as changed
  5194. */
  5195. markAsTexturesDirty(): void;
  5196. /**
  5197. * Marks the fresnel state as changed
  5198. */
  5199. markAsFresnelDirty(): void;
  5200. /**
  5201. * Marks the misc state as changed
  5202. */
  5203. markAsMiscDirty(): void;
  5204. /**
  5205. * Rebuilds the material defines
  5206. */
  5207. rebuild(): void;
  5208. /**
  5209. * Specifies if two material defines are equal
  5210. * @param other - A material define instance to compare to
  5211. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5212. */
  5213. isEqual(other: MaterialDefines): boolean;
  5214. /**
  5215. * Clones this instance's defines to another instance
  5216. * @param other - material defines to clone values to
  5217. */
  5218. cloneTo(other: MaterialDefines): void;
  5219. /**
  5220. * Resets the material define values
  5221. */
  5222. reset(): void;
  5223. /**
  5224. * Converts the material define values to a string
  5225. * @returns - String of material define information
  5226. */
  5227. toString(): string;
  5228. }
  5229. }
  5230. declare module BABYLON {
  5231. /**
  5232. * Class used to store and describe the pipeline context associated with an effect
  5233. */
  5234. export interface IPipelineContext {
  5235. /**
  5236. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5237. */
  5238. isAsync: boolean;
  5239. /**
  5240. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5241. */
  5242. isReady: boolean;
  5243. /** @hidden */
  5244. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5245. }
  5246. }
  5247. declare module BABYLON {
  5248. /**
  5249. * Class used to store gfx data (like WebGLBuffer)
  5250. */
  5251. export class DataBuffer {
  5252. /**
  5253. * Gets or sets the number of objects referencing this buffer
  5254. */
  5255. references: number;
  5256. /** Gets or sets the size of the underlying buffer */
  5257. capacity: number;
  5258. /**
  5259. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5260. */
  5261. is32Bits: boolean;
  5262. /**
  5263. * Gets the underlying buffer
  5264. */
  5265. readonly underlyingResource: any;
  5266. }
  5267. }
  5268. declare module BABYLON {
  5269. /**
  5270. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5271. */
  5272. export class PerformanceMonitor {
  5273. private _enabled;
  5274. private _rollingFrameTime;
  5275. private _lastFrameTimeMs;
  5276. /**
  5277. * constructor
  5278. * @param frameSampleSize The number of samples required to saturate the sliding window
  5279. */
  5280. constructor(frameSampleSize?: number);
  5281. /**
  5282. * Samples current frame
  5283. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5284. */
  5285. sampleFrame(timeMs?: number): void;
  5286. /**
  5287. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5288. */
  5289. readonly averageFrameTime: number;
  5290. /**
  5291. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5292. */
  5293. readonly averageFrameTimeVariance: number;
  5294. /**
  5295. * Returns the frame time of the most recent frame
  5296. */
  5297. readonly instantaneousFrameTime: number;
  5298. /**
  5299. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5300. */
  5301. readonly averageFPS: number;
  5302. /**
  5303. * Returns the average framerate in frames per second using the most recent frame time
  5304. */
  5305. readonly instantaneousFPS: number;
  5306. /**
  5307. * Returns true if enough samples have been taken to completely fill the sliding window
  5308. */
  5309. readonly isSaturated: boolean;
  5310. /**
  5311. * Enables contributions to the sliding window sample set
  5312. */
  5313. enable(): void;
  5314. /**
  5315. * Disables contributions to the sliding window sample set
  5316. * Samples will not be interpolated over the disabled period
  5317. */
  5318. disable(): void;
  5319. /**
  5320. * Returns true if sampling is enabled
  5321. */
  5322. readonly isEnabled: boolean;
  5323. /**
  5324. * Resets performance monitor
  5325. */
  5326. reset(): void;
  5327. }
  5328. /**
  5329. * RollingAverage
  5330. *
  5331. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5332. */
  5333. export class RollingAverage {
  5334. /**
  5335. * Current average
  5336. */
  5337. average: number;
  5338. /**
  5339. * Current variance
  5340. */
  5341. variance: number;
  5342. protected _samples: Array<number>;
  5343. protected _sampleCount: number;
  5344. protected _pos: number;
  5345. protected _m2: number;
  5346. /**
  5347. * constructor
  5348. * @param length The number of samples required to saturate the sliding window
  5349. */
  5350. constructor(length: number);
  5351. /**
  5352. * Adds a sample to the sample set
  5353. * @param v The sample value
  5354. */
  5355. add(v: number): void;
  5356. /**
  5357. * Returns previously added values or null if outside of history or outside the sliding window domain
  5358. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5359. * @return Value previously recorded with add() or null if outside of range
  5360. */
  5361. history(i: number): number;
  5362. /**
  5363. * Returns true if enough samples have been taken to completely fill the sliding window
  5364. * @return true if sample-set saturated
  5365. */
  5366. isSaturated(): boolean;
  5367. /**
  5368. * Resets the rolling average (equivalent to 0 samples taken so far)
  5369. */
  5370. reset(): void;
  5371. /**
  5372. * Wraps a value around the sample range boundaries
  5373. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5374. * @return Wrapped position in sample range
  5375. */
  5376. protected _wrapPosition(i: number): number;
  5377. }
  5378. }
  5379. declare module BABYLON {
  5380. /**
  5381. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5382. * The underlying implementation relies on an associative array to ensure the best performances.
  5383. * The value can be anything including 'null' but except 'undefined'
  5384. */
  5385. export class StringDictionary<T> {
  5386. /**
  5387. * This will clear this dictionary and copy the content from the 'source' one.
  5388. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5389. * @param source the dictionary to take the content from and copy to this dictionary
  5390. */
  5391. copyFrom(source: StringDictionary<T>): void;
  5392. /**
  5393. * Get a value based from its key
  5394. * @param key the given key to get the matching value from
  5395. * @return the value if found, otherwise undefined is returned
  5396. */
  5397. get(key: string): T | undefined;
  5398. /**
  5399. * Get a value from its key or add it if it doesn't exist.
  5400. * This method will ensure you that a given key/data will be present in the dictionary.
  5401. * @param key the given key to get the matching value from
  5402. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5403. * The factory will only be invoked if there's no data for the given key.
  5404. * @return the value corresponding to the key.
  5405. */
  5406. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5407. /**
  5408. * Get a value from its key if present in the dictionary otherwise add it
  5409. * @param key the key to get the value from
  5410. * @param val if there's no such key/value pair in the dictionary add it with this value
  5411. * @return the value corresponding to the key
  5412. */
  5413. getOrAdd(key: string, val: T): T;
  5414. /**
  5415. * Check if there's a given key in the dictionary
  5416. * @param key the key to check for
  5417. * @return true if the key is present, false otherwise
  5418. */
  5419. contains(key: string): boolean;
  5420. /**
  5421. * Add a new key and its corresponding value
  5422. * @param key the key to add
  5423. * @param value the value corresponding to the key
  5424. * @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
  5425. */
  5426. add(key: string, value: T): boolean;
  5427. /**
  5428. * Update a specific value associated to a key
  5429. * @param key defines the key to use
  5430. * @param value defines the value to store
  5431. * @returns true if the value was updated (or false if the key was not found)
  5432. */
  5433. set(key: string, value: T): boolean;
  5434. /**
  5435. * Get the element of the given key and remove it from the dictionary
  5436. * @param key defines the key to search
  5437. * @returns the value associated with the key or null if not found
  5438. */
  5439. getAndRemove(key: string): Nullable<T>;
  5440. /**
  5441. * Remove a key/value from the dictionary.
  5442. * @param key the key to remove
  5443. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5444. */
  5445. remove(key: string): boolean;
  5446. /**
  5447. * Clear the whole content of the dictionary
  5448. */
  5449. clear(): void;
  5450. /**
  5451. * Gets the current count
  5452. */
  5453. readonly count: number;
  5454. /**
  5455. * Execute a callback on each key/val of the dictionary.
  5456. * Note that you can remove any element in this dictionary in the callback implementation
  5457. * @param callback the callback to execute on a given key/value pair
  5458. */
  5459. forEach(callback: (key: string, val: T) => void): void;
  5460. /**
  5461. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5462. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5463. * Note that you can remove any element in this dictionary in the callback implementation
  5464. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5465. * @returns the first item
  5466. */
  5467. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5468. private _count;
  5469. private _data;
  5470. }
  5471. }
  5472. declare module BABYLON {
  5473. /**
  5474. * Helper class that provides a small promise polyfill
  5475. */
  5476. export class PromisePolyfill {
  5477. /**
  5478. * Static function used to check if the polyfill is required
  5479. * If this is the case then the function will inject the polyfill to window.Promise
  5480. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5481. */
  5482. static Apply(force?: boolean): void;
  5483. }
  5484. }
  5485. declare module BABYLON {
  5486. /**
  5487. * Class used to store data that will be store in GPU memory
  5488. */
  5489. export class Buffer {
  5490. private _engine;
  5491. private _buffer;
  5492. /** @hidden */
  5493. _data: Nullable<DataArray>;
  5494. private _updatable;
  5495. private _instanced;
  5496. /**
  5497. * Gets the byte stride.
  5498. */
  5499. readonly byteStride: number;
  5500. /**
  5501. * Constructor
  5502. * @param engine the engine
  5503. * @param data the data to use for this buffer
  5504. * @param updatable whether the data is updatable
  5505. * @param stride the stride (optional)
  5506. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5507. * @param instanced whether the buffer is instanced (optional)
  5508. * @param useBytes set to true if the stride in in bytes (optional)
  5509. */
  5510. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5511. /**
  5512. * Create a new VertexBuffer based on the current buffer
  5513. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5514. * @param offset defines offset in the buffer (0 by default)
  5515. * @param size defines the size in floats of attributes (position is 3 for instance)
  5516. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5517. * @param instanced defines if the vertex buffer contains indexed data
  5518. * @param useBytes defines if the offset and stride are in bytes
  5519. * @returns the new vertex buffer
  5520. */
  5521. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5522. /**
  5523. * Gets a boolean indicating if the Buffer is updatable?
  5524. * @returns true if the buffer is updatable
  5525. */
  5526. isUpdatable(): boolean;
  5527. /**
  5528. * Gets current buffer's data
  5529. * @returns a DataArray or null
  5530. */
  5531. getData(): Nullable<DataArray>;
  5532. /**
  5533. * Gets underlying native buffer
  5534. * @returns underlying native buffer
  5535. */
  5536. getBuffer(): Nullable<DataBuffer>;
  5537. /**
  5538. * Gets the stride in float32 units (i.e. byte stride / 4).
  5539. * May not be an integer if the byte stride is not divisible by 4.
  5540. * DEPRECATED. Use byteStride instead.
  5541. * @returns the stride in float32 units
  5542. */
  5543. getStrideSize(): number;
  5544. /**
  5545. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5546. * @param data defines the data to store
  5547. */
  5548. create(data?: Nullable<DataArray>): void;
  5549. /** @hidden */
  5550. _rebuild(): void;
  5551. /**
  5552. * Update current buffer data
  5553. * @param data defines the data to store
  5554. */
  5555. update(data: DataArray): void;
  5556. /**
  5557. * Updates the data directly.
  5558. * @param data the new data
  5559. * @param offset the new offset
  5560. * @param vertexCount the vertex count (optional)
  5561. * @param useBytes set to true if the offset is in bytes
  5562. */
  5563. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5564. /**
  5565. * Release all resources
  5566. */
  5567. dispose(): void;
  5568. }
  5569. /**
  5570. * Specialized buffer used to store vertex data
  5571. */
  5572. export class VertexBuffer {
  5573. /** @hidden */
  5574. _buffer: Buffer;
  5575. private _kind;
  5576. private _size;
  5577. private _ownsBuffer;
  5578. private _instanced;
  5579. private _instanceDivisor;
  5580. /**
  5581. * The byte type.
  5582. */
  5583. static readonly BYTE: number;
  5584. /**
  5585. * The unsigned byte type.
  5586. */
  5587. static readonly UNSIGNED_BYTE: number;
  5588. /**
  5589. * The short type.
  5590. */
  5591. static readonly SHORT: number;
  5592. /**
  5593. * The unsigned short type.
  5594. */
  5595. static readonly UNSIGNED_SHORT: number;
  5596. /**
  5597. * The integer type.
  5598. */
  5599. static readonly INT: number;
  5600. /**
  5601. * The unsigned integer type.
  5602. */
  5603. static readonly UNSIGNED_INT: number;
  5604. /**
  5605. * The float type.
  5606. */
  5607. static readonly FLOAT: number;
  5608. /**
  5609. * Gets or sets the instance divisor when in instanced mode
  5610. */
  5611. instanceDivisor: number;
  5612. /**
  5613. * Gets the byte stride.
  5614. */
  5615. readonly byteStride: number;
  5616. /**
  5617. * Gets the byte offset.
  5618. */
  5619. readonly byteOffset: number;
  5620. /**
  5621. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5622. */
  5623. readonly normalized: boolean;
  5624. /**
  5625. * Gets the data type of each component in the array.
  5626. */
  5627. readonly type: number;
  5628. /**
  5629. * Constructor
  5630. * @param engine the engine
  5631. * @param data the data to use for this vertex buffer
  5632. * @param kind the vertex buffer kind
  5633. * @param updatable whether the data is updatable
  5634. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5635. * @param stride the stride (optional)
  5636. * @param instanced whether the buffer is instanced (optional)
  5637. * @param offset the offset of the data (optional)
  5638. * @param size the number of components (optional)
  5639. * @param type the type of the component (optional)
  5640. * @param normalized whether the data contains normalized data (optional)
  5641. * @param useBytes set to true if stride and offset are in bytes (optional)
  5642. */
  5643. 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);
  5644. /** @hidden */
  5645. _rebuild(): void;
  5646. /**
  5647. * Returns the kind of the VertexBuffer (string)
  5648. * @returns a string
  5649. */
  5650. getKind(): string;
  5651. /**
  5652. * Gets a boolean indicating if the VertexBuffer is updatable?
  5653. * @returns true if the buffer is updatable
  5654. */
  5655. isUpdatable(): boolean;
  5656. /**
  5657. * Gets current buffer's data
  5658. * @returns a DataArray or null
  5659. */
  5660. getData(): Nullable<DataArray>;
  5661. /**
  5662. * Gets underlying native buffer
  5663. * @returns underlying native buffer
  5664. */
  5665. getBuffer(): Nullable<DataBuffer>;
  5666. /**
  5667. * Gets the stride in float32 units (i.e. byte stride / 4).
  5668. * May not be an integer if the byte stride is not divisible by 4.
  5669. * DEPRECATED. Use byteStride instead.
  5670. * @returns the stride in float32 units
  5671. */
  5672. getStrideSize(): number;
  5673. /**
  5674. * Returns the offset as a multiple of the type byte length.
  5675. * DEPRECATED. Use byteOffset instead.
  5676. * @returns the offset in bytes
  5677. */
  5678. getOffset(): number;
  5679. /**
  5680. * Returns the number of components per vertex attribute (integer)
  5681. * @returns the size in float
  5682. */
  5683. getSize(): number;
  5684. /**
  5685. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5686. * @returns true if this buffer is instanced
  5687. */
  5688. getIsInstanced(): boolean;
  5689. /**
  5690. * Returns the instancing divisor, zero for non-instanced (integer).
  5691. * @returns a number
  5692. */
  5693. getInstanceDivisor(): number;
  5694. /**
  5695. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5696. * @param data defines the data to store
  5697. */
  5698. create(data?: DataArray): void;
  5699. /**
  5700. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5701. * This function will create a new buffer if the current one is not updatable
  5702. * @param data defines the data to store
  5703. */
  5704. update(data: DataArray): void;
  5705. /**
  5706. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5707. * Returns the directly updated WebGLBuffer.
  5708. * @param data the new data
  5709. * @param offset the new offset
  5710. * @param useBytes set to true if the offset is in bytes
  5711. */
  5712. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5713. /**
  5714. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5715. */
  5716. dispose(): void;
  5717. /**
  5718. * Enumerates each value of this vertex buffer as numbers.
  5719. * @param count the number of values to enumerate
  5720. * @param callback the callback function called for each value
  5721. */
  5722. forEach(count: number, callback: (value: number, index: number) => void): void;
  5723. /**
  5724. * Positions
  5725. */
  5726. static readonly PositionKind: string;
  5727. /**
  5728. * Normals
  5729. */
  5730. static readonly NormalKind: string;
  5731. /**
  5732. * Tangents
  5733. */
  5734. static readonly TangentKind: string;
  5735. /**
  5736. * Texture coordinates
  5737. */
  5738. static readonly UVKind: string;
  5739. /**
  5740. * Texture coordinates 2
  5741. */
  5742. static readonly UV2Kind: string;
  5743. /**
  5744. * Texture coordinates 3
  5745. */
  5746. static readonly UV3Kind: string;
  5747. /**
  5748. * Texture coordinates 4
  5749. */
  5750. static readonly UV4Kind: string;
  5751. /**
  5752. * Texture coordinates 5
  5753. */
  5754. static readonly UV5Kind: string;
  5755. /**
  5756. * Texture coordinates 6
  5757. */
  5758. static readonly UV6Kind: string;
  5759. /**
  5760. * Colors
  5761. */
  5762. static readonly ColorKind: string;
  5763. /**
  5764. * Matrix indices (for bones)
  5765. */
  5766. static readonly MatricesIndicesKind: string;
  5767. /**
  5768. * Matrix weights (for bones)
  5769. */
  5770. static readonly MatricesWeightsKind: string;
  5771. /**
  5772. * Additional matrix indices (for bones)
  5773. */
  5774. static readonly MatricesIndicesExtraKind: string;
  5775. /**
  5776. * Additional matrix weights (for bones)
  5777. */
  5778. static readonly MatricesWeightsExtraKind: string;
  5779. /**
  5780. * Deduces the stride given a kind.
  5781. * @param kind The kind string to deduce
  5782. * @returns The deduced stride
  5783. */
  5784. static DeduceStride(kind: string): number;
  5785. /**
  5786. * Gets the byte length of the given type.
  5787. * @param type the type
  5788. * @returns the number of bytes
  5789. */
  5790. static GetTypeByteLength(type: number): number;
  5791. /**
  5792. * Enumerates each value of the given parameters as numbers.
  5793. * @param data the data to enumerate
  5794. * @param byteOffset the byte offset of the data
  5795. * @param byteStride the byte stride of the data
  5796. * @param componentCount the number of components per element
  5797. * @param componentType the type of the component
  5798. * @param count the total number of components
  5799. * @param normalized whether the data is normalized
  5800. * @param callback the callback function called for each value
  5801. */
  5802. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5803. private static _GetFloatValue;
  5804. }
  5805. }
  5806. declare module BABYLON {
  5807. /**
  5808. * Class representing spherical harmonics coefficients to the 3rd degree
  5809. */
  5810. export class SphericalHarmonics {
  5811. /**
  5812. * Defines whether or not the harmonics have been prescaled for rendering.
  5813. */
  5814. preScaled: boolean;
  5815. /**
  5816. * The l0,0 coefficients of the spherical harmonics
  5817. */
  5818. l00: Vector3;
  5819. /**
  5820. * The l1,-1 coefficients of the spherical harmonics
  5821. */
  5822. l1_1: Vector3;
  5823. /**
  5824. * The l1,0 coefficients of the spherical harmonics
  5825. */
  5826. l10: Vector3;
  5827. /**
  5828. * The l1,1 coefficients of the spherical harmonics
  5829. */
  5830. l11: Vector3;
  5831. /**
  5832. * The l2,-2 coefficients of the spherical harmonics
  5833. */
  5834. l2_2: Vector3;
  5835. /**
  5836. * The l2,-1 coefficients of the spherical harmonics
  5837. */
  5838. l2_1: Vector3;
  5839. /**
  5840. * The l2,0 coefficients of the spherical harmonics
  5841. */
  5842. l20: Vector3;
  5843. /**
  5844. * The l2,1 coefficients of the spherical harmonics
  5845. */
  5846. l21: Vector3;
  5847. /**
  5848. * The l2,2 coefficients of the spherical harmonics
  5849. */
  5850. l22: Vector3;
  5851. /**
  5852. * Adds a light to the spherical harmonics
  5853. * @param direction the direction of the light
  5854. * @param color the color of the light
  5855. * @param deltaSolidAngle the delta solid angle of the light
  5856. */
  5857. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5858. /**
  5859. * Scales the spherical harmonics by the given amount
  5860. * @param scale the amount to scale
  5861. */
  5862. scaleInPlace(scale: number): void;
  5863. /**
  5864. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5865. *
  5866. * ```
  5867. * E_lm = A_l * L_lm
  5868. * ```
  5869. *
  5870. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5871. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5872. * the scaling factors are given in equation 9.
  5873. */
  5874. convertIncidentRadianceToIrradiance(): void;
  5875. /**
  5876. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5877. *
  5878. * ```
  5879. * L = (1/pi) * E * rho
  5880. * ```
  5881. *
  5882. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5883. */
  5884. convertIrradianceToLambertianRadiance(): void;
  5885. /**
  5886. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5887. * required operations at run time.
  5888. *
  5889. * This is simply done by scaling back the SH with Ylm constants parameter.
  5890. * The trigonometric part being applied by the shader at run time.
  5891. */
  5892. preScaleForRendering(): void;
  5893. /**
  5894. * Constructs a spherical harmonics from an array.
  5895. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5896. * @returns the spherical harmonics
  5897. */
  5898. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5899. /**
  5900. * Gets the spherical harmonics from polynomial
  5901. * @param polynomial the spherical polynomial
  5902. * @returns the spherical harmonics
  5903. */
  5904. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5905. }
  5906. /**
  5907. * Class representing spherical polynomial coefficients to the 3rd degree
  5908. */
  5909. export class SphericalPolynomial {
  5910. private _harmonics;
  5911. /**
  5912. * The spherical harmonics used to create the polynomials.
  5913. */
  5914. readonly preScaledHarmonics: SphericalHarmonics;
  5915. /**
  5916. * The x coefficients of the spherical polynomial
  5917. */
  5918. x: Vector3;
  5919. /**
  5920. * The y coefficients of the spherical polynomial
  5921. */
  5922. y: Vector3;
  5923. /**
  5924. * The z coefficients of the spherical polynomial
  5925. */
  5926. z: Vector3;
  5927. /**
  5928. * The xx coefficients of the spherical polynomial
  5929. */
  5930. xx: Vector3;
  5931. /**
  5932. * The yy coefficients of the spherical polynomial
  5933. */
  5934. yy: Vector3;
  5935. /**
  5936. * The zz coefficients of the spherical polynomial
  5937. */
  5938. zz: Vector3;
  5939. /**
  5940. * The xy coefficients of the spherical polynomial
  5941. */
  5942. xy: Vector3;
  5943. /**
  5944. * The yz coefficients of the spherical polynomial
  5945. */
  5946. yz: Vector3;
  5947. /**
  5948. * The zx coefficients of the spherical polynomial
  5949. */
  5950. zx: Vector3;
  5951. /**
  5952. * Adds an ambient color to the spherical polynomial
  5953. * @param color the color to add
  5954. */
  5955. addAmbient(color: Color3): void;
  5956. /**
  5957. * Scales the spherical polynomial by the given amount
  5958. * @param scale the amount to scale
  5959. */
  5960. scaleInPlace(scale: number): void;
  5961. /**
  5962. * Gets the spherical polynomial from harmonics
  5963. * @param harmonics the spherical harmonics
  5964. * @returns the spherical polynomial
  5965. */
  5966. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5967. /**
  5968. * Constructs a spherical polynomial from an array.
  5969. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5970. * @returns the spherical polynomial
  5971. */
  5972. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5973. }
  5974. }
  5975. declare module BABYLON {
  5976. /**
  5977. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5978. */
  5979. export interface CubeMapInfo {
  5980. /**
  5981. * The pixel array for the front face.
  5982. * This is stored in format, left to right, up to down format.
  5983. */
  5984. front: Nullable<ArrayBufferView>;
  5985. /**
  5986. * The pixel array for the back face.
  5987. * This is stored in format, left to right, up to down format.
  5988. */
  5989. back: Nullable<ArrayBufferView>;
  5990. /**
  5991. * The pixel array for the left face.
  5992. * This is stored in format, left to right, up to down format.
  5993. */
  5994. left: Nullable<ArrayBufferView>;
  5995. /**
  5996. * The pixel array for the right face.
  5997. * This is stored in format, left to right, up to down format.
  5998. */
  5999. right: Nullable<ArrayBufferView>;
  6000. /**
  6001. * The pixel array for the up face.
  6002. * This is stored in format, left to right, up to down format.
  6003. */
  6004. up: Nullable<ArrayBufferView>;
  6005. /**
  6006. * The pixel array for the down face.
  6007. * This is stored in format, left to right, up to down format.
  6008. */
  6009. down: Nullable<ArrayBufferView>;
  6010. /**
  6011. * The size of the cubemap stored.
  6012. *
  6013. * Each faces will be size * size pixels.
  6014. */
  6015. size: number;
  6016. /**
  6017. * The format of the texture.
  6018. *
  6019. * RGBA, RGB.
  6020. */
  6021. format: number;
  6022. /**
  6023. * The type of the texture data.
  6024. *
  6025. * UNSIGNED_INT, FLOAT.
  6026. */
  6027. type: number;
  6028. /**
  6029. * Specifies whether the texture is in gamma space.
  6030. */
  6031. gammaSpace: boolean;
  6032. }
  6033. /**
  6034. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6035. */
  6036. export class PanoramaToCubeMapTools {
  6037. private static FACE_FRONT;
  6038. private static FACE_BACK;
  6039. private static FACE_RIGHT;
  6040. private static FACE_LEFT;
  6041. private static FACE_DOWN;
  6042. private static FACE_UP;
  6043. /**
  6044. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6045. *
  6046. * @param float32Array The source data.
  6047. * @param inputWidth The width of the input panorama.
  6048. * @param inputHeight The height of the input panorama.
  6049. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6050. * @return The cubemap data
  6051. */
  6052. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6053. private static CreateCubemapTexture;
  6054. private static CalcProjectionSpherical;
  6055. }
  6056. }
  6057. declare module BABYLON {
  6058. /**
  6059. * Helper class dealing with the extraction of spherical polynomial dataArray
  6060. * from a cube map.
  6061. */
  6062. export class CubeMapToSphericalPolynomialTools {
  6063. private static FileFaces;
  6064. /**
  6065. * Converts a texture to the according Spherical Polynomial data.
  6066. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6067. *
  6068. * @param texture The texture to extract the information from.
  6069. * @return The Spherical Polynomial data.
  6070. */
  6071. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6072. /**
  6073. * Converts a cubemap to the according Spherical Polynomial data.
  6074. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6075. *
  6076. * @param cubeInfo The Cube map to extract the information from.
  6077. * @return The Spherical Polynomial data.
  6078. */
  6079. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6080. }
  6081. }
  6082. declare module BABYLON {
  6083. /**
  6084. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6085. * during the life time of the application.
  6086. */
  6087. export class EngineStore {
  6088. /** Gets the list of created engines */
  6089. static Instances: Engine[];
  6090. /**
  6091. * Gets the latest created engine
  6092. */
  6093. static readonly LastCreatedEngine: Nullable<Engine>;
  6094. /**
  6095. * Gets the latest created scene
  6096. */
  6097. static readonly LastCreatedScene: Nullable<Scene>;
  6098. }
  6099. }
  6100. declare module BABYLON {
  6101. /**
  6102. * Define options used to create a render target texture
  6103. */
  6104. export class RenderTargetCreationOptions {
  6105. /**
  6106. * Specifies is mipmaps must be generated
  6107. */
  6108. generateMipMaps?: boolean;
  6109. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6110. generateDepthBuffer?: boolean;
  6111. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6112. generateStencilBuffer?: boolean;
  6113. /** Defines texture type (int by default) */
  6114. type?: number;
  6115. /** Defines sampling mode (trilinear by default) */
  6116. samplingMode?: number;
  6117. /** Defines format (RGBA by default) */
  6118. format?: number;
  6119. }
  6120. }
  6121. declare module BABYLON {
  6122. /**
  6123. * @hidden
  6124. **/
  6125. export class _AlphaState {
  6126. private _isAlphaBlendDirty;
  6127. private _isBlendFunctionParametersDirty;
  6128. private _isBlendEquationParametersDirty;
  6129. private _isBlendConstantsDirty;
  6130. private _alphaBlend;
  6131. private _blendFunctionParameters;
  6132. private _blendEquationParameters;
  6133. private _blendConstants;
  6134. /**
  6135. * Initializes the state.
  6136. */
  6137. constructor();
  6138. readonly isDirty: boolean;
  6139. alphaBlend: boolean;
  6140. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6141. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6142. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6143. reset(): void;
  6144. apply(gl: WebGLRenderingContext): void;
  6145. }
  6146. }
  6147. declare module BABYLON {
  6148. /**
  6149. * @hidden
  6150. **/
  6151. export class _DepthCullingState {
  6152. private _isDepthTestDirty;
  6153. private _isDepthMaskDirty;
  6154. private _isDepthFuncDirty;
  6155. private _isCullFaceDirty;
  6156. private _isCullDirty;
  6157. private _isZOffsetDirty;
  6158. private _isFrontFaceDirty;
  6159. private _depthTest;
  6160. private _depthMask;
  6161. private _depthFunc;
  6162. private _cull;
  6163. private _cullFace;
  6164. private _zOffset;
  6165. private _frontFace;
  6166. /**
  6167. * Initializes the state.
  6168. */
  6169. constructor();
  6170. readonly isDirty: boolean;
  6171. zOffset: number;
  6172. cullFace: Nullable<number>;
  6173. cull: Nullable<boolean>;
  6174. depthFunc: Nullable<number>;
  6175. depthMask: boolean;
  6176. depthTest: boolean;
  6177. frontFace: Nullable<number>;
  6178. reset(): void;
  6179. apply(gl: WebGLRenderingContext): void;
  6180. }
  6181. }
  6182. declare module BABYLON {
  6183. /**
  6184. * @hidden
  6185. **/
  6186. export class _StencilState {
  6187. /** 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 */
  6188. static readonly ALWAYS: number;
  6189. /** Passed to stencilOperation to specify that stencil value must be kept */
  6190. static readonly KEEP: number;
  6191. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6192. static readonly REPLACE: number;
  6193. private _isStencilTestDirty;
  6194. private _isStencilMaskDirty;
  6195. private _isStencilFuncDirty;
  6196. private _isStencilOpDirty;
  6197. private _stencilTest;
  6198. private _stencilMask;
  6199. private _stencilFunc;
  6200. private _stencilFuncRef;
  6201. private _stencilFuncMask;
  6202. private _stencilOpStencilFail;
  6203. private _stencilOpDepthFail;
  6204. private _stencilOpStencilDepthPass;
  6205. readonly isDirty: boolean;
  6206. stencilFunc: number;
  6207. stencilFuncRef: number;
  6208. stencilFuncMask: number;
  6209. stencilOpStencilFail: number;
  6210. stencilOpDepthFail: number;
  6211. stencilOpStencilDepthPass: number;
  6212. stencilMask: number;
  6213. stencilTest: boolean;
  6214. constructor();
  6215. reset(): void;
  6216. apply(gl: WebGLRenderingContext): void;
  6217. }
  6218. }
  6219. declare module BABYLON {
  6220. /**
  6221. * @hidden
  6222. **/
  6223. export class _TimeToken {
  6224. _startTimeQuery: Nullable<WebGLQuery>;
  6225. _endTimeQuery: Nullable<WebGLQuery>;
  6226. _timeElapsedQuery: Nullable<WebGLQuery>;
  6227. _timeElapsedQueryEnded: boolean;
  6228. }
  6229. }
  6230. declare module BABYLON {
  6231. /**
  6232. * Class used to store data associated with WebGL texture data for the engine
  6233. * This class should not be used directly
  6234. */
  6235. export class InternalTexture {
  6236. /** hidden */
  6237. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6238. /**
  6239. * The source of the texture data is unknown
  6240. */
  6241. static DATASOURCE_UNKNOWN: number;
  6242. /**
  6243. * Texture data comes from an URL
  6244. */
  6245. static DATASOURCE_URL: number;
  6246. /**
  6247. * Texture data is only used for temporary storage
  6248. */
  6249. static DATASOURCE_TEMP: number;
  6250. /**
  6251. * Texture data comes from raw data (ArrayBuffer)
  6252. */
  6253. static DATASOURCE_RAW: number;
  6254. /**
  6255. * Texture content is dynamic (video or dynamic texture)
  6256. */
  6257. static DATASOURCE_DYNAMIC: number;
  6258. /**
  6259. * Texture content is generated by rendering to it
  6260. */
  6261. static DATASOURCE_RENDERTARGET: number;
  6262. /**
  6263. * Texture content is part of a multi render target process
  6264. */
  6265. static DATASOURCE_MULTIRENDERTARGET: number;
  6266. /**
  6267. * Texture data comes from a cube data file
  6268. */
  6269. static DATASOURCE_CUBE: number;
  6270. /**
  6271. * Texture data comes from a raw cube data
  6272. */
  6273. static DATASOURCE_CUBERAW: number;
  6274. /**
  6275. * Texture data come from a prefiltered cube data file
  6276. */
  6277. static DATASOURCE_CUBEPREFILTERED: number;
  6278. /**
  6279. * Texture content is raw 3D data
  6280. */
  6281. static DATASOURCE_RAW3D: number;
  6282. /**
  6283. * Texture content is a depth texture
  6284. */
  6285. static DATASOURCE_DEPTHTEXTURE: number;
  6286. /**
  6287. * Texture data comes from a raw cube data encoded with RGBD
  6288. */
  6289. static DATASOURCE_CUBERAW_RGBD: number;
  6290. /**
  6291. * Defines if the texture is ready
  6292. */
  6293. isReady: boolean;
  6294. /**
  6295. * Defines if the texture is a cube texture
  6296. */
  6297. isCube: boolean;
  6298. /**
  6299. * Defines if the texture contains 3D data
  6300. */
  6301. is3D: boolean;
  6302. /**
  6303. * Defines if the texture contains multiview data
  6304. */
  6305. isMultiview: boolean;
  6306. /**
  6307. * Gets the URL used to load this texture
  6308. */
  6309. url: string;
  6310. /**
  6311. * Gets the sampling mode of the texture
  6312. */
  6313. samplingMode: number;
  6314. /**
  6315. * Gets a boolean indicating if the texture needs mipmaps generation
  6316. */
  6317. generateMipMaps: boolean;
  6318. /**
  6319. * Gets the number of samples used by the texture (WebGL2+ only)
  6320. */
  6321. samples: number;
  6322. /**
  6323. * Gets the type of the texture (int, float...)
  6324. */
  6325. type: number;
  6326. /**
  6327. * Gets the format of the texture (RGB, RGBA...)
  6328. */
  6329. format: number;
  6330. /**
  6331. * Observable called when the texture is loaded
  6332. */
  6333. onLoadedObservable: Observable<InternalTexture>;
  6334. /**
  6335. * Gets the width of the texture
  6336. */
  6337. width: number;
  6338. /**
  6339. * Gets the height of the texture
  6340. */
  6341. height: number;
  6342. /**
  6343. * Gets the depth of the texture
  6344. */
  6345. depth: number;
  6346. /**
  6347. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6348. */
  6349. baseWidth: number;
  6350. /**
  6351. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6352. */
  6353. baseHeight: number;
  6354. /**
  6355. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6356. */
  6357. baseDepth: number;
  6358. /**
  6359. * Gets a boolean indicating if the texture is inverted on Y axis
  6360. */
  6361. invertY: boolean;
  6362. /** @hidden */
  6363. _invertVScale: boolean;
  6364. /** @hidden */
  6365. _associatedChannel: number;
  6366. /** @hidden */
  6367. _dataSource: number;
  6368. /** @hidden */
  6369. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6370. /** @hidden */
  6371. _bufferView: Nullable<ArrayBufferView>;
  6372. /** @hidden */
  6373. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6374. /** @hidden */
  6375. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6376. /** @hidden */
  6377. _size: number;
  6378. /** @hidden */
  6379. _extension: string;
  6380. /** @hidden */
  6381. _files: Nullable<string[]>;
  6382. /** @hidden */
  6383. _workingCanvas: Nullable<HTMLCanvasElement>;
  6384. /** @hidden */
  6385. _workingContext: Nullable<CanvasRenderingContext2D>;
  6386. /** @hidden */
  6387. _framebuffer: Nullable<WebGLFramebuffer>;
  6388. /** @hidden */
  6389. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6390. /** @hidden */
  6391. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6392. /** @hidden */
  6393. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6394. /** @hidden */
  6395. _attachments: Nullable<number[]>;
  6396. /** @hidden */
  6397. _cachedCoordinatesMode: Nullable<number>;
  6398. /** @hidden */
  6399. _cachedWrapU: Nullable<number>;
  6400. /** @hidden */
  6401. _cachedWrapV: Nullable<number>;
  6402. /** @hidden */
  6403. _cachedWrapR: Nullable<number>;
  6404. /** @hidden */
  6405. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6406. /** @hidden */
  6407. _isDisabled: boolean;
  6408. /** @hidden */
  6409. _compression: Nullable<string>;
  6410. /** @hidden */
  6411. _generateStencilBuffer: boolean;
  6412. /** @hidden */
  6413. _generateDepthBuffer: boolean;
  6414. /** @hidden */
  6415. _comparisonFunction: number;
  6416. /** @hidden */
  6417. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6418. /** @hidden */
  6419. _lodGenerationScale: number;
  6420. /** @hidden */
  6421. _lodGenerationOffset: number;
  6422. /** @hidden */
  6423. _colorTextureArray: Nullable<WebGLTexture>;
  6424. /** @hidden */
  6425. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6426. /** @hidden */
  6427. _lodTextureHigh: Nullable<BaseTexture>;
  6428. /** @hidden */
  6429. _lodTextureMid: Nullable<BaseTexture>;
  6430. /** @hidden */
  6431. _lodTextureLow: Nullable<BaseTexture>;
  6432. /** @hidden */
  6433. _isRGBD: boolean;
  6434. /** @hidden */
  6435. _webGLTexture: Nullable<WebGLTexture>;
  6436. /** @hidden */
  6437. _references: number;
  6438. private _engine;
  6439. /**
  6440. * Gets the Engine the texture belongs to.
  6441. * @returns The babylon engine
  6442. */
  6443. getEngine(): Engine;
  6444. /**
  6445. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6446. */
  6447. readonly dataSource: number;
  6448. /**
  6449. * Creates a new InternalTexture
  6450. * @param engine defines the engine to use
  6451. * @param dataSource defines the type of data that will be used
  6452. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6453. */
  6454. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6455. /**
  6456. * Increments the number of references (ie. the number of Texture that point to it)
  6457. */
  6458. incrementReferences(): void;
  6459. /**
  6460. * Change the size of the texture (not the size of the content)
  6461. * @param width defines the new width
  6462. * @param height defines the new height
  6463. * @param depth defines the new depth (1 by default)
  6464. */
  6465. updateSize(width: int, height: int, depth?: int): void;
  6466. /** @hidden */
  6467. _rebuild(): void;
  6468. /** @hidden */
  6469. _swapAndDie(target: InternalTexture): void;
  6470. /**
  6471. * Dispose the current allocated resources
  6472. */
  6473. dispose(): void;
  6474. }
  6475. }
  6476. declare module BABYLON {
  6477. /**
  6478. * This represents the main contract an easing function should follow.
  6479. * Easing functions are used throughout the animation system.
  6480. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6481. */
  6482. export interface IEasingFunction {
  6483. /**
  6484. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6485. * of the easing function.
  6486. * The link below provides some of the most common examples of easing functions.
  6487. * @see https://easings.net/
  6488. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6489. * @returns the corresponding value on the curve defined by the easing function
  6490. */
  6491. ease(gradient: number): number;
  6492. }
  6493. /**
  6494. * Base class used for every default easing function.
  6495. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6496. */
  6497. export class EasingFunction implements IEasingFunction {
  6498. /**
  6499. * Interpolation follows the mathematical formula associated with the easing function.
  6500. */
  6501. static readonly EASINGMODE_EASEIN: number;
  6502. /**
  6503. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6504. */
  6505. static readonly EASINGMODE_EASEOUT: number;
  6506. /**
  6507. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6508. */
  6509. static readonly EASINGMODE_EASEINOUT: number;
  6510. private _easingMode;
  6511. /**
  6512. * Sets the easing mode of the current function.
  6513. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6514. */
  6515. setEasingMode(easingMode: number): void;
  6516. /**
  6517. * Gets the current easing mode.
  6518. * @returns the easing mode
  6519. */
  6520. getEasingMode(): number;
  6521. /**
  6522. * @hidden
  6523. */
  6524. easeInCore(gradient: number): number;
  6525. /**
  6526. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6527. * of the easing function.
  6528. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6529. * @returns the corresponding value on the curve defined by the easing function
  6530. */
  6531. ease(gradient: number): number;
  6532. }
  6533. /**
  6534. * Easing function with a circle shape (see link below).
  6535. * @see https://easings.net/#easeInCirc
  6536. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6537. */
  6538. export class CircleEase extends EasingFunction implements IEasingFunction {
  6539. /** @hidden */
  6540. easeInCore(gradient: number): number;
  6541. }
  6542. /**
  6543. * Easing function with a ease back shape (see link below).
  6544. * @see https://easings.net/#easeInBack
  6545. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6546. */
  6547. export class BackEase extends EasingFunction implements IEasingFunction {
  6548. /** Defines the amplitude of the function */
  6549. amplitude: number;
  6550. /**
  6551. * Instantiates a back ease easing
  6552. * @see https://easings.net/#easeInBack
  6553. * @param amplitude Defines the amplitude of the function
  6554. */
  6555. constructor(
  6556. /** Defines the amplitude of the function */
  6557. amplitude?: number);
  6558. /** @hidden */
  6559. easeInCore(gradient: number): number;
  6560. }
  6561. /**
  6562. * Easing function with a bouncing shape (see link below).
  6563. * @see https://easings.net/#easeInBounce
  6564. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6565. */
  6566. export class BounceEase extends EasingFunction implements IEasingFunction {
  6567. /** Defines the number of bounces */
  6568. bounces: number;
  6569. /** Defines the amplitude of the bounce */
  6570. bounciness: number;
  6571. /**
  6572. * Instantiates a bounce easing
  6573. * @see https://easings.net/#easeInBounce
  6574. * @param bounces Defines the number of bounces
  6575. * @param bounciness Defines the amplitude of the bounce
  6576. */
  6577. constructor(
  6578. /** Defines the number of bounces */
  6579. bounces?: number,
  6580. /** Defines the amplitude of the bounce */
  6581. bounciness?: number);
  6582. /** @hidden */
  6583. easeInCore(gradient: number): number;
  6584. }
  6585. /**
  6586. * Easing function with a power of 3 shape (see link below).
  6587. * @see https://easings.net/#easeInCubic
  6588. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6589. */
  6590. export class CubicEase extends EasingFunction implements IEasingFunction {
  6591. /** @hidden */
  6592. easeInCore(gradient: number): number;
  6593. }
  6594. /**
  6595. * Easing function with an elastic shape (see link below).
  6596. * @see https://easings.net/#easeInElastic
  6597. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6598. */
  6599. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6600. /** Defines the number of oscillations*/
  6601. oscillations: number;
  6602. /** Defines the amplitude of the oscillations*/
  6603. springiness: number;
  6604. /**
  6605. * Instantiates an elastic easing function
  6606. * @see https://easings.net/#easeInElastic
  6607. * @param oscillations Defines the number of oscillations
  6608. * @param springiness Defines the amplitude of the oscillations
  6609. */
  6610. constructor(
  6611. /** Defines the number of oscillations*/
  6612. oscillations?: number,
  6613. /** Defines the amplitude of the oscillations*/
  6614. springiness?: number);
  6615. /** @hidden */
  6616. easeInCore(gradient: number): number;
  6617. }
  6618. /**
  6619. * Easing function with an exponential shape (see link below).
  6620. * @see https://easings.net/#easeInExpo
  6621. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6622. */
  6623. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6624. /** Defines the exponent of the function */
  6625. exponent: number;
  6626. /**
  6627. * Instantiates an exponential easing function
  6628. * @see https://easings.net/#easeInExpo
  6629. * @param exponent Defines the exponent of the function
  6630. */
  6631. constructor(
  6632. /** Defines the exponent of the function */
  6633. exponent?: number);
  6634. /** @hidden */
  6635. easeInCore(gradient: number): number;
  6636. }
  6637. /**
  6638. * Easing function with a power shape (see link below).
  6639. * @see https://easings.net/#easeInQuad
  6640. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6641. */
  6642. export class PowerEase extends EasingFunction implements IEasingFunction {
  6643. /** Defines the power of the function */
  6644. power: number;
  6645. /**
  6646. * Instantiates an power base easing function
  6647. * @see https://easings.net/#easeInQuad
  6648. * @param power Defines the power of the function
  6649. */
  6650. constructor(
  6651. /** Defines the power of the function */
  6652. power?: number);
  6653. /** @hidden */
  6654. easeInCore(gradient: number): number;
  6655. }
  6656. /**
  6657. * Easing function with a power of 2 shape (see link below).
  6658. * @see https://easings.net/#easeInQuad
  6659. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6660. */
  6661. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6662. /** @hidden */
  6663. easeInCore(gradient: number): number;
  6664. }
  6665. /**
  6666. * Easing function with a power of 4 shape (see link below).
  6667. * @see https://easings.net/#easeInQuart
  6668. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6669. */
  6670. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6671. /** @hidden */
  6672. easeInCore(gradient: number): number;
  6673. }
  6674. /**
  6675. * Easing function with a power of 5 shape (see link below).
  6676. * @see https://easings.net/#easeInQuint
  6677. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6678. */
  6679. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6680. /** @hidden */
  6681. easeInCore(gradient: number): number;
  6682. }
  6683. /**
  6684. * Easing function with a sin shape (see link below).
  6685. * @see https://easings.net/#easeInSine
  6686. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6687. */
  6688. export class SineEase extends EasingFunction implements IEasingFunction {
  6689. /** @hidden */
  6690. easeInCore(gradient: number): number;
  6691. }
  6692. /**
  6693. * Easing function with a bezier shape (see link below).
  6694. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6695. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6696. */
  6697. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6698. /** Defines the x component of the start tangent in the bezier curve */
  6699. x1: number;
  6700. /** Defines the y component of the start tangent in the bezier curve */
  6701. y1: number;
  6702. /** Defines the x component of the end tangent in the bezier curve */
  6703. x2: number;
  6704. /** Defines the y component of the end tangent in the bezier curve */
  6705. y2: number;
  6706. /**
  6707. * Instantiates a bezier function
  6708. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6709. * @param x1 Defines the x component of the start tangent in the bezier curve
  6710. * @param y1 Defines the y component of the start tangent in the bezier curve
  6711. * @param x2 Defines the x component of the end tangent in the bezier curve
  6712. * @param y2 Defines the y component of the end tangent in the bezier curve
  6713. */
  6714. constructor(
  6715. /** Defines the x component of the start tangent in the bezier curve */
  6716. x1?: number,
  6717. /** Defines the y component of the start tangent in the bezier curve */
  6718. y1?: number,
  6719. /** Defines the x component of the end tangent in the bezier curve */
  6720. x2?: number,
  6721. /** Defines the y component of the end tangent in the bezier curve */
  6722. y2?: number);
  6723. /** @hidden */
  6724. easeInCore(gradient: number): number;
  6725. }
  6726. }
  6727. declare module BABYLON {
  6728. /**
  6729. * Defines an interface which represents an animation key frame
  6730. */
  6731. export interface IAnimationKey {
  6732. /**
  6733. * Frame of the key frame
  6734. */
  6735. frame: number;
  6736. /**
  6737. * Value at the specifies key frame
  6738. */
  6739. value: any;
  6740. /**
  6741. * The input tangent for the cubic hermite spline
  6742. */
  6743. inTangent?: any;
  6744. /**
  6745. * The output tangent for the cubic hermite spline
  6746. */
  6747. outTangent?: any;
  6748. /**
  6749. * The animation interpolation type
  6750. */
  6751. interpolation?: AnimationKeyInterpolation;
  6752. }
  6753. /**
  6754. * Enum for the animation key frame interpolation type
  6755. */
  6756. export enum AnimationKeyInterpolation {
  6757. /**
  6758. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6759. */
  6760. STEP = 1
  6761. }
  6762. }
  6763. declare module BABYLON {
  6764. /**
  6765. * Represents the range of an animation
  6766. */
  6767. export class AnimationRange {
  6768. /**The name of the animation range**/
  6769. name: string;
  6770. /**The starting frame of the animation */
  6771. from: number;
  6772. /**The ending frame of the animation*/
  6773. to: number;
  6774. /**
  6775. * Initializes the range of an animation
  6776. * @param name The name of the animation range
  6777. * @param from The starting frame of the animation
  6778. * @param to The ending frame of the animation
  6779. */
  6780. constructor(
  6781. /**The name of the animation range**/
  6782. name: string,
  6783. /**The starting frame of the animation */
  6784. from: number,
  6785. /**The ending frame of the animation*/
  6786. to: number);
  6787. /**
  6788. * Makes a copy of the animation range
  6789. * @returns A copy of the animation range
  6790. */
  6791. clone(): AnimationRange;
  6792. }
  6793. }
  6794. declare module BABYLON {
  6795. /**
  6796. * Composed of a frame, and an action function
  6797. */
  6798. export class AnimationEvent {
  6799. /** The frame for which the event is triggered **/
  6800. frame: number;
  6801. /** The event to perform when triggered **/
  6802. action: (currentFrame: number) => void;
  6803. /** Specifies if the event should be triggered only once**/
  6804. onlyOnce?: boolean | undefined;
  6805. /**
  6806. * Specifies if the animation event is done
  6807. */
  6808. isDone: boolean;
  6809. /**
  6810. * Initializes the animation event
  6811. * @param frame The frame for which the event is triggered
  6812. * @param action The event to perform when triggered
  6813. * @param onlyOnce Specifies if the event should be triggered only once
  6814. */
  6815. constructor(
  6816. /** The frame for which the event is triggered **/
  6817. frame: number,
  6818. /** The event to perform when triggered **/
  6819. action: (currentFrame: number) => void,
  6820. /** Specifies if the event should be triggered only once**/
  6821. onlyOnce?: boolean | undefined);
  6822. /** @hidden */
  6823. _clone(): AnimationEvent;
  6824. }
  6825. }
  6826. declare module BABYLON {
  6827. /**
  6828. * Interface used to define a behavior
  6829. */
  6830. export interface Behavior<T> {
  6831. /** gets or sets behavior's name */
  6832. name: string;
  6833. /**
  6834. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6835. */
  6836. init(): void;
  6837. /**
  6838. * Called when the behavior is attached to a target
  6839. * @param target defines the target where the behavior is attached to
  6840. */
  6841. attach(target: T): void;
  6842. /**
  6843. * Called when the behavior is detached from its target
  6844. */
  6845. detach(): void;
  6846. }
  6847. /**
  6848. * Interface implemented by classes supporting behaviors
  6849. */
  6850. export interface IBehaviorAware<T> {
  6851. /**
  6852. * Attach a behavior
  6853. * @param behavior defines the behavior to attach
  6854. * @returns the current host
  6855. */
  6856. addBehavior(behavior: Behavior<T>): T;
  6857. /**
  6858. * Remove a behavior from the current object
  6859. * @param behavior defines the behavior to detach
  6860. * @returns the current host
  6861. */
  6862. removeBehavior(behavior: Behavior<T>): T;
  6863. /**
  6864. * Gets a behavior using its name to search
  6865. * @param name defines the name to search
  6866. * @returns the behavior or null if not found
  6867. */
  6868. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6869. }
  6870. }
  6871. declare module BABYLON {
  6872. /**
  6873. * @hidden
  6874. */
  6875. export class IntersectionInfo {
  6876. bu: Nullable<number>;
  6877. bv: Nullable<number>;
  6878. distance: number;
  6879. faceId: number;
  6880. subMeshId: number;
  6881. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6882. }
  6883. }
  6884. declare module BABYLON {
  6885. /**
  6886. * Class used to store bounding sphere information
  6887. */
  6888. export class BoundingSphere {
  6889. /**
  6890. * Gets the center of the bounding sphere in local space
  6891. */
  6892. readonly center: Vector3;
  6893. /**
  6894. * Radius of the bounding sphere in local space
  6895. */
  6896. radius: number;
  6897. /**
  6898. * Gets the center of the bounding sphere in world space
  6899. */
  6900. readonly centerWorld: Vector3;
  6901. /**
  6902. * Radius of the bounding sphere in world space
  6903. */
  6904. radiusWorld: number;
  6905. /**
  6906. * Gets the minimum vector in local space
  6907. */
  6908. readonly minimum: Vector3;
  6909. /**
  6910. * Gets the maximum vector in local space
  6911. */
  6912. readonly maximum: Vector3;
  6913. private _worldMatrix;
  6914. private static readonly TmpVector3;
  6915. /**
  6916. * Creates a new bounding sphere
  6917. * @param min defines the minimum vector (in local space)
  6918. * @param max defines the maximum vector (in local space)
  6919. * @param worldMatrix defines the new world matrix
  6920. */
  6921. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6922. /**
  6923. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6924. * @param min defines the new minimum vector (in local space)
  6925. * @param max defines the new maximum vector (in local space)
  6926. * @param worldMatrix defines the new world matrix
  6927. */
  6928. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6929. /**
  6930. * Scale the current bounding sphere by applying a scale factor
  6931. * @param factor defines the scale factor to apply
  6932. * @returns the current bounding box
  6933. */
  6934. scale(factor: number): BoundingSphere;
  6935. /**
  6936. * Gets the world matrix of the bounding box
  6937. * @returns a matrix
  6938. */
  6939. getWorldMatrix(): DeepImmutable<Matrix>;
  6940. /** @hidden */
  6941. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6942. /**
  6943. * Tests if the bounding sphere is intersecting the frustum planes
  6944. * @param frustumPlanes defines the frustum planes to test
  6945. * @returns true if there is an intersection
  6946. */
  6947. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6948. /**
  6949. * Tests if the bounding sphere center is in between the frustum planes.
  6950. * Used for optimistic fast inclusion.
  6951. * @param frustumPlanes defines the frustum planes to test
  6952. * @returns true if the sphere center is in between the frustum planes
  6953. */
  6954. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6955. /**
  6956. * Tests if a point is inside the bounding sphere
  6957. * @param point defines the point to test
  6958. * @returns true if the point is inside the bounding sphere
  6959. */
  6960. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6961. /**
  6962. * Checks if two sphere intersct
  6963. * @param sphere0 sphere 0
  6964. * @param sphere1 sphere 1
  6965. * @returns true if the speres intersect
  6966. */
  6967. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6968. }
  6969. }
  6970. declare module BABYLON {
  6971. /**
  6972. * Class used to store bounding box information
  6973. */
  6974. export class BoundingBox implements ICullable {
  6975. /**
  6976. * Gets the 8 vectors representing the bounding box in local space
  6977. */
  6978. readonly vectors: Vector3[];
  6979. /**
  6980. * Gets the center of the bounding box in local space
  6981. */
  6982. readonly center: Vector3;
  6983. /**
  6984. * Gets the center of the bounding box in world space
  6985. */
  6986. readonly centerWorld: Vector3;
  6987. /**
  6988. * Gets the extend size in local space
  6989. */
  6990. readonly extendSize: Vector3;
  6991. /**
  6992. * Gets the extend size in world space
  6993. */
  6994. readonly extendSizeWorld: Vector3;
  6995. /**
  6996. * Gets the OBB (object bounding box) directions
  6997. */
  6998. readonly directions: Vector3[];
  6999. /**
  7000. * Gets the 8 vectors representing the bounding box in world space
  7001. */
  7002. readonly vectorsWorld: Vector3[];
  7003. /**
  7004. * Gets the minimum vector in world space
  7005. */
  7006. readonly minimumWorld: Vector3;
  7007. /**
  7008. * Gets the maximum vector in world space
  7009. */
  7010. readonly maximumWorld: Vector3;
  7011. /**
  7012. * Gets the minimum vector in local space
  7013. */
  7014. readonly minimum: Vector3;
  7015. /**
  7016. * Gets the maximum vector in local space
  7017. */
  7018. readonly maximum: Vector3;
  7019. private _worldMatrix;
  7020. private static readonly TmpVector3;
  7021. /**
  7022. * @hidden
  7023. */
  7024. _tag: number;
  7025. /**
  7026. * Creates a new bounding box
  7027. * @param min defines the minimum vector (in local space)
  7028. * @param max defines the maximum vector (in local space)
  7029. * @param worldMatrix defines the new world matrix
  7030. */
  7031. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7032. /**
  7033. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7034. * @param min defines the new minimum vector (in local space)
  7035. * @param max defines the new maximum vector (in local space)
  7036. * @param worldMatrix defines the new world matrix
  7037. */
  7038. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7039. /**
  7040. * Scale the current bounding box by applying a scale factor
  7041. * @param factor defines the scale factor to apply
  7042. * @returns the current bounding box
  7043. */
  7044. scale(factor: number): BoundingBox;
  7045. /**
  7046. * Gets the world matrix of the bounding box
  7047. * @returns a matrix
  7048. */
  7049. getWorldMatrix(): DeepImmutable<Matrix>;
  7050. /** @hidden */
  7051. _update(world: DeepImmutable<Matrix>): void;
  7052. /**
  7053. * Tests if the bounding box is intersecting the frustum planes
  7054. * @param frustumPlanes defines the frustum planes to test
  7055. * @returns true if there is an intersection
  7056. */
  7057. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7058. /**
  7059. * Tests if the bounding box is entirely inside the frustum planes
  7060. * @param frustumPlanes defines the frustum planes to test
  7061. * @returns true if there is an inclusion
  7062. */
  7063. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7064. /**
  7065. * Tests if a point is inside the bounding box
  7066. * @param point defines the point to test
  7067. * @returns true if the point is inside the bounding box
  7068. */
  7069. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7070. /**
  7071. * Tests if the bounding box intersects with a bounding sphere
  7072. * @param sphere defines the sphere to test
  7073. * @returns true if there is an intersection
  7074. */
  7075. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7076. /**
  7077. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7078. * @param min defines the min vector to use
  7079. * @param max defines the max vector to use
  7080. * @returns true if there is an intersection
  7081. */
  7082. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7083. /**
  7084. * Tests if two bounding boxes are intersections
  7085. * @param box0 defines the first box to test
  7086. * @param box1 defines the second box to test
  7087. * @returns true if there is an intersection
  7088. */
  7089. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7090. /**
  7091. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7092. * @param minPoint defines the minimum vector of the bounding box
  7093. * @param maxPoint defines the maximum vector of the bounding box
  7094. * @param sphereCenter defines the sphere center
  7095. * @param sphereRadius defines the sphere radius
  7096. * @returns true if there is an intersection
  7097. */
  7098. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7099. /**
  7100. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7101. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7102. * @param frustumPlanes defines the frustum planes to test
  7103. * @return true if there is an inclusion
  7104. */
  7105. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7106. /**
  7107. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7108. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7109. * @param frustumPlanes defines the frustum planes to test
  7110. * @return true if there is an intersection
  7111. */
  7112. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7113. }
  7114. }
  7115. declare module BABYLON {
  7116. /** @hidden */
  7117. export class Collider {
  7118. /** Define if a collision was found */
  7119. collisionFound: boolean;
  7120. /**
  7121. * Define last intersection point in local space
  7122. */
  7123. intersectionPoint: Vector3;
  7124. /**
  7125. * Define last collided mesh
  7126. */
  7127. collidedMesh: Nullable<AbstractMesh>;
  7128. private _collisionPoint;
  7129. private _planeIntersectionPoint;
  7130. private _tempVector;
  7131. private _tempVector2;
  7132. private _tempVector3;
  7133. private _tempVector4;
  7134. private _edge;
  7135. private _baseToVertex;
  7136. private _destinationPoint;
  7137. private _slidePlaneNormal;
  7138. private _displacementVector;
  7139. /** @hidden */
  7140. _radius: Vector3;
  7141. /** @hidden */
  7142. _retry: number;
  7143. private _velocity;
  7144. private _basePoint;
  7145. private _epsilon;
  7146. /** @hidden */
  7147. _velocityWorldLength: number;
  7148. /** @hidden */
  7149. _basePointWorld: Vector3;
  7150. private _velocityWorld;
  7151. private _normalizedVelocity;
  7152. /** @hidden */
  7153. _initialVelocity: Vector3;
  7154. /** @hidden */
  7155. _initialPosition: Vector3;
  7156. private _nearestDistance;
  7157. private _collisionMask;
  7158. collisionMask: number;
  7159. /**
  7160. * Gets the plane normal used to compute the sliding response (in local space)
  7161. */
  7162. readonly slidePlaneNormal: Vector3;
  7163. /** @hidden */
  7164. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7165. /** @hidden */
  7166. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7167. /** @hidden */
  7168. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7169. /** @hidden */
  7170. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7171. /** @hidden */
  7172. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7173. /** @hidden */
  7174. _getResponse(pos: Vector3, vel: Vector3): void;
  7175. }
  7176. }
  7177. declare module BABYLON {
  7178. /**
  7179. * Interface for cullable objects
  7180. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7181. */
  7182. export interface ICullable {
  7183. /**
  7184. * Checks if the object or part of the object is in the frustum
  7185. * @param frustumPlanes Camera near/planes
  7186. * @returns true if the object is in frustum otherwise false
  7187. */
  7188. isInFrustum(frustumPlanes: Plane[]): boolean;
  7189. /**
  7190. * Checks if a cullable object (mesh...) is in the camera frustum
  7191. * Unlike isInFrustum this cheks the full bounding box
  7192. * @param frustumPlanes Camera near/planes
  7193. * @returns true if the object is in frustum otherwise false
  7194. */
  7195. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7196. }
  7197. /**
  7198. * Info for a bounding data of a mesh
  7199. */
  7200. export class BoundingInfo implements ICullable {
  7201. /**
  7202. * Bounding box for the mesh
  7203. */
  7204. readonly boundingBox: BoundingBox;
  7205. /**
  7206. * Bounding sphere for the mesh
  7207. */
  7208. readonly boundingSphere: BoundingSphere;
  7209. private _isLocked;
  7210. private static readonly TmpVector3;
  7211. /**
  7212. * Constructs bounding info
  7213. * @param minimum min vector of the bounding box/sphere
  7214. * @param maximum max vector of the bounding box/sphere
  7215. * @param worldMatrix defines the new world matrix
  7216. */
  7217. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7218. /**
  7219. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7220. * @param min defines the new minimum vector (in local space)
  7221. * @param max defines the new maximum vector (in local space)
  7222. * @param worldMatrix defines the new world matrix
  7223. */
  7224. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7225. /**
  7226. * min vector of the bounding box/sphere
  7227. */
  7228. readonly minimum: Vector3;
  7229. /**
  7230. * max vector of the bounding box/sphere
  7231. */
  7232. readonly maximum: Vector3;
  7233. /**
  7234. * If the info is locked and won't be updated to avoid perf overhead
  7235. */
  7236. isLocked: boolean;
  7237. /**
  7238. * Updates the bounding sphere and box
  7239. * @param world world matrix to be used to update
  7240. */
  7241. update(world: DeepImmutable<Matrix>): void;
  7242. /**
  7243. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7244. * @param center New center of the bounding info
  7245. * @param extend New extend of the bounding info
  7246. * @returns the current bounding info
  7247. */
  7248. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7249. /**
  7250. * Scale the current bounding info by applying a scale factor
  7251. * @param factor defines the scale factor to apply
  7252. * @returns the current bounding info
  7253. */
  7254. scale(factor: number): BoundingInfo;
  7255. /**
  7256. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7257. * @param frustumPlanes defines the frustum to test
  7258. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7259. * @returns true if the bounding info is in the frustum planes
  7260. */
  7261. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7262. /**
  7263. * Gets the world distance between the min and max points of the bounding box
  7264. */
  7265. readonly diagonalLength: number;
  7266. /**
  7267. * Checks if a cullable object (mesh...) is in the camera frustum
  7268. * Unlike isInFrustum this cheks the full bounding box
  7269. * @param frustumPlanes Camera near/planes
  7270. * @returns true if the object is in frustum otherwise false
  7271. */
  7272. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7273. /** @hidden */
  7274. _checkCollision(collider: Collider): boolean;
  7275. /**
  7276. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7277. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7278. * @param point the point to check intersection with
  7279. * @returns if the point intersects
  7280. */
  7281. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7282. /**
  7283. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7284. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7285. * @param boundingInfo the bounding info to check intersection with
  7286. * @param precise if the intersection should be done using OBB
  7287. * @returns if the bounding info intersects
  7288. */
  7289. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7290. }
  7291. }
  7292. declare module BABYLON {
  7293. /**
  7294. * Defines an array and its length.
  7295. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7296. */
  7297. export interface ISmartArrayLike<T> {
  7298. /**
  7299. * The data of the array.
  7300. */
  7301. data: Array<T>;
  7302. /**
  7303. * The active length of the array.
  7304. */
  7305. length: number;
  7306. }
  7307. /**
  7308. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7309. */
  7310. export class SmartArray<T> implements ISmartArrayLike<T> {
  7311. /**
  7312. * The full set of data from the array.
  7313. */
  7314. data: Array<T>;
  7315. /**
  7316. * The active length of the array.
  7317. */
  7318. length: number;
  7319. protected _id: number;
  7320. /**
  7321. * Instantiates a Smart Array.
  7322. * @param capacity defines the default capacity of the array.
  7323. */
  7324. constructor(capacity: number);
  7325. /**
  7326. * Pushes a value at the end of the active data.
  7327. * @param value defines the object to push in the array.
  7328. */
  7329. push(value: T): void;
  7330. /**
  7331. * Iterates over the active data and apply the lambda to them.
  7332. * @param func defines the action to apply on each value.
  7333. */
  7334. forEach(func: (content: T) => void): void;
  7335. /**
  7336. * Sorts the full sets of data.
  7337. * @param compareFn defines the comparison function to apply.
  7338. */
  7339. sort(compareFn: (a: T, b: T) => number): void;
  7340. /**
  7341. * Resets the active data to an empty array.
  7342. */
  7343. reset(): void;
  7344. /**
  7345. * Releases all the data from the array as well as the array.
  7346. */
  7347. dispose(): void;
  7348. /**
  7349. * Concats the active data with a given array.
  7350. * @param array defines the data to concatenate with.
  7351. */
  7352. concat(array: any): void;
  7353. /**
  7354. * Returns the position of a value in the active data.
  7355. * @param value defines the value to find the index for
  7356. * @returns the index if found in the active data otherwise -1
  7357. */
  7358. indexOf(value: T): number;
  7359. /**
  7360. * Returns whether an element is part of the active data.
  7361. * @param value defines the value to look for
  7362. * @returns true if found in the active data otherwise false
  7363. */
  7364. contains(value: T): boolean;
  7365. private static _GlobalId;
  7366. }
  7367. /**
  7368. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7369. * The data in this array can only be present once
  7370. */
  7371. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7372. private _duplicateId;
  7373. /**
  7374. * Pushes a value at the end of the active data.
  7375. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7376. * @param value defines the object to push in the array.
  7377. */
  7378. push(value: T): void;
  7379. /**
  7380. * Pushes a value at the end of the active data.
  7381. * If the data is already present, it won t be added again
  7382. * @param value defines the object to push in the array.
  7383. * @returns true if added false if it was already present
  7384. */
  7385. pushNoDuplicate(value: T): boolean;
  7386. /**
  7387. * Resets the active data to an empty array.
  7388. */
  7389. reset(): void;
  7390. /**
  7391. * Concats the active data with a given array.
  7392. * This ensures no dupplicate will be present in the result.
  7393. * @param array defines the data to concatenate with.
  7394. */
  7395. concatWithNoDuplicate(array: any): void;
  7396. }
  7397. }
  7398. declare module BABYLON {
  7399. /**
  7400. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7401. * separate meshes. This can be use to improve performances.
  7402. * @see http://doc.babylonjs.com/how_to/multi_materials
  7403. */
  7404. export class MultiMaterial extends Material {
  7405. private _subMaterials;
  7406. /**
  7407. * Gets or Sets the list of Materials used within the multi material.
  7408. * They need to be ordered according to the submeshes order in the associated mesh
  7409. */
  7410. subMaterials: Nullable<Material>[];
  7411. /**
  7412. * Function used to align with Node.getChildren()
  7413. * @returns the list of Materials used within the multi material
  7414. */
  7415. getChildren(): Nullable<Material>[];
  7416. /**
  7417. * Instantiates a new Multi Material
  7418. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7419. * separate meshes. This can be use to improve performances.
  7420. * @see http://doc.babylonjs.com/how_to/multi_materials
  7421. * @param name Define the name in the scene
  7422. * @param scene Define the scene the material belongs to
  7423. */
  7424. constructor(name: string, scene: Scene);
  7425. private _hookArray;
  7426. /**
  7427. * Get one of the submaterial by its index in the submaterials array
  7428. * @param index The index to look the sub material at
  7429. * @returns The Material if the index has been defined
  7430. */
  7431. getSubMaterial(index: number): Nullable<Material>;
  7432. /**
  7433. * Get the list of active textures for the whole sub materials list.
  7434. * @returns All the textures that will be used during the rendering
  7435. */
  7436. getActiveTextures(): BaseTexture[];
  7437. /**
  7438. * Gets the current class name of the material e.g. "MultiMaterial"
  7439. * Mainly use in serialization.
  7440. * @returns the class name
  7441. */
  7442. getClassName(): string;
  7443. /**
  7444. * Checks if the material is ready to render the requested sub mesh
  7445. * @param mesh Define the mesh the submesh belongs to
  7446. * @param subMesh Define the sub mesh to look readyness for
  7447. * @param useInstances Define whether or not the material is used with instances
  7448. * @returns true if ready, otherwise false
  7449. */
  7450. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7451. /**
  7452. * Clones the current material and its related sub materials
  7453. * @param name Define the name of the newly cloned material
  7454. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7455. * @returns the cloned material
  7456. */
  7457. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7458. /**
  7459. * Serializes the materials into a JSON representation.
  7460. * @returns the JSON representation
  7461. */
  7462. serialize(): any;
  7463. /**
  7464. * Dispose the material and release its associated resources
  7465. * @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)
  7466. * @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)
  7467. * @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)
  7468. */
  7469. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7470. /**
  7471. * Creates a MultiMaterial from parsed MultiMaterial data.
  7472. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7473. * @param scene defines the hosting scene
  7474. * @returns a new MultiMaterial
  7475. */
  7476. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7477. }
  7478. }
  7479. declare module BABYLON {
  7480. /**
  7481. * Class used to represent data loading progression
  7482. */
  7483. export class SceneLoaderFlags {
  7484. private static _ForceFullSceneLoadingForIncremental;
  7485. private static _ShowLoadingScreen;
  7486. private static _CleanBoneMatrixWeights;
  7487. private static _loggingLevel;
  7488. /**
  7489. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7490. */
  7491. static ForceFullSceneLoadingForIncremental: boolean;
  7492. /**
  7493. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7494. */
  7495. static ShowLoadingScreen: boolean;
  7496. /**
  7497. * Defines the current logging level (while loading the scene)
  7498. * @ignorenaming
  7499. */
  7500. static loggingLevel: number;
  7501. /**
  7502. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7503. */
  7504. static CleanBoneMatrixWeights: boolean;
  7505. }
  7506. }
  7507. declare module BABYLON {
  7508. /**
  7509. * 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.
  7510. * @see https://doc.babylonjs.com/how_to/transformnode
  7511. */
  7512. export class TransformNode extends Node {
  7513. /**
  7514. * Object will not rotate to face the camera
  7515. */
  7516. static BILLBOARDMODE_NONE: number;
  7517. /**
  7518. * Object will rotate to face the camera but only on the x axis
  7519. */
  7520. static BILLBOARDMODE_X: number;
  7521. /**
  7522. * Object will rotate to face the camera but only on the y axis
  7523. */
  7524. static BILLBOARDMODE_Y: number;
  7525. /**
  7526. * Object will rotate to face the camera but only on the z axis
  7527. */
  7528. static BILLBOARDMODE_Z: number;
  7529. /**
  7530. * Object will rotate to face the camera
  7531. */
  7532. static BILLBOARDMODE_ALL: number;
  7533. private _forward;
  7534. private _forwardInverted;
  7535. private _up;
  7536. private _right;
  7537. private _rightInverted;
  7538. private _position;
  7539. private _rotation;
  7540. private _rotationQuaternion;
  7541. protected _scaling: Vector3;
  7542. protected _isDirty: boolean;
  7543. private _transformToBoneReferal;
  7544. private _billboardMode;
  7545. /**
  7546. * Gets or sets the billboard mode. Default is 0.
  7547. *
  7548. * | Value | Type | Description |
  7549. * | --- | --- | --- |
  7550. * | 0 | BILLBOARDMODE_NONE | |
  7551. * | 1 | BILLBOARDMODE_X | |
  7552. * | 2 | BILLBOARDMODE_Y | |
  7553. * | 4 | BILLBOARDMODE_Z | |
  7554. * | 7 | BILLBOARDMODE_ALL | |
  7555. *
  7556. */
  7557. billboardMode: number;
  7558. private _preserveParentRotationForBillboard;
  7559. /**
  7560. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7561. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7562. */
  7563. preserveParentRotationForBillboard: boolean;
  7564. /**
  7565. * 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
  7566. */
  7567. scalingDeterminant: number;
  7568. private _infiniteDistance;
  7569. /**
  7570. * Gets or sets the distance of the object to max, often used by skybox
  7571. */
  7572. infiniteDistance: boolean;
  7573. /**
  7574. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7575. * By default the system will update normals to compensate
  7576. */
  7577. ignoreNonUniformScaling: boolean;
  7578. /**
  7579. * 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
  7580. */
  7581. reIntegrateRotationIntoRotationQuaternion: boolean;
  7582. /** @hidden */
  7583. _poseMatrix: Nullable<Matrix>;
  7584. /** @hidden */
  7585. _localMatrix: Matrix;
  7586. private _usePivotMatrix;
  7587. private _absolutePosition;
  7588. private _pivotMatrix;
  7589. private _pivotMatrixInverse;
  7590. protected _postMultiplyPivotMatrix: boolean;
  7591. protected _isWorldMatrixFrozen: boolean;
  7592. /** @hidden */
  7593. _indexInSceneTransformNodesArray: number;
  7594. /**
  7595. * An event triggered after the world matrix is updated
  7596. */
  7597. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7598. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7599. /**
  7600. * Gets a string identifying the name of the class
  7601. * @returns "TransformNode" string
  7602. */
  7603. getClassName(): string;
  7604. /**
  7605. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7606. */
  7607. position: Vector3;
  7608. /**
  7609. * 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)).
  7610. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7611. */
  7612. rotation: Vector3;
  7613. /**
  7614. * 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)).
  7615. */
  7616. scaling: Vector3;
  7617. /**
  7618. * 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).
  7619. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7620. */
  7621. rotationQuaternion: Nullable<Quaternion>;
  7622. /**
  7623. * The forward direction of that transform in world space.
  7624. */
  7625. readonly forward: Vector3;
  7626. /**
  7627. * The up direction of that transform in world space.
  7628. */
  7629. readonly up: Vector3;
  7630. /**
  7631. * The right direction of that transform in world space.
  7632. */
  7633. readonly right: Vector3;
  7634. /**
  7635. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7636. * @param matrix the matrix to copy the pose from
  7637. * @returns this TransformNode.
  7638. */
  7639. updatePoseMatrix(matrix: Matrix): TransformNode;
  7640. /**
  7641. * Returns the mesh Pose matrix.
  7642. * @returns the pose matrix
  7643. */
  7644. getPoseMatrix(): Matrix;
  7645. /** @hidden */
  7646. _isSynchronized(): boolean;
  7647. /** @hidden */
  7648. _initCache(): void;
  7649. /**
  7650. * Flag the transform node as dirty (Forcing it to update everything)
  7651. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7652. * @returns this transform node
  7653. */
  7654. markAsDirty(property: string): TransformNode;
  7655. /**
  7656. * Returns the current mesh absolute position.
  7657. * Returns a Vector3.
  7658. */
  7659. readonly absolutePosition: Vector3;
  7660. /**
  7661. * Sets a new matrix to apply before all other transformation
  7662. * @param matrix defines the transform matrix
  7663. * @returns the current TransformNode
  7664. */
  7665. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7666. /**
  7667. * Sets a new pivot matrix to the current node
  7668. * @param matrix defines the new pivot matrix to use
  7669. * @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
  7670. * @returns the current TransformNode
  7671. */
  7672. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7673. /**
  7674. * Returns the mesh pivot matrix.
  7675. * Default : Identity.
  7676. * @returns the matrix
  7677. */
  7678. getPivotMatrix(): Matrix;
  7679. /**
  7680. * Prevents the World matrix to be computed any longer.
  7681. * @returns the TransformNode.
  7682. */
  7683. freezeWorldMatrix(): TransformNode;
  7684. /**
  7685. * Allows back the World matrix computation.
  7686. * @returns the TransformNode.
  7687. */
  7688. unfreezeWorldMatrix(): this;
  7689. /**
  7690. * True if the World matrix has been frozen.
  7691. */
  7692. readonly isWorldMatrixFrozen: boolean;
  7693. /**
  7694. * Retuns the mesh absolute position in the World.
  7695. * @returns a Vector3.
  7696. */
  7697. getAbsolutePosition(): Vector3;
  7698. /**
  7699. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7700. * @param absolutePosition the absolute position to set
  7701. * @returns the TransformNode.
  7702. */
  7703. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7704. /**
  7705. * Sets the mesh position in its local space.
  7706. * @param vector3 the position to set in localspace
  7707. * @returns the TransformNode.
  7708. */
  7709. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7710. /**
  7711. * Returns the mesh position in the local space from the current World matrix values.
  7712. * @returns a new Vector3.
  7713. */
  7714. getPositionExpressedInLocalSpace(): Vector3;
  7715. /**
  7716. * Translates the mesh along the passed Vector3 in its local space.
  7717. * @param vector3 the distance to translate in localspace
  7718. * @returns the TransformNode.
  7719. */
  7720. locallyTranslate(vector3: Vector3): TransformNode;
  7721. private static _lookAtVectorCache;
  7722. /**
  7723. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7724. * @param targetPoint the position (must be in same space as current mesh) to look at
  7725. * @param yawCor optional yaw (y-axis) correction in radians
  7726. * @param pitchCor optional pitch (x-axis) correction in radians
  7727. * @param rollCor optional roll (z-axis) correction in radians
  7728. * @param space the choosen space of the target
  7729. * @returns the TransformNode.
  7730. */
  7731. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7732. /**
  7733. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7734. * This Vector3 is expressed in the World space.
  7735. * @param localAxis axis to rotate
  7736. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7737. */
  7738. getDirection(localAxis: Vector3): Vector3;
  7739. /**
  7740. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7741. * localAxis is expressed in the mesh local space.
  7742. * result is computed in the Wordl space from the mesh World matrix.
  7743. * @param localAxis axis to rotate
  7744. * @param result the resulting transformnode
  7745. * @returns this TransformNode.
  7746. */
  7747. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7748. /**
  7749. * Sets this transform node rotation to the given local axis.
  7750. * @param localAxis the axis in local space
  7751. * @param yawCor optional yaw (y-axis) correction in radians
  7752. * @param pitchCor optional pitch (x-axis) correction in radians
  7753. * @param rollCor optional roll (z-axis) correction in radians
  7754. * @returns this TransformNode
  7755. */
  7756. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7757. /**
  7758. * Sets a new pivot point to the current node
  7759. * @param point defines the new pivot point to use
  7760. * @param space defines if the point is in world or local space (local by default)
  7761. * @returns the current TransformNode
  7762. */
  7763. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7764. /**
  7765. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7766. * @returns the pivot point
  7767. */
  7768. getPivotPoint(): Vector3;
  7769. /**
  7770. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7771. * @param result the vector3 to store the result
  7772. * @returns this TransformNode.
  7773. */
  7774. getPivotPointToRef(result: Vector3): TransformNode;
  7775. /**
  7776. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7777. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7778. */
  7779. getAbsolutePivotPoint(): Vector3;
  7780. /**
  7781. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7782. * @param result vector3 to store the result
  7783. * @returns this TransformNode.
  7784. */
  7785. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7786. /**
  7787. * Defines the passed node as the parent of the current node.
  7788. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7789. * @see https://doc.babylonjs.com/how_to/parenting
  7790. * @param node the node ot set as the parent
  7791. * @returns this TransformNode.
  7792. */
  7793. setParent(node: Nullable<Node>): TransformNode;
  7794. private _nonUniformScaling;
  7795. /**
  7796. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7797. */
  7798. readonly nonUniformScaling: boolean;
  7799. /** @hidden */
  7800. _updateNonUniformScalingState(value: boolean): boolean;
  7801. /**
  7802. * Attach the current TransformNode to another TransformNode associated with a bone
  7803. * @param bone Bone affecting the TransformNode
  7804. * @param affectedTransformNode TransformNode associated with the bone
  7805. * @returns this object
  7806. */
  7807. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7808. /**
  7809. * Detach the transform node if its associated with a bone
  7810. * @returns this object
  7811. */
  7812. detachFromBone(): TransformNode;
  7813. private static _rotationAxisCache;
  7814. /**
  7815. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7816. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7817. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7818. * The passed axis is also normalized.
  7819. * @param axis the axis to rotate around
  7820. * @param amount the amount to rotate in radians
  7821. * @param space Space to rotate in (Default: local)
  7822. * @returns the TransformNode.
  7823. */
  7824. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7825. /**
  7826. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7827. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7828. * The passed axis is also normalized. .
  7829. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7830. * @param point the point to rotate around
  7831. * @param axis the axis to rotate around
  7832. * @param amount the amount to rotate in radians
  7833. * @returns the TransformNode
  7834. */
  7835. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7836. /**
  7837. * Translates the mesh along the axis vector for the passed distance in the given space.
  7838. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7839. * @param axis the axis to translate in
  7840. * @param distance the distance to translate
  7841. * @param space Space to rotate in (Default: local)
  7842. * @returns the TransformNode.
  7843. */
  7844. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7845. /**
  7846. * Adds a rotation step to the mesh current rotation.
  7847. * x, y, z are Euler angles expressed in radians.
  7848. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7849. * This means this rotation is made in the mesh local space only.
  7850. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7851. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7852. * ```javascript
  7853. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7854. * ```
  7855. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7856. * 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.
  7857. * @param x Rotation to add
  7858. * @param y Rotation to add
  7859. * @param z Rotation to add
  7860. * @returns the TransformNode.
  7861. */
  7862. addRotation(x: number, y: number, z: number): TransformNode;
  7863. /**
  7864. * @hidden
  7865. */
  7866. protected _getEffectiveParent(): Nullable<Node>;
  7867. /**
  7868. * Computes the world matrix of the node
  7869. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7870. * @returns the world matrix
  7871. */
  7872. computeWorldMatrix(force?: boolean): Matrix;
  7873. protected _afterComputeWorldMatrix(): void;
  7874. /**
  7875. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7876. * @param func callback function to add
  7877. *
  7878. * @returns the TransformNode.
  7879. */
  7880. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7881. /**
  7882. * Removes a registered callback function.
  7883. * @param func callback function to remove
  7884. * @returns the TransformNode.
  7885. */
  7886. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7887. /**
  7888. * Gets the position of the current mesh in camera space
  7889. * @param camera defines the camera to use
  7890. * @returns a position
  7891. */
  7892. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7893. /**
  7894. * Returns the distance from the mesh to the active camera
  7895. * @param camera defines the camera to use
  7896. * @returns the distance
  7897. */
  7898. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7899. /**
  7900. * Clone the current transform node
  7901. * @param name Name of the new clone
  7902. * @param newParent New parent for the clone
  7903. * @param doNotCloneChildren Do not clone children hierarchy
  7904. * @returns the new transform node
  7905. */
  7906. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7907. /**
  7908. * Serializes the objects information.
  7909. * @param currentSerializationObject defines the object to serialize in
  7910. * @returns the serialized object
  7911. */
  7912. serialize(currentSerializationObject?: any): any;
  7913. /**
  7914. * Returns a new TransformNode object parsed from the source provided.
  7915. * @param parsedTransformNode is the source.
  7916. * @param scene the scne the object belongs to
  7917. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7918. * @returns a new TransformNode object parsed from the source provided.
  7919. */
  7920. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7921. /**
  7922. * Get all child-transformNodes of this node
  7923. * @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
  7924. * @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
  7925. * @returns an array of TransformNode
  7926. */
  7927. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7928. /**
  7929. * Releases resources associated with this transform node.
  7930. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7931. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7932. */
  7933. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7934. }
  7935. }
  7936. declare module BABYLON {
  7937. /**
  7938. * Class used to override all child animations of a given target
  7939. */
  7940. export class AnimationPropertiesOverride {
  7941. /**
  7942. * Gets or sets a value indicating if animation blending must be used
  7943. */
  7944. enableBlending: boolean;
  7945. /**
  7946. * Gets or sets the blending speed to use when enableBlending is true
  7947. */
  7948. blendingSpeed: number;
  7949. /**
  7950. * Gets or sets the default loop mode to use
  7951. */
  7952. loopMode: number;
  7953. }
  7954. }
  7955. declare module BABYLON {
  7956. /**
  7957. * Class used to store bone information
  7958. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7959. */
  7960. export class Bone extends Node {
  7961. /**
  7962. * defines the bone name
  7963. */
  7964. name: string;
  7965. private static _tmpVecs;
  7966. private static _tmpQuat;
  7967. private static _tmpMats;
  7968. /**
  7969. * Gets the list of child bones
  7970. */
  7971. children: Bone[];
  7972. /** Gets the animations associated with this bone */
  7973. animations: Animation[];
  7974. /**
  7975. * Gets or sets bone length
  7976. */
  7977. length: number;
  7978. /**
  7979. * @hidden Internal only
  7980. * Set this value to map this bone to a different index in the transform matrices
  7981. * Set this value to -1 to exclude the bone from the transform matrices
  7982. */
  7983. _index: Nullable<number>;
  7984. private _skeleton;
  7985. private _localMatrix;
  7986. private _restPose;
  7987. private _baseMatrix;
  7988. private _absoluteTransform;
  7989. private _invertedAbsoluteTransform;
  7990. private _parent;
  7991. private _scalingDeterminant;
  7992. private _worldTransform;
  7993. private _localScaling;
  7994. private _localRotation;
  7995. private _localPosition;
  7996. private _needToDecompose;
  7997. private _needToCompose;
  7998. /** @hidden */
  7999. _linkedTransformNode: Nullable<TransformNode>;
  8000. /** @hidden */
  8001. _waitingTransformNodeId: Nullable<string>;
  8002. /** @hidden */
  8003. /** @hidden */
  8004. _matrix: Matrix;
  8005. /**
  8006. * Create a new bone
  8007. * @param name defines the bone name
  8008. * @param skeleton defines the parent skeleton
  8009. * @param parentBone defines the parent (can be null if the bone is the root)
  8010. * @param localMatrix defines the local matrix
  8011. * @param restPose defines the rest pose matrix
  8012. * @param baseMatrix defines the base matrix
  8013. * @param index defines index of the bone in the hiearchy
  8014. */
  8015. constructor(
  8016. /**
  8017. * defines the bone name
  8018. */
  8019. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8020. /**
  8021. * Gets the current object class name.
  8022. * @return the class name
  8023. */
  8024. getClassName(): string;
  8025. /**
  8026. * Gets the parent skeleton
  8027. * @returns a skeleton
  8028. */
  8029. getSkeleton(): Skeleton;
  8030. /**
  8031. * Gets parent bone
  8032. * @returns a bone or null if the bone is the root of the bone hierarchy
  8033. */
  8034. getParent(): Nullable<Bone>;
  8035. /**
  8036. * Returns an array containing the root bones
  8037. * @returns an array containing the root bones
  8038. */
  8039. getChildren(): Array<Bone>;
  8040. /**
  8041. * Sets the parent bone
  8042. * @param parent defines the parent (can be null if the bone is the root)
  8043. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8044. */
  8045. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8046. /**
  8047. * Gets the local matrix
  8048. * @returns a matrix
  8049. */
  8050. getLocalMatrix(): Matrix;
  8051. /**
  8052. * Gets the base matrix (initial matrix which remains unchanged)
  8053. * @returns a matrix
  8054. */
  8055. getBaseMatrix(): Matrix;
  8056. /**
  8057. * Gets the rest pose matrix
  8058. * @returns a matrix
  8059. */
  8060. getRestPose(): Matrix;
  8061. /**
  8062. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8063. */
  8064. getWorldMatrix(): Matrix;
  8065. /**
  8066. * Sets the local matrix to rest pose matrix
  8067. */
  8068. returnToRest(): void;
  8069. /**
  8070. * Gets the inverse of the absolute transform matrix.
  8071. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8072. * @returns a matrix
  8073. */
  8074. getInvertedAbsoluteTransform(): Matrix;
  8075. /**
  8076. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8077. * @returns a matrix
  8078. */
  8079. getAbsoluteTransform(): Matrix;
  8080. /**
  8081. * Links with the given transform node.
  8082. * The local matrix of this bone is copied from the transform node every frame.
  8083. * @param transformNode defines the transform node to link to
  8084. */
  8085. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8086. /** Gets or sets current position (in local space) */
  8087. position: Vector3;
  8088. /** Gets or sets current rotation (in local space) */
  8089. rotation: Vector3;
  8090. /** Gets or sets current rotation quaternion (in local space) */
  8091. rotationQuaternion: Quaternion;
  8092. /** Gets or sets current scaling (in local space) */
  8093. scaling: Vector3;
  8094. /**
  8095. * Gets the animation properties override
  8096. */
  8097. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8098. private _decompose;
  8099. private _compose;
  8100. /**
  8101. * Update the base and local matrices
  8102. * @param matrix defines the new base or local matrix
  8103. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8104. * @param updateLocalMatrix defines if the local matrix should be updated
  8105. */
  8106. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8107. /** @hidden */
  8108. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8109. /**
  8110. * Flag the bone as dirty (Forcing it to update everything)
  8111. */
  8112. markAsDirty(): void;
  8113. private _markAsDirtyAndCompose;
  8114. private _markAsDirtyAndDecompose;
  8115. /**
  8116. * Translate the bone in local or world space
  8117. * @param vec The amount to translate the bone
  8118. * @param space The space that the translation is in
  8119. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8120. */
  8121. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8122. /**
  8123. * Set the postion of the bone in local or world space
  8124. * @param position The position to set the bone
  8125. * @param space The space that the position is in
  8126. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8127. */
  8128. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8129. /**
  8130. * Set the absolute position of the bone (world space)
  8131. * @param position The position to set the bone
  8132. * @param mesh The mesh that this bone is attached to
  8133. */
  8134. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8135. /**
  8136. * Scale the bone on the x, y and z axes (in local space)
  8137. * @param x The amount to scale the bone on the x axis
  8138. * @param y The amount to scale the bone on the y axis
  8139. * @param z The amount to scale the bone on the z axis
  8140. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8141. */
  8142. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8143. /**
  8144. * Set the bone scaling in local space
  8145. * @param scale defines the scaling vector
  8146. */
  8147. setScale(scale: Vector3): void;
  8148. /**
  8149. * Gets the current scaling in local space
  8150. * @returns the current scaling vector
  8151. */
  8152. getScale(): Vector3;
  8153. /**
  8154. * Gets the current scaling in local space and stores it in a target vector
  8155. * @param result defines the target vector
  8156. */
  8157. getScaleToRef(result: Vector3): void;
  8158. /**
  8159. * Set the yaw, pitch, and roll of the bone in local or world space
  8160. * @param yaw The rotation of the bone on the y axis
  8161. * @param pitch The rotation of the bone on the x axis
  8162. * @param roll The rotation of the bone on the z axis
  8163. * @param space The space that the axes of rotation are in
  8164. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8165. */
  8166. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8167. /**
  8168. * Add a rotation to the bone on an axis in local or world space
  8169. * @param axis The axis to rotate the bone on
  8170. * @param amount The amount to rotate the bone
  8171. * @param space The space that the axis is in
  8172. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8173. */
  8174. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8175. /**
  8176. * Set the rotation of the bone to a particular axis angle in local or world space
  8177. * @param axis The axis to rotate the bone on
  8178. * @param angle The angle that the bone should be rotated to
  8179. * @param space The space that the axis is in
  8180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8181. */
  8182. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8183. /**
  8184. * Set the euler rotation of the bone in local of world space
  8185. * @param rotation The euler rotation that the bone should be set to
  8186. * @param space The space that the rotation is in
  8187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8188. */
  8189. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8190. /**
  8191. * Set the quaternion rotation of the bone in local of world space
  8192. * @param quat The quaternion rotation that the bone should be set to
  8193. * @param space The space that the rotation is in
  8194. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8195. */
  8196. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8197. /**
  8198. * Set the rotation matrix of the bone in local of world space
  8199. * @param rotMat The rotation matrix that the bone should be set to
  8200. * @param space The space that the rotation is in
  8201. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8202. */
  8203. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8204. private _rotateWithMatrix;
  8205. private _getNegativeRotationToRef;
  8206. /**
  8207. * Get the position of the bone in local or world space
  8208. * @param space The space that the returned position is in
  8209. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8210. * @returns The position of the bone
  8211. */
  8212. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8213. /**
  8214. * Copy the position of the bone to a vector3 in local or world space
  8215. * @param space The space that the returned position is in
  8216. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8217. * @param result The vector3 to copy the position to
  8218. */
  8219. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8220. /**
  8221. * Get the absolute position of the bone (world space)
  8222. * @param mesh The mesh that this bone is attached to
  8223. * @returns The absolute position of the bone
  8224. */
  8225. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8226. /**
  8227. * Copy the absolute position of the bone (world space) to the result param
  8228. * @param mesh The mesh that this bone is attached to
  8229. * @param result The vector3 to copy the absolute position to
  8230. */
  8231. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8232. /**
  8233. * Compute the absolute transforms of this bone and its children
  8234. */
  8235. computeAbsoluteTransforms(): void;
  8236. /**
  8237. * Get the world direction from an axis that is in the local space of the bone
  8238. * @param localAxis The local direction that is used to compute the world direction
  8239. * @param mesh The mesh that this bone is attached to
  8240. * @returns The world direction
  8241. */
  8242. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8243. /**
  8244. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8245. * @param localAxis The local direction that is used to compute the world direction
  8246. * @param mesh The mesh that this bone is attached to
  8247. * @param result The vector3 that the world direction will be copied to
  8248. */
  8249. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8250. /**
  8251. * Get the euler rotation of the bone in local or world space
  8252. * @param space The space that the rotation should be in
  8253. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8254. * @returns The euler rotation
  8255. */
  8256. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8257. /**
  8258. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8259. * @param space The space that the rotation should be in
  8260. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8261. * @param result The vector3 that the rotation should be copied to
  8262. */
  8263. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8264. /**
  8265. * Get the quaternion rotation of the bone in either local or world space
  8266. * @param space The space that the rotation should be in
  8267. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8268. * @returns The quaternion rotation
  8269. */
  8270. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8271. /**
  8272. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8273. * @param space The space that the rotation should be in
  8274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8275. * @param result The quaternion that the rotation should be copied to
  8276. */
  8277. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8278. /**
  8279. * Get the rotation matrix of the bone in local or world space
  8280. * @param space The space that the rotation should be in
  8281. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8282. * @returns The rotation matrix
  8283. */
  8284. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8285. /**
  8286. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8287. * @param space The space that the rotation should be in
  8288. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8289. * @param result The quaternion that the rotation should be copied to
  8290. */
  8291. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8292. /**
  8293. * Get the world position of a point that is in the local space of the bone
  8294. * @param position The local position
  8295. * @param mesh The mesh that this bone is attached to
  8296. * @returns The world position
  8297. */
  8298. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8299. /**
  8300. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8301. * @param position The local position
  8302. * @param mesh The mesh that this bone is attached to
  8303. * @param result The vector3 that the world position should be copied to
  8304. */
  8305. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8306. /**
  8307. * Get the local position of a point that is in world space
  8308. * @param position The world position
  8309. * @param mesh The mesh that this bone is attached to
  8310. * @returns The local position
  8311. */
  8312. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8313. /**
  8314. * Get the local position of a point that is in world space and copy it to the result param
  8315. * @param position The world position
  8316. * @param mesh The mesh that this bone is attached to
  8317. * @param result The vector3 that the local position should be copied to
  8318. */
  8319. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8320. }
  8321. }
  8322. declare module BABYLON {
  8323. /**
  8324. * Enum that determines the text-wrapping mode to use.
  8325. */
  8326. export enum InspectableType {
  8327. /**
  8328. * Checkbox for booleans
  8329. */
  8330. Checkbox = 0,
  8331. /**
  8332. * Sliders for numbers
  8333. */
  8334. Slider = 1,
  8335. /**
  8336. * Vector3
  8337. */
  8338. Vector3 = 2,
  8339. /**
  8340. * Quaternions
  8341. */
  8342. Quaternion = 3,
  8343. /**
  8344. * Color3
  8345. */
  8346. Color3 = 4
  8347. }
  8348. /**
  8349. * Interface used to define custom inspectable properties.
  8350. * This interface is used by the inspector to display custom property grids
  8351. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8352. */
  8353. export interface IInspectable {
  8354. /**
  8355. * Gets the label to display
  8356. */
  8357. label: string;
  8358. /**
  8359. * Gets the name of the property to edit
  8360. */
  8361. propertyName: string;
  8362. /**
  8363. * Gets the type of the editor to use
  8364. */
  8365. type: InspectableType;
  8366. /**
  8367. * Gets the minimum value of the property when using in "slider" mode
  8368. */
  8369. min?: number;
  8370. /**
  8371. * Gets the maximum value of the property when using in "slider" mode
  8372. */
  8373. max?: number;
  8374. /**
  8375. * Gets the setp to use when using in "slider" mode
  8376. */
  8377. step?: number;
  8378. }
  8379. }
  8380. declare module BABYLON {
  8381. /**
  8382. * This represents the required contract to create a new type of texture loader.
  8383. */
  8384. export interface IInternalTextureLoader {
  8385. /**
  8386. * Defines wether the loader supports cascade loading the different faces.
  8387. */
  8388. supportCascades: boolean;
  8389. /**
  8390. * This returns if the loader support the current file information.
  8391. * @param extension defines the file extension of the file being loaded
  8392. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8393. * @param fallback defines the fallback internal texture if any
  8394. * @param isBase64 defines whether the texture is encoded as a base64
  8395. * @param isBuffer defines whether the texture data are stored as a buffer
  8396. * @returns true if the loader can load the specified file
  8397. */
  8398. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8399. /**
  8400. * Transform the url before loading if required.
  8401. * @param rootUrl the url of the texture
  8402. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8403. * @returns the transformed texture
  8404. */
  8405. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8406. /**
  8407. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8408. * @param rootUrl the url of the texture
  8409. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8410. * @returns the fallback texture
  8411. */
  8412. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8413. /**
  8414. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8415. * @param data contains the texture data
  8416. * @param texture defines the BabylonJS internal texture
  8417. * @param createPolynomials will be true if polynomials have been requested
  8418. * @param onLoad defines the callback to trigger once the texture is ready
  8419. * @param onError defines the callback to trigger in case of error
  8420. */
  8421. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8422. /**
  8423. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8424. * @param data contains the texture data
  8425. * @param texture defines the BabylonJS internal texture
  8426. * @param callback defines the method to call once ready to upload
  8427. */
  8428. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8429. }
  8430. }
  8431. declare module BABYLON {
  8432. interface Engine {
  8433. /**
  8434. * Creates a depth stencil cube texture.
  8435. * This is only available in WebGL 2.
  8436. * @param size The size of face edge in the cube texture.
  8437. * @param options The options defining the cube texture.
  8438. * @returns The cube texture
  8439. */
  8440. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8441. /**
  8442. * Creates a cube texture
  8443. * @param rootUrl defines the url where the files to load is located
  8444. * @param scene defines the current scene
  8445. * @param files defines the list of files to load (1 per face)
  8446. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8447. * @param onLoad defines an optional callback raised when the texture is loaded
  8448. * @param onError defines an optional callback raised if there is an issue to load the texture
  8449. * @param format defines the format of the data
  8450. * @param forcedExtension defines the extension to use to pick the right loader
  8451. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8452. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8453. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8454. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8455. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8456. * @returns the cube texture as an InternalTexture
  8457. */
  8458. 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;
  8459. /**
  8460. * Creates a cube texture
  8461. * @param rootUrl defines the url where the files to load is located
  8462. * @param scene defines the current scene
  8463. * @param files defines the list of files to load (1 per face)
  8464. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8465. * @param onLoad defines an optional callback raised when the texture is loaded
  8466. * @param onError defines an optional callback raised if there is an issue to load the texture
  8467. * @param format defines the format of the data
  8468. * @param forcedExtension defines the extension to use to pick the right loader
  8469. * @returns the cube texture as an InternalTexture
  8470. */
  8471. 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;
  8472. /**
  8473. * Creates a cube texture
  8474. * @param rootUrl defines the url where the files to load is located
  8475. * @param scene defines the current scene
  8476. * @param files defines the list of files to load (1 per face)
  8477. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8478. * @param onLoad defines an optional callback raised when the texture is loaded
  8479. * @param onError defines an optional callback raised if there is an issue to load the texture
  8480. * @param format defines the format of the data
  8481. * @param forcedExtension defines the extension to use to pick the right loader
  8482. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8483. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8484. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8485. * @returns the cube texture as an InternalTexture
  8486. */
  8487. 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;
  8488. /** @hidden */
  8489. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8490. /** @hidden */
  8491. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8492. /** @hidden */
  8493. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8494. /** @hidden */
  8495. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8496. }
  8497. }
  8498. declare module BABYLON {
  8499. /**
  8500. * Class for creating a cube texture
  8501. */
  8502. export class CubeTexture extends BaseTexture {
  8503. private _delayedOnLoad;
  8504. /**
  8505. * The url of the texture
  8506. */
  8507. url: string;
  8508. /**
  8509. * Gets or sets the center of the bounding box associated with the cube texture.
  8510. * It must define where the camera used to render the texture was set
  8511. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8512. */
  8513. boundingBoxPosition: Vector3;
  8514. private _boundingBoxSize;
  8515. /**
  8516. * Gets or sets the size of the bounding box associated with the cube texture
  8517. * When defined, the cubemap will switch to local mode
  8518. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8519. * @example https://www.babylonjs-playground.com/#RNASML
  8520. */
  8521. /**
  8522. * Returns the bounding box size
  8523. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8524. */
  8525. boundingBoxSize: Vector3;
  8526. protected _rotationY: number;
  8527. /**
  8528. * Sets texture matrix rotation angle around Y axis in radians.
  8529. */
  8530. /**
  8531. * Gets texture matrix rotation angle around Y axis radians.
  8532. */
  8533. rotationY: number;
  8534. /**
  8535. * Are mip maps generated for this texture or not.
  8536. */
  8537. readonly noMipmap: boolean;
  8538. private _noMipmap;
  8539. private _files;
  8540. private _extensions;
  8541. private _textureMatrix;
  8542. private _format;
  8543. private _createPolynomials;
  8544. /** @hidden */
  8545. _prefiltered: boolean;
  8546. /**
  8547. * Creates a cube texture from an array of image urls
  8548. * @param files defines an array of image urls
  8549. * @param scene defines the hosting scene
  8550. * @param noMipmap specifies if mip maps are not used
  8551. * @returns a cube texture
  8552. */
  8553. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8554. /**
  8555. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8556. * @param url defines the url of the prefiltered texture
  8557. * @param scene defines the scene the texture is attached to
  8558. * @param forcedExtension defines the extension of the file if different from the url
  8559. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8560. * @return the prefiltered texture
  8561. */
  8562. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8563. /**
  8564. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8565. * as prefiltered data.
  8566. * @param rootUrl defines the url of the texture or the root name of the six images
  8567. * @param scene defines the scene the texture is attached to
  8568. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8569. * @param noMipmap defines if mipmaps should be created or not
  8570. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8571. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8572. * @param onError defines a callback triggered in case of error during load
  8573. * @param format defines the internal format to use for the texture once loaded
  8574. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8575. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8576. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8577. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8578. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8579. * @return the cube texture
  8580. */
  8581. 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);
  8582. /**
  8583. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8584. */
  8585. readonly isPrefiltered: boolean;
  8586. /**
  8587. * Get the current class name of the texture useful for serialization or dynamic coding.
  8588. * @returns "CubeTexture"
  8589. */
  8590. getClassName(): string;
  8591. /**
  8592. * Update the url (and optional buffer) of this texture if url was null during construction.
  8593. * @param url the url of the texture
  8594. * @param forcedExtension defines the extension to use
  8595. * @param onLoad callback called when the texture is loaded (defaults to null)
  8596. */
  8597. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8598. /**
  8599. * Delays loading of the cube texture
  8600. * @param forcedExtension defines the extension to use
  8601. */
  8602. delayLoad(forcedExtension?: string): void;
  8603. /**
  8604. * Returns the reflection texture matrix
  8605. * @returns the reflection texture matrix
  8606. */
  8607. getReflectionTextureMatrix(): Matrix;
  8608. /**
  8609. * Sets the reflection texture matrix
  8610. * @param value Reflection texture matrix
  8611. */
  8612. setReflectionTextureMatrix(value: Matrix): void;
  8613. /**
  8614. * Parses text to create a cube texture
  8615. * @param parsedTexture define the serialized text to read from
  8616. * @param scene defines the hosting scene
  8617. * @param rootUrl defines the root url of the cube texture
  8618. * @returns a cube texture
  8619. */
  8620. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8621. /**
  8622. * Makes a clone, or deep copy, of the cube texture
  8623. * @returns a new cube texture
  8624. */
  8625. clone(): CubeTexture;
  8626. }
  8627. }
  8628. declare module BABYLON {
  8629. /** @hidden */
  8630. export var postprocessVertexShader: {
  8631. name: string;
  8632. shader: string;
  8633. };
  8634. }
  8635. declare module BABYLON {
  8636. /**
  8637. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8638. * This is the base of the follow, arc rotate cameras and Free camera
  8639. * @see http://doc.babylonjs.com/features/cameras
  8640. */
  8641. export class TargetCamera extends Camera {
  8642. private static _RigCamTransformMatrix;
  8643. private static _TargetTransformMatrix;
  8644. private static _TargetFocalPoint;
  8645. /**
  8646. * Define the current direction the camera is moving to
  8647. */
  8648. cameraDirection: Vector3;
  8649. /**
  8650. * Define the current rotation the camera is rotating to
  8651. */
  8652. cameraRotation: Vector2;
  8653. /**
  8654. * When set, the up vector of the camera will be updated by the rotation of the camera
  8655. */
  8656. updateUpVectorFromRotation: boolean;
  8657. private _tmpQuaternion;
  8658. /**
  8659. * Define the current rotation of the camera
  8660. */
  8661. rotation: Vector3;
  8662. /**
  8663. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8664. */
  8665. rotationQuaternion: Quaternion;
  8666. /**
  8667. * Define the current speed of the camera
  8668. */
  8669. speed: number;
  8670. /**
  8671. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8672. * around all axis.
  8673. */
  8674. noRotationConstraint: boolean;
  8675. /**
  8676. * Define the current target of the camera as an object or a position.
  8677. */
  8678. lockedTarget: any;
  8679. /** @hidden */
  8680. _currentTarget: Vector3;
  8681. /** @hidden */
  8682. _initialFocalDistance: number;
  8683. /** @hidden */
  8684. _viewMatrix: Matrix;
  8685. /** @hidden */
  8686. _camMatrix: Matrix;
  8687. /** @hidden */
  8688. _cameraTransformMatrix: Matrix;
  8689. /** @hidden */
  8690. _cameraRotationMatrix: Matrix;
  8691. /** @hidden */
  8692. _referencePoint: Vector3;
  8693. /** @hidden */
  8694. _transformedReferencePoint: Vector3;
  8695. protected _globalCurrentTarget: Vector3;
  8696. protected _globalCurrentUpVector: Vector3;
  8697. /** @hidden */
  8698. _reset: () => void;
  8699. private _defaultUp;
  8700. /**
  8701. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8702. * This is the base of the follow, arc rotate cameras and Free camera
  8703. * @see http://doc.babylonjs.com/features/cameras
  8704. * @param name Defines the name of the camera in the scene
  8705. * @param position Defines the start position of the camera in the scene
  8706. * @param scene Defines the scene the camera belongs to
  8707. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8708. */
  8709. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8710. /**
  8711. * Gets the position in front of the camera at a given distance.
  8712. * @param distance The distance from the camera we want the position to be
  8713. * @returns the position
  8714. */
  8715. getFrontPosition(distance: number): Vector3;
  8716. /** @hidden */
  8717. _getLockedTargetPosition(): Nullable<Vector3>;
  8718. private _storedPosition;
  8719. private _storedRotation;
  8720. private _storedRotationQuaternion;
  8721. /**
  8722. * Store current camera state of the camera (fov, position, rotation, etc..)
  8723. * @returns the camera
  8724. */
  8725. storeState(): Camera;
  8726. /**
  8727. * Restored camera state. You must call storeState() first
  8728. * @returns whether it was successful or not
  8729. * @hidden
  8730. */
  8731. _restoreStateValues(): boolean;
  8732. /** @hidden */
  8733. _initCache(): void;
  8734. /** @hidden */
  8735. _updateCache(ignoreParentClass?: boolean): void;
  8736. /** @hidden */
  8737. _isSynchronizedViewMatrix(): boolean;
  8738. /** @hidden */
  8739. _computeLocalCameraSpeed(): number;
  8740. /**
  8741. * Defines the target the camera should look at.
  8742. * This will automatically adapt alpha beta and radius to fit within the new target.
  8743. * @param target Defines the new target as a Vector or a mesh
  8744. */
  8745. setTarget(target: Vector3): void;
  8746. /**
  8747. * Return the current target position of the camera. This value is expressed in local space.
  8748. * @returns the target position
  8749. */
  8750. getTarget(): Vector3;
  8751. /** @hidden */
  8752. _decideIfNeedsToMove(): boolean;
  8753. /** @hidden */
  8754. _updatePosition(): void;
  8755. /** @hidden */
  8756. _checkInputs(): void;
  8757. protected _updateCameraRotationMatrix(): void;
  8758. /**
  8759. * 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)
  8760. * @returns the current camera
  8761. */
  8762. private _rotateUpVectorWithCameraRotationMatrix;
  8763. private _cachedRotationZ;
  8764. private _cachedQuaternionRotationZ;
  8765. /** @hidden */
  8766. _getViewMatrix(): Matrix;
  8767. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8768. /**
  8769. * @hidden
  8770. */
  8771. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8772. /**
  8773. * @hidden
  8774. */
  8775. _updateRigCameras(): void;
  8776. private _getRigCamPositionAndTarget;
  8777. /**
  8778. * Gets the current object class name.
  8779. * @return the class name
  8780. */
  8781. getClassName(): string;
  8782. }
  8783. }
  8784. declare module BABYLON {
  8785. /**
  8786. * @ignore
  8787. * This is a list of all the different input types that are available in the application.
  8788. * Fo instance: ArcRotateCameraGamepadInput...
  8789. */
  8790. export var CameraInputTypes: {};
  8791. /**
  8792. * This is the contract to implement in order to create a new input class.
  8793. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8794. */
  8795. export interface ICameraInput<TCamera extends Camera> {
  8796. /**
  8797. * Defines the camera the input is attached to.
  8798. */
  8799. camera: Nullable<TCamera>;
  8800. /**
  8801. * Gets the class name of the current intput.
  8802. * @returns the class name
  8803. */
  8804. getClassName(): string;
  8805. /**
  8806. * Get the friendly name associated with the input class.
  8807. * @returns the input friendly name
  8808. */
  8809. getSimpleName(): string;
  8810. /**
  8811. * Attach the input controls to a specific dom element to get the input from.
  8812. * @param element Defines the element the controls should be listened from
  8813. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8814. */
  8815. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8816. /**
  8817. * Detach the current controls from the specified dom element.
  8818. * @param element Defines the element to stop listening the inputs from
  8819. */
  8820. detachControl(element: Nullable<HTMLElement>): void;
  8821. /**
  8822. * Update the current camera state depending on the inputs that have been used this frame.
  8823. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8824. */
  8825. checkInputs?: () => void;
  8826. }
  8827. /**
  8828. * Represents a map of input types to input instance or input index to input instance.
  8829. */
  8830. export interface CameraInputsMap<TCamera extends Camera> {
  8831. /**
  8832. * Accessor to the input by input type.
  8833. */
  8834. [name: string]: ICameraInput<TCamera>;
  8835. /**
  8836. * Accessor to the input by input index.
  8837. */
  8838. [idx: number]: ICameraInput<TCamera>;
  8839. }
  8840. /**
  8841. * This represents the input manager used within a camera.
  8842. * It helps dealing with all the different kind of input attached to a camera.
  8843. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8844. */
  8845. export class CameraInputsManager<TCamera extends Camera> {
  8846. /**
  8847. * Defines the list of inputs attahed to the camera.
  8848. */
  8849. attached: CameraInputsMap<TCamera>;
  8850. /**
  8851. * Defines the dom element the camera is collecting inputs from.
  8852. * This is null if the controls have not been attached.
  8853. */
  8854. attachedElement: Nullable<HTMLElement>;
  8855. /**
  8856. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8857. */
  8858. noPreventDefault: boolean;
  8859. /**
  8860. * Defined the camera the input manager belongs to.
  8861. */
  8862. camera: TCamera;
  8863. /**
  8864. * Update the current camera state depending on the inputs that have been used this frame.
  8865. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8866. */
  8867. checkInputs: () => void;
  8868. /**
  8869. * Instantiate a new Camera Input Manager.
  8870. * @param camera Defines the camera the input manager blongs to
  8871. */
  8872. constructor(camera: TCamera);
  8873. /**
  8874. * Add an input method to a camera
  8875. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8876. * @param input camera input method
  8877. */
  8878. add(input: ICameraInput<TCamera>): void;
  8879. /**
  8880. * Remove a specific input method from a camera
  8881. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8882. * @param inputToRemove camera input method
  8883. */
  8884. remove(inputToRemove: ICameraInput<TCamera>): void;
  8885. /**
  8886. * Remove a specific input type from a camera
  8887. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8888. * @param inputType the type of the input to remove
  8889. */
  8890. removeByType(inputType: string): void;
  8891. private _addCheckInputs;
  8892. /**
  8893. * Attach the input controls to the currently attached dom element to listen the events from.
  8894. * @param input Defines the input to attach
  8895. */
  8896. attachInput(input: ICameraInput<TCamera>): void;
  8897. /**
  8898. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8899. * @param element Defines the dom element to collect the events from
  8900. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8901. */
  8902. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8903. /**
  8904. * Detach the current manager inputs controls from a specific dom element.
  8905. * @param element Defines the dom element to collect the events from
  8906. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8907. */
  8908. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8909. /**
  8910. * Rebuild the dynamic inputCheck function from the current list of
  8911. * defined inputs in the manager.
  8912. */
  8913. rebuildInputCheck(): void;
  8914. /**
  8915. * Remove all attached input methods from a camera
  8916. */
  8917. clear(): void;
  8918. /**
  8919. * Serialize the current input manager attached to a camera.
  8920. * This ensures than once parsed,
  8921. * the input associated to the camera will be identical to the current ones
  8922. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8923. */
  8924. serialize(serializedCamera: any): void;
  8925. /**
  8926. * Parses an input manager serialized JSON to restore the previous list of inputs
  8927. * and states associated to a camera.
  8928. * @param parsedCamera Defines the JSON to parse
  8929. */
  8930. parse(parsedCamera: any): void;
  8931. }
  8932. }
  8933. declare module BABYLON {
  8934. /**
  8935. * Gather the list of keyboard event types as constants.
  8936. */
  8937. export class KeyboardEventTypes {
  8938. /**
  8939. * The keydown event is fired when a key becomes active (pressed).
  8940. */
  8941. static readonly KEYDOWN: number;
  8942. /**
  8943. * The keyup event is fired when a key has been released.
  8944. */
  8945. static readonly KEYUP: number;
  8946. }
  8947. /**
  8948. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8949. */
  8950. export class KeyboardInfo {
  8951. /**
  8952. * Defines the type of event (KeyboardEventTypes)
  8953. */
  8954. type: number;
  8955. /**
  8956. * Defines the related dom event
  8957. */
  8958. event: KeyboardEvent;
  8959. /**
  8960. * Instantiates a new keyboard info.
  8961. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8962. * @param type Defines the type of event (KeyboardEventTypes)
  8963. * @param event Defines the related dom event
  8964. */
  8965. constructor(
  8966. /**
  8967. * Defines the type of event (KeyboardEventTypes)
  8968. */
  8969. type: number,
  8970. /**
  8971. * Defines the related dom event
  8972. */
  8973. event: KeyboardEvent);
  8974. }
  8975. /**
  8976. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8977. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8978. */
  8979. export class KeyboardInfoPre extends KeyboardInfo {
  8980. /**
  8981. * Defines the type of event (KeyboardEventTypes)
  8982. */
  8983. type: number;
  8984. /**
  8985. * Defines the related dom event
  8986. */
  8987. event: KeyboardEvent;
  8988. /**
  8989. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8990. */
  8991. skipOnPointerObservable: boolean;
  8992. /**
  8993. * Instantiates a new keyboard pre info.
  8994. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8995. * @param type Defines the type of event (KeyboardEventTypes)
  8996. * @param event Defines the related dom event
  8997. */
  8998. constructor(
  8999. /**
  9000. * Defines the type of event (KeyboardEventTypes)
  9001. */
  9002. type: number,
  9003. /**
  9004. * Defines the related dom event
  9005. */
  9006. event: KeyboardEvent);
  9007. }
  9008. }
  9009. declare module BABYLON {
  9010. /**
  9011. * Manage the keyboard inputs to control the movement of a free camera.
  9012. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9013. */
  9014. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9015. /**
  9016. * Defines the camera the input is attached to.
  9017. */
  9018. camera: FreeCamera;
  9019. /**
  9020. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9021. */
  9022. keysUp: number[];
  9023. /**
  9024. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9025. */
  9026. keysDown: number[];
  9027. /**
  9028. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9029. */
  9030. keysLeft: number[];
  9031. /**
  9032. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9033. */
  9034. keysRight: number[];
  9035. private _keys;
  9036. private _onCanvasBlurObserver;
  9037. private _onKeyboardObserver;
  9038. private _engine;
  9039. private _scene;
  9040. /**
  9041. * Attach the input controls to a specific dom element to get the input from.
  9042. * @param element Defines the element the controls should be listened from
  9043. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9044. */
  9045. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9046. /**
  9047. * Detach the current controls from the specified dom element.
  9048. * @param element Defines the element to stop listening the inputs from
  9049. */
  9050. detachControl(element: Nullable<HTMLElement>): void;
  9051. /**
  9052. * Update the current camera state depending on the inputs that have been used this frame.
  9053. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9054. */
  9055. checkInputs(): void;
  9056. /**
  9057. * Gets the class name of the current intput.
  9058. * @returns the class name
  9059. */
  9060. getClassName(): string;
  9061. /** @hidden */
  9062. _onLostFocus(): void;
  9063. /**
  9064. * Get the friendly name associated with the input class.
  9065. * @returns the input friendly name
  9066. */
  9067. getSimpleName(): string;
  9068. }
  9069. }
  9070. declare module BABYLON {
  9071. /**
  9072. * Interface describing all the common properties and methods a shadow light needs to implement.
  9073. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9074. * as well as binding the different shadow properties to the effects.
  9075. */
  9076. export interface IShadowLight extends Light {
  9077. /**
  9078. * The light id in the scene (used in scene.findLighById for instance)
  9079. */
  9080. id: string;
  9081. /**
  9082. * The position the shdow will be casted from.
  9083. */
  9084. position: Vector3;
  9085. /**
  9086. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9087. */
  9088. direction: Vector3;
  9089. /**
  9090. * The transformed position. Position of the light in world space taking parenting in account.
  9091. */
  9092. transformedPosition: Vector3;
  9093. /**
  9094. * The transformed direction. Direction of the light in world space taking parenting in account.
  9095. */
  9096. transformedDirection: Vector3;
  9097. /**
  9098. * The friendly name of the light in the scene.
  9099. */
  9100. name: string;
  9101. /**
  9102. * Defines the shadow projection clipping minimum z value.
  9103. */
  9104. shadowMinZ: number;
  9105. /**
  9106. * Defines the shadow projection clipping maximum z value.
  9107. */
  9108. shadowMaxZ: number;
  9109. /**
  9110. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9111. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9112. */
  9113. computeTransformedInformation(): boolean;
  9114. /**
  9115. * Gets the scene the light belongs to.
  9116. * @returns The scene
  9117. */
  9118. getScene(): Scene;
  9119. /**
  9120. * Callback defining a custom Projection Matrix Builder.
  9121. * This can be used to override the default projection matrix computation.
  9122. */
  9123. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9124. /**
  9125. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9126. * @param matrix The materix to updated with the projection information
  9127. * @param viewMatrix The transform matrix of the light
  9128. * @param renderList The list of mesh to render in the map
  9129. * @returns The current light
  9130. */
  9131. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9132. /**
  9133. * Gets the current depth scale used in ESM.
  9134. * @returns The scale
  9135. */
  9136. getDepthScale(): number;
  9137. /**
  9138. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9139. * @returns true if a cube texture needs to be use
  9140. */
  9141. needCube(): boolean;
  9142. /**
  9143. * Detects if the projection matrix requires to be recomputed this frame.
  9144. * @returns true if it requires to be recomputed otherwise, false.
  9145. */
  9146. needProjectionMatrixCompute(): boolean;
  9147. /**
  9148. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9149. */
  9150. forceProjectionMatrixCompute(): void;
  9151. /**
  9152. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9153. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9154. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9155. */
  9156. getShadowDirection(faceIndex?: number): Vector3;
  9157. /**
  9158. * Gets the minZ used for shadow according to both the scene and the light.
  9159. * @param activeCamera The camera we are returning the min for
  9160. * @returns the depth min z
  9161. */
  9162. getDepthMinZ(activeCamera: Camera): number;
  9163. /**
  9164. * Gets the maxZ used for shadow according to both the scene and the light.
  9165. * @param activeCamera The camera we are returning the max for
  9166. * @returns the depth max z
  9167. */
  9168. getDepthMaxZ(activeCamera: Camera): number;
  9169. }
  9170. /**
  9171. * Base implementation IShadowLight
  9172. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9173. */
  9174. export abstract class ShadowLight extends Light implements IShadowLight {
  9175. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9176. protected _position: Vector3;
  9177. protected _setPosition(value: Vector3): void;
  9178. /**
  9179. * Sets the position the shadow will be casted from. Also use as the light position for both
  9180. * point and spot lights.
  9181. */
  9182. /**
  9183. * Sets the position the shadow will be casted from. Also use as the light position for both
  9184. * point and spot lights.
  9185. */
  9186. position: Vector3;
  9187. protected _direction: Vector3;
  9188. protected _setDirection(value: Vector3): void;
  9189. /**
  9190. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9191. * Also use as the light direction on spot and directional lights.
  9192. */
  9193. /**
  9194. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9195. * Also use as the light direction on spot and directional lights.
  9196. */
  9197. direction: Vector3;
  9198. private _shadowMinZ;
  9199. /**
  9200. * Gets the shadow projection clipping minimum z value.
  9201. */
  9202. /**
  9203. * Sets the shadow projection clipping minimum z value.
  9204. */
  9205. shadowMinZ: number;
  9206. private _shadowMaxZ;
  9207. /**
  9208. * Sets the shadow projection clipping maximum z value.
  9209. */
  9210. /**
  9211. * Gets the shadow projection clipping maximum z value.
  9212. */
  9213. shadowMaxZ: number;
  9214. /**
  9215. * Callback defining a custom Projection Matrix Builder.
  9216. * This can be used to override the default projection matrix computation.
  9217. */
  9218. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9219. /**
  9220. * The transformed position. Position of the light in world space taking parenting in account.
  9221. */
  9222. transformedPosition: Vector3;
  9223. /**
  9224. * The transformed direction. Direction of the light in world space taking parenting in account.
  9225. */
  9226. transformedDirection: Vector3;
  9227. private _needProjectionMatrixCompute;
  9228. /**
  9229. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9230. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9231. */
  9232. computeTransformedInformation(): boolean;
  9233. /**
  9234. * Return the depth scale used for the shadow map.
  9235. * @returns the depth scale.
  9236. */
  9237. getDepthScale(): number;
  9238. /**
  9239. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9240. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9241. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9242. */
  9243. getShadowDirection(faceIndex?: number): Vector3;
  9244. /**
  9245. * Returns the ShadowLight absolute position in the World.
  9246. * @returns the position vector in world space
  9247. */
  9248. getAbsolutePosition(): Vector3;
  9249. /**
  9250. * Sets the ShadowLight direction toward the passed target.
  9251. * @param target The point to target in local space
  9252. * @returns the updated ShadowLight direction
  9253. */
  9254. setDirectionToTarget(target: Vector3): Vector3;
  9255. /**
  9256. * Returns the light rotation in euler definition.
  9257. * @returns the x y z rotation in local space.
  9258. */
  9259. getRotation(): Vector3;
  9260. /**
  9261. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9262. * @returns true if a cube texture needs to be use
  9263. */
  9264. needCube(): boolean;
  9265. /**
  9266. * Detects if the projection matrix requires to be recomputed this frame.
  9267. * @returns true if it requires to be recomputed otherwise, false.
  9268. */
  9269. needProjectionMatrixCompute(): boolean;
  9270. /**
  9271. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9272. */
  9273. forceProjectionMatrixCompute(): void;
  9274. /** @hidden */
  9275. _initCache(): void;
  9276. /** @hidden */
  9277. _isSynchronized(): boolean;
  9278. /**
  9279. * Computes the world matrix of the node
  9280. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9281. * @returns the world matrix
  9282. */
  9283. computeWorldMatrix(force?: boolean): Matrix;
  9284. /**
  9285. * Gets the minZ used for shadow according to both the scene and the light.
  9286. * @param activeCamera The camera we are returning the min for
  9287. * @returns the depth min z
  9288. */
  9289. getDepthMinZ(activeCamera: Camera): number;
  9290. /**
  9291. * Gets the maxZ used for shadow according to both the scene and the light.
  9292. * @param activeCamera The camera we are returning the max for
  9293. * @returns the depth max z
  9294. */
  9295. getDepthMaxZ(activeCamera: Camera): number;
  9296. /**
  9297. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9298. * @param matrix The materix to updated with the projection information
  9299. * @param viewMatrix The transform matrix of the light
  9300. * @param renderList The list of mesh to render in the map
  9301. * @returns The current light
  9302. */
  9303. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9304. }
  9305. }
  9306. declare module BABYLON {
  9307. /**
  9308. * "Static Class" containing the most commonly used helper while dealing with material for
  9309. * rendering purpose.
  9310. *
  9311. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9312. *
  9313. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9314. */
  9315. export class MaterialHelper {
  9316. /**
  9317. * Bind the current view position to an effect.
  9318. * @param effect The effect to be bound
  9319. * @param scene The scene the eyes position is used from
  9320. */
  9321. static BindEyePosition(effect: Effect, scene: Scene): void;
  9322. /**
  9323. * Helps preparing the defines values about the UVs in used in the effect.
  9324. * UVs are shared as much as we can accross channels in the shaders.
  9325. * @param texture The texture we are preparing the UVs for
  9326. * @param defines The defines to update
  9327. * @param key The channel key "diffuse", "specular"... used in the shader
  9328. */
  9329. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9330. /**
  9331. * Binds a texture matrix value to its corrsponding uniform
  9332. * @param texture The texture to bind the matrix for
  9333. * @param uniformBuffer The uniform buffer receivin the data
  9334. * @param key The channel key "diffuse", "specular"... used in the shader
  9335. */
  9336. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9337. /**
  9338. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9339. * @param mesh defines the current mesh
  9340. * @param scene defines the current scene
  9341. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9342. * @param pointsCloud defines if point cloud rendering has to be turned on
  9343. * @param fogEnabled defines if fog has to be turned on
  9344. * @param alphaTest defines if alpha testing has to be turned on
  9345. * @param defines defines the current list of defines
  9346. */
  9347. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9348. /**
  9349. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9350. * @param scene defines the current scene
  9351. * @param engine defines the current engine
  9352. * @param defines specifies the list of active defines
  9353. * @param useInstances defines if instances have to be turned on
  9354. * @param useClipPlane defines if clip plane have to be turned on
  9355. */
  9356. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9357. /**
  9358. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9359. * @param mesh The mesh containing the geometry data we will draw
  9360. * @param defines The defines to update
  9361. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9362. * @param useBones Precise whether bones should be used or not (override mesh info)
  9363. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9364. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9365. * @returns false if defines are considered not dirty and have not been checked
  9366. */
  9367. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9368. /**
  9369. * Prepares the defines related to multiview
  9370. * @param scene The scene we are intending to draw
  9371. * @param defines The defines to update
  9372. */
  9373. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9374. /**
  9375. * Prepares the defines related to the light information passed in parameter
  9376. * @param scene The scene we are intending to draw
  9377. * @param mesh The mesh the effect is compiling for
  9378. * @param defines The defines to update
  9379. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9380. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9381. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9382. * @returns true if normals will be required for the rest of the effect
  9383. */
  9384. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9385. /**
  9386. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9387. * that won t be acctive due to defines being turned off.
  9388. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9389. * @param samplersList The samplers list
  9390. * @param defines The defines helping in the list generation
  9391. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9392. */
  9393. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9394. /**
  9395. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9396. * @param defines The defines to update while falling back
  9397. * @param fallbacks The authorized effect fallbacks
  9398. * @param maxSimultaneousLights The maximum number of lights allowed
  9399. * @param rank the current rank of the Effect
  9400. * @returns The newly affected rank
  9401. */
  9402. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9403. /**
  9404. * Prepares the list of attributes required for morph targets according to the effect defines.
  9405. * @param attribs The current list of supported attribs
  9406. * @param mesh The mesh to prepare the morph targets attributes for
  9407. * @param defines The current Defines of the effect
  9408. */
  9409. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9410. /**
  9411. * Prepares the list of attributes required for bones according to the effect defines.
  9412. * @param attribs The current list of supported attribs
  9413. * @param mesh The mesh to prepare the bones attributes for
  9414. * @param defines The current Defines of the effect
  9415. * @param fallbacks The current efffect fallback strategy
  9416. */
  9417. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9418. /**
  9419. * Prepares the list of attributes required for instances according to the effect defines.
  9420. * @param attribs The current list of supported attribs
  9421. * @param defines The current Defines of the effect
  9422. */
  9423. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9424. /**
  9425. * Binds the light shadow information to the effect for the given mesh.
  9426. * @param light The light containing the generator
  9427. * @param scene The scene the lights belongs to
  9428. * @param mesh The mesh we are binding the information to render
  9429. * @param lightIndex The light index in the effect used to render the mesh
  9430. * @param effect The effect we are binding the data to
  9431. */
  9432. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9433. /**
  9434. * Binds the light information to the effect.
  9435. * @param light The light containing the generator
  9436. * @param effect The effect we are binding the data to
  9437. * @param lightIndex The light index in the effect used to render
  9438. */
  9439. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9440. /**
  9441. * Binds the lights information from the scene to the effect for the given mesh.
  9442. * @param scene The scene the lights belongs to
  9443. * @param mesh The mesh we are binding the information to render
  9444. * @param effect The effect we are binding the data to
  9445. * @param defines The generated defines for the effect
  9446. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9447. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9448. */
  9449. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9450. private static _tempFogColor;
  9451. /**
  9452. * Binds the fog information from the scene to the effect for the given mesh.
  9453. * @param scene The scene the lights belongs to
  9454. * @param mesh The mesh we are binding the information to render
  9455. * @param effect The effect we are binding the data to
  9456. * @param linearSpace Defines if the fog effect is applied in linear space
  9457. */
  9458. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9459. /**
  9460. * Binds the bones information from the mesh to the effect.
  9461. * @param mesh The mesh we are binding the information to render
  9462. * @param effect The effect we are binding the data to
  9463. */
  9464. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9465. /**
  9466. * Binds the morph targets information from the mesh to the effect.
  9467. * @param abstractMesh The mesh we are binding the information to render
  9468. * @param effect The effect we are binding the data to
  9469. */
  9470. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9471. /**
  9472. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9473. * @param defines The generated defines used in the effect
  9474. * @param effect The effect we are binding the data to
  9475. * @param scene The scene we are willing to render with logarithmic scale for
  9476. */
  9477. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9478. /**
  9479. * Binds the clip plane information from the scene to the effect.
  9480. * @param scene The scene the clip plane information are extracted from
  9481. * @param effect The effect we are binding the data to
  9482. */
  9483. static BindClipPlane(effect: Effect, scene: Scene): void;
  9484. }
  9485. }
  9486. declare module BABYLON {
  9487. /** @hidden */
  9488. export var kernelBlurVaryingDeclaration: {
  9489. name: string;
  9490. shader: string;
  9491. };
  9492. }
  9493. declare module BABYLON {
  9494. /** @hidden */
  9495. export var kernelBlurFragment: {
  9496. name: string;
  9497. shader: string;
  9498. };
  9499. }
  9500. declare module BABYLON {
  9501. /** @hidden */
  9502. export var kernelBlurFragment2: {
  9503. name: string;
  9504. shader: string;
  9505. };
  9506. }
  9507. declare module BABYLON {
  9508. /** @hidden */
  9509. export var kernelBlurPixelShader: {
  9510. name: string;
  9511. shader: string;
  9512. };
  9513. }
  9514. declare module BABYLON {
  9515. /** @hidden */
  9516. export var kernelBlurVertex: {
  9517. name: string;
  9518. shader: string;
  9519. };
  9520. }
  9521. declare module BABYLON {
  9522. /** @hidden */
  9523. export var kernelBlurVertexShader: {
  9524. name: string;
  9525. shader: string;
  9526. };
  9527. }
  9528. declare module BABYLON {
  9529. /**
  9530. * The Blur Post Process which blurs an image based on a kernel and direction.
  9531. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9532. */
  9533. export class BlurPostProcess extends PostProcess {
  9534. /** The direction in which to blur the image. */
  9535. direction: Vector2;
  9536. private blockCompilation;
  9537. protected _kernel: number;
  9538. protected _idealKernel: number;
  9539. protected _packedFloat: boolean;
  9540. private _staticDefines;
  9541. /**
  9542. * Sets the length in pixels of the blur sample region
  9543. */
  9544. /**
  9545. * Gets the length in pixels of the blur sample region
  9546. */
  9547. kernel: number;
  9548. /**
  9549. * Sets wether or not the blur needs to unpack/repack floats
  9550. */
  9551. /**
  9552. * Gets wether or not the blur is unpacking/repacking floats
  9553. */
  9554. packedFloat: boolean;
  9555. /**
  9556. * Creates a new instance BlurPostProcess
  9557. * @param name The name of the effect.
  9558. * @param direction The direction in which to blur the image.
  9559. * @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.
  9560. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9561. * @param camera The camera to apply the render pass to.
  9562. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9563. * @param engine The engine which the post process will be applied. (default: current engine)
  9564. * @param reusable If the post process can be reused on the same frame. (default: false)
  9565. * @param textureType Type of textures used when performing the post process. (default: 0)
  9566. * @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)
  9567. */
  9568. constructor(name: string,
  9569. /** The direction in which to blur the image. */
  9570. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9571. /**
  9572. * Updates the effect with the current post process compile time values and recompiles the shader.
  9573. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9574. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9575. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9576. * @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
  9577. * @param onCompiled Called when the shader has been compiled.
  9578. * @param onError Called if there is an error when compiling a shader.
  9579. */
  9580. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9581. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9582. /**
  9583. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9584. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9585. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9586. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9587. * The gaps between physical kernels are compensated for in the weighting of the samples
  9588. * @param idealKernel Ideal blur kernel.
  9589. * @return Nearest best kernel.
  9590. */
  9591. protected _nearestBestKernel(idealKernel: number): number;
  9592. /**
  9593. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9594. * @param x The point on the Gaussian distribution to sample.
  9595. * @return the value of the Gaussian function at x.
  9596. */
  9597. protected _gaussianWeight(x: number): number;
  9598. /**
  9599. * Generates a string that can be used as a floating point number in GLSL.
  9600. * @param x Value to print.
  9601. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9602. * @return GLSL float string.
  9603. */
  9604. protected _glslFloat(x: number, decimalFigures?: number): string;
  9605. }
  9606. }
  9607. declare module BABYLON {
  9608. /** @hidden */
  9609. export var shadowMapPixelShader: {
  9610. name: string;
  9611. shader: string;
  9612. };
  9613. }
  9614. declare module BABYLON {
  9615. /** @hidden */
  9616. export var bonesDeclaration: {
  9617. name: string;
  9618. shader: string;
  9619. };
  9620. }
  9621. declare module BABYLON {
  9622. /** @hidden */
  9623. export var morphTargetsVertexGlobalDeclaration: {
  9624. name: string;
  9625. shader: string;
  9626. };
  9627. }
  9628. declare module BABYLON {
  9629. /** @hidden */
  9630. export var morphTargetsVertexDeclaration: {
  9631. name: string;
  9632. shader: string;
  9633. };
  9634. }
  9635. declare module BABYLON {
  9636. /** @hidden */
  9637. export var instancesDeclaration: {
  9638. name: string;
  9639. shader: string;
  9640. };
  9641. }
  9642. declare module BABYLON {
  9643. /** @hidden */
  9644. export var helperFunctions: {
  9645. name: string;
  9646. shader: string;
  9647. };
  9648. }
  9649. declare module BABYLON {
  9650. /** @hidden */
  9651. export var morphTargetsVertex: {
  9652. name: string;
  9653. shader: string;
  9654. };
  9655. }
  9656. declare module BABYLON {
  9657. /** @hidden */
  9658. export var instancesVertex: {
  9659. name: string;
  9660. shader: string;
  9661. };
  9662. }
  9663. declare module BABYLON {
  9664. /** @hidden */
  9665. export var bonesVertex: {
  9666. name: string;
  9667. shader: string;
  9668. };
  9669. }
  9670. declare module BABYLON {
  9671. /** @hidden */
  9672. export var shadowMapVertexShader: {
  9673. name: string;
  9674. shader: string;
  9675. };
  9676. }
  9677. declare module BABYLON {
  9678. /** @hidden */
  9679. export var depthBoxBlurPixelShader: {
  9680. name: string;
  9681. shader: string;
  9682. };
  9683. }
  9684. declare module BABYLON {
  9685. /**
  9686. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9687. */
  9688. export interface ICustomShaderOptions {
  9689. /**
  9690. * Gets or sets the custom shader name to use
  9691. */
  9692. shaderName: string;
  9693. /**
  9694. * The list of attribute names used in the shader
  9695. */
  9696. attributes?: string[];
  9697. /**
  9698. * The list of unifrom names used in the shader
  9699. */
  9700. uniforms?: string[];
  9701. /**
  9702. * The list of sampler names used in the shader
  9703. */
  9704. samplers?: string[];
  9705. /**
  9706. * The list of defines used in the shader
  9707. */
  9708. defines?: string[];
  9709. }
  9710. /**
  9711. * Interface to implement to create a shadow generator compatible with BJS.
  9712. */
  9713. export interface IShadowGenerator {
  9714. /**
  9715. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9716. * @returns The render target texture if present otherwise, null
  9717. */
  9718. getShadowMap(): Nullable<RenderTargetTexture>;
  9719. /**
  9720. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9721. * @returns The render target texture if the shadow map is present otherwise, null
  9722. */
  9723. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9724. /**
  9725. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9726. * @param subMesh The submesh we want to render in the shadow map
  9727. * @param useInstances Defines wether will draw in the map using instances
  9728. * @returns true if ready otherwise, false
  9729. */
  9730. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9731. /**
  9732. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9733. * @param defines Defines of the material we want to update
  9734. * @param lightIndex Index of the light in the enabled light list of the material
  9735. */
  9736. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9737. /**
  9738. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9739. * defined in the generator but impacting the effect).
  9740. * It implies the unifroms available on the materials are the standard BJS ones.
  9741. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9742. * @param effect The effect we are binfing the information for
  9743. */
  9744. bindShadowLight(lightIndex: string, effect: Effect): void;
  9745. /**
  9746. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9747. * (eq to shadow prjection matrix * light transform matrix)
  9748. * @returns The transform matrix used to create the shadow map
  9749. */
  9750. getTransformMatrix(): Matrix;
  9751. /**
  9752. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9753. * Cube and 2D textures for instance.
  9754. */
  9755. recreateShadowMap(): void;
  9756. /**
  9757. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9758. * @param onCompiled Callback triggered at the and of the effects compilation
  9759. * @param options Sets of optional options forcing the compilation with different modes
  9760. */
  9761. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9762. useInstances: boolean;
  9763. }>): void;
  9764. /**
  9765. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9766. * @param options Sets of optional options forcing the compilation with different modes
  9767. * @returns A promise that resolves when the compilation completes
  9768. */
  9769. forceCompilationAsync(options?: Partial<{
  9770. useInstances: boolean;
  9771. }>): Promise<void>;
  9772. /**
  9773. * Serializes the shadow generator setup to a json object.
  9774. * @returns The serialized JSON object
  9775. */
  9776. serialize(): any;
  9777. /**
  9778. * Disposes the Shadow map and related Textures and effects.
  9779. */
  9780. dispose(): void;
  9781. }
  9782. /**
  9783. * Default implementation IShadowGenerator.
  9784. * This is the main object responsible of generating shadows in the framework.
  9785. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9786. */
  9787. export class ShadowGenerator implements IShadowGenerator {
  9788. /**
  9789. * Shadow generator mode None: no filtering applied.
  9790. */
  9791. static readonly FILTER_NONE: number;
  9792. /**
  9793. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9794. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9795. */
  9796. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9797. /**
  9798. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9799. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9800. */
  9801. static readonly FILTER_POISSONSAMPLING: number;
  9802. /**
  9803. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9804. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9805. */
  9806. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9807. /**
  9808. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9809. * edge artifacts on steep falloff.
  9810. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9811. */
  9812. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9813. /**
  9814. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9815. * edge artifacts on steep falloff.
  9816. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9817. */
  9818. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9819. /**
  9820. * Shadow generator mode PCF: Percentage Closer Filtering
  9821. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9822. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9823. */
  9824. static readonly FILTER_PCF: number;
  9825. /**
  9826. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9827. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9828. * Contact Hardening
  9829. */
  9830. static readonly FILTER_PCSS: number;
  9831. /**
  9832. * Reserved for PCF and PCSS
  9833. * Highest Quality.
  9834. *
  9835. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9836. *
  9837. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9838. */
  9839. static readonly QUALITY_HIGH: number;
  9840. /**
  9841. * Reserved for PCF and PCSS
  9842. * Good tradeoff for quality/perf cross devices
  9843. *
  9844. * Execute PCF on a 3*3 kernel.
  9845. *
  9846. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9847. */
  9848. static readonly QUALITY_MEDIUM: number;
  9849. /**
  9850. * Reserved for PCF and PCSS
  9851. * The lowest quality but the fastest.
  9852. *
  9853. * Execute PCF on a 1*1 kernel.
  9854. *
  9855. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9856. */
  9857. static readonly QUALITY_LOW: number;
  9858. /** Gets or sets the custom shader name to use */
  9859. customShaderOptions: ICustomShaderOptions;
  9860. /**
  9861. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9862. */
  9863. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9864. /**
  9865. * Observable triggered before a mesh is rendered in the shadow map.
  9866. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9867. */
  9868. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9869. private _bias;
  9870. /**
  9871. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9872. */
  9873. /**
  9874. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9875. */
  9876. bias: number;
  9877. private _normalBias;
  9878. /**
  9879. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9880. */
  9881. /**
  9882. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9883. */
  9884. normalBias: number;
  9885. private _blurBoxOffset;
  9886. /**
  9887. * Gets the blur box offset: offset applied during the blur pass.
  9888. * Only useful if useKernelBlur = false
  9889. */
  9890. /**
  9891. * Sets the blur box offset: offset applied during the blur pass.
  9892. * Only useful if useKernelBlur = false
  9893. */
  9894. blurBoxOffset: number;
  9895. private _blurScale;
  9896. /**
  9897. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9898. * 2 means half of the size.
  9899. */
  9900. /**
  9901. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9902. * 2 means half of the size.
  9903. */
  9904. blurScale: number;
  9905. private _blurKernel;
  9906. /**
  9907. * Gets the blur kernel: kernel size of the blur pass.
  9908. * Only useful if useKernelBlur = true
  9909. */
  9910. /**
  9911. * Sets the blur kernel: kernel size of the blur pass.
  9912. * Only useful if useKernelBlur = true
  9913. */
  9914. blurKernel: number;
  9915. private _useKernelBlur;
  9916. /**
  9917. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9918. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9919. */
  9920. /**
  9921. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9922. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9923. */
  9924. useKernelBlur: boolean;
  9925. private _depthScale;
  9926. /**
  9927. * Gets the depth scale used in ESM mode.
  9928. */
  9929. /**
  9930. * Sets the depth scale used in ESM mode.
  9931. * This can override the scale stored on the light.
  9932. */
  9933. depthScale: number;
  9934. private _filter;
  9935. /**
  9936. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9937. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9938. */
  9939. /**
  9940. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9941. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9942. */
  9943. filter: number;
  9944. /**
  9945. * Gets if the current filter is set to Poisson Sampling.
  9946. */
  9947. /**
  9948. * Sets the current filter to Poisson Sampling.
  9949. */
  9950. usePoissonSampling: boolean;
  9951. /**
  9952. * Gets if the current filter is set to ESM.
  9953. */
  9954. /**
  9955. * Sets the current filter is to ESM.
  9956. */
  9957. useExponentialShadowMap: boolean;
  9958. /**
  9959. * Gets if the current filter is set to filtered ESM.
  9960. */
  9961. /**
  9962. * Gets if the current filter is set to filtered ESM.
  9963. */
  9964. useBlurExponentialShadowMap: boolean;
  9965. /**
  9966. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9967. * exponential to prevent steep falloff artifacts).
  9968. */
  9969. /**
  9970. * Sets the current filter to "close ESM" (using the inverse of the
  9971. * exponential to prevent steep falloff artifacts).
  9972. */
  9973. useCloseExponentialShadowMap: boolean;
  9974. /**
  9975. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9976. * exponential to prevent steep falloff artifacts).
  9977. */
  9978. /**
  9979. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9980. * exponential to prevent steep falloff artifacts).
  9981. */
  9982. useBlurCloseExponentialShadowMap: boolean;
  9983. /**
  9984. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9985. */
  9986. /**
  9987. * Sets the current filter to "PCF" (percentage closer filtering).
  9988. */
  9989. usePercentageCloserFiltering: boolean;
  9990. private _filteringQuality;
  9991. /**
  9992. * Gets the PCF or PCSS Quality.
  9993. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9994. */
  9995. /**
  9996. * Sets the PCF or PCSS Quality.
  9997. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9998. */
  9999. filteringQuality: number;
  10000. /**
  10001. * Gets if the current filter is set to "PCSS" (contact hardening).
  10002. */
  10003. /**
  10004. * Sets the current filter to "PCSS" (contact hardening).
  10005. */
  10006. useContactHardeningShadow: boolean;
  10007. private _contactHardeningLightSizeUVRatio;
  10008. /**
  10009. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10010. * Using a ratio helps keeping shape stability independently of the map size.
  10011. *
  10012. * It does not account for the light projection as it was having too much
  10013. * instability during the light setup or during light position changes.
  10014. *
  10015. * Only valid if useContactHardeningShadow is true.
  10016. */
  10017. /**
  10018. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10019. * Using a ratio helps keeping shape stability independently of the map size.
  10020. *
  10021. * It does not account for the light projection as it was having too much
  10022. * instability during the light setup or during light position changes.
  10023. *
  10024. * Only valid if useContactHardeningShadow is true.
  10025. */
  10026. contactHardeningLightSizeUVRatio: number;
  10027. private _darkness;
  10028. /**
  10029. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10030. * 0 means strongest and 1 would means no shadow.
  10031. * @returns the darkness.
  10032. */
  10033. getDarkness(): number;
  10034. /**
  10035. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10036. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10037. * @returns the shadow generator allowing fluent coding.
  10038. */
  10039. setDarkness(darkness: number): ShadowGenerator;
  10040. private _transparencyShadow;
  10041. /**
  10042. * Sets the ability to have transparent shadow (boolean).
  10043. * @param transparent True if transparent else False
  10044. * @returns the shadow generator allowing fluent coding
  10045. */
  10046. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10047. private _shadowMap;
  10048. private _shadowMap2;
  10049. /**
  10050. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10051. * @returns The render target texture if present otherwise, null
  10052. */
  10053. getShadowMap(): Nullable<RenderTargetTexture>;
  10054. /**
  10055. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10056. * @returns The render target texture if the shadow map is present otherwise, null
  10057. */
  10058. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10059. /**
  10060. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10061. * @param mesh Mesh to add
  10062. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10063. * @returns the Shadow Generator itself
  10064. */
  10065. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10066. /**
  10067. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10068. * @param mesh Mesh to remove
  10069. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10070. * @returns the Shadow Generator itself
  10071. */
  10072. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10073. /**
  10074. * Controls the extent to which the shadows fade out at the edge of the frustum
  10075. * Used only by directionals and spots
  10076. */
  10077. frustumEdgeFalloff: number;
  10078. private _light;
  10079. /**
  10080. * Returns the associated light object.
  10081. * @returns the light generating the shadow
  10082. */
  10083. getLight(): IShadowLight;
  10084. /**
  10085. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10086. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10087. * It might on the other hand introduce peter panning.
  10088. */
  10089. forceBackFacesOnly: boolean;
  10090. private _scene;
  10091. private _lightDirection;
  10092. private _effect;
  10093. private _viewMatrix;
  10094. private _projectionMatrix;
  10095. private _transformMatrix;
  10096. private _cachedPosition;
  10097. private _cachedDirection;
  10098. private _cachedDefines;
  10099. private _currentRenderID;
  10100. private _boxBlurPostprocess;
  10101. private _kernelBlurXPostprocess;
  10102. private _kernelBlurYPostprocess;
  10103. private _blurPostProcesses;
  10104. private _mapSize;
  10105. private _currentFaceIndex;
  10106. private _currentFaceIndexCache;
  10107. private _textureType;
  10108. private _defaultTextureMatrix;
  10109. /** @hidden */
  10110. static _SceneComponentInitialization: (scene: Scene) => void;
  10111. /**
  10112. * Creates a ShadowGenerator object.
  10113. * A ShadowGenerator is the required tool to use the shadows.
  10114. * Each light casting shadows needs to use its own ShadowGenerator.
  10115. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10116. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10117. * @param light The light object generating the shadows.
  10118. * @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.
  10119. */
  10120. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10121. private _initializeGenerator;
  10122. private _initializeShadowMap;
  10123. private _initializeBlurRTTAndPostProcesses;
  10124. private _renderForShadowMap;
  10125. private _renderSubMeshForShadowMap;
  10126. private _applyFilterValues;
  10127. /**
  10128. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10129. * @param onCompiled Callback triggered at the and of the effects compilation
  10130. * @param options Sets of optional options forcing the compilation with different modes
  10131. */
  10132. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10133. useInstances: boolean;
  10134. }>): void;
  10135. /**
  10136. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10137. * @param options Sets of optional options forcing the compilation with different modes
  10138. * @returns A promise that resolves when the compilation completes
  10139. */
  10140. forceCompilationAsync(options?: Partial<{
  10141. useInstances: boolean;
  10142. }>): Promise<void>;
  10143. /**
  10144. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10145. * @param subMesh The submesh we want to render in the shadow map
  10146. * @param useInstances Defines wether will draw in the map using instances
  10147. * @returns true if ready otherwise, false
  10148. */
  10149. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10150. /**
  10151. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10152. * @param defines Defines of the material we want to update
  10153. * @param lightIndex Index of the light in the enabled light list of the material
  10154. */
  10155. prepareDefines(defines: any, lightIndex: number): void;
  10156. /**
  10157. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10158. * defined in the generator but impacting the effect).
  10159. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10160. * @param effect The effect we are binfing the information for
  10161. */
  10162. bindShadowLight(lightIndex: string, effect: Effect): void;
  10163. /**
  10164. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10165. * (eq to shadow prjection matrix * light transform matrix)
  10166. * @returns The transform matrix used to create the shadow map
  10167. */
  10168. getTransformMatrix(): Matrix;
  10169. /**
  10170. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10171. * Cube and 2D textures for instance.
  10172. */
  10173. recreateShadowMap(): void;
  10174. private _disposeBlurPostProcesses;
  10175. private _disposeRTTandPostProcesses;
  10176. /**
  10177. * Disposes the ShadowGenerator.
  10178. * Returns nothing.
  10179. */
  10180. dispose(): void;
  10181. /**
  10182. * Serializes the shadow generator setup to a json object.
  10183. * @returns The serialized JSON object
  10184. */
  10185. serialize(): any;
  10186. /**
  10187. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10188. * @param parsedShadowGenerator The JSON object to parse
  10189. * @param scene The scene to create the shadow map for
  10190. * @returns The parsed shadow generator
  10191. */
  10192. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10193. }
  10194. }
  10195. declare module BABYLON {
  10196. /**
  10197. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10198. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10199. * 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.
  10200. */
  10201. export abstract class Light extends Node {
  10202. /**
  10203. * Falloff Default: light is falling off following the material specification:
  10204. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10205. */
  10206. static readonly FALLOFF_DEFAULT: number;
  10207. /**
  10208. * Falloff Physical: light is falling off following the inverse squared distance law.
  10209. */
  10210. static readonly FALLOFF_PHYSICAL: number;
  10211. /**
  10212. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10213. * to enhance interoperability with other engines.
  10214. */
  10215. static readonly FALLOFF_GLTF: number;
  10216. /**
  10217. * Falloff Standard: light is falling off like in the standard material
  10218. * to enhance interoperability with other materials.
  10219. */
  10220. static readonly FALLOFF_STANDARD: number;
  10221. /**
  10222. * If every light affecting the material is in this lightmapMode,
  10223. * material.lightmapTexture adds or multiplies
  10224. * (depends on material.useLightmapAsShadowmap)
  10225. * after every other light calculations.
  10226. */
  10227. static readonly LIGHTMAP_DEFAULT: number;
  10228. /**
  10229. * material.lightmapTexture as only diffuse lighting from this light
  10230. * adds only specular lighting from this light
  10231. * adds dynamic shadows
  10232. */
  10233. static readonly LIGHTMAP_SPECULAR: number;
  10234. /**
  10235. * material.lightmapTexture as only lighting
  10236. * no light calculation from this light
  10237. * only adds dynamic shadows from this light
  10238. */
  10239. static readonly LIGHTMAP_SHADOWSONLY: number;
  10240. /**
  10241. * Each light type uses the default quantity according to its type:
  10242. * point/spot lights use luminous intensity
  10243. * directional lights use illuminance
  10244. */
  10245. static readonly INTENSITYMODE_AUTOMATIC: number;
  10246. /**
  10247. * lumen (lm)
  10248. */
  10249. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10250. /**
  10251. * candela (lm/sr)
  10252. */
  10253. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10254. /**
  10255. * lux (lm/m^2)
  10256. */
  10257. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10258. /**
  10259. * nit (cd/m^2)
  10260. */
  10261. static readonly INTENSITYMODE_LUMINANCE: number;
  10262. /**
  10263. * Light type const id of the point light.
  10264. */
  10265. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10266. /**
  10267. * Light type const id of the directional light.
  10268. */
  10269. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10270. /**
  10271. * Light type const id of the spot light.
  10272. */
  10273. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10274. /**
  10275. * Light type const id of the hemispheric light.
  10276. */
  10277. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10278. /**
  10279. * Diffuse gives the basic color to an object.
  10280. */
  10281. diffuse: Color3;
  10282. /**
  10283. * Specular produces a highlight color on an object.
  10284. * Note: This is note affecting PBR materials.
  10285. */
  10286. specular: Color3;
  10287. /**
  10288. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10289. * falling off base on range or angle.
  10290. * This can be set to any values in Light.FALLOFF_x.
  10291. *
  10292. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10293. * other types of materials.
  10294. */
  10295. falloffType: number;
  10296. /**
  10297. * Strength of the light.
  10298. * Note: By default it is define in the framework own unit.
  10299. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10300. */
  10301. intensity: number;
  10302. private _range;
  10303. protected _inverseSquaredRange: number;
  10304. /**
  10305. * Defines how far from the source the light is impacting in scene units.
  10306. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10307. */
  10308. /**
  10309. * Defines how far from the source the light is impacting in scene units.
  10310. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10311. */
  10312. range: number;
  10313. /**
  10314. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10315. * of light.
  10316. */
  10317. private _photometricScale;
  10318. private _intensityMode;
  10319. /**
  10320. * Gets the photometric scale used to interpret the intensity.
  10321. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10322. */
  10323. /**
  10324. * Sets the photometric scale used to interpret the intensity.
  10325. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10326. */
  10327. intensityMode: number;
  10328. private _radius;
  10329. /**
  10330. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10331. */
  10332. /**
  10333. * sets the light radius used by PBR Materials to simulate soft area lights.
  10334. */
  10335. radius: number;
  10336. private _renderPriority;
  10337. /**
  10338. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10339. * exceeding the number allowed of the materials.
  10340. */
  10341. renderPriority: number;
  10342. private _shadowEnabled;
  10343. /**
  10344. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10345. * the current shadow generator.
  10346. */
  10347. /**
  10348. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10349. * the current shadow generator.
  10350. */
  10351. shadowEnabled: boolean;
  10352. private _includedOnlyMeshes;
  10353. /**
  10354. * Gets the only meshes impacted by this light.
  10355. */
  10356. /**
  10357. * Sets the only meshes impacted by this light.
  10358. */
  10359. includedOnlyMeshes: AbstractMesh[];
  10360. private _excludedMeshes;
  10361. /**
  10362. * Gets the meshes not impacted by this light.
  10363. */
  10364. /**
  10365. * Sets the meshes not impacted by this light.
  10366. */
  10367. excludedMeshes: AbstractMesh[];
  10368. private _excludeWithLayerMask;
  10369. /**
  10370. * Gets the layer id use to find what meshes are not impacted by the light.
  10371. * Inactive if 0
  10372. */
  10373. /**
  10374. * Sets the layer id use to find what meshes are not impacted by the light.
  10375. * Inactive if 0
  10376. */
  10377. excludeWithLayerMask: number;
  10378. private _includeOnlyWithLayerMask;
  10379. /**
  10380. * Gets the layer id use to find what meshes are impacted by the light.
  10381. * Inactive if 0
  10382. */
  10383. /**
  10384. * Sets the layer id use to find what meshes are impacted by the light.
  10385. * Inactive if 0
  10386. */
  10387. includeOnlyWithLayerMask: number;
  10388. private _lightmapMode;
  10389. /**
  10390. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10391. */
  10392. /**
  10393. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10394. */
  10395. lightmapMode: number;
  10396. /**
  10397. * Shadow generator associted to the light.
  10398. * @hidden Internal use only.
  10399. */
  10400. _shadowGenerator: Nullable<IShadowGenerator>;
  10401. /**
  10402. * @hidden Internal use only.
  10403. */
  10404. _excludedMeshesIds: string[];
  10405. /**
  10406. * @hidden Internal use only.
  10407. */
  10408. _includedOnlyMeshesIds: string[];
  10409. /**
  10410. * The current light unifom buffer.
  10411. * @hidden Internal use only.
  10412. */
  10413. _uniformBuffer: UniformBuffer;
  10414. /**
  10415. * Creates a Light object in the scene.
  10416. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10417. * @param name The firendly name of the light
  10418. * @param scene The scene the light belongs too
  10419. */
  10420. constructor(name: string, scene: Scene);
  10421. protected abstract _buildUniformLayout(): void;
  10422. /**
  10423. * Sets the passed Effect "effect" with the Light information.
  10424. * @param effect The effect to update
  10425. * @param lightIndex The index of the light in the effect to update
  10426. * @returns The light
  10427. */
  10428. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10429. /**
  10430. * Returns the string "Light".
  10431. * @returns the class name
  10432. */
  10433. getClassName(): string;
  10434. /** @hidden */
  10435. readonly _isLight: boolean;
  10436. /**
  10437. * Converts the light information to a readable string for debug purpose.
  10438. * @param fullDetails Supports for multiple levels of logging within scene loading
  10439. * @returns the human readable light info
  10440. */
  10441. toString(fullDetails?: boolean): string;
  10442. /** @hidden */
  10443. protected _syncParentEnabledState(): void;
  10444. /**
  10445. * Set the enabled state of this node.
  10446. * @param value - the new enabled state
  10447. */
  10448. setEnabled(value: boolean): void;
  10449. /**
  10450. * Returns the Light associated shadow generator if any.
  10451. * @return the associated shadow generator.
  10452. */
  10453. getShadowGenerator(): Nullable<IShadowGenerator>;
  10454. /**
  10455. * Returns a Vector3, the absolute light position in the World.
  10456. * @returns the world space position of the light
  10457. */
  10458. getAbsolutePosition(): Vector3;
  10459. /**
  10460. * Specifies if the light will affect the passed mesh.
  10461. * @param mesh The mesh to test against the light
  10462. * @return true the mesh is affected otherwise, false.
  10463. */
  10464. canAffectMesh(mesh: AbstractMesh): boolean;
  10465. /**
  10466. * Sort function to order lights for rendering.
  10467. * @param a First Light object to compare to second.
  10468. * @param b Second Light object to compare first.
  10469. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10470. */
  10471. static CompareLightsPriority(a: Light, b: Light): number;
  10472. /**
  10473. * Releases resources associated with this node.
  10474. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10475. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10476. */
  10477. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10478. /**
  10479. * Returns the light type ID (integer).
  10480. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10481. */
  10482. getTypeID(): number;
  10483. /**
  10484. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10485. * @returns the scaled intensity in intensity mode unit
  10486. */
  10487. getScaledIntensity(): number;
  10488. /**
  10489. * Returns a new Light object, named "name", from the current one.
  10490. * @param name The name of the cloned light
  10491. * @returns the new created light
  10492. */
  10493. clone(name: string): Nullable<Light>;
  10494. /**
  10495. * Serializes the current light into a Serialization object.
  10496. * @returns the serialized object.
  10497. */
  10498. serialize(): any;
  10499. /**
  10500. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10501. * This new light is named "name" and added to the passed scene.
  10502. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10503. * @param name The friendly name of the light
  10504. * @param scene The scene the new light will belong to
  10505. * @returns the constructor function
  10506. */
  10507. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10508. /**
  10509. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10510. * @param parsedLight The JSON representation of the light
  10511. * @param scene The scene to create the parsed light in
  10512. * @returns the created light after parsing
  10513. */
  10514. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10515. private _hookArrayForExcluded;
  10516. private _hookArrayForIncludedOnly;
  10517. private _resyncMeshes;
  10518. /**
  10519. * Forces the meshes to update their light related information in their rendering used effects
  10520. * @hidden Internal Use Only
  10521. */
  10522. _markMeshesAsLightDirty(): void;
  10523. /**
  10524. * Recomputes the cached photometric scale if needed.
  10525. */
  10526. private _computePhotometricScale;
  10527. /**
  10528. * Returns the Photometric Scale according to the light type and intensity mode.
  10529. */
  10530. private _getPhotometricScale;
  10531. /**
  10532. * Reorder the light in the scene according to their defined priority.
  10533. * @hidden Internal Use Only
  10534. */
  10535. _reorderLightsInScene(): void;
  10536. /**
  10537. * Prepares the list of defines specific to the light type.
  10538. * @param defines the list of defines
  10539. * @param lightIndex defines the index of the light for the effect
  10540. */
  10541. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10542. }
  10543. }
  10544. declare module BABYLON {
  10545. /**
  10546. * Interface used to define Action
  10547. */
  10548. export interface IAction {
  10549. /**
  10550. * Trigger for the action
  10551. */
  10552. trigger: number;
  10553. /** Options of the trigger */
  10554. triggerOptions: any;
  10555. /**
  10556. * Gets the trigger parameters
  10557. * @returns the trigger parameters
  10558. */
  10559. getTriggerParameter(): any;
  10560. /**
  10561. * Internal only - executes current action event
  10562. * @hidden
  10563. */
  10564. _executeCurrent(evt?: ActionEvent): void;
  10565. /**
  10566. * Serialize placeholder for child classes
  10567. * @param parent of child
  10568. * @returns the serialized object
  10569. */
  10570. serialize(parent: any): any;
  10571. /**
  10572. * Internal only
  10573. * @hidden
  10574. */
  10575. _prepare(): void;
  10576. /**
  10577. * Internal only - manager for action
  10578. * @hidden
  10579. */
  10580. _actionManager: AbstractActionManager;
  10581. }
  10582. /**
  10583. * The action to be carried out following a trigger
  10584. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10585. */
  10586. export class Action implements IAction {
  10587. /** the trigger, with or without parameters, for the action */
  10588. triggerOptions: any;
  10589. /**
  10590. * Trigger for the action
  10591. */
  10592. trigger: number;
  10593. /**
  10594. * Internal only - manager for action
  10595. * @hidden
  10596. */
  10597. _actionManager: ActionManager;
  10598. private _nextActiveAction;
  10599. private _child;
  10600. private _condition?;
  10601. private _triggerParameter;
  10602. /**
  10603. * An event triggered prior to action being executed.
  10604. */
  10605. onBeforeExecuteObservable: Observable<Action>;
  10606. /**
  10607. * Creates a new Action
  10608. * @param triggerOptions the trigger, with or without parameters, for the action
  10609. * @param condition an optional determinant of action
  10610. */
  10611. constructor(
  10612. /** the trigger, with or without parameters, for the action */
  10613. triggerOptions: any, condition?: Condition);
  10614. /**
  10615. * Internal only
  10616. * @hidden
  10617. */
  10618. _prepare(): void;
  10619. /**
  10620. * Gets the trigger parameters
  10621. * @returns the trigger parameters
  10622. */
  10623. getTriggerParameter(): any;
  10624. /**
  10625. * Internal only - executes current action event
  10626. * @hidden
  10627. */
  10628. _executeCurrent(evt?: ActionEvent): void;
  10629. /**
  10630. * Execute placeholder for child classes
  10631. * @param evt optional action event
  10632. */
  10633. execute(evt?: ActionEvent): void;
  10634. /**
  10635. * Skips to next active action
  10636. */
  10637. skipToNextActiveAction(): void;
  10638. /**
  10639. * Adds action to chain of actions, may be a DoNothingAction
  10640. * @param action defines the next action to execute
  10641. * @returns The action passed in
  10642. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10643. */
  10644. then(action: Action): Action;
  10645. /**
  10646. * Internal only
  10647. * @hidden
  10648. */
  10649. _getProperty(propertyPath: string): string;
  10650. /**
  10651. * Internal only
  10652. * @hidden
  10653. */
  10654. _getEffectiveTarget(target: any, propertyPath: string): any;
  10655. /**
  10656. * Serialize placeholder for child classes
  10657. * @param parent of child
  10658. * @returns the serialized object
  10659. */
  10660. serialize(parent: any): any;
  10661. /**
  10662. * Internal only called by serialize
  10663. * @hidden
  10664. */
  10665. protected _serialize(serializedAction: any, parent?: any): any;
  10666. /**
  10667. * Internal only
  10668. * @hidden
  10669. */
  10670. static _SerializeValueAsString: (value: any) => string;
  10671. /**
  10672. * Internal only
  10673. * @hidden
  10674. */
  10675. static _GetTargetProperty: (target: Scene | Node) => {
  10676. name: string;
  10677. targetType: string;
  10678. value: string;
  10679. };
  10680. }
  10681. }
  10682. declare module BABYLON {
  10683. /**
  10684. * A Condition applied to an Action
  10685. */
  10686. export class Condition {
  10687. /**
  10688. * Internal only - manager for action
  10689. * @hidden
  10690. */
  10691. _actionManager: ActionManager;
  10692. /**
  10693. * Internal only
  10694. * @hidden
  10695. */
  10696. _evaluationId: number;
  10697. /**
  10698. * Internal only
  10699. * @hidden
  10700. */
  10701. _currentResult: boolean;
  10702. /**
  10703. * Creates a new Condition
  10704. * @param actionManager the manager of the action the condition is applied to
  10705. */
  10706. constructor(actionManager: ActionManager);
  10707. /**
  10708. * Check if the current condition is valid
  10709. * @returns a boolean
  10710. */
  10711. isValid(): boolean;
  10712. /**
  10713. * Internal only
  10714. * @hidden
  10715. */
  10716. _getProperty(propertyPath: string): string;
  10717. /**
  10718. * Internal only
  10719. * @hidden
  10720. */
  10721. _getEffectiveTarget(target: any, propertyPath: string): any;
  10722. /**
  10723. * Serialize placeholder for child classes
  10724. * @returns the serialized object
  10725. */
  10726. serialize(): any;
  10727. /**
  10728. * Internal only
  10729. * @hidden
  10730. */
  10731. protected _serialize(serializedCondition: any): any;
  10732. }
  10733. /**
  10734. * Defines specific conditional operators as extensions of Condition
  10735. */
  10736. export class ValueCondition extends Condition {
  10737. /** path to specify the property of the target the conditional operator uses */
  10738. propertyPath: string;
  10739. /** the value compared by the conditional operator against the current value of the property */
  10740. value: any;
  10741. /** the conditional operator, default ValueCondition.IsEqual */
  10742. operator: number;
  10743. /**
  10744. * Internal only
  10745. * @hidden
  10746. */
  10747. private static _IsEqual;
  10748. /**
  10749. * Internal only
  10750. * @hidden
  10751. */
  10752. private static _IsDifferent;
  10753. /**
  10754. * Internal only
  10755. * @hidden
  10756. */
  10757. private static _IsGreater;
  10758. /**
  10759. * Internal only
  10760. * @hidden
  10761. */
  10762. private static _IsLesser;
  10763. /**
  10764. * returns the number for IsEqual
  10765. */
  10766. static readonly IsEqual: number;
  10767. /**
  10768. * Returns the number for IsDifferent
  10769. */
  10770. static readonly IsDifferent: number;
  10771. /**
  10772. * Returns the number for IsGreater
  10773. */
  10774. static readonly IsGreater: number;
  10775. /**
  10776. * Returns the number for IsLesser
  10777. */
  10778. static readonly IsLesser: number;
  10779. /**
  10780. * Internal only The action manager for the condition
  10781. * @hidden
  10782. */
  10783. _actionManager: ActionManager;
  10784. /**
  10785. * Internal only
  10786. * @hidden
  10787. */
  10788. private _target;
  10789. /**
  10790. * Internal only
  10791. * @hidden
  10792. */
  10793. private _effectiveTarget;
  10794. /**
  10795. * Internal only
  10796. * @hidden
  10797. */
  10798. private _property;
  10799. /**
  10800. * Creates a new ValueCondition
  10801. * @param actionManager manager for the action the condition applies to
  10802. * @param target for the action
  10803. * @param propertyPath path to specify the property of the target the conditional operator uses
  10804. * @param value the value compared by the conditional operator against the current value of the property
  10805. * @param operator the conditional operator, default ValueCondition.IsEqual
  10806. */
  10807. constructor(actionManager: ActionManager, target: any,
  10808. /** path to specify the property of the target the conditional operator uses */
  10809. propertyPath: string,
  10810. /** the value compared by the conditional operator against the current value of the property */
  10811. value: any,
  10812. /** the conditional operator, default ValueCondition.IsEqual */
  10813. operator?: number);
  10814. /**
  10815. * Compares the given value with the property value for the specified conditional operator
  10816. * @returns the result of the comparison
  10817. */
  10818. isValid(): boolean;
  10819. /**
  10820. * Serialize the ValueCondition into a JSON compatible object
  10821. * @returns serialization object
  10822. */
  10823. serialize(): any;
  10824. /**
  10825. * Gets the name of the conditional operator for the ValueCondition
  10826. * @param operator the conditional operator
  10827. * @returns the name
  10828. */
  10829. static GetOperatorName(operator: number): string;
  10830. }
  10831. /**
  10832. * Defines a predicate condition as an extension of Condition
  10833. */
  10834. export class PredicateCondition extends Condition {
  10835. /** defines the predicate function used to validate the condition */
  10836. predicate: () => boolean;
  10837. /**
  10838. * Internal only - manager for action
  10839. * @hidden
  10840. */
  10841. _actionManager: ActionManager;
  10842. /**
  10843. * Creates a new PredicateCondition
  10844. * @param actionManager manager for the action the condition applies to
  10845. * @param predicate defines the predicate function used to validate the condition
  10846. */
  10847. constructor(actionManager: ActionManager,
  10848. /** defines the predicate function used to validate the condition */
  10849. predicate: () => boolean);
  10850. /**
  10851. * @returns the validity of the predicate condition
  10852. */
  10853. isValid(): boolean;
  10854. }
  10855. /**
  10856. * Defines a state condition as an extension of Condition
  10857. */
  10858. export class StateCondition extends Condition {
  10859. /** Value to compare with target state */
  10860. value: string;
  10861. /**
  10862. * Internal only - manager for action
  10863. * @hidden
  10864. */
  10865. _actionManager: ActionManager;
  10866. /**
  10867. * Internal only
  10868. * @hidden
  10869. */
  10870. private _target;
  10871. /**
  10872. * Creates a new StateCondition
  10873. * @param actionManager manager for the action the condition applies to
  10874. * @param target of the condition
  10875. * @param value to compare with target state
  10876. */
  10877. constructor(actionManager: ActionManager, target: any,
  10878. /** Value to compare with target state */
  10879. value: string);
  10880. /**
  10881. * Gets a boolean indicating if the current condition is met
  10882. * @returns the validity of the state
  10883. */
  10884. isValid(): boolean;
  10885. /**
  10886. * Serialize the StateCondition into a JSON compatible object
  10887. * @returns serialization object
  10888. */
  10889. serialize(): any;
  10890. }
  10891. }
  10892. declare module BABYLON {
  10893. /**
  10894. * This defines an action responsible to toggle a boolean once triggered.
  10895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10896. */
  10897. export class SwitchBooleanAction extends Action {
  10898. /**
  10899. * The path to the boolean property in the target object
  10900. */
  10901. propertyPath: string;
  10902. private _target;
  10903. private _effectiveTarget;
  10904. private _property;
  10905. /**
  10906. * Instantiate the action
  10907. * @param triggerOptions defines the trigger options
  10908. * @param target defines the object containing the boolean
  10909. * @param propertyPath defines the path to the boolean property in the target object
  10910. * @param condition defines the trigger related conditions
  10911. */
  10912. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10913. /** @hidden */
  10914. _prepare(): void;
  10915. /**
  10916. * Execute the action toggle the boolean value.
  10917. */
  10918. execute(): void;
  10919. /**
  10920. * Serializes the actions and its related information.
  10921. * @param parent defines the object to serialize in
  10922. * @returns the serialized object
  10923. */
  10924. serialize(parent: any): any;
  10925. }
  10926. /**
  10927. * This defines an action responsible to set a the state field of the target
  10928. * to a desired value once triggered.
  10929. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10930. */
  10931. export class SetStateAction extends Action {
  10932. /**
  10933. * The value to store in the state field.
  10934. */
  10935. value: string;
  10936. private _target;
  10937. /**
  10938. * Instantiate the action
  10939. * @param triggerOptions defines the trigger options
  10940. * @param target defines the object containing the state property
  10941. * @param value defines the value to store in the state field
  10942. * @param condition defines the trigger related conditions
  10943. */
  10944. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10945. /**
  10946. * Execute the action and store the value on the target state property.
  10947. */
  10948. execute(): void;
  10949. /**
  10950. * Serializes the actions and its related information.
  10951. * @param parent defines the object to serialize in
  10952. * @returns the serialized object
  10953. */
  10954. serialize(parent: any): any;
  10955. }
  10956. /**
  10957. * This defines an action responsible to set a property of the target
  10958. * to a desired value once triggered.
  10959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10960. */
  10961. export class SetValueAction extends Action {
  10962. /**
  10963. * The path of the property to set in the target.
  10964. */
  10965. propertyPath: string;
  10966. /**
  10967. * The value to set in the property
  10968. */
  10969. value: any;
  10970. private _target;
  10971. private _effectiveTarget;
  10972. private _property;
  10973. /**
  10974. * Instantiate the action
  10975. * @param triggerOptions defines the trigger options
  10976. * @param target defines the object containing the property
  10977. * @param propertyPath defines the path of the property to set in the target
  10978. * @param value defines the value to set in the property
  10979. * @param condition defines the trigger related conditions
  10980. */
  10981. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10982. /** @hidden */
  10983. _prepare(): void;
  10984. /**
  10985. * Execute the action and set the targetted property to the desired value.
  10986. */
  10987. execute(): void;
  10988. /**
  10989. * Serializes the actions and its related information.
  10990. * @param parent defines the object to serialize in
  10991. * @returns the serialized object
  10992. */
  10993. serialize(parent: any): any;
  10994. }
  10995. /**
  10996. * This defines an action responsible to increment the target value
  10997. * to a desired value once triggered.
  10998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10999. */
  11000. export class IncrementValueAction extends Action {
  11001. /**
  11002. * The path of the property to increment in the target.
  11003. */
  11004. propertyPath: string;
  11005. /**
  11006. * The value we should increment the property by.
  11007. */
  11008. value: any;
  11009. private _target;
  11010. private _effectiveTarget;
  11011. private _property;
  11012. /**
  11013. * Instantiate the action
  11014. * @param triggerOptions defines the trigger options
  11015. * @param target defines the object containing the property
  11016. * @param propertyPath defines the path of the property to increment in the target
  11017. * @param value defines the value value we should increment the property by
  11018. * @param condition defines the trigger related conditions
  11019. */
  11020. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11021. /** @hidden */
  11022. _prepare(): void;
  11023. /**
  11024. * Execute the action and increment the target of the value amount.
  11025. */
  11026. execute(): void;
  11027. /**
  11028. * Serializes the actions and its related information.
  11029. * @param parent defines the object to serialize in
  11030. * @returns the serialized object
  11031. */
  11032. serialize(parent: any): any;
  11033. }
  11034. /**
  11035. * This defines an action responsible to start an animation once triggered.
  11036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11037. */
  11038. export class PlayAnimationAction extends Action {
  11039. /**
  11040. * Where the animation should start (animation frame)
  11041. */
  11042. from: number;
  11043. /**
  11044. * Where the animation should stop (animation frame)
  11045. */
  11046. to: number;
  11047. /**
  11048. * Define if the animation should loop or stop after the first play.
  11049. */
  11050. loop?: boolean;
  11051. private _target;
  11052. /**
  11053. * Instantiate the action
  11054. * @param triggerOptions defines the trigger options
  11055. * @param target defines the target animation or animation name
  11056. * @param from defines from where the animation should start (animation frame)
  11057. * @param end defines where the animation should stop (animation frame)
  11058. * @param loop defines if the animation should loop or stop after the first play
  11059. * @param condition defines the trigger related conditions
  11060. */
  11061. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11062. /** @hidden */
  11063. _prepare(): void;
  11064. /**
  11065. * Execute the action and play the animation.
  11066. */
  11067. execute(): void;
  11068. /**
  11069. * Serializes the actions and its related information.
  11070. * @param parent defines the object to serialize in
  11071. * @returns the serialized object
  11072. */
  11073. serialize(parent: any): any;
  11074. }
  11075. /**
  11076. * This defines an action responsible to stop an animation once triggered.
  11077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11078. */
  11079. export class StopAnimationAction extends Action {
  11080. private _target;
  11081. /**
  11082. * Instantiate the action
  11083. * @param triggerOptions defines the trigger options
  11084. * @param target defines the target animation or animation name
  11085. * @param condition defines the trigger related conditions
  11086. */
  11087. constructor(triggerOptions: any, target: any, condition?: Condition);
  11088. /** @hidden */
  11089. _prepare(): void;
  11090. /**
  11091. * Execute the action and stop the animation.
  11092. */
  11093. execute(): void;
  11094. /**
  11095. * Serializes the actions and its related information.
  11096. * @param parent defines the object to serialize in
  11097. * @returns the serialized object
  11098. */
  11099. serialize(parent: any): any;
  11100. }
  11101. /**
  11102. * This defines an action responsible that does nothing once triggered.
  11103. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11104. */
  11105. export class DoNothingAction extends Action {
  11106. /**
  11107. * Instantiate the action
  11108. * @param triggerOptions defines the trigger options
  11109. * @param condition defines the trigger related conditions
  11110. */
  11111. constructor(triggerOptions?: any, condition?: Condition);
  11112. /**
  11113. * Execute the action and do nothing.
  11114. */
  11115. execute(): void;
  11116. /**
  11117. * Serializes the actions and its related information.
  11118. * @param parent defines the object to serialize in
  11119. * @returns the serialized object
  11120. */
  11121. serialize(parent: any): any;
  11122. }
  11123. /**
  11124. * This defines an action responsible to trigger several actions once triggered.
  11125. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11126. */
  11127. export class CombineAction extends Action {
  11128. /**
  11129. * The list of aggregated animations to run.
  11130. */
  11131. children: Action[];
  11132. /**
  11133. * Instantiate the action
  11134. * @param triggerOptions defines the trigger options
  11135. * @param children defines the list of aggregated animations to run
  11136. * @param condition defines the trigger related conditions
  11137. */
  11138. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11139. /** @hidden */
  11140. _prepare(): void;
  11141. /**
  11142. * Execute the action and executes all the aggregated actions.
  11143. */
  11144. execute(evt: ActionEvent): void;
  11145. /**
  11146. * Serializes the actions and its related information.
  11147. * @param parent defines the object to serialize in
  11148. * @returns the serialized object
  11149. */
  11150. serialize(parent: any): any;
  11151. }
  11152. /**
  11153. * This defines an action responsible to run code (external event) once triggered.
  11154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11155. */
  11156. export class ExecuteCodeAction extends Action {
  11157. /**
  11158. * The callback function to run.
  11159. */
  11160. func: (evt: ActionEvent) => void;
  11161. /**
  11162. * Instantiate the action
  11163. * @param triggerOptions defines the trigger options
  11164. * @param func defines the callback function to run
  11165. * @param condition defines the trigger related conditions
  11166. */
  11167. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11168. /**
  11169. * Execute the action and run the attached code.
  11170. */
  11171. execute(evt: ActionEvent): void;
  11172. }
  11173. /**
  11174. * This defines an action responsible to set the parent property of the target once triggered.
  11175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11176. */
  11177. export class SetParentAction extends Action {
  11178. private _parent;
  11179. private _target;
  11180. /**
  11181. * Instantiate the action
  11182. * @param triggerOptions defines the trigger options
  11183. * @param target defines the target containing the parent property
  11184. * @param parent defines from where the animation should start (animation frame)
  11185. * @param condition defines the trigger related conditions
  11186. */
  11187. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11188. /** @hidden */
  11189. _prepare(): void;
  11190. /**
  11191. * Execute the action and set the parent property.
  11192. */
  11193. execute(): void;
  11194. /**
  11195. * Serializes the actions and its related information.
  11196. * @param parent defines the object to serialize in
  11197. * @returns the serialized object
  11198. */
  11199. serialize(parent: any): any;
  11200. }
  11201. }
  11202. declare module BABYLON {
  11203. /**
  11204. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11205. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11207. */
  11208. export class ActionManager extends AbstractActionManager {
  11209. /**
  11210. * Nothing
  11211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11212. */
  11213. static readonly NothingTrigger: number;
  11214. /**
  11215. * On pick
  11216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11217. */
  11218. static readonly OnPickTrigger: number;
  11219. /**
  11220. * On left pick
  11221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11222. */
  11223. static readonly OnLeftPickTrigger: number;
  11224. /**
  11225. * On right pick
  11226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11227. */
  11228. static readonly OnRightPickTrigger: number;
  11229. /**
  11230. * On center pick
  11231. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11232. */
  11233. static readonly OnCenterPickTrigger: number;
  11234. /**
  11235. * On pick down
  11236. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11237. */
  11238. static readonly OnPickDownTrigger: number;
  11239. /**
  11240. * On double pick
  11241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11242. */
  11243. static readonly OnDoublePickTrigger: number;
  11244. /**
  11245. * On pick up
  11246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11247. */
  11248. static readonly OnPickUpTrigger: number;
  11249. /**
  11250. * On pick out.
  11251. * This trigger will only be raised if you also declared a OnPickDown
  11252. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11253. */
  11254. static readonly OnPickOutTrigger: number;
  11255. /**
  11256. * On long press
  11257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11258. */
  11259. static readonly OnLongPressTrigger: number;
  11260. /**
  11261. * On pointer over
  11262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11263. */
  11264. static readonly OnPointerOverTrigger: number;
  11265. /**
  11266. * On pointer out
  11267. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11268. */
  11269. static readonly OnPointerOutTrigger: number;
  11270. /**
  11271. * On every frame
  11272. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11273. */
  11274. static readonly OnEveryFrameTrigger: number;
  11275. /**
  11276. * On intersection enter
  11277. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11278. */
  11279. static readonly OnIntersectionEnterTrigger: number;
  11280. /**
  11281. * On intersection exit
  11282. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11283. */
  11284. static readonly OnIntersectionExitTrigger: number;
  11285. /**
  11286. * On key down
  11287. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11288. */
  11289. static readonly OnKeyDownTrigger: number;
  11290. /**
  11291. * On key up
  11292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11293. */
  11294. static readonly OnKeyUpTrigger: number;
  11295. private _scene;
  11296. /**
  11297. * Creates a new action manager
  11298. * @param scene defines the hosting scene
  11299. */
  11300. constructor(scene: Scene);
  11301. /**
  11302. * Releases all associated resources
  11303. */
  11304. dispose(): void;
  11305. /**
  11306. * Gets hosting scene
  11307. * @returns the hosting scene
  11308. */
  11309. getScene(): Scene;
  11310. /**
  11311. * Does this action manager handles actions of any of the given triggers
  11312. * @param triggers defines the triggers to be tested
  11313. * @return a boolean indicating whether one (or more) of the triggers is handled
  11314. */
  11315. hasSpecificTriggers(triggers: number[]): boolean;
  11316. /**
  11317. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11318. * speed.
  11319. * @param triggerA defines the trigger to be tested
  11320. * @param triggerB defines the trigger to be tested
  11321. * @return a boolean indicating whether one (or more) of the triggers is handled
  11322. */
  11323. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11324. /**
  11325. * Does this action manager handles actions of a given trigger
  11326. * @param trigger defines the trigger to be tested
  11327. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11328. * @return whether the trigger is handled
  11329. */
  11330. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11331. /**
  11332. * Does this action manager has pointer triggers
  11333. */
  11334. readonly hasPointerTriggers: boolean;
  11335. /**
  11336. * Does this action manager has pick triggers
  11337. */
  11338. readonly hasPickTriggers: boolean;
  11339. /**
  11340. * Registers an action to this action manager
  11341. * @param action defines the action to be registered
  11342. * @return the action amended (prepared) after registration
  11343. */
  11344. registerAction(action: IAction): Nullable<IAction>;
  11345. /**
  11346. * Unregisters an action to this action manager
  11347. * @param action defines the action to be unregistered
  11348. * @return a boolean indicating whether the action has been unregistered
  11349. */
  11350. unregisterAction(action: IAction): Boolean;
  11351. /**
  11352. * Process a specific trigger
  11353. * @param trigger defines the trigger to process
  11354. * @param evt defines the event details to be processed
  11355. */
  11356. processTrigger(trigger: number, evt?: IActionEvent): void;
  11357. /** @hidden */
  11358. _getEffectiveTarget(target: any, propertyPath: string): any;
  11359. /** @hidden */
  11360. _getProperty(propertyPath: string): string;
  11361. /**
  11362. * Serialize this manager to a JSON object
  11363. * @param name defines the property name to store this manager
  11364. * @returns a JSON representation of this manager
  11365. */
  11366. serialize(name: string): any;
  11367. /**
  11368. * Creates a new ActionManager from a JSON data
  11369. * @param parsedActions defines the JSON data to read from
  11370. * @param object defines the hosting mesh
  11371. * @param scene defines the hosting scene
  11372. */
  11373. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11374. /**
  11375. * Get a trigger name by index
  11376. * @param trigger defines the trigger index
  11377. * @returns a trigger name
  11378. */
  11379. static GetTriggerName(trigger: number): string;
  11380. }
  11381. }
  11382. declare module BABYLON {
  11383. /**
  11384. * Class representing a ray with position and direction
  11385. */
  11386. export class Ray {
  11387. /** origin point */
  11388. origin: Vector3;
  11389. /** direction */
  11390. direction: Vector3;
  11391. /** length of the ray */
  11392. length: number;
  11393. private static readonly TmpVector3;
  11394. private _tmpRay;
  11395. /**
  11396. * Creates a new ray
  11397. * @param origin origin point
  11398. * @param direction direction
  11399. * @param length length of the ray
  11400. */
  11401. constructor(
  11402. /** origin point */
  11403. origin: Vector3,
  11404. /** direction */
  11405. direction: Vector3,
  11406. /** length of the ray */
  11407. length?: number);
  11408. /**
  11409. * Checks if the ray intersects a box
  11410. * @param minimum bound of the box
  11411. * @param maximum bound of the box
  11412. * @param intersectionTreshold extra extend to be added to the box in all direction
  11413. * @returns if the box was hit
  11414. */
  11415. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11416. /**
  11417. * Checks if the ray intersects a box
  11418. * @param box the bounding box to check
  11419. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11420. * @returns if the box was hit
  11421. */
  11422. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11423. /**
  11424. * If the ray hits a sphere
  11425. * @param sphere the bounding sphere to check
  11426. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11427. * @returns true if it hits the sphere
  11428. */
  11429. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11430. /**
  11431. * If the ray hits a triange
  11432. * @param vertex0 triangle vertex
  11433. * @param vertex1 triangle vertex
  11434. * @param vertex2 triangle vertex
  11435. * @returns intersection information if hit
  11436. */
  11437. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11438. /**
  11439. * Checks if ray intersects a plane
  11440. * @param plane the plane to check
  11441. * @returns the distance away it was hit
  11442. */
  11443. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11444. /**
  11445. * Checks if ray intersects a mesh
  11446. * @param mesh the mesh to check
  11447. * @param fastCheck if only the bounding box should checked
  11448. * @returns picking info of the intersecton
  11449. */
  11450. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11451. /**
  11452. * Checks if ray intersects a mesh
  11453. * @param meshes the meshes to check
  11454. * @param fastCheck if only the bounding box should checked
  11455. * @param results array to store result in
  11456. * @returns Array of picking infos
  11457. */
  11458. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11459. private _comparePickingInfo;
  11460. private static smallnum;
  11461. private static rayl;
  11462. /**
  11463. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11464. * @param sega the first point of the segment to test the intersection against
  11465. * @param segb the second point of the segment to test the intersection against
  11466. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11467. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11468. */
  11469. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11470. /**
  11471. * Update the ray from viewport position
  11472. * @param x position
  11473. * @param y y position
  11474. * @param viewportWidth viewport width
  11475. * @param viewportHeight viewport height
  11476. * @param world world matrix
  11477. * @param view view matrix
  11478. * @param projection projection matrix
  11479. * @returns this ray updated
  11480. */
  11481. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11482. /**
  11483. * Creates a ray with origin and direction of 0,0,0
  11484. * @returns the new ray
  11485. */
  11486. static Zero(): Ray;
  11487. /**
  11488. * Creates a new ray from screen space and viewport
  11489. * @param x position
  11490. * @param y y position
  11491. * @param viewportWidth viewport width
  11492. * @param viewportHeight viewport height
  11493. * @param world world matrix
  11494. * @param view view matrix
  11495. * @param projection projection matrix
  11496. * @returns new ray
  11497. */
  11498. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11499. /**
  11500. * 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
  11501. * transformed to the given world matrix.
  11502. * @param origin The origin point
  11503. * @param end The end point
  11504. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11505. * @returns the new ray
  11506. */
  11507. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11508. /**
  11509. * Transforms a ray by a matrix
  11510. * @param ray ray to transform
  11511. * @param matrix matrix to apply
  11512. * @returns the resulting new ray
  11513. */
  11514. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11515. /**
  11516. * Transforms a ray by a matrix
  11517. * @param ray ray to transform
  11518. * @param matrix matrix to apply
  11519. * @param result ray to store result in
  11520. */
  11521. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11522. /**
  11523. * Unproject a ray from screen space to object space
  11524. * @param sourceX defines the screen space x coordinate to use
  11525. * @param sourceY defines the screen space y coordinate to use
  11526. * @param viewportWidth defines the current width of the viewport
  11527. * @param viewportHeight defines the current height of the viewport
  11528. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11529. * @param view defines the view matrix to use
  11530. * @param projection defines the projection matrix to use
  11531. */
  11532. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11533. }
  11534. /**
  11535. * Type used to define predicate used to select faces when a mesh intersection is detected
  11536. */
  11537. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11538. interface Scene {
  11539. /** @hidden */
  11540. _tempPickingRay: Nullable<Ray>;
  11541. /** @hidden */
  11542. _cachedRayForTransform: Ray;
  11543. /** @hidden */
  11544. _pickWithRayInverseMatrix: Matrix;
  11545. /** @hidden */
  11546. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11547. /** @hidden */
  11548. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11549. }
  11550. }
  11551. declare module BABYLON {
  11552. /**
  11553. * Groups all the scene component constants in one place to ease maintenance.
  11554. * @hidden
  11555. */
  11556. export class SceneComponentConstants {
  11557. static readonly NAME_EFFECTLAYER: string;
  11558. static readonly NAME_LAYER: string;
  11559. static readonly NAME_LENSFLARESYSTEM: string;
  11560. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11561. static readonly NAME_PARTICLESYSTEM: string;
  11562. static readonly NAME_GAMEPAD: string;
  11563. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11564. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11565. static readonly NAME_DEPTHRENDERER: string;
  11566. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11567. static readonly NAME_SPRITE: string;
  11568. static readonly NAME_OUTLINERENDERER: string;
  11569. static readonly NAME_PROCEDURALTEXTURE: string;
  11570. static readonly NAME_SHADOWGENERATOR: string;
  11571. static readonly NAME_OCTREE: string;
  11572. static readonly NAME_PHYSICSENGINE: string;
  11573. static readonly NAME_AUDIO: string;
  11574. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11575. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11576. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11577. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11578. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11579. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11580. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11581. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11582. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11583. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11584. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11585. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11586. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11587. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11588. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11589. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11590. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11591. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11592. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11593. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11594. static readonly STEP_AFTERRENDER_AUDIO: number;
  11595. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11596. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11597. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11598. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11599. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11600. static readonly STEP_POINTERMOVE_SPRITE: number;
  11601. static readonly STEP_POINTERDOWN_SPRITE: number;
  11602. static readonly STEP_POINTERUP_SPRITE: number;
  11603. }
  11604. /**
  11605. * This represents a scene component.
  11606. *
  11607. * This is used to decouple the dependency the scene is having on the different workloads like
  11608. * layers, post processes...
  11609. */
  11610. export interface ISceneComponent {
  11611. /**
  11612. * The name of the component. Each component must have a unique name.
  11613. */
  11614. name: string;
  11615. /**
  11616. * The scene the component belongs to.
  11617. */
  11618. scene: Scene;
  11619. /**
  11620. * Register the component to one instance of a scene.
  11621. */
  11622. register(): void;
  11623. /**
  11624. * Rebuilds the elements related to this component in case of
  11625. * context lost for instance.
  11626. */
  11627. rebuild(): void;
  11628. /**
  11629. * Disposes the component and the associated ressources.
  11630. */
  11631. dispose(): void;
  11632. }
  11633. /**
  11634. * This represents a SERIALIZABLE scene component.
  11635. *
  11636. * This extends Scene Component to add Serialization methods on top.
  11637. */
  11638. export interface ISceneSerializableComponent extends ISceneComponent {
  11639. /**
  11640. * Adds all the element from the container to the scene
  11641. * @param container the container holding the elements
  11642. */
  11643. addFromContainer(container: AbstractScene): void;
  11644. /**
  11645. * Removes all the elements in the container from the scene
  11646. * @param container contains the elements to remove
  11647. * @param dispose if the removed element should be disposed (default: false)
  11648. */
  11649. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11650. /**
  11651. * Serializes the component data to the specified json object
  11652. * @param serializationObject The object to serialize to
  11653. */
  11654. serialize(serializationObject: any): void;
  11655. }
  11656. /**
  11657. * Strong typing of a Mesh related stage step action
  11658. */
  11659. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11660. /**
  11661. * Strong typing of a Evaluate Sub Mesh related stage step action
  11662. */
  11663. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11664. /**
  11665. * Strong typing of a Active Mesh related stage step action
  11666. */
  11667. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11668. /**
  11669. * Strong typing of a Camera related stage step action
  11670. */
  11671. export type CameraStageAction = (camera: Camera) => void;
  11672. /**
  11673. * Strong typing of a Camera Frame buffer related stage step action
  11674. */
  11675. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11676. /**
  11677. * Strong typing of a Render Target related stage step action
  11678. */
  11679. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11680. /**
  11681. * Strong typing of a RenderingGroup related stage step action
  11682. */
  11683. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11684. /**
  11685. * Strong typing of a Mesh Render related stage step action
  11686. */
  11687. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11688. /**
  11689. * Strong typing of a simple stage step action
  11690. */
  11691. export type SimpleStageAction = () => void;
  11692. /**
  11693. * Strong typing of a render target action.
  11694. */
  11695. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11696. /**
  11697. * Strong typing of a pointer move action.
  11698. */
  11699. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11700. /**
  11701. * Strong typing of a pointer up/down action.
  11702. */
  11703. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11704. /**
  11705. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11706. * @hidden
  11707. */
  11708. export class Stage<T extends Function> extends Array<{
  11709. index: number;
  11710. component: ISceneComponent;
  11711. action: T;
  11712. }> {
  11713. /**
  11714. * Hide ctor from the rest of the world.
  11715. * @param items The items to add.
  11716. */
  11717. private constructor();
  11718. /**
  11719. * Creates a new Stage.
  11720. * @returns A new instance of a Stage
  11721. */
  11722. static Create<T extends Function>(): Stage<T>;
  11723. /**
  11724. * Registers a step in an ordered way in the targeted stage.
  11725. * @param index Defines the position to register the step in
  11726. * @param component Defines the component attached to the step
  11727. * @param action Defines the action to launch during the step
  11728. */
  11729. registerStep(index: number, component: ISceneComponent, action: T): void;
  11730. /**
  11731. * Clears all the steps from the stage.
  11732. */
  11733. clear(): void;
  11734. }
  11735. }
  11736. declare module BABYLON {
  11737. interface Scene {
  11738. /** @hidden */
  11739. _pointerOverSprite: Nullable<Sprite>;
  11740. /** @hidden */
  11741. _pickedDownSprite: Nullable<Sprite>;
  11742. /** @hidden */
  11743. _tempSpritePickingRay: Nullable<Ray>;
  11744. /**
  11745. * All of the sprite managers added to this scene
  11746. * @see http://doc.babylonjs.com/babylon101/sprites
  11747. */
  11748. spriteManagers: Array<ISpriteManager>;
  11749. /**
  11750. * An event triggered when sprites rendering is about to start
  11751. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11752. */
  11753. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11754. /**
  11755. * An event triggered when sprites rendering is done
  11756. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11757. */
  11758. onAfterSpritesRenderingObservable: Observable<Scene>;
  11759. /** @hidden */
  11760. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11761. /** Launch a ray to try to pick a sprite in the scene
  11762. * @param x position on screen
  11763. * @param y position on screen
  11764. * @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
  11765. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11766. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11767. * @returns a PickingInfo
  11768. */
  11769. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11770. /** Use the given ray to pick a sprite in the scene
  11771. * @param ray The ray (in world space) to use to pick meshes
  11772. * @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
  11773. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11774. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11775. * @returns a PickingInfo
  11776. */
  11777. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11778. /**
  11779. * Force the sprite under the pointer
  11780. * @param sprite defines the sprite to use
  11781. */
  11782. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11783. /**
  11784. * Gets the sprite under the pointer
  11785. * @returns a Sprite or null if no sprite is under the pointer
  11786. */
  11787. getPointerOverSprite(): Nullable<Sprite>;
  11788. }
  11789. /**
  11790. * Defines the sprite scene component responsible to manage sprites
  11791. * in a given scene.
  11792. */
  11793. export class SpriteSceneComponent implements ISceneComponent {
  11794. /**
  11795. * The component name helpfull to identify the component in the list of scene components.
  11796. */
  11797. readonly name: string;
  11798. /**
  11799. * The scene the component belongs to.
  11800. */
  11801. scene: Scene;
  11802. /** @hidden */
  11803. private _spritePredicate;
  11804. /**
  11805. * Creates a new instance of the component for the given scene
  11806. * @param scene Defines the scene to register the component in
  11807. */
  11808. constructor(scene: Scene);
  11809. /**
  11810. * Registers the component in a given scene
  11811. */
  11812. register(): void;
  11813. /**
  11814. * Rebuilds the elements related to this component in case of
  11815. * context lost for instance.
  11816. */
  11817. rebuild(): void;
  11818. /**
  11819. * Disposes the component and the associated ressources.
  11820. */
  11821. dispose(): void;
  11822. private _pickSpriteButKeepRay;
  11823. private _pointerMove;
  11824. private _pointerDown;
  11825. private _pointerUp;
  11826. }
  11827. }
  11828. declare module BABYLON {
  11829. /** @hidden */
  11830. export var fogFragmentDeclaration: {
  11831. name: string;
  11832. shader: string;
  11833. };
  11834. }
  11835. declare module BABYLON {
  11836. /** @hidden */
  11837. export var fogFragment: {
  11838. name: string;
  11839. shader: string;
  11840. };
  11841. }
  11842. declare module BABYLON {
  11843. /** @hidden */
  11844. export var spritesPixelShader: {
  11845. name: string;
  11846. shader: string;
  11847. };
  11848. }
  11849. declare module BABYLON {
  11850. /** @hidden */
  11851. export var fogVertexDeclaration: {
  11852. name: string;
  11853. shader: string;
  11854. };
  11855. }
  11856. declare module BABYLON {
  11857. /** @hidden */
  11858. export var spritesVertexShader: {
  11859. name: string;
  11860. shader: string;
  11861. };
  11862. }
  11863. declare module BABYLON {
  11864. /**
  11865. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11866. */
  11867. export interface ISpriteManager extends IDisposable {
  11868. /**
  11869. * Restricts the camera to viewing objects with the same layerMask.
  11870. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11871. */
  11872. layerMask: number;
  11873. /**
  11874. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11875. */
  11876. isPickable: boolean;
  11877. /**
  11878. * Specifies the rendering group id for this mesh (0 by default)
  11879. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11880. */
  11881. renderingGroupId: number;
  11882. /**
  11883. * Defines the list of sprites managed by the manager.
  11884. */
  11885. sprites: Array<Sprite>;
  11886. /**
  11887. * Tests the intersection of a sprite with a specific ray.
  11888. * @param ray The ray we are sending to test the collision
  11889. * @param camera The camera space we are sending rays in
  11890. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11891. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11892. * @returns picking info or null.
  11893. */
  11894. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11895. /**
  11896. * Renders the list of sprites on screen.
  11897. */
  11898. render(): void;
  11899. }
  11900. /**
  11901. * Class used to manage multiple sprites on the same spritesheet
  11902. * @see http://doc.babylonjs.com/babylon101/sprites
  11903. */
  11904. export class SpriteManager implements ISpriteManager {
  11905. /** defines the manager's name */
  11906. name: string;
  11907. /** Gets the list of sprites */
  11908. sprites: Sprite[];
  11909. /** Gets or sets the rendering group id (0 by default) */
  11910. renderingGroupId: number;
  11911. /** Gets or sets camera layer mask */
  11912. layerMask: number;
  11913. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11914. fogEnabled: boolean;
  11915. /** Gets or sets a boolean indicating if the sprites are pickable */
  11916. isPickable: boolean;
  11917. /** Defines the default width of a cell in the spritesheet */
  11918. cellWidth: number;
  11919. /** Defines the default height of a cell in the spritesheet */
  11920. cellHeight: number;
  11921. /**
  11922. * An event triggered when the manager is disposed.
  11923. */
  11924. onDisposeObservable: Observable<SpriteManager>;
  11925. private _onDisposeObserver;
  11926. /**
  11927. * Callback called when the manager is disposed
  11928. */
  11929. onDispose: () => void;
  11930. private _capacity;
  11931. private _spriteTexture;
  11932. private _epsilon;
  11933. private _scene;
  11934. private _vertexData;
  11935. private _buffer;
  11936. private _vertexBuffers;
  11937. private _indexBuffer;
  11938. private _effectBase;
  11939. private _effectFog;
  11940. /**
  11941. * Gets or sets the spritesheet texture
  11942. */
  11943. texture: Texture;
  11944. /**
  11945. * Creates a new sprite manager
  11946. * @param name defines the manager's name
  11947. * @param imgUrl defines the sprite sheet url
  11948. * @param capacity defines the maximum allowed number of sprites
  11949. * @param cellSize defines the size of a sprite cell
  11950. * @param scene defines the hosting scene
  11951. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11952. * @param samplingMode defines the smapling mode to use with spritesheet
  11953. */
  11954. constructor(
  11955. /** defines the manager's name */
  11956. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11957. private _appendSpriteVertex;
  11958. /**
  11959. * Intersects the sprites with a ray
  11960. * @param ray defines the ray to intersect with
  11961. * @param camera defines the current active camera
  11962. * @param predicate defines a predicate used to select candidate sprites
  11963. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11964. * @returns null if no hit or a PickingInfo
  11965. */
  11966. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11967. /**
  11968. * Render all child sprites
  11969. */
  11970. render(): void;
  11971. /**
  11972. * Release associated resources
  11973. */
  11974. dispose(): void;
  11975. }
  11976. }
  11977. declare module BABYLON {
  11978. /**
  11979. * Class used to represent a sprite
  11980. * @see http://doc.babylonjs.com/babylon101/sprites
  11981. */
  11982. export class Sprite {
  11983. /** defines the name */
  11984. name: string;
  11985. /** Gets or sets the current world position */
  11986. position: Vector3;
  11987. /** Gets or sets the main color */
  11988. color: Color4;
  11989. /** Gets or sets the width */
  11990. width: number;
  11991. /** Gets or sets the height */
  11992. height: number;
  11993. /** Gets or sets rotation angle */
  11994. angle: number;
  11995. /** Gets or sets the cell index in the sprite sheet */
  11996. cellIndex: number;
  11997. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11998. invertU: number;
  11999. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12000. invertV: number;
  12001. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12002. disposeWhenFinishedAnimating: boolean;
  12003. /** Gets the list of attached animations */
  12004. animations: Animation[];
  12005. /** Gets or sets a boolean indicating if the sprite can be picked */
  12006. isPickable: boolean;
  12007. /**
  12008. * Gets or sets the associated action manager
  12009. */
  12010. actionManager: Nullable<ActionManager>;
  12011. private _animationStarted;
  12012. private _loopAnimation;
  12013. private _fromIndex;
  12014. private _toIndex;
  12015. private _delay;
  12016. private _direction;
  12017. private _manager;
  12018. private _time;
  12019. private _onAnimationEnd;
  12020. /**
  12021. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12022. */
  12023. isVisible: boolean;
  12024. /**
  12025. * Gets or sets the sprite size
  12026. */
  12027. size: number;
  12028. /**
  12029. * Creates a new Sprite
  12030. * @param name defines the name
  12031. * @param manager defines the manager
  12032. */
  12033. constructor(
  12034. /** defines the name */
  12035. name: string, manager: ISpriteManager);
  12036. /**
  12037. * Starts an animation
  12038. * @param from defines the initial key
  12039. * @param to defines the end key
  12040. * @param loop defines if the animation must loop
  12041. * @param delay defines the start delay (in ms)
  12042. * @param onAnimationEnd defines a callback to call when animation ends
  12043. */
  12044. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12045. /** Stops current animation (if any) */
  12046. stopAnimation(): void;
  12047. /** @hidden */
  12048. _animate(deltaTime: number): void;
  12049. /** Release associated resources */
  12050. dispose(): void;
  12051. }
  12052. }
  12053. declare module BABYLON {
  12054. /**
  12055. * Information about the result of picking within a scene
  12056. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12057. */
  12058. export class PickingInfo {
  12059. /** @hidden */
  12060. _pickingUnavailable: boolean;
  12061. /**
  12062. * If the pick collided with an object
  12063. */
  12064. hit: boolean;
  12065. /**
  12066. * Distance away where the pick collided
  12067. */
  12068. distance: number;
  12069. /**
  12070. * The location of pick collision
  12071. */
  12072. pickedPoint: Nullable<Vector3>;
  12073. /**
  12074. * The mesh corresponding the the pick collision
  12075. */
  12076. pickedMesh: Nullable<AbstractMesh>;
  12077. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12078. bu: number;
  12079. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12080. bv: number;
  12081. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12082. faceId: number;
  12083. /** Id of the the submesh that was picked */
  12084. subMeshId: number;
  12085. /** If a sprite was picked, this will be the sprite the pick collided with */
  12086. pickedSprite: Nullable<Sprite>;
  12087. /**
  12088. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12089. */
  12090. originMesh: Nullable<AbstractMesh>;
  12091. /**
  12092. * The ray that was used to perform the picking.
  12093. */
  12094. ray: Nullable<Ray>;
  12095. /**
  12096. * Gets the normal correspodning to the face the pick collided with
  12097. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12098. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12099. * @returns The normal correspodning to the face the pick collided with
  12100. */
  12101. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12102. /**
  12103. * Gets the texture coordinates of where the pick occured
  12104. * @returns the vector containing the coordnates of the texture
  12105. */
  12106. getTextureCoordinates(): Nullable<Vector2>;
  12107. }
  12108. }
  12109. declare module BABYLON {
  12110. /**
  12111. * Gather the list of pointer event types as constants.
  12112. */
  12113. export class PointerEventTypes {
  12114. /**
  12115. * 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.
  12116. */
  12117. static readonly POINTERDOWN: number;
  12118. /**
  12119. * The pointerup event is fired when a pointer is no longer active.
  12120. */
  12121. static readonly POINTERUP: number;
  12122. /**
  12123. * The pointermove event is fired when a pointer changes coordinates.
  12124. */
  12125. static readonly POINTERMOVE: number;
  12126. /**
  12127. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12128. */
  12129. static readonly POINTERWHEEL: number;
  12130. /**
  12131. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12132. */
  12133. static readonly POINTERPICK: number;
  12134. /**
  12135. * The pointertap event is fired when a the object has been touched and released without drag.
  12136. */
  12137. static readonly POINTERTAP: number;
  12138. /**
  12139. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12140. */
  12141. static readonly POINTERDOUBLETAP: number;
  12142. }
  12143. /**
  12144. * Base class of pointer info types.
  12145. */
  12146. export class PointerInfoBase {
  12147. /**
  12148. * Defines the type of event (PointerEventTypes)
  12149. */
  12150. type: number;
  12151. /**
  12152. * Defines the related dom event
  12153. */
  12154. event: PointerEvent | MouseWheelEvent;
  12155. /**
  12156. * Instantiates the base class of pointers info.
  12157. * @param type Defines the type of event (PointerEventTypes)
  12158. * @param event Defines the related dom event
  12159. */
  12160. constructor(
  12161. /**
  12162. * Defines the type of event (PointerEventTypes)
  12163. */
  12164. type: number,
  12165. /**
  12166. * Defines the related dom event
  12167. */
  12168. event: PointerEvent | MouseWheelEvent);
  12169. }
  12170. /**
  12171. * This class is used to store pointer related info for the onPrePointerObservable event.
  12172. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12173. */
  12174. export class PointerInfoPre extends PointerInfoBase {
  12175. /**
  12176. * Ray from a pointer if availible (eg. 6dof controller)
  12177. */
  12178. ray: Nullable<Ray>;
  12179. /**
  12180. * Defines the local position of the pointer on the canvas.
  12181. */
  12182. localPosition: Vector2;
  12183. /**
  12184. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12185. */
  12186. skipOnPointerObservable: boolean;
  12187. /**
  12188. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12189. * @param type Defines the type of event (PointerEventTypes)
  12190. * @param event Defines the related dom event
  12191. * @param localX Defines the local x coordinates of the pointer when the event occured
  12192. * @param localY Defines the local y coordinates of the pointer when the event occured
  12193. */
  12194. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12195. }
  12196. /**
  12197. * This type contains all the data related to a pointer event in Babylon.js.
  12198. * 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.
  12199. */
  12200. export class PointerInfo extends PointerInfoBase {
  12201. /**
  12202. * Defines the picking info associated to the info (if any)\
  12203. */
  12204. pickInfo: Nullable<PickingInfo>;
  12205. /**
  12206. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12207. * @param type Defines the type of event (PointerEventTypes)
  12208. * @param event Defines the related dom event
  12209. * @param pickInfo Defines the picking info associated to the info (if any)\
  12210. */
  12211. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12212. /**
  12213. * Defines the picking info associated to the info (if any)\
  12214. */
  12215. pickInfo: Nullable<PickingInfo>);
  12216. }
  12217. /**
  12218. * Data relating to a touch event on the screen.
  12219. */
  12220. export interface PointerTouch {
  12221. /**
  12222. * X coordinate of touch.
  12223. */
  12224. x: number;
  12225. /**
  12226. * Y coordinate of touch.
  12227. */
  12228. y: number;
  12229. /**
  12230. * Id of touch. Unique for each finger.
  12231. */
  12232. pointerId: number;
  12233. /**
  12234. * Event type passed from DOM.
  12235. */
  12236. type: any;
  12237. }
  12238. }
  12239. declare module BABYLON {
  12240. /**
  12241. * Manage the mouse inputs to control the movement of a free camera.
  12242. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12243. */
  12244. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12245. /**
  12246. * Define if touch is enabled in the mouse input
  12247. */
  12248. touchEnabled: boolean;
  12249. /**
  12250. * Defines the camera the input is attached to.
  12251. */
  12252. camera: FreeCamera;
  12253. /**
  12254. * Defines the buttons associated with the input to handle camera move.
  12255. */
  12256. buttons: number[];
  12257. /**
  12258. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12259. */
  12260. angularSensibility: number;
  12261. private _pointerInput;
  12262. private _onMouseMove;
  12263. private _observer;
  12264. private previousPosition;
  12265. /**
  12266. * Observable for when a pointer move event occurs containing the move offset
  12267. */
  12268. onPointerMovedObservable: Observable<{
  12269. offsetX: number;
  12270. offsetY: number;
  12271. }>;
  12272. /**
  12273. * @hidden
  12274. * If the camera should be rotated automatically based on pointer movement
  12275. */
  12276. _allowCameraRotation: boolean;
  12277. /**
  12278. * Manage the mouse inputs to control the movement of a free camera.
  12279. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12280. * @param touchEnabled Defines if touch is enabled or not
  12281. */
  12282. constructor(
  12283. /**
  12284. * Define if touch is enabled in the mouse input
  12285. */
  12286. touchEnabled?: boolean);
  12287. /**
  12288. * Attach the input controls to a specific dom element to get the input from.
  12289. * @param element Defines the element the controls should be listened from
  12290. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12291. */
  12292. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12293. /**
  12294. * Called on JS contextmenu event.
  12295. * Override this method to provide functionality.
  12296. */
  12297. protected onContextMenu(evt: PointerEvent): void;
  12298. /**
  12299. * Detach the current controls from the specified dom element.
  12300. * @param element Defines the element to stop listening the inputs from
  12301. */
  12302. detachControl(element: Nullable<HTMLElement>): void;
  12303. /**
  12304. * Gets the class name of the current intput.
  12305. * @returns the class name
  12306. */
  12307. getClassName(): string;
  12308. /**
  12309. * Get the friendly name associated with the input class.
  12310. * @returns the input friendly name
  12311. */
  12312. getSimpleName(): string;
  12313. }
  12314. }
  12315. declare module BABYLON {
  12316. /**
  12317. * Manage the touch inputs to control the movement of a free camera.
  12318. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12319. */
  12320. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12321. /**
  12322. * Defines the camera the input is attached to.
  12323. */
  12324. camera: FreeCamera;
  12325. /**
  12326. * Defines the touch sensibility for rotation.
  12327. * The higher the faster.
  12328. */
  12329. touchAngularSensibility: number;
  12330. /**
  12331. * Defines the touch sensibility for move.
  12332. * The higher the faster.
  12333. */
  12334. touchMoveSensibility: number;
  12335. private _offsetX;
  12336. private _offsetY;
  12337. private _pointerPressed;
  12338. private _pointerInput;
  12339. private _observer;
  12340. private _onLostFocus;
  12341. /**
  12342. * Attach the input controls to a specific dom element to get the input from.
  12343. * @param element Defines the element the controls should be listened from
  12344. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12345. */
  12346. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12347. /**
  12348. * Detach the current controls from the specified dom element.
  12349. * @param element Defines the element to stop listening the inputs from
  12350. */
  12351. detachControl(element: Nullable<HTMLElement>): void;
  12352. /**
  12353. * Update the current camera state depending on the inputs that have been used this frame.
  12354. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12355. */
  12356. checkInputs(): void;
  12357. /**
  12358. * Gets the class name of the current intput.
  12359. * @returns the class name
  12360. */
  12361. getClassName(): string;
  12362. /**
  12363. * Get the friendly name associated with the input class.
  12364. * @returns the input friendly name
  12365. */
  12366. getSimpleName(): string;
  12367. }
  12368. }
  12369. declare module BABYLON {
  12370. /**
  12371. * Default Inputs manager for the FreeCamera.
  12372. * It groups all the default supported inputs for ease of use.
  12373. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12374. */
  12375. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12376. /**
  12377. * @hidden
  12378. */
  12379. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12380. /**
  12381. * @hidden
  12382. */
  12383. _mouseInput: Nullable<FreeCameraMouseInput>;
  12384. /**
  12385. * Instantiates a new FreeCameraInputsManager.
  12386. * @param camera Defines the camera the inputs belong to
  12387. */
  12388. constructor(camera: FreeCamera);
  12389. /**
  12390. * Add keyboard input support to the input manager.
  12391. * @returns the current input manager
  12392. */
  12393. addKeyboard(): FreeCameraInputsManager;
  12394. /**
  12395. * Add mouse input support to the input manager.
  12396. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12397. * @returns the current input manager
  12398. */
  12399. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12400. /**
  12401. * Removes the mouse input support from the manager
  12402. * @returns the current input manager
  12403. */
  12404. removeMouse(): FreeCameraInputsManager;
  12405. /**
  12406. * Add touch input support to the input manager.
  12407. * @returns the current input manager
  12408. */
  12409. addTouch(): FreeCameraInputsManager;
  12410. }
  12411. }
  12412. declare module BABYLON {
  12413. /**
  12414. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12415. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12416. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12417. */
  12418. export class FreeCamera extends TargetCamera {
  12419. /**
  12420. * Define the collision ellipsoid of the camera.
  12421. * This is helpful to simulate a camera body like the player body around the camera
  12422. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12423. */
  12424. ellipsoid: Vector3;
  12425. /**
  12426. * Define an offset for the position of the ellipsoid around the camera.
  12427. * This can be helpful to determine the center of the body near the gravity center of the body
  12428. * instead of its head.
  12429. */
  12430. ellipsoidOffset: Vector3;
  12431. /**
  12432. * Enable or disable collisions of the camera with the rest of the scene objects.
  12433. */
  12434. checkCollisions: boolean;
  12435. /**
  12436. * Enable or disable gravity on the camera.
  12437. */
  12438. applyGravity: boolean;
  12439. /**
  12440. * Define the input manager associated to the camera.
  12441. */
  12442. inputs: FreeCameraInputsManager;
  12443. /**
  12444. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12445. * Higher values reduce sensitivity.
  12446. */
  12447. /**
  12448. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12449. * Higher values reduce sensitivity.
  12450. */
  12451. angularSensibility: number;
  12452. /**
  12453. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12454. */
  12455. keysUp: number[];
  12456. /**
  12457. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12458. */
  12459. keysDown: number[];
  12460. /**
  12461. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12462. */
  12463. keysLeft: number[];
  12464. /**
  12465. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12466. */
  12467. keysRight: number[];
  12468. /**
  12469. * Event raised when the camera collide with a mesh in the scene.
  12470. */
  12471. onCollide: (collidedMesh: AbstractMesh) => void;
  12472. private _collider;
  12473. private _needMoveForGravity;
  12474. private _oldPosition;
  12475. private _diffPosition;
  12476. private _newPosition;
  12477. /** @hidden */
  12478. _localDirection: Vector3;
  12479. /** @hidden */
  12480. _transformedDirection: Vector3;
  12481. /**
  12482. * Instantiates a Free Camera.
  12483. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12484. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12485. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12486. * @param name Define the name of the camera in the scene
  12487. * @param position Define the start position of the camera in the scene
  12488. * @param scene Define the scene the camera belongs to
  12489. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12490. */
  12491. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12492. /**
  12493. * Attached controls to the current camera.
  12494. * @param element Defines the element the controls should be listened from
  12495. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12496. */
  12497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12498. /**
  12499. * Detach the current controls from the camera.
  12500. * The camera will stop reacting to inputs.
  12501. * @param element Defines the element to stop listening the inputs from
  12502. */
  12503. detachControl(element: HTMLElement): void;
  12504. private _collisionMask;
  12505. /**
  12506. * Define a collision mask to limit the list of object the camera can collide with
  12507. */
  12508. collisionMask: number;
  12509. /** @hidden */
  12510. _collideWithWorld(displacement: Vector3): void;
  12511. private _onCollisionPositionChange;
  12512. /** @hidden */
  12513. _checkInputs(): void;
  12514. /** @hidden */
  12515. _decideIfNeedsToMove(): boolean;
  12516. /** @hidden */
  12517. _updatePosition(): void;
  12518. /**
  12519. * Destroy the camera and release the current resources hold by it.
  12520. */
  12521. dispose(): void;
  12522. /**
  12523. * Gets the current object class name.
  12524. * @return the class name
  12525. */
  12526. getClassName(): string;
  12527. }
  12528. }
  12529. declare module BABYLON {
  12530. /**
  12531. * Represents a gamepad control stick position
  12532. */
  12533. export class StickValues {
  12534. /**
  12535. * The x component of the control stick
  12536. */
  12537. x: number;
  12538. /**
  12539. * The y component of the control stick
  12540. */
  12541. y: number;
  12542. /**
  12543. * Initializes the gamepad x and y control stick values
  12544. * @param x The x component of the gamepad control stick value
  12545. * @param y The y component of the gamepad control stick value
  12546. */
  12547. constructor(
  12548. /**
  12549. * The x component of the control stick
  12550. */
  12551. x: number,
  12552. /**
  12553. * The y component of the control stick
  12554. */
  12555. y: number);
  12556. }
  12557. /**
  12558. * An interface which manages callbacks for gamepad button changes
  12559. */
  12560. export interface GamepadButtonChanges {
  12561. /**
  12562. * Called when a gamepad has been changed
  12563. */
  12564. changed: boolean;
  12565. /**
  12566. * Called when a gamepad press event has been triggered
  12567. */
  12568. pressChanged: boolean;
  12569. /**
  12570. * Called when a touch event has been triggered
  12571. */
  12572. touchChanged: boolean;
  12573. /**
  12574. * Called when a value has changed
  12575. */
  12576. valueChanged: boolean;
  12577. }
  12578. /**
  12579. * Represents a gamepad
  12580. */
  12581. export class Gamepad {
  12582. /**
  12583. * The id of the gamepad
  12584. */
  12585. id: string;
  12586. /**
  12587. * The index of the gamepad
  12588. */
  12589. index: number;
  12590. /**
  12591. * The browser gamepad
  12592. */
  12593. browserGamepad: any;
  12594. /**
  12595. * Specifies what type of gamepad this represents
  12596. */
  12597. type: number;
  12598. private _leftStick;
  12599. private _rightStick;
  12600. /** @hidden */
  12601. _isConnected: boolean;
  12602. private _leftStickAxisX;
  12603. private _leftStickAxisY;
  12604. private _rightStickAxisX;
  12605. private _rightStickAxisY;
  12606. /**
  12607. * Triggered when the left control stick has been changed
  12608. */
  12609. private _onleftstickchanged;
  12610. /**
  12611. * Triggered when the right control stick has been changed
  12612. */
  12613. private _onrightstickchanged;
  12614. /**
  12615. * Represents a gamepad controller
  12616. */
  12617. static GAMEPAD: number;
  12618. /**
  12619. * Represents a generic controller
  12620. */
  12621. static GENERIC: number;
  12622. /**
  12623. * Represents an XBox controller
  12624. */
  12625. static XBOX: number;
  12626. /**
  12627. * Represents a pose-enabled controller
  12628. */
  12629. static POSE_ENABLED: number;
  12630. /**
  12631. * Specifies whether the left control stick should be Y-inverted
  12632. */
  12633. protected _invertLeftStickY: boolean;
  12634. /**
  12635. * Specifies if the gamepad has been connected
  12636. */
  12637. readonly isConnected: boolean;
  12638. /**
  12639. * Initializes the gamepad
  12640. * @param id The id of the gamepad
  12641. * @param index The index of the gamepad
  12642. * @param browserGamepad The browser gamepad
  12643. * @param leftStickX The x component of the left joystick
  12644. * @param leftStickY The y component of the left joystick
  12645. * @param rightStickX The x component of the right joystick
  12646. * @param rightStickY The y component of the right joystick
  12647. */
  12648. constructor(
  12649. /**
  12650. * The id of the gamepad
  12651. */
  12652. id: string,
  12653. /**
  12654. * The index of the gamepad
  12655. */
  12656. index: number,
  12657. /**
  12658. * The browser gamepad
  12659. */
  12660. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12661. /**
  12662. * Callback triggered when the left joystick has changed
  12663. * @param callback
  12664. */
  12665. onleftstickchanged(callback: (values: StickValues) => void): void;
  12666. /**
  12667. * Callback triggered when the right joystick has changed
  12668. * @param callback
  12669. */
  12670. onrightstickchanged(callback: (values: StickValues) => void): void;
  12671. /**
  12672. * Gets the left joystick
  12673. */
  12674. /**
  12675. * Sets the left joystick values
  12676. */
  12677. leftStick: StickValues;
  12678. /**
  12679. * Gets the right joystick
  12680. */
  12681. /**
  12682. * Sets the right joystick value
  12683. */
  12684. rightStick: StickValues;
  12685. /**
  12686. * Updates the gamepad joystick positions
  12687. */
  12688. update(): void;
  12689. /**
  12690. * Disposes the gamepad
  12691. */
  12692. dispose(): void;
  12693. }
  12694. /**
  12695. * Represents a generic gamepad
  12696. */
  12697. export class GenericPad extends Gamepad {
  12698. private _buttons;
  12699. private _onbuttondown;
  12700. private _onbuttonup;
  12701. /**
  12702. * Observable triggered when a button has been pressed
  12703. */
  12704. onButtonDownObservable: Observable<number>;
  12705. /**
  12706. * Observable triggered when a button has been released
  12707. */
  12708. onButtonUpObservable: Observable<number>;
  12709. /**
  12710. * Callback triggered when a button has been pressed
  12711. * @param callback Called when a button has been pressed
  12712. */
  12713. onbuttondown(callback: (buttonPressed: number) => void): void;
  12714. /**
  12715. * Callback triggered when a button has been released
  12716. * @param callback Called when a button has been released
  12717. */
  12718. onbuttonup(callback: (buttonReleased: number) => void): void;
  12719. /**
  12720. * Initializes the generic gamepad
  12721. * @param id The id of the generic gamepad
  12722. * @param index The index of the generic gamepad
  12723. * @param browserGamepad The browser gamepad
  12724. */
  12725. constructor(id: string, index: number, browserGamepad: any);
  12726. private _setButtonValue;
  12727. /**
  12728. * Updates the generic gamepad
  12729. */
  12730. update(): void;
  12731. /**
  12732. * Disposes the generic gamepad
  12733. */
  12734. dispose(): void;
  12735. }
  12736. }
  12737. declare module BABYLON {
  12738. /**
  12739. * Defines the types of pose enabled controllers that are supported
  12740. */
  12741. export enum PoseEnabledControllerType {
  12742. /**
  12743. * HTC Vive
  12744. */
  12745. VIVE = 0,
  12746. /**
  12747. * Oculus Rift
  12748. */
  12749. OCULUS = 1,
  12750. /**
  12751. * Windows mixed reality
  12752. */
  12753. WINDOWS = 2,
  12754. /**
  12755. * Samsung gear VR
  12756. */
  12757. GEAR_VR = 3,
  12758. /**
  12759. * Google Daydream
  12760. */
  12761. DAYDREAM = 4,
  12762. /**
  12763. * Generic
  12764. */
  12765. GENERIC = 5
  12766. }
  12767. /**
  12768. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12769. */
  12770. export interface MutableGamepadButton {
  12771. /**
  12772. * Value of the button/trigger
  12773. */
  12774. value: number;
  12775. /**
  12776. * If the button/trigger is currently touched
  12777. */
  12778. touched: boolean;
  12779. /**
  12780. * If the button/trigger is currently pressed
  12781. */
  12782. pressed: boolean;
  12783. }
  12784. /**
  12785. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12786. * @hidden
  12787. */
  12788. export interface ExtendedGamepadButton extends GamepadButton {
  12789. /**
  12790. * If the button/trigger is currently pressed
  12791. */
  12792. readonly pressed: boolean;
  12793. /**
  12794. * If the button/trigger is currently touched
  12795. */
  12796. readonly touched: boolean;
  12797. /**
  12798. * Value of the button/trigger
  12799. */
  12800. readonly value: number;
  12801. }
  12802. /** @hidden */
  12803. export interface _GamePadFactory {
  12804. /**
  12805. * Returns wether or not the current gamepad can be created for this type of controller.
  12806. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12807. * @returns true if it can be created, otherwise false
  12808. */
  12809. canCreate(gamepadInfo: any): boolean;
  12810. /**
  12811. * Creates a new instance of the Gamepad.
  12812. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12813. * @returns the new gamepad instance
  12814. */
  12815. create(gamepadInfo: any): Gamepad;
  12816. }
  12817. /**
  12818. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12819. */
  12820. export class PoseEnabledControllerHelper {
  12821. /** @hidden */
  12822. static _ControllerFactories: _GamePadFactory[];
  12823. /** @hidden */
  12824. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12825. /**
  12826. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12827. * @param vrGamepad the gamepad to initialized
  12828. * @returns a vr controller of the type the gamepad identified as
  12829. */
  12830. static InitiateController(vrGamepad: any): Gamepad;
  12831. }
  12832. /**
  12833. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12834. */
  12835. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12836. private _deviceRoomPosition;
  12837. private _deviceRoomRotationQuaternion;
  12838. /**
  12839. * The device position in babylon space
  12840. */
  12841. devicePosition: Vector3;
  12842. /**
  12843. * The device rotation in babylon space
  12844. */
  12845. deviceRotationQuaternion: Quaternion;
  12846. /**
  12847. * The scale factor of the device in babylon space
  12848. */
  12849. deviceScaleFactor: number;
  12850. /**
  12851. * (Likely devicePosition should be used instead) The device position in its room space
  12852. */
  12853. position: Vector3;
  12854. /**
  12855. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12856. */
  12857. rotationQuaternion: Quaternion;
  12858. /**
  12859. * The type of controller (Eg. Windows mixed reality)
  12860. */
  12861. controllerType: PoseEnabledControllerType;
  12862. protected _calculatedPosition: Vector3;
  12863. private _calculatedRotation;
  12864. /**
  12865. * The raw pose from the device
  12866. */
  12867. rawPose: DevicePose;
  12868. private _trackPosition;
  12869. private _maxRotationDistFromHeadset;
  12870. private _draggedRoomRotation;
  12871. /**
  12872. * @hidden
  12873. */
  12874. _disableTrackPosition(fixedPosition: Vector3): void;
  12875. /**
  12876. * Internal, the mesh attached to the controller
  12877. * @hidden
  12878. */
  12879. _mesh: Nullable<AbstractMesh>;
  12880. private _poseControlledCamera;
  12881. private _leftHandSystemQuaternion;
  12882. /**
  12883. * Internal, matrix used to convert room space to babylon space
  12884. * @hidden
  12885. */
  12886. _deviceToWorld: Matrix;
  12887. /**
  12888. * Node to be used when casting a ray from the controller
  12889. * @hidden
  12890. */
  12891. _pointingPoseNode: Nullable<TransformNode>;
  12892. /**
  12893. * Name of the child mesh that can be used to cast a ray from the controller
  12894. */
  12895. static readonly POINTING_POSE: string;
  12896. /**
  12897. * Creates a new PoseEnabledController from a gamepad
  12898. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12899. */
  12900. constructor(browserGamepad: any);
  12901. private _workingMatrix;
  12902. /**
  12903. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12904. */
  12905. update(): void;
  12906. /**
  12907. * Updates only the pose device and mesh without doing any button event checking
  12908. */
  12909. protected _updatePoseAndMesh(): void;
  12910. /**
  12911. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12912. * @param poseData raw pose fromthe device
  12913. */
  12914. updateFromDevice(poseData: DevicePose): void;
  12915. /**
  12916. * @hidden
  12917. */
  12918. _meshAttachedObservable: Observable<AbstractMesh>;
  12919. /**
  12920. * Attaches a mesh to the controller
  12921. * @param mesh the mesh to be attached
  12922. */
  12923. attachToMesh(mesh: AbstractMesh): void;
  12924. /**
  12925. * Attaches the controllers mesh to a camera
  12926. * @param camera the camera the mesh should be attached to
  12927. */
  12928. attachToPoseControlledCamera(camera: TargetCamera): void;
  12929. /**
  12930. * Disposes of the controller
  12931. */
  12932. dispose(): void;
  12933. /**
  12934. * The mesh that is attached to the controller
  12935. */
  12936. readonly mesh: Nullable<AbstractMesh>;
  12937. /**
  12938. * Gets the ray of the controller in the direction the controller is pointing
  12939. * @param length the length the resulting ray should be
  12940. * @returns a ray in the direction the controller is pointing
  12941. */
  12942. getForwardRay(length?: number): Ray;
  12943. }
  12944. }
  12945. declare module BABYLON {
  12946. /**
  12947. * Defines the WebVRController object that represents controllers tracked in 3D space
  12948. */
  12949. export abstract class WebVRController extends PoseEnabledController {
  12950. /**
  12951. * Internal, the default controller model for the controller
  12952. */
  12953. protected _defaultModel: AbstractMesh;
  12954. /**
  12955. * Fired when the trigger state has changed
  12956. */
  12957. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12958. /**
  12959. * Fired when the main button state has changed
  12960. */
  12961. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12962. /**
  12963. * Fired when the secondary button state has changed
  12964. */
  12965. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12966. /**
  12967. * Fired when the pad state has changed
  12968. */
  12969. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12970. /**
  12971. * Fired when controllers stick values have changed
  12972. */
  12973. onPadValuesChangedObservable: Observable<StickValues>;
  12974. /**
  12975. * Array of button availible on the controller
  12976. */
  12977. protected _buttons: Array<MutableGamepadButton>;
  12978. private _onButtonStateChange;
  12979. /**
  12980. * Fired when a controller button's state has changed
  12981. * @param callback the callback containing the button that was modified
  12982. */
  12983. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12984. /**
  12985. * X and Y axis corrisponding to the controllers joystick
  12986. */
  12987. pad: StickValues;
  12988. /**
  12989. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12990. */
  12991. hand: string;
  12992. /**
  12993. * The default controller model for the controller
  12994. */
  12995. readonly defaultModel: AbstractMesh;
  12996. /**
  12997. * Creates a new WebVRController from a gamepad
  12998. * @param vrGamepad the gamepad that the WebVRController should be created from
  12999. */
  13000. constructor(vrGamepad: any);
  13001. /**
  13002. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13003. */
  13004. update(): void;
  13005. /**
  13006. * Function to be called when a button is modified
  13007. */
  13008. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13009. /**
  13010. * Loads a mesh and attaches it to the controller
  13011. * @param scene the scene the mesh should be added to
  13012. * @param meshLoaded callback for when the mesh has been loaded
  13013. */
  13014. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13015. private _setButtonValue;
  13016. private _changes;
  13017. private _checkChanges;
  13018. /**
  13019. * Disposes of th webVRCOntroller
  13020. */
  13021. dispose(): void;
  13022. }
  13023. }
  13024. declare module BABYLON {
  13025. /**
  13026. * The HemisphericLight simulates the ambient environment light,
  13027. * so the passed direction is the light reflection direction, not the incoming direction.
  13028. */
  13029. export class HemisphericLight extends Light {
  13030. /**
  13031. * The groundColor is the light in the opposite direction to the one specified during creation.
  13032. * 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.
  13033. */
  13034. groundColor: Color3;
  13035. /**
  13036. * The light reflection direction, not the incoming direction.
  13037. */
  13038. direction: Vector3;
  13039. /**
  13040. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13041. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13042. * The HemisphericLight can't cast shadows.
  13043. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13044. * @param name The friendly name of the light
  13045. * @param direction The direction of the light reflection
  13046. * @param scene The scene the light belongs to
  13047. */
  13048. constructor(name: string, direction: Vector3, scene: Scene);
  13049. protected _buildUniformLayout(): void;
  13050. /**
  13051. * Returns the string "HemisphericLight".
  13052. * @return The class name
  13053. */
  13054. getClassName(): string;
  13055. /**
  13056. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13057. * Returns the updated direction.
  13058. * @param target The target the direction should point to
  13059. * @return The computed direction
  13060. */
  13061. setDirectionToTarget(target: Vector3): Vector3;
  13062. /**
  13063. * Returns the shadow generator associated to the light.
  13064. * @returns Always null for hemispheric lights because it does not support shadows.
  13065. */
  13066. getShadowGenerator(): Nullable<IShadowGenerator>;
  13067. /**
  13068. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13069. * @param effect The effect to update
  13070. * @param lightIndex The index of the light in the effect to update
  13071. * @returns The hemispheric light
  13072. */
  13073. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13074. /**
  13075. * Computes the world matrix of the node
  13076. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13077. * @param useWasUpdatedFlag defines a reserved property
  13078. * @returns the world matrix
  13079. */
  13080. computeWorldMatrix(): Matrix;
  13081. /**
  13082. * Returns the integer 3.
  13083. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13084. */
  13085. getTypeID(): number;
  13086. /**
  13087. * Prepares the list of defines specific to the light type.
  13088. * @param defines the list of defines
  13089. * @param lightIndex defines the index of the light for the effect
  13090. */
  13091. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13092. }
  13093. }
  13094. declare module BABYLON {
  13095. /** @hidden */
  13096. export var vrMultiviewToSingleviewPixelShader: {
  13097. name: string;
  13098. shader: string;
  13099. };
  13100. }
  13101. declare module BABYLON {
  13102. /**
  13103. * Renders to multiple views with a single draw call
  13104. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13105. */
  13106. export class MultiviewRenderTarget extends RenderTargetTexture {
  13107. /**
  13108. * Creates a multiview render target
  13109. * @param scene scene used with the render target
  13110. * @param size the size of the render target (used for each view)
  13111. */
  13112. constructor(scene: Scene, size?: number | {
  13113. width: number;
  13114. height: number;
  13115. } | {
  13116. ratio: number;
  13117. });
  13118. /**
  13119. * @hidden
  13120. * @param faceIndex the face index, if its a cube texture
  13121. */
  13122. _bindFrameBuffer(faceIndex?: number): void;
  13123. /**
  13124. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13125. * @returns the view count
  13126. */
  13127. getViewCount(): number;
  13128. }
  13129. }
  13130. declare module BABYLON {
  13131. interface Engine {
  13132. /**
  13133. * Creates a new multiview render target
  13134. * @param width defines the width of the texture
  13135. * @param height defines the height of the texture
  13136. * @returns the created multiview texture
  13137. */
  13138. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13139. /**
  13140. * Binds a multiview framebuffer to be drawn to
  13141. * @param multiviewTexture texture to bind
  13142. */
  13143. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13144. }
  13145. interface Camera {
  13146. /**
  13147. * @hidden
  13148. * 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)
  13149. */
  13150. _useMultiviewToSingleView: boolean;
  13151. /**
  13152. * @hidden
  13153. * 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)
  13154. */
  13155. _multiviewTexture: Nullable<RenderTargetTexture>;
  13156. /**
  13157. * @hidden
  13158. * ensures the multiview texture of the camera exists and has the specified width/height
  13159. * @param width height to set on the multiview texture
  13160. * @param height width to set on the multiview texture
  13161. */
  13162. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13163. }
  13164. interface Scene {
  13165. /** @hidden */
  13166. _transformMatrixR: Matrix;
  13167. /** @hidden */
  13168. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13169. /** @hidden */
  13170. _createMultiviewUbo(): void;
  13171. /** @hidden */
  13172. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13173. /** @hidden */
  13174. _renderMultiviewToSingleView(camera: Camera): void;
  13175. }
  13176. }
  13177. declare module BABYLON {
  13178. /**
  13179. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13180. * This will not be used for webXR as it supports displaying texture arrays directly
  13181. */
  13182. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13183. /**
  13184. * Initializes a VRMultiviewToSingleview
  13185. * @param name name of the post process
  13186. * @param camera camera to be applied to
  13187. * @param scaleFactor scaling factor to the size of the output texture
  13188. */
  13189. constructor(name: string, camera: Camera, scaleFactor: number);
  13190. }
  13191. }
  13192. declare module BABYLON {
  13193. /**
  13194. * Defines the interface used by display changed events
  13195. */
  13196. interface IDisplayChangedEventArgs {
  13197. /** Gets the vrDisplay object (if any) */
  13198. vrDisplay: Nullable<any>;
  13199. /** Gets a boolean indicating if webVR is supported */
  13200. vrSupported: boolean;
  13201. }
  13202. interface Engine {
  13203. /** @hidden */
  13204. _vrDisplay: any;
  13205. /** @hidden */
  13206. _vrSupported: boolean;
  13207. /** @hidden */
  13208. _oldSize: Size;
  13209. /** @hidden */
  13210. _oldHardwareScaleFactor: number;
  13211. /** @hidden */
  13212. _vrExclusivePointerMode: boolean;
  13213. /** @hidden */
  13214. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13215. /** @hidden */
  13216. _onVRDisplayPointerRestricted: () => void;
  13217. /** @hidden */
  13218. _onVRDisplayPointerUnrestricted: () => void;
  13219. /** @hidden */
  13220. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13221. /** @hidden */
  13222. _onVrDisplayDisconnect: Nullable<() => void>;
  13223. /** @hidden */
  13224. _onVrDisplayPresentChange: Nullable<() => void>;
  13225. /**
  13226. * Observable signaled when VR display mode changes
  13227. */
  13228. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13229. /**
  13230. * Observable signaled when VR request present is complete
  13231. */
  13232. onVRRequestPresentComplete: Observable<boolean>;
  13233. /**
  13234. * Observable signaled when VR request present starts
  13235. */
  13236. onVRRequestPresentStart: Observable<Engine>;
  13237. /**
  13238. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13239. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13240. */
  13241. isInVRExclusivePointerMode: boolean;
  13242. /**
  13243. * Gets a boolean indicating if a webVR device was detected
  13244. * @returns true if a webVR device was detected
  13245. */
  13246. isVRDevicePresent(): boolean;
  13247. /**
  13248. * Gets the current webVR device
  13249. * @returns the current webVR device (or null)
  13250. */
  13251. getVRDevice(): any;
  13252. /**
  13253. * Initializes a webVR display and starts listening to display change events
  13254. * The onVRDisplayChangedObservable will be notified upon these changes
  13255. * @returns A promise containing a VRDisplay and if vr is supported
  13256. */
  13257. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13258. /** @hidden */
  13259. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13260. /**
  13261. * Call this function to switch to webVR mode
  13262. * Will do nothing if webVR is not supported or if there is no webVR device
  13263. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13264. */
  13265. enableVR(): void;
  13266. /** @hidden */
  13267. _onVRFullScreenTriggered(): void;
  13268. }
  13269. }
  13270. declare module BABYLON {
  13271. /**
  13272. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13273. * IMPORTANT!! The data is right-hand data.
  13274. * @export
  13275. * @interface DevicePose
  13276. */
  13277. export interface DevicePose {
  13278. /**
  13279. * The position of the device, values in array are [x,y,z].
  13280. */
  13281. readonly position: Nullable<Float32Array>;
  13282. /**
  13283. * The linearVelocity of the device, values in array are [x,y,z].
  13284. */
  13285. readonly linearVelocity: Nullable<Float32Array>;
  13286. /**
  13287. * The linearAcceleration of the device, values in array are [x,y,z].
  13288. */
  13289. readonly linearAcceleration: Nullable<Float32Array>;
  13290. /**
  13291. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13292. */
  13293. readonly orientation: Nullable<Float32Array>;
  13294. /**
  13295. * The angularVelocity of the device, values in array are [x,y,z].
  13296. */
  13297. readonly angularVelocity: Nullable<Float32Array>;
  13298. /**
  13299. * The angularAcceleration of the device, values in array are [x,y,z].
  13300. */
  13301. readonly angularAcceleration: Nullable<Float32Array>;
  13302. }
  13303. /**
  13304. * Interface representing a pose controlled object in Babylon.
  13305. * A pose controlled object has both regular pose values as well as pose values
  13306. * from an external device such as a VR head mounted display
  13307. */
  13308. export interface PoseControlled {
  13309. /**
  13310. * The position of the object in babylon space.
  13311. */
  13312. position: Vector3;
  13313. /**
  13314. * The rotation quaternion of the object in babylon space.
  13315. */
  13316. rotationQuaternion: Quaternion;
  13317. /**
  13318. * The position of the device in babylon space.
  13319. */
  13320. devicePosition?: Vector3;
  13321. /**
  13322. * The rotation quaternion of the device in babylon space.
  13323. */
  13324. deviceRotationQuaternion: Quaternion;
  13325. /**
  13326. * The raw pose coming from the device.
  13327. */
  13328. rawPose: Nullable<DevicePose>;
  13329. /**
  13330. * The scale of the device to be used when translating from device space to babylon space.
  13331. */
  13332. deviceScaleFactor: number;
  13333. /**
  13334. * Updates the poseControlled values based on the input device pose.
  13335. * @param poseData the pose data to update the object with
  13336. */
  13337. updateFromDevice(poseData: DevicePose): void;
  13338. }
  13339. /**
  13340. * Set of options to customize the webVRCamera
  13341. */
  13342. export interface WebVROptions {
  13343. /**
  13344. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13345. */
  13346. trackPosition?: boolean;
  13347. /**
  13348. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13349. */
  13350. positionScale?: number;
  13351. /**
  13352. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13353. */
  13354. displayName?: string;
  13355. /**
  13356. * Should the native controller meshes be initialized. (default: true)
  13357. */
  13358. controllerMeshes?: boolean;
  13359. /**
  13360. * Creating a default HemiLight only on controllers. (default: true)
  13361. */
  13362. defaultLightingOnControllers?: boolean;
  13363. /**
  13364. * If you don't want to use the default VR button of the helper. (default: false)
  13365. */
  13366. useCustomVRButton?: boolean;
  13367. /**
  13368. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13369. */
  13370. customVRButton?: HTMLButtonElement;
  13371. /**
  13372. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13373. */
  13374. rayLength?: number;
  13375. /**
  13376. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13377. */
  13378. defaultHeight?: number;
  13379. /**
  13380. * If multiview should be used if availible (default: false)
  13381. */
  13382. useMultiview?: boolean;
  13383. }
  13384. /**
  13385. * This represents a WebVR camera.
  13386. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13387. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13388. */
  13389. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13390. private webVROptions;
  13391. /**
  13392. * @hidden
  13393. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13394. */
  13395. _vrDevice: any;
  13396. /**
  13397. * The rawPose of the vrDevice.
  13398. */
  13399. rawPose: Nullable<DevicePose>;
  13400. private _onVREnabled;
  13401. private _specsVersion;
  13402. private _attached;
  13403. private _frameData;
  13404. protected _descendants: Array<Node>;
  13405. private _deviceRoomPosition;
  13406. /** @hidden */
  13407. _deviceRoomRotationQuaternion: Quaternion;
  13408. private _standingMatrix;
  13409. /**
  13410. * Represents device position in babylon space.
  13411. */
  13412. devicePosition: Vector3;
  13413. /**
  13414. * Represents device rotation in babylon space.
  13415. */
  13416. deviceRotationQuaternion: Quaternion;
  13417. /**
  13418. * The scale of the device to be used when translating from device space to babylon space.
  13419. */
  13420. deviceScaleFactor: number;
  13421. private _deviceToWorld;
  13422. private _worldToDevice;
  13423. /**
  13424. * References to the webVR controllers for the vrDevice.
  13425. */
  13426. controllers: Array<WebVRController>;
  13427. /**
  13428. * Emits an event when a controller is attached.
  13429. */
  13430. onControllersAttachedObservable: Observable<WebVRController[]>;
  13431. /**
  13432. * Emits an event when a controller's mesh has been loaded;
  13433. */
  13434. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13435. /**
  13436. * Emits an event when the HMD's pose has been updated.
  13437. */
  13438. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13439. private _poseSet;
  13440. /**
  13441. * If the rig cameras be used as parent instead of this camera.
  13442. */
  13443. rigParenting: boolean;
  13444. private _lightOnControllers;
  13445. private _defaultHeight?;
  13446. /**
  13447. * Instantiates a WebVRFreeCamera.
  13448. * @param name The name of the WebVRFreeCamera
  13449. * @param position The starting anchor position for the camera
  13450. * @param scene The scene the camera belongs to
  13451. * @param webVROptions a set of customizable options for the webVRCamera
  13452. */
  13453. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13454. /**
  13455. * Gets the device distance from the ground in meters.
  13456. * @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.
  13457. */
  13458. deviceDistanceToRoomGround(): number;
  13459. /**
  13460. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13461. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13462. */
  13463. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13464. /**
  13465. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13466. * @returns A promise with a boolean set to if the standing matrix is supported.
  13467. */
  13468. useStandingMatrixAsync(): Promise<boolean>;
  13469. /**
  13470. * Disposes the camera
  13471. */
  13472. dispose(): void;
  13473. /**
  13474. * Gets a vrController by name.
  13475. * @param name The name of the controller to retreive
  13476. * @returns the controller matching the name specified or null if not found
  13477. */
  13478. getControllerByName(name: string): Nullable<WebVRController>;
  13479. private _leftController;
  13480. /**
  13481. * The controller corrisponding to the users left hand.
  13482. */
  13483. readonly leftController: Nullable<WebVRController>;
  13484. private _rightController;
  13485. /**
  13486. * The controller corrisponding to the users right hand.
  13487. */
  13488. readonly rightController: Nullable<WebVRController>;
  13489. /**
  13490. * Casts a ray forward from the vrCamera's gaze.
  13491. * @param length Length of the ray (default: 100)
  13492. * @returns the ray corrisponding to the gaze
  13493. */
  13494. getForwardRay(length?: number): Ray;
  13495. /**
  13496. * @hidden
  13497. * Updates the camera based on device's frame data
  13498. */
  13499. _checkInputs(): void;
  13500. /**
  13501. * Updates the poseControlled values based on the input device pose.
  13502. * @param poseData Pose coming from the device
  13503. */
  13504. updateFromDevice(poseData: DevicePose): void;
  13505. private _htmlElementAttached;
  13506. private _detachIfAttached;
  13507. /**
  13508. * WebVR's attach control will start broadcasting frames to the device.
  13509. * Note that in certain browsers (chrome for example) this function must be called
  13510. * within a user-interaction callback. Example:
  13511. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13512. *
  13513. * @param element html element to attach the vrDevice to
  13514. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13515. */
  13516. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13517. /**
  13518. * Detaches the camera from the html element and disables VR
  13519. *
  13520. * @param element html element to detach from
  13521. */
  13522. detachControl(element: HTMLElement): void;
  13523. /**
  13524. * @returns the name of this class
  13525. */
  13526. getClassName(): string;
  13527. /**
  13528. * Calls resetPose on the vrDisplay
  13529. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13530. */
  13531. resetToCurrentRotation(): void;
  13532. /**
  13533. * @hidden
  13534. * Updates the rig cameras (left and right eye)
  13535. */
  13536. _updateRigCameras(): void;
  13537. private _workingVector;
  13538. private _oneVector;
  13539. private _workingMatrix;
  13540. private updateCacheCalled;
  13541. private _correctPositionIfNotTrackPosition;
  13542. /**
  13543. * @hidden
  13544. * Updates the cached values of the camera
  13545. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13546. */
  13547. _updateCache(ignoreParentClass?: boolean): void;
  13548. /**
  13549. * @hidden
  13550. * Get current device position in babylon world
  13551. */
  13552. _computeDevicePosition(): void;
  13553. /**
  13554. * Updates the current device position and rotation in the babylon world
  13555. */
  13556. update(): void;
  13557. /**
  13558. * @hidden
  13559. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13560. * @returns an identity matrix
  13561. */
  13562. _getViewMatrix(): Matrix;
  13563. private _tmpMatrix;
  13564. /**
  13565. * This function is called by the two RIG cameras.
  13566. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13567. * @hidden
  13568. */
  13569. _getWebVRViewMatrix(): Matrix;
  13570. /** @hidden */
  13571. _getWebVRProjectionMatrix(): Matrix;
  13572. private _onGamepadConnectedObserver;
  13573. private _onGamepadDisconnectedObserver;
  13574. private _updateCacheWhenTrackingDisabledObserver;
  13575. /**
  13576. * Initializes the controllers and their meshes
  13577. */
  13578. initControllers(): void;
  13579. }
  13580. }
  13581. declare module BABYLON {
  13582. /**
  13583. * Size options for a post process
  13584. */
  13585. export type PostProcessOptions = {
  13586. width: number;
  13587. height: number;
  13588. };
  13589. /**
  13590. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13591. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13592. */
  13593. export class PostProcess {
  13594. /** Name of the PostProcess. */
  13595. name: string;
  13596. /**
  13597. * Gets or sets the unique id of the post process
  13598. */
  13599. uniqueId: number;
  13600. /**
  13601. * Width of the texture to apply the post process on
  13602. */
  13603. width: number;
  13604. /**
  13605. * Height of the texture to apply the post process on
  13606. */
  13607. height: number;
  13608. /**
  13609. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13610. * @hidden
  13611. */
  13612. _outputTexture: Nullable<InternalTexture>;
  13613. /**
  13614. * Sampling mode used by the shader
  13615. * See https://doc.babylonjs.com/classes/3.1/texture
  13616. */
  13617. renderTargetSamplingMode: number;
  13618. /**
  13619. * Clear color to use when screen clearing
  13620. */
  13621. clearColor: Color4;
  13622. /**
  13623. * If the buffer needs to be cleared before applying the post process. (default: true)
  13624. * Should be set to false if shader will overwrite all previous pixels.
  13625. */
  13626. autoClear: boolean;
  13627. /**
  13628. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13629. */
  13630. alphaMode: number;
  13631. /**
  13632. * Sets the setAlphaBlendConstants of the babylon engine
  13633. */
  13634. alphaConstants: Color4;
  13635. /**
  13636. * Animations to be used for the post processing
  13637. */
  13638. animations: Animation[];
  13639. /**
  13640. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13641. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13642. */
  13643. enablePixelPerfectMode: boolean;
  13644. /**
  13645. * Force the postprocess to be applied without taking in account viewport
  13646. */
  13647. forceFullscreenViewport: boolean;
  13648. /**
  13649. * List of inspectable custom properties (used by the Inspector)
  13650. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13651. */
  13652. inspectableCustomProperties: IInspectable[];
  13653. /**
  13654. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13655. *
  13656. * | Value | Type | Description |
  13657. * | ----- | ----------------------------------- | ----------- |
  13658. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13659. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13660. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13661. *
  13662. */
  13663. scaleMode: number;
  13664. /**
  13665. * Force textures to be a power of two (default: false)
  13666. */
  13667. alwaysForcePOT: boolean;
  13668. private _samples;
  13669. /**
  13670. * Number of sample textures (default: 1)
  13671. */
  13672. samples: number;
  13673. /**
  13674. * Modify the scale of the post process to be the same as the viewport (default: false)
  13675. */
  13676. adaptScaleToCurrentViewport: boolean;
  13677. private _camera;
  13678. private _scene;
  13679. private _engine;
  13680. private _options;
  13681. private _reusable;
  13682. private _textureType;
  13683. /**
  13684. * Smart array of input and output textures for the post process.
  13685. * @hidden
  13686. */
  13687. _textures: SmartArray<InternalTexture>;
  13688. /**
  13689. * The index in _textures that corresponds to the output texture.
  13690. * @hidden
  13691. */
  13692. _currentRenderTextureInd: number;
  13693. private _effect;
  13694. private _samplers;
  13695. private _fragmentUrl;
  13696. private _vertexUrl;
  13697. private _parameters;
  13698. private _scaleRatio;
  13699. protected _indexParameters: any;
  13700. private _shareOutputWithPostProcess;
  13701. private _texelSize;
  13702. private _forcedOutputTexture;
  13703. /**
  13704. * Returns the fragment url or shader name used in the post process.
  13705. * @returns the fragment url or name in the shader store.
  13706. */
  13707. getEffectName(): string;
  13708. /**
  13709. * An event triggered when the postprocess is activated.
  13710. */
  13711. onActivateObservable: Observable<Camera>;
  13712. private _onActivateObserver;
  13713. /**
  13714. * A function that is added to the onActivateObservable
  13715. */
  13716. onActivate: Nullable<(camera: Camera) => void>;
  13717. /**
  13718. * An event triggered when the postprocess changes its size.
  13719. */
  13720. onSizeChangedObservable: Observable<PostProcess>;
  13721. private _onSizeChangedObserver;
  13722. /**
  13723. * A function that is added to the onSizeChangedObservable
  13724. */
  13725. onSizeChanged: (postProcess: PostProcess) => void;
  13726. /**
  13727. * An event triggered when the postprocess applies its effect.
  13728. */
  13729. onApplyObservable: Observable<Effect>;
  13730. private _onApplyObserver;
  13731. /**
  13732. * A function that is added to the onApplyObservable
  13733. */
  13734. onApply: (effect: Effect) => void;
  13735. /**
  13736. * An event triggered before rendering the postprocess
  13737. */
  13738. onBeforeRenderObservable: Observable<Effect>;
  13739. private _onBeforeRenderObserver;
  13740. /**
  13741. * A function that is added to the onBeforeRenderObservable
  13742. */
  13743. onBeforeRender: (effect: Effect) => void;
  13744. /**
  13745. * An event triggered after rendering the postprocess
  13746. */
  13747. onAfterRenderObservable: Observable<Effect>;
  13748. private _onAfterRenderObserver;
  13749. /**
  13750. * A function that is added to the onAfterRenderObservable
  13751. */
  13752. onAfterRender: (efect: Effect) => void;
  13753. /**
  13754. * 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
  13755. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13756. */
  13757. inputTexture: InternalTexture;
  13758. /**
  13759. * Gets the camera which post process is applied to.
  13760. * @returns The camera the post process is applied to.
  13761. */
  13762. getCamera(): Camera;
  13763. /**
  13764. * Gets the texel size of the postprocess.
  13765. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13766. */
  13767. readonly texelSize: Vector2;
  13768. /**
  13769. * Creates a new instance PostProcess
  13770. * @param name The name of the PostProcess.
  13771. * @param fragmentUrl The url of the fragment shader to be used.
  13772. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13773. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13774. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13775. * @param camera The camera to apply the render pass to.
  13776. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13777. * @param engine The engine which the post process will be applied. (default: current engine)
  13778. * @param reusable If the post process can be reused on the same frame. (default: false)
  13779. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13780. * @param textureType Type of textures used when performing the post process. (default: 0)
  13781. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13782. * @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
  13783. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13784. */
  13785. constructor(
  13786. /** Name of the PostProcess. */
  13787. 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);
  13788. /**
  13789. * Gets a string idenfifying the name of the class
  13790. * @returns "PostProcess" string
  13791. */
  13792. getClassName(): string;
  13793. /**
  13794. * Gets the engine which this post process belongs to.
  13795. * @returns The engine the post process was enabled with.
  13796. */
  13797. getEngine(): Engine;
  13798. /**
  13799. * The effect that is created when initializing the post process.
  13800. * @returns The created effect corrisponding the the postprocess.
  13801. */
  13802. getEffect(): Effect;
  13803. /**
  13804. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13805. * @param postProcess The post process to share the output with.
  13806. * @returns This post process.
  13807. */
  13808. shareOutputWith(postProcess: PostProcess): PostProcess;
  13809. /**
  13810. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13811. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13812. */
  13813. useOwnOutput(): void;
  13814. /**
  13815. * Updates the effect with the current post process compile time values and recompiles the shader.
  13816. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13817. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13818. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13819. * @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
  13820. * @param onCompiled Called when the shader has been compiled.
  13821. * @param onError Called if there is an error when compiling a shader.
  13822. */
  13823. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13824. /**
  13825. * The post process is reusable if it can be used multiple times within one frame.
  13826. * @returns If the post process is reusable
  13827. */
  13828. isReusable(): boolean;
  13829. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13830. markTextureDirty(): void;
  13831. /**
  13832. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13833. * 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.
  13834. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13835. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13836. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13837. * @returns The target texture that was bound to be written to.
  13838. */
  13839. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13840. /**
  13841. * If the post process is supported.
  13842. */
  13843. readonly isSupported: boolean;
  13844. /**
  13845. * The aspect ratio of the output texture.
  13846. */
  13847. readonly aspectRatio: number;
  13848. /**
  13849. * Get a value indicating if the post-process is ready to be used
  13850. * @returns true if the post-process is ready (shader is compiled)
  13851. */
  13852. isReady(): boolean;
  13853. /**
  13854. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13855. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13856. */
  13857. apply(): Nullable<Effect>;
  13858. private _disposeTextures;
  13859. /**
  13860. * Disposes the post process.
  13861. * @param camera The camera to dispose the post process on.
  13862. */
  13863. dispose(camera?: Camera): void;
  13864. }
  13865. }
  13866. declare module BABYLON {
  13867. /**
  13868. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13869. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13870. */
  13871. export class PostProcessManager {
  13872. private _scene;
  13873. private _indexBuffer;
  13874. private _vertexBuffers;
  13875. /**
  13876. * Creates a new instance PostProcess
  13877. * @param scene The scene that the post process is associated with.
  13878. */
  13879. constructor(scene: Scene);
  13880. private _prepareBuffers;
  13881. private _buildIndexBuffer;
  13882. /**
  13883. * Rebuilds the vertex buffers of the manager.
  13884. * @hidden
  13885. */
  13886. _rebuild(): void;
  13887. /**
  13888. * Prepares a frame to be run through a post process.
  13889. * @param sourceTexture The input texture to the post procesess. (default: null)
  13890. * @param postProcesses An array of post processes to be run. (default: null)
  13891. * @returns True if the post processes were able to be run.
  13892. * @hidden
  13893. */
  13894. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13895. /**
  13896. * Manually render a set of post processes to a texture.
  13897. * @param postProcesses An array of post processes to be run.
  13898. * @param targetTexture The target texture to render to.
  13899. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13900. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13901. * @param lodLevel defines which lod of the texture to render to
  13902. */
  13903. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13904. /**
  13905. * Finalize the result of the output of the postprocesses.
  13906. * @param doNotPresent If true the result will not be displayed to the screen.
  13907. * @param targetTexture The target texture to render to.
  13908. * @param faceIndex The index of the face to bind the target texture to.
  13909. * @param postProcesses The array of post processes to render.
  13910. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13911. * @hidden
  13912. */
  13913. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13914. /**
  13915. * Disposes of the post process manager.
  13916. */
  13917. dispose(): void;
  13918. }
  13919. }
  13920. declare module BABYLON {
  13921. interface AbstractScene {
  13922. /**
  13923. * The list of layers (background and foreground) of the scene
  13924. */
  13925. layers: Array<Layer>;
  13926. }
  13927. /**
  13928. * Defines the layer scene component responsible to manage any layers
  13929. * in a given scene.
  13930. */
  13931. export class LayerSceneComponent implements ISceneComponent {
  13932. /**
  13933. * The component name helpfull to identify the component in the list of scene components.
  13934. */
  13935. readonly name: string;
  13936. /**
  13937. * The scene the component belongs to.
  13938. */
  13939. scene: Scene;
  13940. private _engine;
  13941. /**
  13942. * Creates a new instance of the component for the given scene
  13943. * @param scene Defines the scene to register the component in
  13944. */
  13945. constructor(scene: Scene);
  13946. /**
  13947. * Registers the component in a given scene
  13948. */
  13949. register(): void;
  13950. /**
  13951. * Rebuilds the elements related to this component in case of
  13952. * context lost for instance.
  13953. */
  13954. rebuild(): void;
  13955. /**
  13956. * Disposes the component and the associated ressources.
  13957. */
  13958. dispose(): void;
  13959. private _draw;
  13960. private _drawCameraPredicate;
  13961. private _drawCameraBackground;
  13962. private _drawCameraForeground;
  13963. private _drawRenderTargetPredicate;
  13964. private _drawRenderTargetBackground;
  13965. private _drawRenderTargetForeground;
  13966. }
  13967. }
  13968. declare module BABYLON {
  13969. /** @hidden */
  13970. export var layerPixelShader: {
  13971. name: string;
  13972. shader: string;
  13973. };
  13974. }
  13975. declare module BABYLON {
  13976. /** @hidden */
  13977. export var layerVertexShader: {
  13978. name: string;
  13979. shader: string;
  13980. };
  13981. }
  13982. declare module BABYLON {
  13983. /**
  13984. * This represents a full screen 2d layer.
  13985. * This can be useful to display a picture in the background of your scene for instance.
  13986. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13987. */
  13988. export class Layer {
  13989. /**
  13990. * Define the name of the layer.
  13991. */
  13992. name: string;
  13993. /**
  13994. * Define the texture the layer should display.
  13995. */
  13996. texture: Nullable<Texture>;
  13997. /**
  13998. * Is the layer in background or foreground.
  13999. */
  14000. isBackground: boolean;
  14001. /**
  14002. * Define the color of the layer (instead of texture).
  14003. */
  14004. color: Color4;
  14005. /**
  14006. * Define the scale of the layer in order to zoom in out of the texture.
  14007. */
  14008. scale: Vector2;
  14009. /**
  14010. * Define an offset for the layer in order to shift the texture.
  14011. */
  14012. offset: Vector2;
  14013. /**
  14014. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14015. */
  14016. alphaBlendingMode: number;
  14017. /**
  14018. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14019. * Alpha test will not mix with the background color in case of transparency.
  14020. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14021. */
  14022. alphaTest: boolean;
  14023. /**
  14024. * Define a mask to restrict the layer to only some of the scene cameras.
  14025. */
  14026. layerMask: number;
  14027. /**
  14028. * Define the list of render target the layer is visible into.
  14029. */
  14030. renderTargetTextures: RenderTargetTexture[];
  14031. /**
  14032. * Define if the layer is only used in renderTarget or if it also
  14033. * renders in the main frame buffer of the canvas.
  14034. */
  14035. renderOnlyInRenderTargetTextures: boolean;
  14036. private _scene;
  14037. private _vertexBuffers;
  14038. private _indexBuffer;
  14039. private _effect;
  14040. private _alphaTestEffect;
  14041. /**
  14042. * An event triggered when the layer is disposed.
  14043. */
  14044. onDisposeObservable: Observable<Layer>;
  14045. private _onDisposeObserver;
  14046. /**
  14047. * Back compatibility with callback before the onDisposeObservable existed.
  14048. * The set callback will be triggered when the layer has been disposed.
  14049. */
  14050. onDispose: () => void;
  14051. /**
  14052. * An event triggered before rendering the scene
  14053. */
  14054. onBeforeRenderObservable: Observable<Layer>;
  14055. private _onBeforeRenderObserver;
  14056. /**
  14057. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14058. * The set callback will be triggered just before rendering the layer.
  14059. */
  14060. onBeforeRender: () => void;
  14061. /**
  14062. * An event triggered after rendering the scene
  14063. */
  14064. onAfterRenderObservable: Observable<Layer>;
  14065. private _onAfterRenderObserver;
  14066. /**
  14067. * Back compatibility with callback before the onAfterRenderObservable existed.
  14068. * The set callback will be triggered just after rendering the layer.
  14069. */
  14070. onAfterRender: () => void;
  14071. /**
  14072. * Instantiates a new layer.
  14073. * This represents a full screen 2d layer.
  14074. * This can be useful to display a picture in the background of your scene for instance.
  14075. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14076. * @param name Define the name of the layer in the scene
  14077. * @param imgUrl Define the url of the texture to display in the layer
  14078. * @param scene Define the scene the layer belongs to
  14079. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14080. * @param color Defines a color for the layer
  14081. */
  14082. constructor(
  14083. /**
  14084. * Define the name of the layer.
  14085. */
  14086. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14087. private _createIndexBuffer;
  14088. /** @hidden */
  14089. _rebuild(): void;
  14090. /**
  14091. * Renders the layer in the scene.
  14092. */
  14093. render(): void;
  14094. /**
  14095. * Disposes and releases the associated ressources.
  14096. */
  14097. dispose(): void;
  14098. }
  14099. }
  14100. declare module BABYLON {
  14101. interface AbstractScene {
  14102. /**
  14103. * The list of procedural textures added to the scene
  14104. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14105. */
  14106. proceduralTextures: Array<ProceduralTexture>;
  14107. }
  14108. /**
  14109. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14110. * in a given scene.
  14111. */
  14112. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14113. /**
  14114. * The component name helpfull to identify the component in the list of scene components.
  14115. */
  14116. readonly name: string;
  14117. /**
  14118. * The scene the component belongs to.
  14119. */
  14120. scene: Scene;
  14121. /**
  14122. * Creates a new instance of the component for the given scene
  14123. * @param scene Defines the scene to register the component in
  14124. */
  14125. constructor(scene: Scene);
  14126. /**
  14127. * Registers the component in a given scene
  14128. */
  14129. register(): void;
  14130. /**
  14131. * Rebuilds the elements related to this component in case of
  14132. * context lost for instance.
  14133. */
  14134. rebuild(): void;
  14135. /**
  14136. * Disposes the component and the associated ressources.
  14137. */
  14138. dispose(): void;
  14139. private _beforeClear;
  14140. }
  14141. }
  14142. declare module BABYLON {
  14143. interface Engine {
  14144. /**
  14145. * Creates a new render target cube texture
  14146. * @param size defines the size of the texture
  14147. * @param options defines the options used to create the texture
  14148. * @returns a new render target cube texture stored in an InternalTexture
  14149. */
  14150. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14151. }
  14152. }
  14153. declare module BABYLON {
  14154. /** @hidden */
  14155. export var proceduralVertexShader: {
  14156. name: string;
  14157. shader: string;
  14158. };
  14159. }
  14160. declare module BABYLON {
  14161. /**
  14162. * 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.
  14163. * This is the base class of any Procedural texture and contains most of the shareable code.
  14164. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14165. */
  14166. export class ProceduralTexture extends Texture {
  14167. isCube: boolean;
  14168. /**
  14169. * Define if the texture is enabled or not (disabled texture will not render)
  14170. */
  14171. isEnabled: boolean;
  14172. /**
  14173. * Define if the texture must be cleared before rendering (default is true)
  14174. */
  14175. autoClear: boolean;
  14176. /**
  14177. * Callback called when the texture is generated
  14178. */
  14179. onGenerated: () => void;
  14180. /**
  14181. * Event raised when the texture is generated
  14182. */
  14183. onGeneratedObservable: Observable<ProceduralTexture>;
  14184. /** @hidden */
  14185. _generateMipMaps: boolean;
  14186. /** @hidden **/
  14187. _effect: Effect;
  14188. /** @hidden */
  14189. _textures: {
  14190. [key: string]: Texture;
  14191. };
  14192. private _size;
  14193. private _currentRefreshId;
  14194. private _refreshRate;
  14195. private _vertexBuffers;
  14196. private _indexBuffer;
  14197. private _uniforms;
  14198. private _samplers;
  14199. private _fragment;
  14200. private _floats;
  14201. private _ints;
  14202. private _floatsArrays;
  14203. private _colors3;
  14204. private _colors4;
  14205. private _vectors2;
  14206. private _vectors3;
  14207. private _matrices;
  14208. private _fallbackTexture;
  14209. private _fallbackTextureUsed;
  14210. private _engine;
  14211. private _cachedDefines;
  14212. private _contentUpdateId;
  14213. private _contentData;
  14214. /**
  14215. * Instantiates a new procedural texture.
  14216. * 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.
  14217. * This is the base class of any Procedural texture and contains most of the shareable code.
  14218. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14219. * @param name Define the name of the texture
  14220. * @param size Define the size of the texture to create
  14221. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14222. * @param scene Define the scene the texture belongs to
  14223. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14224. * @param generateMipMaps Define if the texture should creates mip maps or not
  14225. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14226. */
  14227. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14228. /**
  14229. * The effect that is created when initializing the post process.
  14230. * @returns The created effect corrisponding the the postprocess.
  14231. */
  14232. getEffect(): Effect;
  14233. /**
  14234. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14235. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14236. */
  14237. getContent(): Nullable<ArrayBufferView>;
  14238. private _createIndexBuffer;
  14239. /** @hidden */
  14240. _rebuild(): void;
  14241. /**
  14242. * Resets the texture in order to recreate its associated resources.
  14243. * This can be called in case of context loss
  14244. */
  14245. reset(): void;
  14246. protected _getDefines(): string;
  14247. /**
  14248. * Is the texture ready to be used ? (rendered at least once)
  14249. * @returns true if ready, otherwise, false.
  14250. */
  14251. isReady(): boolean;
  14252. /**
  14253. * Resets the refresh counter of the texture and start bak from scratch.
  14254. * Could be useful to regenerate the texture if it is setup to render only once.
  14255. */
  14256. resetRefreshCounter(): void;
  14257. /**
  14258. * Set the fragment shader to use in order to render the texture.
  14259. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14260. */
  14261. setFragment(fragment: any): void;
  14262. /**
  14263. * Define the refresh rate of the texture or the rendering frequency.
  14264. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14265. */
  14266. refreshRate: number;
  14267. /** @hidden */
  14268. _shouldRender(): boolean;
  14269. /**
  14270. * Get the size the texture is rendering at.
  14271. * @returns the size (texture is always squared)
  14272. */
  14273. getRenderSize(): number;
  14274. /**
  14275. * Resize the texture to new value.
  14276. * @param size Define the new size the texture should have
  14277. * @param generateMipMaps Define whether the new texture should create mip maps
  14278. */
  14279. resize(size: number, generateMipMaps: boolean): void;
  14280. private _checkUniform;
  14281. /**
  14282. * Set a texture in the shader program used to render.
  14283. * @param name Define the name of the uniform samplers as defined in the shader
  14284. * @param texture Define the texture to bind to this sampler
  14285. * @return the texture itself allowing "fluent" like uniform updates
  14286. */
  14287. setTexture(name: string, texture: Texture): ProceduralTexture;
  14288. /**
  14289. * Set a float in the shader.
  14290. * @param name Define the name of the uniform as defined in the shader
  14291. * @param value Define the value to give to the uniform
  14292. * @return the texture itself allowing "fluent" like uniform updates
  14293. */
  14294. setFloat(name: string, value: number): ProceduralTexture;
  14295. /**
  14296. * Set a int in the shader.
  14297. * @param name Define the name of the uniform as defined in the shader
  14298. * @param value Define the value to give to the uniform
  14299. * @return the texture itself allowing "fluent" like uniform updates
  14300. */
  14301. setInt(name: string, value: number): ProceduralTexture;
  14302. /**
  14303. * Set an array of floats in the shader.
  14304. * @param name Define the name of the uniform as defined in the shader
  14305. * @param value Define the value to give to the uniform
  14306. * @return the texture itself allowing "fluent" like uniform updates
  14307. */
  14308. setFloats(name: string, value: number[]): ProceduralTexture;
  14309. /**
  14310. * Set a vec3 in the shader from a Color3.
  14311. * @param name Define the name of the uniform as defined in the shader
  14312. * @param value Define the value to give to the uniform
  14313. * @return the texture itself allowing "fluent" like uniform updates
  14314. */
  14315. setColor3(name: string, value: Color3): ProceduralTexture;
  14316. /**
  14317. * Set a vec4 in the shader from a Color4.
  14318. * @param name Define the name of the uniform as defined in the shader
  14319. * @param value Define the value to give to the uniform
  14320. * @return the texture itself allowing "fluent" like uniform updates
  14321. */
  14322. setColor4(name: string, value: Color4): ProceduralTexture;
  14323. /**
  14324. * Set a vec2 in the shader from a Vector2.
  14325. * @param name Define the name of the uniform as defined in the shader
  14326. * @param value Define the value to give to the uniform
  14327. * @return the texture itself allowing "fluent" like uniform updates
  14328. */
  14329. setVector2(name: string, value: Vector2): ProceduralTexture;
  14330. /**
  14331. * Set a vec3 in the shader from a Vector3.
  14332. * @param name Define the name of the uniform as defined in the shader
  14333. * @param value Define the value to give to the uniform
  14334. * @return the texture itself allowing "fluent" like uniform updates
  14335. */
  14336. setVector3(name: string, value: Vector3): ProceduralTexture;
  14337. /**
  14338. * Set a mat4 in the shader from a MAtrix.
  14339. * @param name Define the name of the uniform as defined in the shader
  14340. * @param value Define the value to give to the uniform
  14341. * @return the texture itself allowing "fluent" like uniform updates
  14342. */
  14343. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14344. /**
  14345. * Render the texture to its associated render target.
  14346. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14347. */
  14348. render(useCameraPostProcess?: boolean): void;
  14349. /**
  14350. * Clone the texture.
  14351. * @returns the cloned texture
  14352. */
  14353. clone(): ProceduralTexture;
  14354. /**
  14355. * Dispose the texture and release its asoociated resources.
  14356. */
  14357. dispose(): void;
  14358. }
  14359. }
  14360. declare module BABYLON {
  14361. /**
  14362. * This represents the base class for particle system in Babylon.
  14363. * 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.
  14364. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14365. * @example https://doc.babylonjs.com/babylon101/particles
  14366. */
  14367. export class BaseParticleSystem {
  14368. /**
  14369. * Source color is added to the destination color without alpha affecting the result
  14370. */
  14371. static BLENDMODE_ONEONE: number;
  14372. /**
  14373. * Blend current color and particle color using particle’s alpha
  14374. */
  14375. static BLENDMODE_STANDARD: number;
  14376. /**
  14377. * Add current color and particle color multiplied by particle’s alpha
  14378. */
  14379. static BLENDMODE_ADD: number;
  14380. /**
  14381. * Multiply current color with particle color
  14382. */
  14383. static BLENDMODE_MULTIPLY: number;
  14384. /**
  14385. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14386. */
  14387. static BLENDMODE_MULTIPLYADD: number;
  14388. /**
  14389. * List of animations used by the particle system.
  14390. */
  14391. animations: Animation[];
  14392. /**
  14393. * The id of the Particle system.
  14394. */
  14395. id: string;
  14396. /**
  14397. * The friendly name of the Particle system.
  14398. */
  14399. name: string;
  14400. /**
  14401. * The rendering group used by the Particle system to chose when to render.
  14402. */
  14403. renderingGroupId: number;
  14404. /**
  14405. * The emitter represents the Mesh or position we are attaching the particle system to.
  14406. */
  14407. emitter: Nullable<AbstractMesh | Vector3>;
  14408. /**
  14409. * The maximum number of particles to emit per frame
  14410. */
  14411. emitRate: number;
  14412. /**
  14413. * If you want to launch only a few particles at once, that can be done, as well.
  14414. */
  14415. manualEmitCount: number;
  14416. /**
  14417. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14418. */
  14419. updateSpeed: number;
  14420. /**
  14421. * The amount of time the particle system is running (depends of the overall update speed).
  14422. */
  14423. targetStopDuration: number;
  14424. /**
  14425. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14426. */
  14427. disposeOnStop: boolean;
  14428. /**
  14429. * Minimum power of emitting particles.
  14430. */
  14431. minEmitPower: number;
  14432. /**
  14433. * Maximum power of emitting particles.
  14434. */
  14435. maxEmitPower: number;
  14436. /**
  14437. * Minimum life time of emitting particles.
  14438. */
  14439. minLifeTime: number;
  14440. /**
  14441. * Maximum life time of emitting particles.
  14442. */
  14443. maxLifeTime: number;
  14444. /**
  14445. * Minimum Size of emitting particles.
  14446. */
  14447. minSize: number;
  14448. /**
  14449. * Maximum Size of emitting particles.
  14450. */
  14451. maxSize: number;
  14452. /**
  14453. * Minimum scale of emitting particles on X axis.
  14454. */
  14455. minScaleX: number;
  14456. /**
  14457. * Maximum scale of emitting particles on X axis.
  14458. */
  14459. maxScaleX: number;
  14460. /**
  14461. * Minimum scale of emitting particles on Y axis.
  14462. */
  14463. minScaleY: number;
  14464. /**
  14465. * Maximum scale of emitting particles on Y axis.
  14466. */
  14467. maxScaleY: number;
  14468. /**
  14469. * Gets or sets the minimal initial rotation in radians.
  14470. */
  14471. minInitialRotation: number;
  14472. /**
  14473. * Gets or sets the maximal initial rotation in radians.
  14474. */
  14475. maxInitialRotation: number;
  14476. /**
  14477. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14478. */
  14479. minAngularSpeed: number;
  14480. /**
  14481. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14482. */
  14483. maxAngularSpeed: number;
  14484. /**
  14485. * The texture used to render each particle. (this can be a spritesheet)
  14486. */
  14487. particleTexture: Nullable<Texture>;
  14488. /**
  14489. * The layer mask we are rendering the particles through.
  14490. */
  14491. layerMask: number;
  14492. /**
  14493. * This can help using your own shader to render the particle system.
  14494. * The according effect will be created
  14495. */
  14496. customShader: any;
  14497. /**
  14498. * By default particle system starts as soon as they are created. This prevents the
  14499. * automatic start to happen and let you decide when to start emitting particles.
  14500. */
  14501. preventAutoStart: boolean;
  14502. private _noiseTexture;
  14503. /**
  14504. * Gets or sets a texture used to add random noise to particle positions
  14505. */
  14506. noiseTexture: Nullable<ProceduralTexture>;
  14507. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14508. noiseStrength: Vector3;
  14509. /**
  14510. * Callback triggered when the particle animation is ending.
  14511. */
  14512. onAnimationEnd: Nullable<() => void>;
  14513. /**
  14514. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14515. */
  14516. blendMode: number;
  14517. /**
  14518. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14519. * to override the particles.
  14520. */
  14521. forceDepthWrite: boolean;
  14522. /** 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 */
  14523. preWarmCycles: number;
  14524. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14525. preWarmStepOffset: number;
  14526. /**
  14527. * 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)
  14528. */
  14529. spriteCellChangeSpeed: number;
  14530. /**
  14531. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14532. */
  14533. startSpriteCellID: number;
  14534. /**
  14535. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14536. */
  14537. endSpriteCellID: number;
  14538. /**
  14539. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14540. */
  14541. spriteCellWidth: number;
  14542. /**
  14543. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14544. */
  14545. spriteCellHeight: number;
  14546. /**
  14547. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14548. */
  14549. spriteRandomStartCell: boolean;
  14550. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14551. translationPivot: Vector2;
  14552. /** @hidden */
  14553. protected _isAnimationSheetEnabled: boolean;
  14554. /**
  14555. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14556. */
  14557. beginAnimationOnStart: boolean;
  14558. /**
  14559. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14560. */
  14561. beginAnimationFrom: number;
  14562. /**
  14563. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14564. */
  14565. beginAnimationTo: number;
  14566. /**
  14567. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14568. */
  14569. beginAnimationLoop: boolean;
  14570. /**
  14571. * Gets or sets a world offset applied to all particles
  14572. */
  14573. worldOffset: Vector3;
  14574. /**
  14575. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14576. */
  14577. isAnimationSheetEnabled: boolean;
  14578. /**
  14579. * Get hosting scene
  14580. * @returns the scene
  14581. */
  14582. getScene(): Scene;
  14583. /**
  14584. * You can use gravity if you want to give an orientation to your particles.
  14585. */
  14586. gravity: Vector3;
  14587. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14588. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14589. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14590. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14591. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14592. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14593. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14594. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14595. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14596. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14597. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14598. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14599. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14600. /**
  14601. * Defines the delay in milliseconds before starting the system (0 by default)
  14602. */
  14603. startDelay: number;
  14604. /**
  14605. * Gets the current list of drag gradients.
  14606. * You must use addDragGradient and removeDragGradient to udpate this list
  14607. * @returns the list of drag gradients
  14608. */
  14609. getDragGradients(): Nullable<Array<FactorGradient>>;
  14610. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14611. limitVelocityDamping: number;
  14612. /**
  14613. * Gets the current list of limit velocity gradients.
  14614. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14615. * @returns the list of limit velocity gradients
  14616. */
  14617. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14618. /**
  14619. * Gets the current list of color gradients.
  14620. * You must use addColorGradient and removeColorGradient to udpate this list
  14621. * @returns the list of color gradients
  14622. */
  14623. getColorGradients(): Nullable<Array<ColorGradient>>;
  14624. /**
  14625. * Gets the current list of size gradients.
  14626. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14627. * @returns the list of size gradients
  14628. */
  14629. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14630. /**
  14631. * Gets the current list of color remap gradients.
  14632. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14633. * @returns the list of color remap gradients
  14634. */
  14635. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14636. /**
  14637. * Gets the current list of alpha remap gradients.
  14638. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14639. * @returns the list of alpha remap gradients
  14640. */
  14641. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14642. /**
  14643. * Gets the current list of life time gradients.
  14644. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14645. * @returns the list of life time gradients
  14646. */
  14647. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14648. /**
  14649. * Gets the current list of angular speed gradients.
  14650. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14651. * @returns the list of angular speed gradients
  14652. */
  14653. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14654. /**
  14655. * Gets the current list of velocity gradients.
  14656. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14657. * @returns the list of velocity gradients
  14658. */
  14659. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14660. /**
  14661. * Gets the current list of start size gradients.
  14662. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14663. * @returns the list of start size gradients
  14664. */
  14665. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14666. /**
  14667. * Gets the current list of emit rate gradients.
  14668. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14669. * @returns the list of emit rate gradients
  14670. */
  14671. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14672. /**
  14673. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14674. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14675. */
  14676. direction1: Vector3;
  14677. /**
  14678. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14679. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14680. */
  14681. direction2: Vector3;
  14682. /**
  14683. * 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.
  14684. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14685. */
  14686. minEmitBox: Vector3;
  14687. /**
  14688. * 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.
  14689. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14690. */
  14691. maxEmitBox: Vector3;
  14692. /**
  14693. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14694. */
  14695. color1: Color4;
  14696. /**
  14697. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14698. */
  14699. color2: Color4;
  14700. /**
  14701. * Color the particle will have at the end of its lifetime
  14702. */
  14703. colorDead: Color4;
  14704. /**
  14705. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14706. */
  14707. textureMask: Color4;
  14708. /**
  14709. * The particle emitter type defines the emitter used by the particle system.
  14710. * It can be for example box, sphere, or cone...
  14711. */
  14712. particleEmitterType: IParticleEmitterType;
  14713. /** @hidden */
  14714. _isSubEmitter: boolean;
  14715. /**
  14716. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14717. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14718. */
  14719. billboardMode: number;
  14720. protected _isBillboardBased: boolean;
  14721. /**
  14722. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14723. */
  14724. isBillboardBased: boolean;
  14725. /**
  14726. * The scene the particle system belongs to.
  14727. */
  14728. protected _scene: Scene;
  14729. /**
  14730. * Local cache of defines for image processing.
  14731. */
  14732. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14733. /**
  14734. * Default configuration related to image processing available in the standard Material.
  14735. */
  14736. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14737. /**
  14738. * Gets the image processing configuration used either in this material.
  14739. */
  14740. /**
  14741. * Sets the Default image processing configuration used either in the this material.
  14742. *
  14743. * If sets to null, the scene one is in use.
  14744. */
  14745. imageProcessingConfiguration: ImageProcessingConfiguration;
  14746. /**
  14747. * Attaches a new image processing configuration to the Standard Material.
  14748. * @param configuration
  14749. */
  14750. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14751. /** @hidden */
  14752. protected _reset(): void;
  14753. /** @hidden */
  14754. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14755. /**
  14756. * Instantiates a particle system.
  14757. * 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.
  14758. * @param name The name of the particle system
  14759. */
  14760. constructor(name: string);
  14761. /**
  14762. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14763. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14764. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14765. * @returns the emitter
  14766. */
  14767. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14768. /**
  14769. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14770. * @param radius The radius of the hemisphere to emit from
  14771. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14772. * @returns the emitter
  14773. */
  14774. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14775. /**
  14776. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14777. * @param radius The radius of the sphere to emit from
  14778. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14779. * @returns the emitter
  14780. */
  14781. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14782. /**
  14783. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14784. * @param radius The radius of the sphere to emit from
  14785. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14786. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14787. * @returns the emitter
  14788. */
  14789. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14790. /**
  14791. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14792. * @param radius The radius of the emission cylinder
  14793. * @param height The height of the emission cylinder
  14794. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14795. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14796. * @returns the emitter
  14797. */
  14798. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14799. /**
  14800. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14801. * @param radius The radius of the cylinder to emit from
  14802. * @param height The height of the emission cylinder
  14803. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14804. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14805. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14806. * @returns the emitter
  14807. */
  14808. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14809. /**
  14810. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14811. * @param radius The radius of the cone to emit from
  14812. * @param angle The base angle of the cone
  14813. * @returns the emitter
  14814. */
  14815. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14816. /**
  14817. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14818. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14819. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14820. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14821. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14822. * @returns the emitter
  14823. */
  14824. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14825. }
  14826. }
  14827. declare module BABYLON {
  14828. /**
  14829. * Type of sub emitter
  14830. */
  14831. export enum SubEmitterType {
  14832. /**
  14833. * Attached to the particle over it's lifetime
  14834. */
  14835. ATTACHED = 0,
  14836. /**
  14837. * Created when the particle dies
  14838. */
  14839. END = 1
  14840. }
  14841. /**
  14842. * Sub emitter class used to emit particles from an existing particle
  14843. */
  14844. export class SubEmitter {
  14845. /**
  14846. * the particle system to be used by the sub emitter
  14847. */
  14848. particleSystem: ParticleSystem;
  14849. /**
  14850. * Type of the submitter (Default: END)
  14851. */
  14852. type: SubEmitterType;
  14853. /**
  14854. * 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)
  14855. * Note: This only is supported when using an emitter of type Mesh
  14856. */
  14857. inheritDirection: boolean;
  14858. /**
  14859. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14860. */
  14861. inheritedVelocityAmount: number;
  14862. /**
  14863. * Creates a sub emitter
  14864. * @param particleSystem the particle system to be used by the sub emitter
  14865. */
  14866. constructor(
  14867. /**
  14868. * the particle system to be used by the sub emitter
  14869. */
  14870. particleSystem: ParticleSystem);
  14871. /**
  14872. * Clones the sub emitter
  14873. * @returns the cloned sub emitter
  14874. */
  14875. clone(): SubEmitter;
  14876. /**
  14877. * Serialize current object to a JSON object
  14878. * @returns the serialized object
  14879. */
  14880. serialize(): any;
  14881. /** @hidden */
  14882. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14883. /**
  14884. * Creates a new SubEmitter from a serialized JSON version
  14885. * @param serializationObject defines the JSON object to read from
  14886. * @param scene defines the hosting scene
  14887. * @param rootUrl defines the rootUrl for data loading
  14888. * @returns a new SubEmitter
  14889. */
  14890. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14891. /** Release associated resources */
  14892. dispose(): void;
  14893. }
  14894. }
  14895. declare module BABYLON {
  14896. /** @hidden */
  14897. export var clipPlaneFragmentDeclaration: {
  14898. name: string;
  14899. shader: string;
  14900. };
  14901. }
  14902. declare module BABYLON {
  14903. /** @hidden */
  14904. export var imageProcessingDeclaration: {
  14905. name: string;
  14906. shader: string;
  14907. };
  14908. }
  14909. declare module BABYLON {
  14910. /** @hidden */
  14911. export var imageProcessingFunctions: {
  14912. name: string;
  14913. shader: string;
  14914. };
  14915. }
  14916. declare module BABYLON {
  14917. /** @hidden */
  14918. export var clipPlaneFragment: {
  14919. name: string;
  14920. shader: string;
  14921. };
  14922. }
  14923. declare module BABYLON {
  14924. /** @hidden */
  14925. export var particlesPixelShader: {
  14926. name: string;
  14927. shader: string;
  14928. };
  14929. }
  14930. declare module BABYLON {
  14931. /** @hidden */
  14932. export var clipPlaneVertexDeclaration: {
  14933. name: string;
  14934. shader: string;
  14935. };
  14936. }
  14937. declare module BABYLON {
  14938. /** @hidden */
  14939. export var clipPlaneVertex: {
  14940. name: string;
  14941. shader: string;
  14942. };
  14943. }
  14944. declare module BABYLON {
  14945. /** @hidden */
  14946. export var particlesVertexShader: {
  14947. name: string;
  14948. shader: string;
  14949. };
  14950. }
  14951. declare module BABYLON {
  14952. /**
  14953. * This represents a particle system in Babylon.
  14954. * 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.
  14955. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14956. * @example https://doc.babylonjs.com/babylon101/particles
  14957. */
  14958. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14959. /**
  14960. * Billboard mode will only apply to Y axis
  14961. */
  14962. static readonly BILLBOARDMODE_Y: number;
  14963. /**
  14964. * Billboard mode will apply to all axes
  14965. */
  14966. static readonly BILLBOARDMODE_ALL: number;
  14967. /**
  14968. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14969. */
  14970. static readonly BILLBOARDMODE_STRETCHED: number;
  14971. /**
  14972. * This function can be defined to provide custom update for active particles.
  14973. * This function will be called instead of regular update (age, position, color, etc.).
  14974. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14975. */
  14976. updateFunction: (particles: Particle[]) => void;
  14977. private _emitterWorldMatrix;
  14978. /**
  14979. * This function can be defined to specify initial direction for every new particle.
  14980. * It by default use the emitterType defined function
  14981. */
  14982. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14983. /**
  14984. * This function can be defined to specify initial position for every new particle.
  14985. * It by default use the emitterType defined function
  14986. */
  14987. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14988. /**
  14989. * @hidden
  14990. */
  14991. _inheritedVelocityOffset: Vector3;
  14992. /**
  14993. * An event triggered when the system is disposed
  14994. */
  14995. onDisposeObservable: Observable<ParticleSystem>;
  14996. private _onDisposeObserver;
  14997. /**
  14998. * Sets a callback that will be triggered when the system is disposed
  14999. */
  15000. onDispose: () => void;
  15001. private _particles;
  15002. private _epsilon;
  15003. private _capacity;
  15004. private _stockParticles;
  15005. private _newPartsExcess;
  15006. private _vertexData;
  15007. private _vertexBuffer;
  15008. private _vertexBuffers;
  15009. private _spriteBuffer;
  15010. private _indexBuffer;
  15011. private _effect;
  15012. private _customEffect;
  15013. private _cachedDefines;
  15014. private _scaledColorStep;
  15015. private _colorDiff;
  15016. private _scaledDirection;
  15017. private _scaledGravity;
  15018. private _currentRenderId;
  15019. private _alive;
  15020. private _useInstancing;
  15021. private _started;
  15022. private _stopped;
  15023. private _actualFrame;
  15024. private _scaledUpdateSpeed;
  15025. private _vertexBufferSize;
  15026. /** @hidden */
  15027. _currentEmitRateGradient: Nullable<FactorGradient>;
  15028. /** @hidden */
  15029. _currentEmitRate1: number;
  15030. /** @hidden */
  15031. _currentEmitRate2: number;
  15032. /** @hidden */
  15033. _currentStartSizeGradient: Nullable<FactorGradient>;
  15034. /** @hidden */
  15035. _currentStartSize1: number;
  15036. /** @hidden */
  15037. _currentStartSize2: number;
  15038. private readonly _rawTextureWidth;
  15039. private _rampGradientsTexture;
  15040. private _useRampGradients;
  15041. /** Gets or sets a boolean indicating that ramp gradients must be used
  15042. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15043. */
  15044. useRampGradients: boolean;
  15045. /**
  15046. * 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.
  15047. * 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: [])
  15048. */
  15049. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15050. private _subEmitters;
  15051. /**
  15052. * @hidden
  15053. * If the particle systems emitter should be disposed when the particle system is disposed
  15054. */
  15055. _disposeEmitterOnDispose: boolean;
  15056. /**
  15057. * The current active Sub-systems, this property is used by the root particle system only.
  15058. */
  15059. activeSubSystems: Array<ParticleSystem>;
  15060. private _rootParticleSystem;
  15061. /**
  15062. * Gets the current list of active particles
  15063. */
  15064. readonly particles: Particle[];
  15065. /**
  15066. * Returns the string "ParticleSystem"
  15067. * @returns a string containing the class name
  15068. */
  15069. getClassName(): string;
  15070. /**
  15071. * Instantiates a particle system.
  15072. * 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.
  15073. * @param name The name of the particle system
  15074. * @param capacity The max number of particles alive at the same time
  15075. * @param scene The scene the particle system belongs to
  15076. * @param customEffect a custom effect used to change the way particles are rendered by default
  15077. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15078. * @param epsilon Offset used to render the particles
  15079. */
  15080. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15081. private _addFactorGradient;
  15082. private _removeFactorGradient;
  15083. /**
  15084. * Adds a new life time gradient
  15085. * @param gradient defines the gradient to use (between 0 and 1)
  15086. * @param factor defines the life time factor to affect to the specified gradient
  15087. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15088. * @returns the current particle system
  15089. */
  15090. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15091. /**
  15092. * Remove a specific life time gradient
  15093. * @param gradient defines the gradient to remove
  15094. * @returns the current particle system
  15095. */
  15096. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15097. /**
  15098. * Adds a new size gradient
  15099. * @param gradient defines the gradient to use (between 0 and 1)
  15100. * @param factor defines the size factor to affect to the specified gradient
  15101. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15102. * @returns the current particle system
  15103. */
  15104. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15105. /**
  15106. * Remove a specific size gradient
  15107. * @param gradient defines the gradient to remove
  15108. * @returns the current particle system
  15109. */
  15110. removeSizeGradient(gradient: number): IParticleSystem;
  15111. /**
  15112. * Adds a new color remap gradient
  15113. * @param gradient defines the gradient to use (between 0 and 1)
  15114. * @param min defines the color remap minimal range
  15115. * @param max defines the color remap maximal range
  15116. * @returns the current particle system
  15117. */
  15118. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15119. /**
  15120. * Remove a specific color remap gradient
  15121. * @param gradient defines the gradient to remove
  15122. * @returns the current particle system
  15123. */
  15124. removeColorRemapGradient(gradient: number): IParticleSystem;
  15125. /**
  15126. * Adds a new alpha remap gradient
  15127. * @param gradient defines the gradient to use (between 0 and 1)
  15128. * @param min defines the alpha remap minimal range
  15129. * @param max defines the alpha remap maximal range
  15130. * @returns the current particle system
  15131. */
  15132. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15133. /**
  15134. * Remove a specific alpha remap gradient
  15135. * @param gradient defines the gradient to remove
  15136. * @returns the current particle system
  15137. */
  15138. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15139. /**
  15140. * Adds a new angular speed gradient
  15141. * @param gradient defines the gradient to use (between 0 and 1)
  15142. * @param factor defines the angular speed to affect to the specified gradient
  15143. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15144. * @returns the current particle system
  15145. */
  15146. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15147. /**
  15148. * Remove a specific angular speed gradient
  15149. * @param gradient defines the gradient to remove
  15150. * @returns the current particle system
  15151. */
  15152. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15153. /**
  15154. * Adds a new velocity gradient
  15155. * @param gradient defines the gradient to use (between 0 and 1)
  15156. * @param factor defines the velocity to affect to the specified gradient
  15157. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15158. * @returns the current particle system
  15159. */
  15160. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15161. /**
  15162. * Remove a specific velocity gradient
  15163. * @param gradient defines the gradient to remove
  15164. * @returns the current particle system
  15165. */
  15166. removeVelocityGradient(gradient: number): IParticleSystem;
  15167. /**
  15168. * Adds a new limit velocity gradient
  15169. * @param gradient defines the gradient to use (between 0 and 1)
  15170. * @param factor defines the limit velocity value to affect to the specified gradient
  15171. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15172. * @returns the current particle system
  15173. */
  15174. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15175. /**
  15176. * Remove a specific limit velocity gradient
  15177. * @param gradient defines the gradient to remove
  15178. * @returns the current particle system
  15179. */
  15180. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15181. /**
  15182. * Adds a new drag gradient
  15183. * @param gradient defines the gradient to use (between 0 and 1)
  15184. * @param factor defines the drag value to affect to the specified gradient
  15185. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15186. * @returns the current particle system
  15187. */
  15188. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15189. /**
  15190. * Remove a specific drag gradient
  15191. * @param gradient defines the gradient to remove
  15192. * @returns the current particle system
  15193. */
  15194. removeDragGradient(gradient: number): IParticleSystem;
  15195. /**
  15196. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15197. * @param gradient defines the gradient to use (between 0 and 1)
  15198. * @param factor defines the emit rate value to affect to the specified gradient
  15199. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15200. * @returns the current particle system
  15201. */
  15202. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15203. /**
  15204. * Remove a specific emit rate gradient
  15205. * @param gradient defines the gradient to remove
  15206. * @returns the current particle system
  15207. */
  15208. removeEmitRateGradient(gradient: number): IParticleSystem;
  15209. /**
  15210. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15211. * @param gradient defines the gradient to use (between 0 and 1)
  15212. * @param factor defines the start size value to affect to the specified gradient
  15213. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15214. * @returns the current particle system
  15215. */
  15216. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15217. /**
  15218. * Remove a specific start size gradient
  15219. * @param gradient defines the gradient to remove
  15220. * @returns the current particle system
  15221. */
  15222. removeStartSizeGradient(gradient: number): IParticleSystem;
  15223. private _createRampGradientTexture;
  15224. /**
  15225. * Gets the current list of ramp gradients.
  15226. * You must use addRampGradient and removeRampGradient to udpate this list
  15227. * @returns the list of ramp gradients
  15228. */
  15229. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15230. /**
  15231. * Adds a new ramp gradient used to remap particle colors
  15232. * @param gradient defines the gradient to use (between 0 and 1)
  15233. * @param color defines the color to affect to the specified gradient
  15234. * @returns the current particle system
  15235. */
  15236. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15237. /**
  15238. * Remove a specific ramp gradient
  15239. * @param gradient defines the gradient to remove
  15240. * @returns the current particle system
  15241. */
  15242. removeRampGradient(gradient: number): ParticleSystem;
  15243. /**
  15244. * Adds a new color gradient
  15245. * @param gradient defines the gradient to use (between 0 and 1)
  15246. * @param color1 defines the color to affect to the specified gradient
  15247. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15248. * @returns this particle system
  15249. */
  15250. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15251. /**
  15252. * Remove a specific color gradient
  15253. * @param gradient defines the gradient to remove
  15254. * @returns this particle system
  15255. */
  15256. removeColorGradient(gradient: number): IParticleSystem;
  15257. private _fetchR;
  15258. protected _reset(): void;
  15259. private _resetEffect;
  15260. private _createVertexBuffers;
  15261. private _createIndexBuffer;
  15262. /**
  15263. * Gets the maximum number of particles active at the same time.
  15264. * @returns The max number of active particles.
  15265. */
  15266. getCapacity(): number;
  15267. /**
  15268. * Gets whether there are still active particles in the system.
  15269. * @returns True if it is alive, otherwise false.
  15270. */
  15271. isAlive(): boolean;
  15272. /**
  15273. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15274. * @returns True if it has been started, otherwise false.
  15275. */
  15276. isStarted(): boolean;
  15277. private _prepareSubEmitterInternalArray;
  15278. /**
  15279. * Starts the particle system and begins to emit
  15280. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15281. */
  15282. start(delay?: number): void;
  15283. /**
  15284. * Stops the particle system.
  15285. * @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.
  15286. */
  15287. stop(stopSubEmitters?: boolean): void;
  15288. /**
  15289. * Remove all active particles
  15290. */
  15291. reset(): void;
  15292. /**
  15293. * @hidden (for internal use only)
  15294. */
  15295. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15296. /**
  15297. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15298. * Its lifetime will start back at 0.
  15299. */
  15300. recycleParticle: (particle: Particle) => void;
  15301. private _stopSubEmitters;
  15302. private _createParticle;
  15303. private _removeFromRoot;
  15304. private _emitFromParticle;
  15305. private _update;
  15306. /** @hidden */
  15307. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15308. /** @hidden */
  15309. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15310. /** @hidden */
  15311. private _getEffect;
  15312. /**
  15313. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15314. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15315. */
  15316. animate(preWarmOnly?: boolean): void;
  15317. private _appendParticleVertices;
  15318. /**
  15319. * Rebuilds the particle system.
  15320. */
  15321. rebuild(): void;
  15322. /**
  15323. * Is this system ready to be used/rendered
  15324. * @return true if the system is ready
  15325. */
  15326. isReady(): boolean;
  15327. private _render;
  15328. /**
  15329. * Renders the particle system in its current state.
  15330. * @returns the current number of particles
  15331. */
  15332. render(): number;
  15333. /**
  15334. * Disposes the particle system and free the associated resources
  15335. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15336. */
  15337. dispose(disposeTexture?: boolean): void;
  15338. /**
  15339. * Clones the particle system.
  15340. * @param name The name of the cloned object
  15341. * @param newEmitter The new emitter to use
  15342. * @returns the cloned particle system
  15343. */
  15344. clone(name: string, newEmitter: any): ParticleSystem;
  15345. /**
  15346. * Serializes the particle system to a JSON object.
  15347. * @returns the JSON object
  15348. */
  15349. serialize(): any;
  15350. /** @hidden */
  15351. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15352. /** @hidden */
  15353. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15354. /**
  15355. * Parses a JSON object to create a particle system.
  15356. * @param parsedParticleSystem The JSON object to parse
  15357. * @param scene The scene to create the particle system in
  15358. * @param rootUrl The root url to use to load external dependencies like texture
  15359. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15360. * @returns the Parsed particle system
  15361. */
  15362. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15363. }
  15364. }
  15365. declare module BABYLON {
  15366. /**
  15367. * A particle represents one of the element emitted by a particle system.
  15368. * This is mainly define by its coordinates, direction, velocity and age.
  15369. */
  15370. export class Particle {
  15371. /**
  15372. * The particle system the particle belongs to.
  15373. */
  15374. particleSystem: ParticleSystem;
  15375. private static _Count;
  15376. /**
  15377. * Unique ID of the particle
  15378. */
  15379. id: number;
  15380. /**
  15381. * The world position of the particle in the scene.
  15382. */
  15383. position: Vector3;
  15384. /**
  15385. * The world direction of the particle in the scene.
  15386. */
  15387. direction: Vector3;
  15388. /**
  15389. * The color of the particle.
  15390. */
  15391. color: Color4;
  15392. /**
  15393. * The color change of the particle per step.
  15394. */
  15395. colorStep: Color4;
  15396. /**
  15397. * Defines how long will the life of the particle be.
  15398. */
  15399. lifeTime: number;
  15400. /**
  15401. * The current age of the particle.
  15402. */
  15403. age: number;
  15404. /**
  15405. * The current size of the particle.
  15406. */
  15407. size: number;
  15408. /**
  15409. * The current scale of the particle.
  15410. */
  15411. scale: Vector2;
  15412. /**
  15413. * The current angle of the particle.
  15414. */
  15415. angle: number;
  15416. /**
  15417. * Defines how fast is the angle changing.
  15418. */
  15419. angularSpeed: number;
  15420. /**
  15421. * Defines the cell index used by the particle to be rendered from a sprite.
  15422. */
  15423. cellIndex: number;
  15424. /**
  15425. * The information required to support color remapping
  15426. */
  15427. remapData: Vector4;
  15428. /** @hidden */
  15429. _randomCellOffset?: number;
  15430. /** @hidden */
  15431. _initialDirection: Nullable<Vector3>;
  15432. /** @hidden */
  15433. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15434. /** @hidden */
  15435. _initialStartSpriteCellID: number;
  15436. /** @hidden */
  15437. _initialEndSpriteCellID: number;
  15438. /** @hidden */
  15439. _currentColorGradient: Nullable<ColorGradient>;
  15440. /** @hidden */
  15441. _currentColor1: Color4;
  15442. /** @hidden */
  15443. _currentColor2: Color4;
  15444. /** @hidden */
  15445. _currentSizeGradient: Nullable<FactorGradient>;
  15446. /** @hidden */
  15447. _currentSize1: number;
  15448. /** @hidden */
  15449. _currentSize2: number;
  15450. /** @hidden */
  15451. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15452. /** @hidden */
  15453. _currentAngularSpeed1: number;
  15454. /** @hidden */
  15455. _currentAngularSpeed2: number;
  15456. /** @hidden */
  15457. _currentVelocityGradient: Nullable<FactorGradient>;
  15458. /** @hidden */
  15459. _currentVelocity1: number;
  15460. /** @hidden */
  15461. _currentVelocity2: number;
  15462. /** @hidden */
  15463. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15464. /** @hidden */
  15465. _currentLimitVelocity1: number;
  15466. /** @hidden */
  15467. _currentLimitVelocity2: number;
  15468. /** @hidden */
  15469. _currentDragGradient: Nullable<FactorGradient>;
  15470. /** @hidden */
  15471. _currentDrag1: number;
  15472. /** @hidden */
  15473. _currentDrag2: number;
  15474. /** @hidden */
  15475. _randomNoiseCoordinates1: Vector3;
  15476. /** @hidden */
  15477. _randomNoiseCoordinates2: Vector3;
  15478. /**
  15479. * Creates a new instance Particle
  15480. * @param particleSystem the particle system the particle belongs to
  15481. */
  15482. constructor(
  15483. /**
  15484. * The particle system the particle belongs to.
  15485. */
  15486. particleSystem: ParticleSystem);
  15487. private updateCellInfoFromSystem;
  15488. /**
  15489. * Defines how the sprite cell index is updated for the particle
  15490. */
  15491. updateCellIndex(): void;
  15492. /** @hidden */
  15493. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15494. /** @hidden */
  15495. _inheritParticleInfoToSubEmitters(): void;
  15496. /** @hidden */
  15497. _reset(): void;
  15498. /**
  15499. * Copy the properties of particle to another one.
  15500. * @param other the particle to copy the information to.
  15501. */
  15502. copyTo(other: Particle): void;
  15503. }
  15504. }
  15505. declare module BABYLON {
  15506. /**
  15507. * Particle emitter represents a volume emitting particles.
  15508. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15509. */
  15510. export interface IParticleEmitterType {
  15511. /**
  15512. * Called by the particle System when the direction is computed for the created particle.
  15513. * @param worldMatrix is the world matrix of the particle system
  15514. * @param directionToUpdate is the direction vector to update with the result
  15515. * @param particle is the particle we are computed the direction for
  15516. */
  15517. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15518. /**
  15519. * Called by the particle System when the position is computed for the created particle.
  15520. * @param worldMatrix is the world matrix of the particle system
  15521. * @param positionToUpdate is the position vector to update with the result
  15522. * @param particle is the particle we are computed the position for
  15523. */
  15524. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15525. /**
  15526. * Clones the current emitter and returns a copy of it
  15527. * @returns the new emitter
  15528. */
  15529. clone(): IParticleEmitterType;
  15530. /**
  15531. * Called by the GPUParticleSystem to setup the update shader
  15532. * @param effect defines the update shader
  15533. */
  15534. applyToShader(effect: Effect): void;
  15535. /**
  15536. * Returns a string to use to update the GPU particles update shader
  15537. * @returns the effect defines string
  15538. */
  15539. getEffectDefines(): string;
  15540. /**
  15541. * Returns a string representing the class name
  15542. * @returns a string containing the class name
  15543. */
  15544. getClassName(): string;
  15545. /**
  15546. * Serializes the particle system to a JSON object.
  15547. * @returns the JSON object
  15548. */
  15549. serialize(): any;
  15550. /**
  15551. * Parse properties from a JSON object
  15552. * @param serializationObject defines the JSON object
  15553. */
  15554. parse(serializationObject: any): void;
  15555. }
  15556. }
  15557. declare module BABYLON {
  15558. /**
  15559. * Particle emitter emitting particles from the inside of a box.
  15560. * It emits the particles randomly between 2 given directions.
  15561. */
  15562. export class BoxParticleEmitter implements IParticleEmitterType {
  15563. /**
  15564. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15565. */
  15566. direction1: Vector3;
  15567. /**
  15568. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15569. */
  15570. direction2: Vector3;
  15571. /**
  15572. * 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.
  15573. */
  15574. minEmitBox: Vector3;
  15575. /**
  15576. * 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.
  15577. */
  15578. maxEmitBox: Vector3;
  15579. /**
  15580. * Creates a new instance BoxParticleEmitter
  15581. */
  15582. constructor();
  15583. /**
  15584. * Called by the particle System when the direction is computed for the created particle.
  15585. * @param worldMatrix is the world matrix of the particle system
  15586. * @param directionToUpdate is the direction vector to update with the result
  15587. * @param particle is the particle we are computed the direction for
  15588. */
  15589. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15590. /**
  15591. * Called by the particle System when the position is computed for the created particle.
  15592. * @param worldMatrix is the world matrix of the particle system
  15593. * @param positionToUpdate is the position vector to update with the result
  15594. * @param particle is the particle we are computed the position for
  15595. */
  15596. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15597. /**
  15598. * Clones the current emitter and returns a copy of it
  15599. * @returns the new emitter
  15600. */
  15601. clone(): BoxParticleEmitter;
  15602. /**
  15603. * Called by the GPUParticleSystem to setup the update shader
  15604. * @param effect defines the update shader
  15605. */
  15606. applyToShader(effect: Effect): void;
  15607. /**
  15608. * Returns a string to use to update the GPU particles update shader
  15609. * @returns a string containng the defines string
  15610. */
  15611. getEffectDefines(): string;
  15612. /**
  15613. * Returns the string "BoxParticleEmitter"
  15614. * @returns a string containing the class name
  15615. */
  15616. getClassName(): string;
  15617. /**
  15618. * Serializes the particle system to a JSON object.
  15619. * @returns the JSON object
  15620. */
  15621. serialize(): any;
  15622. /**
  15623. * Parse properties from a JSON object
  15624. * @param serializationObject defines the JSON object
  15625. */
  15626. parse(serializationObject: any): void;
  15627. }
  15628. }
  15629. declare module BABYLON {
  15630. /**
  15631. * Particle emitter emitting particles from the inside of a cone.
  15632. * It emits the particles alongside the cone volume from the base to the particle.
  15633. * The emission direction might be randomized.
  15634. */
  15635. export class ConeParticleEmitter implements IParticleEmitterType {
  15636. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15637. directionRandomizer: number;
  15638. private _radius;
  15639. private _angle;
  15640. private _height;
  15641. /**
  15642. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15643. */
  15644. radiusRange: number;
  15645. /**
  15646. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15647. */
  15648. heightRange: number;
  15649. /**
  15650. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15651. */
  15652. emitFromSpawnPointOnly: boolean;
  15653. /**
  15654. * Gets or sets the radius of the emission cone
  15655. */
  15656. radius: number;
  15657. /**
  15658. * Gets or sets the angle of the emission cone
  15659. */
  15660. angle: number;
  15661. private _buildHeight;
  15662. /**
  15663. * Creates a new instance ConeParticleEmitter
  15664. * @param radius the radius of the emission cone (1 by default)
  15665. * @param angle the cone base angle (PI by default)
  15666. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15667. */
  15668. constructor(radius?: number, angle?: number,
  15669. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15670. directionRandomizer?: number);
  15671. /**
  15672. * Called by the particle System when the direction is computed for the created particle.
  15673. * @param worldMatrix is the world matrix of the particle system
  15674. * @param directionToUpdate is the direction vector to update with the result
  15675. * @param particle is the particle we are computed the direction for
  15676. */
  15677. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15678. /**
  15679. * Called by the particle System when the position is computed for the created particle.
  15680. * @param worldMatrix is the world matrix of the particle system
  15681. * @param positionToUpdate is the position vector to update with the result
  15682. * @param particle is the particle we are computed the position for
  15683. */
  15684. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15685. /**
  15686. * Clones the current emitter and returns a copy of it
  15687. * @returns the new emitter
  15688. */
  15689. clone(): ConeParticleEmitter;
  15690. /**
  15691. * Called by the GPUParticleSystem to setup the update shader
  15692. * @param effect defines the update shader
  15693. */
  15694. applyToShader(effect: Effect): void;
  15695. /**
  15696. * Returns a string to use to update the GPU particles update shader
  15697. * @returns a string containng the defines string
  15698. */
  15699. getEffectDefines(): string;
  15700. /**
  15701. * Returns the string "ConeParticleEmitter"
  15702. * @returns a string containing the class name
  15703. */
  15704. getClassName(): string;
  15705. /**
  15706. * Serializes the particle system to a JSON object.
  15707. * @returns the JSON object
  15708. */
  15709. serialize(): any;
  15710. /**
  15711. * Parse properties from a JSON object
  15712. * @param serializationObject defines the JSON object
  15713. */
  15714. parse(serializationObject: any): void;
  15715. }
  15716. }
  15717. declare module BABYLON {
  15718. /**
  15719. * Particle emitter emitting particles from the inside of a cylinder.
  15720. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15721. */
  15722. export class CylinderParticleEmitter implements IParticleEmitterType {
  15723. /**
  15724. * The radius of the emission cylinder.
  15725. */
  15726. radius: number;
  15727. /**
  15728. * The height of the emission cylinder.
  15729. */
  15730. height: number;
  15731. /**
  15732. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15733. */
  15734. radiusRange: number;
  15735. /**
  15736. * How much to randomize the particle direction [0-1].
  15737. */
  15738. directionRandomizer: number;
  15739. /**
  15740. * Creates a new instance CylinderParticleEmitter
  15741. * @param radius the radius of the emission cylinder (1 by default)
  15742. * @param height the height of the emission cylinder (1 by default)
  15743. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15744. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15745. */
  15746. constructor(
  15747. /**
  15748. * The radius of the emission cylinder.
  15749. */
  15750. radius?: number,
  15751. /**
  15752. * The height of the emission cylinder.
  15753. */
  15754. height?: number,
  15755. /**
  15756. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15757. */
  15758. radiusRange?: number,
  15759. /**
  15760. * How much to randomize the particle direction [0-1].
  15761. */
  15762. directionRandomizer?: number);
  15763. /**
  15764. * Called by the particle System when the direction is computed for the created particle.
  15765. * @param worldMatrix is the world matrix of the particle system
  15766. * @param directionToUpdate is the direction vector to update with the result
  15767. * @param particle is the particle we are computed the direction for
  15768. */
  15769. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15770. /**
  15771. * Called by the particle System when the position is computed for the created particle.
  15772. * @param worldMatrix is the world matrix of the particle system
  15773. * @param positionToUpdate is the position vector to update with the result
  15774. * @param particle is the particle we are computed the position for
  15775. */
  15776. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15777. /**
  15778. * Clones the current emitter and returns a copy of it
  15779. * @returns the new emitter
  15780. */
  15781. clone(): CylinderParticleEmitter;
  15782. /**
  15783. * Called by the GPUParticleSystem to setup the update shader
  15784. * @param effect defines the update shader
  15785. */
  15786. applyToShader(effect: Effect): void;
  15787. /**
  15788. * Returns a string to use to update the GPU particles update shader
  15789. * @returns a string containng the defines string
  15790. */
  15791. getEffectDefines(): string;
  15792. /**
  15793. * Returns the string "CylinderParticleEmitter"
  15794. * @returns a string containing the class name
  15795. */
  15796. getClassName(): string;
  15797. /**
  15798. * Serializes the particle system to a JSON object.
  15799. * @returns the JSON object
  15800. */
  15801. serialize(): any;
  15802. /**
  15803. * Parse properties from a JSON object
  15804. * @param serializationObject defines the JSON object
  15805. */
  15806. parse(serializationObject: any): void;
  15807. }
  15808. /**
  15809. * Particle emitter emitting particles from the inside of a cylinder.
  15810. * It emits the particles randomly between two vectors.
  15811. */
  15812. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15813. /**
  15814. * The min limit of the emission direction.
  15815. */
  15816. direction1: Vector3;
  15817. /**
  15818. * The max limit of the emission direction.
  15819. */
  15820. direction2: Vector3;
  15821. /**
  15822. * Creates a new instance CylinderDirectedParticleEmitter
  15823. * @param radius the radius of the emission cylinder (1 by default)
  15824. * @param height the height of the emission cylinder (1 by default)
  15825. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15826. * @param direction1 the min limit of the emission direction (up vector by default)
  15827. * @param direction2 the max limit of the emission direction (up vector by default)
  15828. */
  15829. constructor(radius?: number, height?: number, radiusRange?: number,
  15830. /**
  15831. * The min limit of the emission direction.
  15832. */
  15833. direction1?: Vector3,
  15834. /**
  15835. * The max limit of the emission direction.
  15836. */
  15837. direction2?: Vector3);
  15838. /**
  15839. * Called by the particle System when the direction is computed for the created particle.
  15840. * @param worldMatrix is the world matrix of the particle system
  15841. * @param directionToUpdate is the direction vector to update with the result
  15842. * @param particle is the particle we are computed the direction for
  15843. */
  15844. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15845. /**
  15846. * Clones the current emitter and returns a copy of it
  15847. * @returns the new emitter
  15848. */
  15849. clone(): CylinderDirectedParticleEmitter;
  15850. /**
  15851. * Called by the GPUParticleSystem to setup the update shader
  15852. * @param effect defines the update shader
  15853. */
  15854. applyToShader(effect: Effect): void;
  15855. /**
  15856. * Returns a string to use to update the GPU particles update shader
  15857. * @returns a string containng the defines string
  15858. */
  15859. getEffectDefines(): string;
  15860. /**
  15861. * Returns the string "CylinderDirectedParticleEmitter"
  15862. * @returns a string containing the class name
  15863. */
  15864. getClassName(): string;
  15865. /**
  15866. * Serializes the particle system to a JSON object.
  15867. * @returns the JSON object
  15868. */
  15869. serialize(): any;
  15870. /**
  15871. * Parse properties from a JSON object
  15872. * @param serializationObject defines the JSON object
  15873. */
  15874. parse(serializationObject: any): void;
  15875. }
  15876. }
  15877. declare module BABYLON {
  15878. /**
  15879. * Particle emitter emitting particles from the inside of a hemisphere.
  15880. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15881. */
  15882. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15883. /**
  15884. * The radius of the emission hemisphere.
  15885. */
  15886. radius: number;
  15887. /**
  15888. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15889. */
  15890. radiusRange: number;
  15891. /**
  15892. * How much to randomize the particle direction [0-1].
  15893. */
  15894. directionRandomizer: number;
  15895. /**
  15896. * Creates a new instance HemisphericParticleEmitter
  15897. * @param radius the radius of the emission hemisphere (1 by default)
  15898. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15899. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15900. */
  15901. constructor(
  15902. /**
  15903. * The radius of the emission hemisphere.
  15904. */
  15905. radius?: number,
  15906. /**
  15907. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15908. */
  15909. radiusRange?: number,
  15910. /**
  15911. * How much to randomize the particle direction [0-1].
  15912. */
  15913. directionRandomizer?: number);
  15914. /**
  15915. * Called by the particle System when the direction is computed for the created particle.
  15916. * @param worldMatrix is the world matrix of the particle system
  15917. * @param directionToUpdate is the direction vector to update with the result
  15918. * @param particle is the particle we are computed the direction for
  15919. */
  15920. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15921. /**
  15922. * Called by the particle System when the position is computed for the created particle.
  15923. * @param worldMatrix is the world matrix of the particle system
  15924. * @param positionToUpdate is the position vector to update with the result
  15925. * @param particle is the particle we are computed the position for
  15926. */
  15927. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15928. /**
  15929. * Clones the current emitter and returns a copy of it
  15930. * @returns the new emitter
  15931. */
  15932. clone(): HemisphericParticleEmitter;
  15933. /**
  15934. * Called by the GPUParticleSystem to setup the update shader
  15935. * @param effect defines the update shader
  15936. */
  15937. applyToShader(effect: Effect): void;
  15938. /**
  15939. * Returns a string to use to update the GPU particles update shader
  15940. * @returns a string containng the defines string
  15941. */
  15942. getEffectDefines(): string;
  15943. /**
  15944. * Returns the string "HemisphericParticleEmitter"
  15945. * @returns a string containing the class name
  15946. */
  15947. getClassName(): string;
  15948. /**
  15949. * Serializes the particle system to a JSON object.
  15950. * @returns the JSON object
  15951. */
  15952. serialize(): any;
  15953. /**
  15954. * Parse properties from a JSON object
  15955. * @param serializationObject defines the JSON object
  15956. */
  15957. parse(serializationObject: any): void;
  15958. }
  15959. }
  15960. declare module BABYLON {
  15961. /**
  15962. * Particle emitter emitting particles from a point.
  15963. * It emits the particles randomly between 2 given directions.
  15964. */
  15965. export class PointParticleEmitter implements IParticleEmitterType {
  15966. /**
  15967. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15968. */
  15969. direction1: Vector3;
  15970. /**
  15971. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15972. */
  15973. direction2: Vector3;
  15974. /**
  15975. * Creates a new instance PointParticleEmitter
  15976. */
  15977. constructor();
  15978. /**
  15979. * Called by the particle System when the direction is computed for the created particle.
  15980. * @param worldMatrix is the world matrix of the particle system
  15981. * @param directionToUpdate is the direction vector to update with the result
  15982. * @param particle is the particle we are computed the direction for
  15983. */
  15984. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15985. /**
  15986. * Called by the particle System when the position is computed for the created particle.
  15987. * @param worldMatrix is the world matrix of the particle system
  15988. * @param positionToUpdate is the position vector to update with the result
  15989. * @param particle is the particle we are computed the position for
  15990. */
  15991. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15992. /**
  15993. * Clones the current emitter and returns a copy of it
  15994. * @returns the new emitter
  15995. */
  15996. clone(): PointParticleEmitter;
  15997. /**
  15998. * Called by the GPUParticleSystem to setup the update shader
  15999. * @param effect defines the update shader
  16000. */
  16001. applyToShader(effect: Effect): void;
  16002. /**
  16003. * Returns a string to use to update the GPU particles update shader
  16004. * @returns a string containng the defines string
  16005. */
  16006. getEffectDefines(): string;
  16007. /**
  16008. * Returns the string "PointParticleEmitter"
  16009. * @returns a string containing the class name
  16010. */
  16011. getClassName(): string;
  16012. /**
  16013. * Serializes the particle system to a JSON object.
  16014. * @returns the JSON object
  16015. */
  16016. serialize(): any;
  16017. /**
  16018. * Parse properties from a JSON object
  16019. * @param serializationObject defines the JSON object
  16020. */
  16021. parse(serializationObject: any): void;
  16022. }
  16023. }
  16024. declare module BABYLON {
  16025. /**
  16026. * Particle emitter emitting particles from the inside of a sphere.
  16027. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16028. */
  16029. export class SphereParticleEmitter implements IParticleEmitterType {
  16030. /**
  16031. * The radius of the emission sphere.
  16032. */
  16033. radius: number;
  16034. /**
  16035. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16036. */
  16037. radiusRange: number;
  16038. /**
  16039. * How much to randomize the particle direction [0-1].
  16040. */
  16041. directionRandomizer: number;
  16042. /**
  16043. * Creates a new instance SphereParticleEmitter
  16044. * @param radius the radius of the emission sphere (1 by default)
  16045. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16046. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16047. */
  16048. constructor(
  16049. /**
  16050. * The radius of the emission sphere.
  16051. */
  16052. radius?: number,
  16053. /**
  16054. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16055. */
  16056. radiusRange?: number,
  16057. /**
  16058. * How much to randomize the particle direction [0-1].
  16059. */
  16060. directionRandomizer?: number);
  16061. /**
  16062. * Called by the particle System when the direction is computed for the created particle.
  16063. * @param worldMatrix is the world matrix of the particle system
  16064. * @param directionToUpdate is the direction vector to update with the result
  16065. * @param particle is the particle we are computed the direction for
  16066. */
  16067. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16068. /**
  16069. * Called by the particle System when the position is computed for the created particle.
  16070. * @param worldMatrix is the world matrix of the particle system
  16071. * @param positionToUpdate is the position vector to update with the result
  16072. * @param particle is the particle we are computed the position for
  16073. */
  16074. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16075. /**
  16076. * Clones the current emitter and returns a copy of it
  16077. * @returns the new emitter
  16078. */
  16079. clone(): SphereParticleEmitter;
  16080. /**
  16081. * Called by the GPUParticleSystem to setup the update shader
  16082. * @param effect defines the update shader
  16083. */
  16084. applyToShader(effect: Effect): void;
  16085. /**
  16086. * Returns a string to use to update the GPU particles update shader
  16087. * @returns a string containng the defines string
  16088. */
  16089. getEffectDefines(): string;
  16090. /**
  16091. * Returns the string "SphereParticleEmitter"
  16092. * @returns a string containing the class name
  16093. */
  16094. getClassName(): string;
  16095. /**
  16096. * Serializes the particle system to a JSON object.
  16097. * @returns the JSON object
  16098. */
  16099. serialize(): any;
  16100. /**
  16101. * Parse properties from a JSON object
  16102. * @param serializationObject defines the JSON object
  16103. */
  16104. parse(serializationObject: any): void;
  16105. }
  16106. /**
  16107. * Particle emitter emitting particles from the inside of a sphere.
  16108. * It emits the particles randomly between two vectors.
  16109. */
  16110. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16111. /**
  16112. * The min limit of the emission direction.
  16113. */
  16114. direction1: Vector3;
  16115. /**
  16116. * The max limit of the emission direction.
  16117. */
  16118. direction2: Vector3;
  16119. /**
  16120. * Creates a new instance SphereDirectedParticleEmitter
  16121. * @param radius the radius of the emission sphere (1 by default)
  16122. * @param direction1 the min limit of the emission direction (up vector by default)
  16123. * @param direction2 the max limit of the emission direction (up vector by default)
  16124. */
  16125. constructor(radius?: number,
  16126. /**
  16127. * The min limit of the emission direction.
  16128. */
  16129. direction1?: Vector3,
  16130. /**
  16131. * The max limit of the emission direction.
  16132. */
  16133. direction2?: Vector3);
  16134. /**
  16135. * Called by the particle System when the direction is computed for the created particle.
  16136. * @param worldMatrix is the world matrix of the particle system
  16137. * @param directionToUpdate is the direction vector to update with the result
  16138. * @param particle is the particle we are computed the direction for
  16139. */
  16140. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16141. /**
  16142. * Clones the current emitter and returns a copy of it
  16143. * @returns the new emitter
  16144. */
  16145. clone(): SphereDirectedParticleEmitter;
  16146. /**
  16147. * Called by the GPUParticleSystem to setup the update shader
  16148. * @param effect defines the update shader
  16149. */
  16150. applyToShader(effect: Effect): void;
  16151. /**
  16152. * Returns a string to use to update the GPU particles update shader
  16153. * @returns a string containng the defines string
  16154. */
  16155. getEffectDefines(): string;
  16156. /**
  16157. * Returns the string "SphereDirectedParticleEmitter"
  16158. * @returns a string containing the class name
  16159. */
  16160. getClassName(): string;
  16161. /**
  16162. * Serializes the particle system to a JSON object.
  16163. * @returns the JSON object
  16164. */
  16165. serialize(): any;
  16166. /**
  16167. * Parse properties from a JSON object
  16168. * @param serializationObject defines the JSON object
  16169. */
  16170. parse(serializationObject: any): void;
  16171. }
  16172. }
  16173. declare module BABYLON {
  16174. /**
  16175. * Interface representing a particle system in Babylon.js.
  16176. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16177. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16178. */
  16179. export interface IParticleSystem {
  16180. /**
  16181. * List of animations used by the particle system.
  16182. */
  16183. animations: Animation[];
  16184. /**
  16185. * The id of the Particle system.
  16186. */
  16187. id: string;
  16188. /**
  16189. * The name of the Particle system.
  16190. */
  16191. name: string;
  16192. /**
  16193. * The emitter represents the Mesh or position we are attaching the particle system to.
  16194. */
  16195. emitter: Nullable<AbstractMesh | Vector3>;
  16196. /**
  16197. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16198. */
  16199. isBillboardBased: boolean;
  16200. /**
  16201. * The rendering group used by the Particle system to chose when to render.
  16202. */
  16203. renderingGroupId: number;
  16204. /**
  16205. * The layer mask we are rendering the particles through.
  16206. */
  16207. layerMask: number;
  16208. /**
  16209. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16210. */
  16211. updateSpeed: number;
  16212. /**
  16213. * The amount of time the particle system is running (depends of the overall update speed).
  16214. */
  16215. targetStopDuration: number;
  16216. /**
  16217. * The texture used to render each particle. (this can be a spritesheet)
  16218. */
  16219. particleTexture: Nullable<Texture>;
  16220. /**
  16221. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16222. */
  16223. blendMode: number;
  16224. /**
  16225. * Minimum life time of emitting particles.
  16226. */
  16227. minLifeTime: number;
  16228. /**
  16229. * Maximum life time of emitting particles.
  16230. */
  16231. maxLifeTime: number;
  16232. /**
  16233. * Minimum Size of emitting particles.
  16234. */
  16235. minSize: number;
  16236. /**
  16237. * Maximum Size of emitting particles.
  16238. */
  16239. maxSize: number;
  16240. /**
  16241. * Minimum scale of emitting particles on X axis.
  16242. */
  16243. minScaleX: number;
  16244. /**
  16245. * Maximum scale of emitting particles on X axis.
  16246. */
  16247. maxScaleX: number;
  16248. /**
  16249. * Minimum scale of emitting particles on Y axis.
  16250. */
  16251. minScaleY: number;
  16252. /**
  16253. * Maximum scale of emitting particles on Y axis.
  16254. */
  16255. maxScaleY: number;
  16256. /**
  16257. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16258. */
  16259. color1: Color4;
  16260. /**
  16261. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16262. */
  16263. color2: Color4;
  16264. /**
  16265. * Color the particle will have at the end of its lifetime.
  16266. */
  16267. colorDead: Color4;
  16268. /**
  16269. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16270. */
  16271. emitRate: number;
  16272. /**
  16273. * You can use gravity if you want to give an orientation to your particles.
  16274. */
  16275. gravity: Vector3;
  16276. /**
  16277. * Minimum power of emitting particles.
  16278. */
  16279. minEmitPower: number;
  16280. /**
  16281. * Maximum power of emitting particles.
  16282. */
  16283. maxEmitPower: number;
  16284. /**
  16285. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16286. */
  16287. minAngularSpeed: number;
  16288. /**
  16289. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16290. */
  16291. maxAngularSpeed: number;
  16292. /**
  16293. * Gets or sets the minimal initial rotation in radians.
  16294. */
  16295. minInitialRotation: number;
  16296. /**
  16297. * Gets or sets the maximal initial rotation in radians.
  16298. */
  16299. maxInitialRotation: number;
  16300. /**
  16301. * The particle emitter type defines the emitter used by the particle system.
  16302. * It can be for example box, sphere, or cone...
  16303. */
  16304. particleEmitterType: Nullable<IParticleEmitterType>;
  16305. /**
  16306. * Defines the delay in milliseconds before starting the system (0 by default)
  16307. */
  16308. startDelay: number;
  16309. /**
  16310. * 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
  16311. */
  16312. preWarmCycles: number;
  16313. /**
  16314. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16315. */
  16316. preWarmStepOffset: number;
  16317. /**
  16318. * 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)
  16319. */
  16320. spriteCellChangeSpeed: number;
  16321. /**
  16322. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16323. */
  16324. startSpriteCellID: number;
  16325. /**
  16326. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16327. */
  16328. endSpriteCellID: number;
  16329. /**
  16330. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16331. */
  16332. spriteCellWidth: number;
  16333. /**
  16334. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16335. */
  16336. spriteCellHeight: number;
  16337. /**
  16338. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16339. */
  16340. spriteRandomStartCell: boolean;
  16341. /**
  16342. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16343. */
  16344. isAnimationSheetEnabled: boolean;
  16345. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16346. translationPivot: Vector2;
  16347. /**
  16348. * Gets or sets a texture used to add random noise to particle positions
  16349. */
  16350. noiseTexture: Nullable<BaseTexture>;
  16351. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16352. noiseStrength: Vector3;
  16353. /**
  16354. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16355. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16356. */
  16357. billboardMode: number;
  16358. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16359. limitVelocityDamping: number;
  16360. /**
  16361. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16362. */
  16363. beginAnimationOnStart: boolean;
  16364. /**
  16365. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16366. */
  16367. beginAnimationFrom: number;
  16368. /**
  16369. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16370. */
  16371. beginAnimationTo: number;
  16372. /**
  16373. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16374. */
  16375. beginAnimationLoop: boolean;
  16376. /**
  16377. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16378. */
  16379. disposeOnStop: boolean;
  16380. /**
  16381. * Gets the maximum number of particles active at the same time.
  16382. * @returns The max number of active particles.
  16383. */
  16384. getCapacity(): number;
  16385. /**
  16386. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16387. * @returns True if it has been started, otherwise false.
  16388. */
  16389. isStarted(): boolean;
  16390. /**
  16391. * Animates the particle system for this frame.
  16392. */
  16393. animate(): void;
  16394. /**
  16395. * Renders the particle system in its current state.
  16396. * @returns the current number of particles
  16397. */
  16398. render(): number;
  16399. /**
  16400. * Dispose the particle system and frees its associated resources.
  16401. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16402. */
  16403. dispose(disposeTexture?: boolean): void;
  16404. /**
  16405. * Clones the particle system.
  16406. * @param name The name of the cloned object
  16407. * @param newEmitter The new emitter to use
  16408. * @returns the cloned particle system
  16409. */
  16410. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16411. /**
  16412. * Serializes the particle system to a JSON object.
  16413. * @returns the JSON object
  16414. */
  16415. serialize(): any;
  16416. /**
  16417. * Rebuild the particle system
  16418. */
  16419. rebuild(): void;
  16420. /**
  16421. * Starts the particle system and begins to emit
  16422. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16423. */
  16424. start(delay?: number): void;
  16425. /**
  16426. * Stops the particle system.
  16427. */
  16428. stop(): void;
  16429. /**
  16430. * Remove all active particles
  16431. */
  16432. reset(): void;
  16433. /**
  16434. * Is this system ready to be used/rendered
  16435. * @return true if the system is ready
  16436. */
  16437. isReady(): boolean;
  16438. /**
  16439. * Adds a new color gradient
  16440. * @param gradient defines the gradient to use (between 0 and 1)
  16441. * @param color1 defines the color to affect to the specified gradient
  16442. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16443. * @returns the current particle system
  16444. */
  16445. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16446. /**
  16447. * Remove a specific color gradient
  16448. * @param gradient defines the gradient to remove
  16449. * @returns the current particle system
  16450. */
  16451. removeColorGradient(gradient: number): IParticleSystem;
  16452. /**
  16453. * Adds a new size gradient
  16454. * @param gradient defines the gradient to use (between 0 and 1)
  16455. * @param factor defines the size factor to affect to the specified gradient
  16456. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16457. * @returns the current particle system
  16458. */
  16459. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16460. /**
  16461. * Remove a specific size gradient
  16462. * @param gradient defines the gradient to remove
  16463. * @returns the current particle system
  16464. */
  16465. removeSizeGradient(gradient: number): IParticleSystem;
  16466. /**
  16467. * Gets the current list of color gradients.
  16468. * You must use addColorGradient and removeColorGradient to udpate this list
  16469. * @returns the list of color gradients
  16470. */
  16471. getColorGradients(): Nullable<Array<ColorGradient>>;
  16472. /**
  16473. * Gets the current list of size gradients.
  16474. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16475. * @returns the list of size gradients
  16476. */
  16477. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16478. /**
  16479. * Gets the current list of angular speed gradients.
  16480. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16481. * @returns the list of angular speed gradients
  16482. */
  16483. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16484. /**
  16485. * Adds a new angular speed gradient
  16486. * @param gradient defines the gradient to use (between 0 and 1)
  16487. * @param factor defines the angular speed to affect to the specified gradient
  16488. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16489. * @returns the current particle system
  16490. */
  16491. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16492. /**
  16493. * Remove a specific angular speed gradient
  16494. * @param gradient defines the gradient to remove
  16495. * @returns the current particle system
  16496. */
  16497. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16498. /**
  16499. * Gets the current list of velocity gradients.
  16500. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16501. * @returns the list of velocity gradients
  16502. */
  16503. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16504. /**
  16505. * Adds a new velocity gradient
  16506. * @param gradient defines the gradient to use (between 0 and 1)
  16507. * @param factor defines the velocity to affect to the specified gradient
  16508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16509. * @returns the current particle system
  16510. */
  16511. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16512. /**
  16513. * Remove a specific velocity gradient
  16514. * @param gradient defines the gradient to remove
  16515. * @returns the current particle system
  16516. */
  16517. removeVelocityGradient(gradient: number): IParticleSystem;
  16518. /**
  16519. * Gets the current list of limit velocity gradients.
  16520. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16521. * @returns the list of limit velocity gradients
  16522. */
  16523. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16524. /**
  16525. * Adds a new limit velocity gradient
  16526. * @param gradient defines the gradient to use (between 0 and 1)
  16527. * @param factor defines the limit velocity to affect to the specified gradient
  16528. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16529. * @returns the current particle system
  16530. */
  16531. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16532. /**
  16533. * Remove a specific limit velocity gradient
  16534. * @param gradient defines the gradient to remove
  16535. * @returns the current particle system
  16536. */
  16537. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16538. /**
  16539. * Adds a new drag gradient
  16540. * @param gradient defines the gradient to use (between 0 and 1)
  16541. * @param factor defines the drag to affect to the specified gradient
  16542. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16543. * @returns the current particle system
  16544. */
  16545. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16546. /**
  16547. * Remove a specific drag gradient
  16548. * @param gradient defines the gradient to remove
  16549. * @returns the current particle system
  16550. */
  16551. removeDragGradient(gradient: number): IParticleSystem;
  16552. /**
  16553. * Gets the current list of drag gradients.
  16554. * You must use addDragGradient and removeDragGradient to udpate this list
  16555. * @returns the list of drag gradients
  16556. */
  16557. getDragGradients(): Nullable<Array<FactorGradient>>;
  16558. /**
  16559. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16560. * @param gradient defines the gradient to use (between 0 and 1)
  16561. * @param factor defines the emit rate to affect to the specified gradient
  16562. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16563. * @returns the current particle system
  16564. */
  16565. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16566. /**
  16567. * Remove a specific emit rate gradient
  16568. * @param gradient defines the gradient to remove
  16569. * @returns the current particle system
  16570. */
  16571. removeEmitRateGradient(gradient: number): IParticleSystem;
  16572. /**
  16573. * Gets the current list of emit rate gradients.
  16574. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16575. * @returns the list of emit rate gradients
  16576. */
  16577. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16578. /**
  16579. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16580. * @param gradient defines the gradient to use (between 0 and 1)
  16581. * @param factor defines the start size to affect to the specified gradient
  16582. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16583. * @returns the current particle system
  16584. */
  16585. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16586. /**
  16587. * Remove a specific start size gradient
  16588. * @param gradient defines the gradient to remove
  16589. * @returns the current particle system
  16590. */
  16591. removeStartSizeGradient(gradient: number): IParticleSystem;
  16592. /**
  16593. * Gets the current list of start size gradients.
  16594. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16595. * @returns the list of start size gradients
  16596. */
  16597. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16598. /**
  16599. * Adds a new life time gradient
  16600. * @param gradient defines the gradient to use (between 0 and 1)
  16601. * @param factor defines the life time factor to affect to the specified gradient
  16602. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16603. * @returns the current particle system
  16604. */
  16605. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16606. /**
  16607. * Remove a specific life time gradient
  16608. * @param gradient defines the gradient to remove
  16609. * @returns the current particle system
  16610. */
  16611. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16612. /**
  16613. * Gets the current list of life time gradients.
  16614. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16615. * @returns the list of life time gradients
  16616. */
  16617. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16618. /**
  16619. * Gets the current list of color gradients.
  16620. * You must use addColorGradient and removeColorGradient to udpate this list
  16621. * @returns the list of color gradients
  16622. */
  16623. getColorGradients(): Nullable<Array<ColorGradient>>;
  16624. /**
  16625. * Adds a new ramp gradient used to remap particle colors
  16626. * @param gradient defines the gradient to use (between 0 and 1)
  16627. * @param color defines the color to affect to the specified gradient
  16628. * @returns the current particle system
  16629. */
  16630. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16631. /**
  16632. * Gets the current list of ramp gradients.
  16633. * You must use addRampGradient and removeRampGradient to udpate this list
  16634. * @returns the list of ramp gradients
  16635. */
  16636. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16637. /** Gets or sets a boolean indicating that ramp gradients must be used
  16638. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16639. */
  16640. useRampGradients: boolean;
  16641. /**
  16642. * Adds a new color remap gradient
  16643. * @param gradient defines the gradient to use (between 0 and 1)
  16644. * @param min defines the color remap minimal range
  16645. * @param max defines the color remap maximal range
  16646. * @returns the current particle system
  16647. */
  16648. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16649. /**
  16650. * Gets the current list of color remap gradients.
  16651. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16652. * @returns the list of color remap gradients
  16653. */
  16654. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16655. /**
  16656. * Adds a new alpha remap gradient
  16657. * @param gradient defines the gradient to use (between 0 and 1)
  16658. * @param min defines the alpha remap minimal range
  16659. * @param max defines the alpha remap maximal range
  16660. * @returns the current particle system
  16661. */
  16662. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16663. /**
  16664. * Gets the current list of alpha remap gradients.
  16665. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16666. * @returns the list of alpha remap gradients
  16667. */
  16668. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16669. /**
  16670. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16671. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16672. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16673. * @returns the emitter
  16674. */
  16675. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16676. /**
  16677. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16678. * @param radius The radius of the hemisphere to emit from
  16679. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16680. * @returns the emitter
  16681. */
  16682. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16683. /**
  16684. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16685. * @param radius The radius of the sphere to emit from
  16686. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16687. * @returns the emitter
  16688. */
  16689. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16690. /**
  16691. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16692. * @param radius The radius of the sphere to emit from
  16693. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16694. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16695. * @returns the emitter
  16696. */
  16697. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16698. /**
  16699. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16700. * @param radius The radius of the emission cylinder
  16701. * @param height The height of the emission cylinder
  16702. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16703. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16704. * @returns the emitter
  16705. */
  16706. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16707. /**
  16708. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16709. * @param radius The radius of the cylinder to emit from
  16710. * @param height The height of the emission cylinder
  16711. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16712. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16713. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16714. * @returns the emitter
  16715. */
  16716. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16717. /**
  16718. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16719. * @param radius The radius of the cone to emit from
  16720. * @param angle The base angle of the cone
  16721. * @returns the emitter
  16722. */
  16723. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16724. /**
  16725. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16726. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16727. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16728. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16729. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16730. * @returns the emitter
  16731. */
  16732. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16733. /**
  16734. * Get hosting scene
  16735. * @returns the scene
  16736. */
  16737. getScene(): Scene;
  16738. }
  16739. }
  16740. declare module BABYLON {
  16741. /**
  16742. * Creates an instance based on a source mesh.
  16743. */
  16744. export class InstancedMesh extends AbstractMesh {
  16745. private _sourceMesh;
  16746. private _currentLOD;
  16747. /** @hidden */
  16748. _indexInSourceMeshInstanceArray: number;
  16749. constructor(name: string, source: Mesh);
  16750. /**
  16751. * Returns the string "InstancedMesh".
  16752. */
  16753. getClassName(): string;
  16754. /** Gets the list of lights affecting that mesh */
  16755. readonly lightSources: Light[];
  16756. _resyncLightSources(): void;
  16757. _resyncLighSource(light: Light): void;
  16758. _removeLightSource(light: Light): void;
  16759. /**
  16760. * If the source mesh receives shadows
  16761. */
  16762. readonly receiveShadows: boolean;
  16763. /**
  16764. * The material of the source mesh
  16765. */
  16766. readonly material: Nullable<Material>;
  16767. /**
  16768. * Visibility of the source mesh
  16769. */
  16770. readonly visibility: number;
  16771. /**
  16772. * Skeleton of the source mesh
  16773. */
  16774. readonly skeleton: Nullable<Skeleton>;
  16775. /**
  16776. * Rendering ground id of the source mesh
  16777. */
  16778. renderingGroupId: number;
  16779. /**
  16780. * Returns the total number of vertices (integer).
  16781. */
  16782. getTotalVertices(): number;
  16783. /**
  16784. * Returns a positive integer : the total number of indices in this mesh geometry.
  16785. * @returns the numner of indices or zero if the mesh has no geometry.
  16786. */
  16787. getTotalIndices(): number;
  16788. /**
  16789. * The source mesh of the instance
  16790. */
  16791. readonly sourceMesh: Mesh;
  16792. /**
  16793. * Is this node ready to be used/rendered
  16794. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16795. * @return {boolean} is it ready
  16796. */
  16797. isReady(completeCheck?: boolean): boolean;
  16798. /**
  16799. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16800. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16801. * @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.
  16802. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16803. */
  16804. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16805. /**
  16806. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16807. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16808. * The `data` are either a numeric array either a Float32Array.
  16809. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16810. * 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).
  16811. * Note that a new underlying VertexBuffer object is created each call.
  16812. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16813. *
  16814. * Possible `kind` values :
  16815. * - VertexBuffer.PositionKind
  16816. * - VertexBuffer.UVKind
  16817. * - VertexBuffer.UV2Kind
  16818. * - VertexBuffer.UV3Kind
  16819. * - VertexBuffer.UV4Kind
  16820. * - VertexBuffer.UV5Kind
  16821. * - VertexBuffer.UV6Kind
  16822. * - VertexBuffer.ColorKind
  16823. * - VertexBuffer.MatricesIndicesKind
  16824. * - VertexBuffer.MatricesIndicesExtraKind
  16825. * - VertexBuffer.MatricesWeightsKind
  16826. * - VertexBuffer.MatricesWeightsExtraKind
  16827. *
  16828. * Returns the Mesh.
  16829. */
  16830. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16831. /**
  16832. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16833. * If the mesh has no geometry, it is simply returned as it is.
  16834. * The `data` are either a numeric array either a Float32Array.
  16835. * No new underlying VertexBuffer object is created.
  16836. * 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.
  16837. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16838. *
  16839. * Possible `kind` values :
  16840. * - VertexBuffer.PositionKind
  16841. * - VertexBuffer.UVKind
  16842. * - VertexBuffer.UV2Kind
  16843. * - VertexBuffer.UV3Kind
  16844. * - VertexBuffer.UV4Kind
  16845. * - VertexBuffer.UV5Kind
  16846. * - VertexBuffer.UV6Kind
  16847. * - VertexBuffer.ColorKind
  16848. * - VertexBuffer.MatricesIndicesKind
  16849. * - VertexBuffer.MatricesIndicesExtraKind
  16850. * - VertexBuffer.MatricesWeightsKind
  16851. * - VertexBuffer.MatricesWeightsExtraKind
  16852. *
  16853. * Returns the Mesh.
  16854. */
  16855. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16856. /**
  16857. * Sets the mesh indices.
  16858. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16859. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16860. * This method creates a new index buffer each call.
  16861. * Returns the Mesh.
  16862. */
  16863. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16864. /**
  16865. * Boolean : True if the mesh owns the requested kind of data.
  16866. */
  16867. isVerticesDataPresent(kind: string): boolean;
  16868. /**
  16869. * Returns an array of indices (IndicesArray).
  16870. */
  16871. getIndices(): Nullable<IndicesArray>;
  16872. readonly _positions: Nullable<Vector3[]>;
  16873. /**
  16874. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16875. * This means the mesh underlying bounding box and sphere are recomputed.
  16876. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16877. * @returns the current mesh
  16878. */
  16879. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16880. /** @hidden */
  16881. _preActivate(): InstancedMesh;
  16882. /** @hidden */
  16883. _activate(renderId: number): boolean;
  16884. /** @hidden */
  16885. _postActivate(): void;
  16886. getWorldMatrix(): Matrix;
  16887. readonly isAnInstance: boolean;
  16888. /**
  16889. * Returns the current associated LOD AbstractMesh.
  16890. */
  16891. getLOD(camera: Camera): AbstractMesh;
  16892. /** @hidden */
  16893. _syncSubMeshes(): InstancedMesh;
  16894. /** @hidden */
  16895. _generatePointsArray(): boolean;
  16896. /**
  16897. * Creates a new InstancedMesh from the current mesh.
  16898. * - name (string) : the cloned mesh name
  16899. * - newParent (optional Node) : the optional Node to parent the clone to.
  16900. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16901. *
  16902. * Returns the clone.
  16903. */
  16904. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16905. /**
  16906. * Disposes the InstancedMesh.
  16907. * Returns nothing.
  16908. */
  16909. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16910. }
  16911. }
  16912. declare module BABYLON {
  16913. /**
  16914. * Defines the options associated with the creation of a shader material.
  16915. */
  16916. export interface IShaderMaterialOptions {
  16917. /**
  16918. * Does the material work in alpha blend mode
  16919. */
  16920. needAlphaBlending: boolean;
  16921. /**
  16922. * Does the material work in alpha test mode
  16923. */
  16924. needAlphaTesting: boolean;
  16925. /**
  16926. * The list of attribute names used in the shader
  16927. */
  16928. attributes: string[];
  16929. /**
  16930. * The list of unifrom names used in the shader
  16931. */
  16932. uniforms: string[];
  16933. /**
  16934. * The list of UBO names used in the shader
  16935. */
  16936. uniformBuffers: string[];
  16937. /**
  16938. * The list of sampler names used in the shader
  16939. */
  16940. samplers: string[];
  16941. /**
  16942. * The list of defines used in the shader
  16943. */
  16944. defines: string[];
  16945. }
  16946. /**
  16947. * 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.
  16948. *
  16949. * This returned material effects how the mesh will look based on the code in the shaders.
  16950. *
  16951. * @see http://doc.babylonjs.com/how_to/shader_material
  16952. */
  16953. export class ShaderMaterial extends Material {
  16954. private _shaderPath;
  16955. private _options;
  16956. private _textures;
  16957. private _textureArrays;
  16958. private _floats;
  16959. private _ints;
  16960. private _floatsArrays;
  16961. private _colors3;
  16962. private _colors3Arrays;
  16963. private _colors4;
  16964. private _vectors2;
  16965. private _vectors3;
  16966. private _vectors4;
  16967. private _matrices;
  16968. private _matrices3x3;
  16969. private _matrices2x2;
  16970. private _vectors2Arrays;
  16971. private _vectors3Arrays;
  16972. private _cachedWorldViewMatrix;
  16973. private _renderId;
  16974. /**
  16975. * Instantiate a new shader material.
  16976. * 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.
  16977. * This returned material effects how the mesh will look based on the code in the shaders.
  16978. * @see http://doc.babylonjs.com/how_to/shader_material
  16979. * @param name Define the name of the material in the scene
  16980. * @param scene Define the scene the material belongs to
  16981. * @param shaderPath Defines the route to the shader code in one of three ways:
  16982. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16983. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16984. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16985. * @param options Define the options used to create the shader
  16986. */
  16987. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16988. /**
  16989. * Gets the options used to compile the shader.
  16990. * They can be modified to trigger a new compilation
  16991. */
  16992. readonly options: IShaderMaterialOptions;
  16993. /**
  16994. * Gets the current class name of the material e.g. "ShaderMaterial"
  16995. * Mainly use in serialization.
  16996. * @returns the class name
  16997. */
  16998. getClassName(): string;
  16999. /**
  17000. * Specifies if the material will require alpha blending
  17001. * @returns a boolean specifying if alpha blending is needed
  17002. */
  17003. needAlphaBlending(): boolean;
  17004. /**
  17005. * Specifies if this material should be rendered in alpha test mode
  17006. * @returns a boolean specifying if an alpha test is needed.
  17007. */
  17008. needAlphaTesting(): boolean;
  17009. private _checkUniform;
  17010. /**
  17011. * Set a texture in the shader.
  17012. * @param name Define the name of the uniform samplers as defined in the shader
  17013. * @param texture Define the texture to bind to this sampler
  17014. * @return the material itself allowing "fluent" like uniform updates
  17015. */
  17016. setTexture(name: string, texture: Texture): ShaderMaterial;
  17017. /**
  17018. * Set a texture array in the shader.
  17019. * @param name Define the name of the uniform sampler array as defined in the shader
  17020. * @param textures Define the list of textures to bind to this sampler
  17021. * @return the material itself allowing "fluent" like uniform updates
  17022. */
  17023. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17024. /**
  17025. * Set a float in the shader.
  17026. * @param name Define the name of the uniform as defined in the shader
  17027. * @param value Define the value to give to the uniform
  17028. * @return the material itself allowing "fluent" like uniform updates
  17029. */
  17030. setFloat(name: string, value: number): ShaderMaterial;
  17031. /**
  17032. * Set a int in the shader.
  17033. * @param name Define the name of the uniform as defined in the shader
  17034. * @param value Define the value to give to the uniform
  17035. * @return the material itself allowing "fluent" like uniform updates
  17036. */
  17037. setInt(name: string, value: number): ShaderMaterial;
  17038. /**
  17039. * Set an array of floats in the shader.
  17040. * @param name Define the name of the uniform as defined in the shader
  17041. * @param value Define the value to give to the uniform
  17042. * @return the material itself allowing "fluent" like uniform updates
  17043. */
  17044. setFloats(name: string, value: number[]): ShaderMaterial;
  17045. /**
  17046. * Set a vec3 in the shader from a Color3.
  17047. * @param name Define the name of the uniform as defined in the shader
  17048. * @param value Define the value to give to the uniform
  17049. * @return the material itself allowing "fluent" like uniform updates
  17050. */
  17051. setColor3(name: string, value: Color3): ShaderMaterial;
  17052. /**
  17053. * Set a vec3 array in the shader from a Color3 array.
  17054. * @param name Define the name of the uniform as defined in the shader
  17055. * @param value Define the value to give to the uniform
  17056. * @return the material itself allowing "fluent" like uniform updates
  17057. */
  17058. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17059. /**
  17060. * Set a vec4 in the shader from a Color4.
  17061. * @param name Define the name of the uniform as defined in the shader
  17062. * @param value Define the value to give to the uniform
  17063. * @return the material itself allowing "fluent" like uniform updates
  17064. */
  17065. setColor4(name: string, value: Color4): ShaderMaterial;
  17066. /**
  17067. * Set a vec2 in the shader from a Vector2.
  17068. * @param name Define the name of the uniform as defined in the shader
  17069. * @param value Define the value to give to the uniform
  17070. * @return the material itself allowing "fluent" like uniform updates
  17071. */
  17072. setVector2(name: string, value: Vector2): ShaderMaterial;
  17073. /**
  17074. * Set a vec3 in the shader from a Vector3.
  17075. * @param name Define the name of the uniform as defined in the shader
  17076. * @param value Define the value to give to the uniform
  17077. * @return the material itself allowing "fluent" like uniform updates
  17078. */
  17079. setVector3(name: string, value: Vector3): ShaderMaterial;
  17080. /**
  17081. * Set a vec4 in the shader from a Vector4.
  17082. * @param name Define the name of the uniform as defined in the shader
  17083. * @param value Define the value to give to the uniform
  17084. * @return the material itself allowing "fluent" like uniform updates
  17085. */
  17086. setVector4(name: string, value: Vector4): ShaderMaterial;
  17087. /**
  17088. * Set a mat4 in the shader from a Matrix.
  17089. * @param name Define the name of the uniform as defined in the shader
  17090. * @param value Define the value to give to the uniform
  17091. * @return the material itself allowing "fluent" like uniform updates
  17092. */
  17093. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17094. /**
  17095. * Set a mat3 in the shader from a Float32Array.
  17096. * @param name Define the name of the uniform as defined in the shader
  17097. * @param value Define the value to give to the uniform
  17098. * @return the material itself allowing "fluent" like uniform updates
  17099. */
  17100. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17101. /**
  17102. * Set a mat2 in the shader from a Float32Array.
  17103. * @param name Define the name of the uniform as defined in the shader
  17104. * @param value Define the value to give to the uniform
  17105. * @return the material itself allowing "fluent" like uniform updates
  17106. */
  17107. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17108. /**
  17109. * Set a vec2 array in the shader from a number array.
  17110. * @param name Define the name of the uniform as defined in the shader
  17111. * @param value Define the value to give to the uniform
  17112. * @return the material itself allowing "fluent" like uniform updates
  17113. */
  17114. setArray2(name: string, value: number[]): ShaderMaterial;
  17115. /**
  17116. * Set a vec3 array in the shader from a number array.
  17117. * @param name Define the name of the uniform as defined in the shader
  17118. * @param value Define the value to give to the uniform
  17119. * @return the material itself allowing "fluent" like uniform updates
  17120. */
  17121. setArray3(name: string, value: number[]): ShaderMaterial;
  17122. private _checkCache;
  17123. /**
  17124. * Specifies that the submesh is ready to be used
  17125. * @param mesh defines the mesh to check
  17126. * @param subMesh defines which submesh to check
  17127. * @param useInstances specifies that instances should be used
  17128. * @returns a boolean indicating that the submesh is ready or not
  17129. */
  17130. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17131. /**
  17132. * Checks if the material is ready to render the requested mesh
  17133. * @param mesh Define the mesh to render
  17134. * @param useInstances Define whether or not the material is used with instances
  17135. * @returns true if ready, otherwise false
  17136. */
  17137. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17138. /**
  17139. * Binds the world matrix to the material
  17140. * @param world defines the world transformation matrix
  17141. */
  17142. bindOnlyWorldMatrix(world: Matrix): void;
  17143. /**
  17144. * Binds the material to the mesh
  17145. * @param world defines the world transformation matrix
  17146. * @param mesh defines the mesh to bind the material to
  17147. */
  17148. bind(world: Matrix, mesh?: Mesh): void;
  17149. /**
  17150. * Gets the active textures from the material
  17151. * @returns an array of textures
  17152. */
  17153. getActiveTextures(): BaseTexture[];
  17154. /**
  17155. * Specifies if the material uses a texture
  17156. * @param texture defines the texture to check against the material
  17157. * @returns a boolean specifying if the material uses the texture
  17158. */
  17159. hasTexture(texture: BaseTexture): boolean;
  17160. /**
  17161. * Makes a duplicate of the material, and gives it a new name
  17162. * @param name defines the new name for the duplicated material
  17163. * @returns the cloned material
  17164. */
  17165. clone(name: string): ShaderMaterial;
  17166. /**
  17167. * Disposes the material
  17168. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17169. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17170. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17171. */
  17172. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17173. /**
  17174. * Serializes this material in a JSON representation
  17175. * @returns the serialized material object
  17176. */
  17177. serialize(): any;
  17178. /**
  17179. * Creates a shader material from parsed shader material data
  17180. * @param source defines the JSON represnetation of the material
  17181. * @param scene defines the hosting scene
  17182. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17183. * @returns a new material
  17184. */
  17185. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17186. }
  17187. }
  17188. declare module BABYLON {
  17189. /** @hidden */
  17190. export var colorPixelShader: {
  17191. name: string;
  17192. shader: string;
  17193. };
  17194. }
  17195. declare module BABYLON {
  17196. /** @hidden */
  17197. export var colorVertexShader: {
  17198. name: string;
  17199. shader: string;
  17200. };
  17201. }
  17202. declare module BABYLON {
  17203. /**
  17204. * Line mesh
  17205. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17206. */
  17207. export class LinesMesh extends Mesh {
  17208. /**
  17209. * If vertex color should be applied to the mesh
  17210. */
  17211. useVertexColor?: boolean | undefined;
  17212. /**
  17213. * If vertex alpha should be applied to the mesh
  17214. */
  17215. useVertexAlpha?: boolean | undefined;
  17216. /**
  17217. * Color of the line (Default: White)
  17218. */
  17219. color: Color3;
  17220. /**
  17221. * Alpha of the line (Default: 1)
  17222. */
  17223. alpha: number;
  17224. /**
  17225. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17226. * This margin is expressed in world space coordinates, so its value may vary.
  17227. * Default value is 0.1
  17228. */
  17229. intersectionThreshold: number;
  17230. private _colorShader;
  17231. /**
  17232. * Creates a new LinesMesh
  17233. * @param name defines the name
  17234. * @param scene defines the hosting scene
  17235. * @param parent defines the parent mesh if any
  17236. * @param source defines the optional source LinesMesh used to clone data from
  17237. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17238. * When false, achieved by calling a clone(), also passing False.
  17239. * This will make creation of children, recursive.
  17240. * @param useVertexColor defines if this LinesMesh supports vertex color
  17241. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17242. */
  17243. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17244. /**
  17245. * If vertex color should be applied to the mesh
  17246. */
  17247. useVertexColor?: boolean | undefined,
  17248. /**
  17249. * If vertex alpha should be applied to the mesh
  17250. */
  17251. useVertexAlpha?: boolean | undefined);
  17252. private _addClipPlaneDefine;
  17253. private _removeClipPlaneDefine;
  17254. isReady(): boolean;
  17255. /**
  17256. * Returns the string "LineMesh"
  17257. */
  17258. getClassName(): string;
  17259. /**
  17260. * @hidden
  17261. */
  17262. /**
  17263. * @hidden
  17264. */
  17265. material: Material;
  17266. /**
  17267. * @hidden
  17268. */
  17269. readonly checkCollisions: boolean;
  17270. /** @hidden */
  17271. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17272. /** @hidden */
  17273. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17274. /**
  17275. * Disposes of the line mesh
  17276. * @param doNotRecurse If children should be disposed
  17277. */
  17278. dispose(doNotRecurse?: boolean): void;
  17279. /**
  17280. * Returns a new LineMesh object cloned from the current one.
  17281. */
  17282. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17283. /**
  17284. * Creates a new InstancedLinesMesh object from the mesh model.
  17285. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17286. * @param name defines the name of the new instance
  17287. * @returns a new InstancedLinesMesh
  17288. */
  17289. createInstance(name: string): InstancedLinesMesh;
  17290. }
  17291. /**
  17292. * Creates an instance based on a source LinesMesh
  17293. */
  17294. export class InstancedLinesMesh extends InstancedMesh {
  17295. /**
  17296. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17297. * This margin is expressed in world space coordinates, so its value may vary.
  17298. * Initilized with the intersectionThreshold value of the source LinesMesh
  17299. */
  17300. intersectionThreshold: number;
  17301. constructor(name: string, source: LinesMesh);
  17302. /**
  17303. * Returns the string "InstancedLinesMesh".
  17304. */
  17305. getClassName(): string;
  17306. }
  17307. }
  17308. declare module BABYLON {
  17309. /** @hidden */
  17310. export var linePixelShader: {
  17311. name: string;
  17312. shader: string;
  17313. };
  17314. }
  17315. declare module BABYLON {
  17316. /** @hidden */
  17317. export var lineVertexShader: {
  17318. name: string;
  17319. shader: string;
  17320. };
  17321. }
  17322. declare module BABYLON {
  17323. interface AbstractMesh {
  17324. /**
  17325. * Disables the mesh edge rendering mode
  17326. * @returns the currentAbstractMesh
  17327. */
  17328. disableEdgesRendering(): AbstractMesh;
  17329. /**
  17330. * Enables the edge rendering mode on the mesh.
  17331. * This mode makes the mesh edges visible
  17332. * @param epsilon defines the maximal distance between two angles to detect a face
  17333. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17334. * @returns the currentAbstractMesh
  17335. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17336. */
  17337. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17338. /**
  17339. * Gets the edgesRenderer associated with the mesh
  17340. */
  17341. edgesRenderer: Nullable<EdgesRenderer>;
  17342. }
  17343. interface LinesMesh {
  17344. /**
  17345. * Enables the edge rendering mode on the mesh.
  17346. * This mode makes the mesh edges visible
  17347. * @param epsilon defines the maximal distance between two angles to detect a face
  17348. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17349. * @returns the currentAbstractMesh
  17350. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17351. */
  17352. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17353. }
  17354. interface InstancedLinesMesh {
  17355. /**
  17356. * Enables the edge rendering mode on the mesh.
  17357. * This mode makes the mesh edges visible
  17358. * @param epsilon defines the maximal distance between two angles to detect a face
  17359. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17360. * @returns the current InstancedLinesMesh
  17361. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17362. */
  17363. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17364. }
  17365. /**
  17366. * Defines the minimum contract an Edges renderer should follow.
  17367. */
  17368. export interface IEdgesRenderer extends IDisposable {
  17369. /**
  17370. * Gets or sets a boolean indicating if the edgesRenderer is active
  17371. */
  17372. isEnabled: boolean;
  17373. /**
  17374. * Renders the edges of the attached mesh,
  17375. */
  17376. render(): void;
  17377. /**
  17378. * Checks wether or not the edges renderer is ready to render.
  17379. * @return true if ready, otherwise false.
  17380. */
  17381. isReady(): boolean;
  17382. }
  17383. /**
  17384. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17385. */
  17386. export class EdgesRenderer implements IEdgesRenderer {
  17387. /**
  17388. * Define the size of the edges with an orthographic camera
  17389. */
  17390. edgesWidthScalerForOrthographic: number;
  17391. /**
  17392. * Define the size of the edges with a perspective camera
  17393. */
  17394. edgesWidthScalerForPerspective: number;
  17395. protected _source: AbstractMesh;
  17396. protected _linesPositions: number[];
  17397. protected _linesNormals: number[];
  17398. protected _linesIndices: number[];
  17399. protected _epsilon: number;
  17400. protected _indicesCount: number;
  17401. protected _lineShader: ShaderMaterial;
  17402. protected _ib: DataBuffer;
  17403. protected _buffers: {
  17404. [key: string]: Nullable<VertexBuffer>;
  17405. };
  17406. protected _checkVerticesInsteadOfIndices: boolean;
  17407. private _meshRebuildObserver;
  17408. private _meshDisposeObserver;
  17409. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17410. isEnabled: boolean;
  17411. /**
  17412. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17413. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17414. * @param source Mesh used to create edges
  17415. * @param epsilon sum of angles in adjacency to check for edge
  17416. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17417. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17418. */
  17419. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17420. protected _prepareRessources(): void;
  17421. /** @hidden */
  17422. _rebuild(): void;
  17423. /**
  17424. * Releases the required resources for the edges renderer
  17425. */
  17426. dispose(): void;
  17427. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17428. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17429. /**
  17430. * Checks if the pair of p0 and p1 is en edge
  17431. * @param faceIndex
  17432. * @param edge
  17433. * @param faceNormals
  17434. * @param p0
  17435. * @param p1
  17436. * @private
  17437. */
  17438. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17439. /**
  17440. * push line into the position, normal and index buffer
  17441. * @protected
  17442. */
  17443. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17444. /**
  17445. * Generates lines edges from adjacencjes
  17446. * @private
  17447. */
  17448. _generateEdgesLines(): void;
  17449. /**
  17450. * Checks wether or not the edges renderer is ready to render.
  17451. * @return true if ready, otherwise false.
  17452. */
  17453. isReady(): boolean;
  17454. /**
  17455. * Renders the edges of the attached mesh,
  17456. */
  17457. render(): void;
  17458. }
  17459. /**
  17460. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17461. */
  17462. export class LineEdgesRenderer extends EdgesRenderer {
  17463. /**
  17464. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17465. * @param source LineMesh used to generate edges
  17466. * @param epsilon not important (specified angle for edge detection)
  17467. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17468. */
  17469. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17470. /**
  17471. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17472. */
  17473. _generateEdgesLines(): void;
  17474. }
  17475. }
  17476. declare module BABYLON {
  17477. /**
  17478. * This represents the object necessary to create a rendering group.
  17479. * This is exclusively used and created by the rendering manager.
  17480. * To modify the behavior, you use the available helpers in your scene or meshes.
  17481. * @hidden
  17482. */
  17483. export class RenderingGroup {
  17484. index: number;
  17485. private _scene;
  17486. private _opaqueSubMeshes;
  17487. private _transparentSubMeshes;
  17488. private _alphaTestSubMeshes;
  17489. private _depthOnlySubMeshes;
  17490. private _particleSystems;
  17491. private _spriteManagers;
  17492. private _opaqueSortCompareFn;
  17493. private _alphaTestSortCompareFn;
  17494. private _transparentSortCompareFn;
  17495. private _renderOpaque;
  17496. private _renderAlphaTest;
  17497. private _renderTransparent;
  17498. /** @hidden */
  17499. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17500. onBeforeTransparentRendering: () => void;
  17501. /**
  17502. * Set the opaque sort comparison function.
  17503. * If null the sub meshes will be render in the order they were created
  17504. */
  17505. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17506. /**
  17507. * Set the alpha test sort comparison function.
  17508. * If null the sub meshes will be render in the order they were created
  17509. */
  17510. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17511. /**
  17512. * Set the transparent sort comparison function.
  17513. * If null the sub meshes will be render in the order they were created
  17514. */
  17515. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17516. /**
  17517. * Creates a new rendering group.
  17518. * @param index The rendering group index
  17519. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17520. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17521. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17522. */
  17523. 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>);
  17524. /**
  17525. * Render all the sub meshes contained in the group.
  17526. * @param customRenderFunction Used to override the default render behaviour of the group.
  17527. * @returns true if rendered some submeshes.
  17528. */
  17529. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17530. /**
  17531. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17532. * @param subMeshes The submeshes to render
  17533. */
  17534. private renderOpaqueSorted;
  17535. /**
  17536. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17537. * @param subMeshes The submeshes to render
  17538. */
  17539. private renderAlphaTestSorted;
  17540. /**
  17541. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17542. * @param subMeshes The submeshes to render
  17543. */
  17544. private renderTransparentSorted;
  17545. /**
  17546. * Renders the submeshes in a specified order.
  17547. * @param subMeshes The submeshes to sort before render
  17548. * @param sortCompareFn The comparison function use to sort
  17549. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17550. * @param transparent Specifies to activate blending if true
  17551. */
  17552. private static renderSorted;
  17553. /**
  17554. * Renders the submeshes in the order they were dispatched (no sort applied).
  17555. * @param subMeshes The submeshes to render
  17556. */
  17557. private static renderUnsorted;
  17558. /**
  17559. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17560. * are rendered back to front if in the same alpha index.
  17561. *
  17562. * @param a The first submesh
  17563. * @param b The second submesh
  17564. * @returns The result of the comparison
  17565. */
  17566. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17567. /**
  17568. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17569. * are rendered back to front.
  17570. *
  17571. * @param a The first submesh
  17572. * @param b The second submesh
  17573. * @returns The result of the comparison
  17574. */
  17575. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17576. /**
  17577. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17578. * are rendered front to back (prevent overdraw).
  17579. *
  17580. * @param a The first submesh
  17581. * @param b The second submesh
  17582. * @returns The result of the comparison
  17583. */
  17584. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17585. /**
  17586. * Resets the different lists of submeshes to prepare a new frame.
  17587. */
  17588. prepare(): void;
  17589. dispose(): void;
  17590. /**
  17591. * Inserts the submesh in its correct queue depending on its material.
  17592. * @param subMesh The submesh to dispatch
  17593. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17594. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17595. */
  17596. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17597. dispatchSprites(spriteManager: ISpriteManager): void;
  17598. dispatchParticles(particleSystem: IParticleSystem): void;
  17599. private _renderParticles;
  17600. private _renderSprites;
  17601. }
  17602. }
  17603. declare module BABYLON {
  17604. /**
  17605. * Interface describing the different options available in the rendering manager
  17606. * regarding Auto Clear between groups.
  17607. */
  17608. export interface IRenderingManagerAutoClearSetup {
  17609. /**
  17610. * Defines whether or not autoclear is enable.
  17611. */
  17612. autoClear: boolean;
  17613. /**
  17614. * Defines whether or not to autoclear the depth buffer.
  17615. */
  17616. depth: boolean;
  17617. /**
  17618. * Defines whether or not to autoclear the stencil buffer.
  17619. */
  17620. stencil: boolean;
  17621. }
  17622. /**
  17623. * This class is used by the onRenderingGroupObservable
  17624. */
  17625. export class RenderingGroupInfo {
  17626. /**
  17627. * The Scene that being rendered
  17628. */
  17629. scene: Scene;
  17630. /**
  17631. * The camera currently used for the rendering pass
  17632. */
  17633. camera: Nullable<Camera>;
  17634. /**
  17635. * The ID of the renderingGroup being processed
  17636. */
  17637. renderingGroupId: number;
  17638. }
  17639. /**
  17640. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17641. * It is enable to manage the different groups as well as the different necessary sort functions.
  17642. * This should not be used directly aside of the few static configurations
  17643. */
  17644. export class RenderingManager {
  17645. /**
  17646. * The max id used for rendering groups (not included)
  17647. */
  17648. static MAX_RENDERINGGROUPS: number;
  17649. /**
  17650. * The min id used for rendering groups (included)
  17651. */
  17652. static MIN_RENDERINGGROUPS: number;
  17653. /**
  17654. * Used to globally prevent autoclearing scenes.
  17655. */
  17656. static AUTOCLEAR: boolean;
  17657. /**
  17658. * @hidden
  17659. */
  17660. _useSceneAutoClearSetup: boolean;
  17661. private _scene;
  17662. private _renderingGroups;
  17663. private _depthStencilBufferAlreadyCleaned;
  17664. private _autoClearDepthStencil;
  17665. private _customOpaqueSortCompareFn;
  17666. private _customAlphaTestSortCompareFn;
  17667. private _customTransparentSortCompareFn;
  17668. private _renderingGroupInfo;
  17669. /**
  17670. * Instantiates a new rendering group for a particular scene
  17671. * @param scene Defines the scene the groups belongs to
  17672. */
  17673. constructor(scene: Scene);
  17674. private _clearDepthStencilBuffer;
  17675. /**
  17676. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17677. * @hidden
  17678. */
  17679. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17680. /**
  17681. * Resets the different information of the group to prepare a new frame
  17682. * @hidden
  17683. */
  17684. reset(): void;
  17685. /**
  17686. * Dispose and release the group and its associated resources.
  17687. * @hidden
  17688. */
  17689. dispose(): void;
  17690. /**
  17691. * Clear the info related to rendering groups preventing retention points during dispose.
  17692. */
  17693. freeRenderingGroups(): void;
  17694. private _prepareRenderingGroup;
  17695. /**
  17696. * Add a sprite manager to the rendering manager in order to render it this frame.
  17697. * @param spriteManager Define the sprite manager to render
  17698. */
  17699. dispatchSprites(spriteManager: ISpriteManager): void;
  17700. /**
  17701. * Add a particle system to the rendering manager in order to render it this frame.
  17702. * @param particleSystem Define the particle system to render
  17703. */
  17704. dispatchParticles(particleSystem: IParticleSystem): void;
  17705. /**
  17706. * Add a submesh to the manager in order to render it this frame
  17707. * @param subMesh The submesh to dispatch
  17708. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17709. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17710. */
  17711. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17712. /**
  17713. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17714. * This allowed control for front to back rendering or reversly depending of the special needs.
  17715. *
  17716. * @param renderingGroupId The rendering group id corresponding to its index
  17717. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17718. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17719. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17720. */
  17721. 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;
  17722. /**
  17723. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17724. *
  17725. * @param renderingGroupId The rendering group id corresponding to its index
  17726. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17727. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17728. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17729. */
  17730. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17731. /**
  17732. * Gets the current auto clear configuration for one rendering group of the rendering
  17733. * manager.
  17734. * @param index the rendering group index to get the information for
  17735. * @returns The auto clear setup for the requested rendering group
  17736. */
  17737. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17738. }
  17739. }
  17740. declare module BABYLON {
  17741. /**
  17742. * This Helps creating a texture that will be created from a camera in your scene.
  17743. * It is basically a dynamic texture that could be used to create special effects for instance.
  17744. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17745. */
  17746. export class RenderTargetTexture extends Texture {
  17747. isCube: boolean;
  17748. /**
  17749. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17750. */
  17751. static readonly REFRESHRATE_RENDER_ONCE: number;
  17752. /**
  17753. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17754. */
  17755. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17756. /**
  17757. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17758. * the central point of your effect and can save a lot of performances.
  17759. */
  17760. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17761. /**
  17762. * Use this predicate to dynamically define the list of mesh you want to render.
  17763. * If set, the renderList property will be overwritten.
  17764. */
  17765. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17766. private _renderList;
  17767. /**
  17768. * Use this list to define the list of mesh you want to render.
  17769. */
  17770. renderList: Nullable<Array<AbstractMesh>>;
  17771. private _hookArray;
  17772. /**
  17773. * Define if particles should be rendered in your texture.
  17774. */
  17775. renderParticles: boolean;
  17776. /**
  17777. * Define if sprites should be rendered in your texture.
  17778. */
  17779. renderSprites: boolean;
  17780. /**
  17781. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17782. */
  17783. coordinatesMode: number;
  17784. /**
  17785. * Define the camera used to render the texture.
  17786. */
  17787. activeCamera: Nullable<Camera>;
  17788. /**
  17789. * Override the render function of the texture with your own one.
  17790. */
  17791. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17792. /**
  17793. * Define if camera post processes should be use while rendering the texture.
  17794. */
  17795. useCameraPostProcesses: boolean;
  17796. /**
  17797. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17798. */
  17799. ignoreCameraViewport: boolean;
  17800. private _postProcessManager;
  17801. private _postProcesses;
  17802. private _resizeObserver;
  17803. /**
  17804. * An event triggered when the texture is unbind.
  17805. */
  17806. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17807. /**
  17808. * An event triggered when the texture is unbind.
  17809. */
  17810. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17811. private _onAfterUnbindObserver;
  17812. /**
  17813. * Set a after unbind callback in the texture.
  17814. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17815. */
  17816. onAfterUnbind: () => void;
  17817. /**
  17818. * An event triggered before rendering the texture
  17819. */
  17820. onBeforeRenderObservable: Observable<number>;
  17821. private _onBeforeRenderObserver;
  17822. /**
  17823. * Set a before render callback in the texture.
  17824. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17825. */
  17826. onBeforeRender: (faceIndex: number) => void;
  17827. /**
  17828. * An event triggered after rendering the texture
  17829. */
  17830. onAfterRenderObservable: Observable<number>;
  17831. private _onAfterRenderObserver;
  17832. /**
  17833. * Set a after render callback in the texture.
  17834. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17835. */
  17836. onAfterRender: (faceIndex: number) => void;
  17837. /**
  17838. * An event triggered after the texture clear
  17839. */
  17840. onClearObservable: Observable<Engine>;
  17841. private _onClearObserver;
  17842. /**
  17843. * Set a clear callback in the texture.
  17844. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17845. */
  17846. onClear: (Engine: Engine) => void;
  17847. /**
  17848. * Define the clear color of the Render Target if it should be different from the scene.
  17849. */
  17850. clearColor: Color4;
  17851. protected _size: number | {
  17852. width: number;
  17853. height: number;
  17854. };
  17855. protected _initialSizeParameter: number | {
  17856. width: number;
  17857. height: number;
  17858. } | {
  17859. ratio: number;
  17860. };
  17861. protected _sizeRatio: Nullable<number>;
  17862. /** @hidden */
  17863. _generateMipMaps: boolean;
  17864. protected _renderingManager: RenderingManager;
  17865. /** @hidden */
  17866. _waitingRenderList: string[];
  17867. protected _doNotChangeAspectRatio: boolean;
  17868. protected _currentRefreshId: number;
  17869. protected _refreshRate: number;
  17870. protected _textureMatrix: Matrix;
  17871. protected _samples: number;
  17872. protected _renderTargetOptions: RenderTargetCreationOptions;
  17873. /**
  17874. * Gets render target creation options that were used.
  17875. */
  17876. readonly renderTargetOptions: RenderTargetCreationOptions;
  17877. protected _engine: Engine;
  17878. protected _onRatioRescale(): void;
  17879. /**
  17880. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17881. * It must define where the camera used to render the texture is set
  17882. */
  17883. boundingBoxPosition: Vector3;
  17884. private _boundingBoxSize;
  17885. /**
  17886. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17887. * When defined, the cubemap will switch to local mode
  17888. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17889. * @example https://www.babylonjs-playground.com/#RNASML
  17890. */
  17891. boundingBoxSize: Vector3;
  17892. /**
  17893. * In case the RTT has been created with a depth texture, get the associated
  17894. * depth texture.
  17895. * Otherwise, return null.
  17896. */
  17897. depthStencilTexture: Nullable<InternalTexture>;
  17898. /**
  17899. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17900. * or used a shadow, depth texture...
  17901. * @param name The friendly name of the texture
  17902. * @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)
  17903. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17904. * @param generateMipMaps True if mip maps need to be generated after render.
  17905. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17906. * @param type The type of the buffer in the RTT (int, half float, float...)
  17907. * @param isCube True if a cube texture needs to be created
  17908. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17909. * @param generateDepthBuffer True to generate a depth buffer
  17910. * @param generateStencilBuffer True to generate a stencil buffer
  17911. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17912. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17913. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17914. */
  17915. constructor(name: string, size: number | {
  17916. width: number;
  17917. height: number;
  17918. } | {
  17919. ratio: number;
  17920. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17921. /**
  17922. * Creates a depth stencil texture.
  17923. * This is only available in WebGL 2 or with the depth texture extension available.
  17924. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17925. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17926. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17927. */
  17928. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17929. private _processSizeParameter;
  17930. /**
  17931. * Define the number of samples to use in case of MSAA.
  17932. * It defaults to one meaning no MSAA has been enabled.
  17933. */
  17934. samples: number;
  17935. /**
  17936. * Resets the refresh counter of the texture and start bak from scratch.
  17937. * Could be useful to regenerate the texture if it is setup to render only once.
  17938. */
  17939. resetRefreshCounter(): void;
  17940. /**
  17941. * Define the refresh rate of the texture or the rendering frequency.
  17942. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17943. */
  17944. refreshRate: number;
  17945. /**
  17946. * Adds a post process to the render target rendering passes.
  17947. * @param postProcess define the post process to add
  17948. */
  17949. addPostProcess(postProcess: PostProcess): void;
  17950. /**
  17951. * Clear all the post processes attached to the render target
  17952. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17953. */
  17954. clearPostProcesses(dispose?: boolean): void;
  17955. /**
  17956. * Remove one of the post process from the list of attached post processes to the texture
  17957. * @param postProcess define the post process to remove from the list
  17958. */
  17959. removePostProcess(postProcess: PostProcess): void;
  17960. /** @hidden */
  17961. _shouldRender(): boolean;
  17962. /**
  17963. * Gets the actual render size of the texture.
  17964. * @returns the width of the render size
  17965. */
  17966. getRenderSize(): number;
  17967. /**
  17968. * Gets the actual render width of the texture.
  17969. * @returns the width of the render size
  17970. */
  17971. getRenderWidth(): number;
  17972. /**
  17973. * Gets the actual render height of the texture.
  17974. * @returns the height of the render size
  17975. */
  17976. getRenderHeight(): number;
  17977. /**
  17978. * Get if the texture can be rescaled or not.
  17979. */
  17980. readonly canRescale: boolean;
  17981. /**
  17982. * Resize the texture using a ratio.
  17983. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17984. */
  17985. scale(ratio: number): void;
  17986. /**
  17987. * Get the texture reflection matrix used to rotate/transform the reflection.
  17988. * @returns the reflection matrix
  17989. */
  17990. getReflectionTextureMatrix(): Matrix;
  17991. /**
  17992. * Resize the texture to a new desired size.
  17993. * Be carrefull as it will recreate all the data in the new texture.
  17994. * @param size Define the new size. It can be:
  17995. * - a number for squared texture,
  17996. * - an object containing { width: number, height: number }
  17997. * - or an object containing a ratio { ratio: number }
  17998. */
  17999. resize(size: number | {
  18000. width: number;
  18001. height: number;
  18002. } | {
  18003. ratio: number;
  18004. }): void;
  18005. /**
  18006. * Renders all the objects from the render list into the texture.
  18007. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18008. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18009. */
  18010. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18011. private _bestReflectionRenderTargetDimension;
  18012. /**
  18013. * @hidden
  18014. * @param faceIndex face index to bind to if this is a cubetexture
  18015. */
  18016. _bindFrameBuffer(faceIndex?: number): void;
  18017. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18018. private renderToTarget;
  18019. /**
  18020. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18021. * This allowed control for front to back rendering or reversly depending of the special needs.
  18022. *
  18023. * @param renderingGroupId The rendering group id corresponding to its index
  18024. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18025. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18026. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18027. */
  18028. 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;
  18029. /**
  18030. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18031. *
  18032. * @param renderingGroupId The rendering group id corresponding to its index
  18033. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18034. */
  18035. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18036. /**
  18037. * Clones the texture.
  18038. * @returns the cloned texture
  18039. */
  18040. clone(): RenderTargetTexture;
  18041. /**
  18042. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18043. * @returns The JSON representation of the texture
  18044. */
  18045. serialize(): any;
  18046. /**
  18047. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18048. */
  18049. disposeFramebufferObjects(): void;
  18050. /**
  18051. * Dispose the texture and release its associated resources.
  18052. */
  18053. dispose(): void;
  18054. /** @hidden */
  18055. _rebuild(): void;
  18056. /**
  18057. * Clear the info related to rendering groups preventing retention point in material dispose.
  18058. */
  18059. freeRenderingGroups(): void;
  18060. /**
  18061. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18062. * @returns the view count
  18063. */
  18064. getViewCount(): number;
  18065. }
  18066. }
  18067. declare module BABYLON {
  18068. /**
  18069. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18070. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18071. * You can then easily use it as a reflectionTexture on a flat surface.
  18072. * In case the surface is not a plane, please consider relying on reflection probes.
  18073. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18074. */
  18075. export class MirrorTexture extends RenderTargetTexture {
  18076. private scene;
  18077. /**
  18078. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18079. * 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.
  18080. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18081. */
  18082. mirrorPlane: Plane;
  18083. /**
  18084. * Define the blur ratio used to blur the reflection if needed.
  18085. */
  18086. blurRatio: number;
  18087. /**
  18088. * Define the adaptive blur kernel used to blur the reflection if needed.
  18089. * This will autocompute the closest best match for the `blurKernel`
  18090. */
  18091. adaptiveBlurKernel: number;
  18092. /**
  18093. * Define the blur kernel used to blur the reflection if needed.
  18094. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18095. */
  18096. blurKernel: number;
  18097. /**
  18098. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18099. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18100. */
  18101. blurKernelX: number;
  18102. /**
  18103. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18104. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18105. */
  18106. blurKernelY: number;
  18107. private _autoComputeBlurKernel;
  18108. protected _onRatioRescale(): void;
  18109. private _updateGammaSpace;
  18110. private _imageProcessingConfigChangeObserver;
  18111. private _transformMatrix;
  18112. private _mirrorMatrix;
  18113. private _savedViewMatrix;
  18114. private _blurX;
  18115. private _blurY;
  18116. private _adaptiveBlurKernel;
  18117. private _blurKernelX;
  18118. private _blurKernelY;
  18119. private _blurRatio;
  18120. /**
  18121. * Instantiates a Mirror Texture.
  18122. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18123. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18124. * You can then easily use it as a reflectionTexture on a flat surface.
  18125. * In case the surface is not a plane, please consider relying on reflection probes.
  18126. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18127. * @param name
  18128. * @param size
  18129. * @param scene
  18130. * @param generateMipMaps
  18131. * @param type
  18132. * @param samplingMode
  18133. * @param generateDepthBuffer
  18134. */
  18135. constructor(name: string, size: number | {
  18136. width: number;
  18137. height: number;
  18138. } | {
  18139. ratio: number;
  18140. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18141. private _preparePostProcesses;
  18142. /**
  18143. * Clone the mirror texture.
  18144. * @returns the cloned texture
  18145. */
  18146. clone(): MirrorTexture;
  18147. /**
  18148. * Serialize the texture to a JSON representation you could use in Parse later on
  18149. * @returns the serialized JSON representation
  18150. */
  18151. serialize(): any;
  18152. /**
  18153. * Dispose the texture and release its associated resources.
  18154. */
  18155. dispose(): void;
  18156. }
  18157. }
  18158. declare module BABYLON {
  18159. /**
  18160. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18161. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18162. */
  18163. export class Texture extends BaseTexture {
  18164. /** @hidden */
  18165. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  18166. /** @hidden */
  18167. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  18168. /** @hidden */
  18169. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  18170. /** nearest is mag = nearest and min = nearest and mip = linear */
  18171. static readonly NEAREST_SAMPLINGMODE: number;
  18172. /** nearest is mag = nearest and min = nearest and mip = linear */
  18173. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18174. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18175. static readonly BILINEAR_SAMPLINGMODE: number;
  18176. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18177. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18178. /** Trilinear is mag = linear and min = linear and mip = linear */
  18179. static readonly TRILINEAR_SAMPLINGMODE: number;
  18180. /** Trilinear is mag = linear and min = linear and mip = linear */
  18181. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18182. /** mag = nearest and min = nearest and mip = nearest */
  18183. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18184. /** mag = nearest and min = linear and mip = nearest */
  18185. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18186. /** mag = nearest and min = linear and mip = linear */
  18187. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18188. /** mag = nearest and min = linear and mip = none */
  18189. static readonly NEAREST_LINEAR: number;
  18190. /** mag = nearest and min = nearest and mip = none */
  18191. static readonly NEAREST_NEAREST: number;
  18192. /** mag = linear and min = nearest and mip = nearest */
  18193. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18194. /** mag = linear and min = nearest and mip = linear */
  18195. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18196. /** mag = linear and min = linear and mip = none */
  18197. static readonly LINEAR_LINEAR: number;
  18198. /** mag = linear and min = nearest and mip = none */
  18199. static readonly LINEAR_NEAREST: number;
  18200. /** Explicit coordinates mode */
  18201. static readonly EXPLICIT_MODE: number;
  18202. /** Spherical coordinates mode */
  18203. static readonly SPHERICAL_MODE: number;
  18204. /** Planar coordinates mode */
  18205. static readonly PLANAR_MODE: number;
  18206. /** Cubic coordinates mode */
  18207. static readonly CUBIC_MODE: number;
  18208. /** Projection coordinates mode */
  18209. static readonly PROJECTION_MODE: number;
  18210. /** Inverse Cubic coordinates mode */
  18211. static readonly SKYBOX_MODE: number;
  18212. /** Inverse Cubic coordinates mode */
  18213. static readonly INVCUBIC_MODE: number;
  18214. /** Equirectangular coordinates mode */
  18215. static readonly EQUIRECTANGULAR_MODE: number;
  18216. /** Equirectangular Fixed coordinates mode */
  18217. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18218. /** Equirectangular Fixed Mirrored coordinates mode */
  18219. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18220. /** Texture is not repeating outside of 0..1 UVs */
  18221. static readonly CLAMP_ADDRESSMODE: number;
  18222. /** Texture is repeating outside of 0..1 UVs */
  18223. static readonly WRAP_ADDRESSMODE: number;
  18224. /** Texture is repeating and mirrored */
  18225. static readonly MIRROR_ADDRESSMODE: number;
  18226. /**
  18227. * 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
  18228. */
  18229. static UseSerializedUrlIfAny: boolean;
  18230. /**
  18231. * Define the url of the texture.
  18232. */
  18233. url: Nullable<string>;
  18234. /**
  18235. * Define an offset on the texture to offset the u coordinates of the UVs
  18236. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18237. */
  18238. uOffset: number;
  18239. /**
  18240. * Define an offset on the texture to offset the v coordinates of the UVs
  18241. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18242. */
  18243. vOffset: number;
  18244. /**
  18245. * Define an offset on the texture to scale the u coordinates of the UVs
  18246. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18247. */
  18248. uScale: number;
  18249. /**
  18250. * Define an offset on the texture to scale the v coordinates of the UVs
  18251. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18252. */
  18253. vScale: number;
  18254. /**
  18255. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18256. * @see http://doc.babylonjs.com/how_to/more_materials
  18257. */
  18258. uAng: number;
  18259. /**
  18260. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18261. * @see http://doc.babylonjs.com/how_to/more_materials
  18262. */
  18263. vAng: number;
  18264. /**
  18265. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18266. * @see http://doc.babylonjs.com/how_to/more_materials
  18267. */
  18268. wAng: number;
  18269. /**
  18270. * Defines the center of rotation (U)
  18271. */
  18272. uRotationCenter: number;
  18273. /**
  18274. * Defines the center of rotation (V)
  18275. */
  18276. vRotationCenter: number;
  18277. /**
  18278. * Defines the center of rotation (W)
  18279. */
  18280. wRotationCenter: number;
  18281. /**
  18282. * Are mip maps generated for this texture or not.
  18283. */
  18284. readonly noMipmap: boolean;
  18285. /**
  18286. * List of inspectable custom properties (used by the Inspector)
  18287. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18288. */
  18289. inspectableCustomProperties: Nullable<IInspectable[]>;
  18290. private _noMipmap;
  18291. /** @hidden */
  18292. _invertY: boolean;
  18293. private _rowGenerationMatrix;
  18294. private _cachedTextureMatrix;
  18295. private _projectionModeMatrix;
  18296. private _t0;
  18297. private _t1;
  18298. private _t2;
  18299. private _cachedUOffset;
  18300. private _cachedVOffset;
  18301. private _cachedUScale;
  18302. private _cachedVScale;
  18303. private _cachedUAng;
  18304. private _cachedVAng;
  18305. private _cachedWAng;
  18306. private _cachedProjectionMatrixId;
  18307. private _cachedCoordinatesMode;
  18308. /** @hidden */
  18309. protected _initialSamplingMode: number;
  18310. /** @hidden */
  18311. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18312. private _deleteBuffer;
  18313. protected _format: Nullable<number>;
  18314. private _delayedOnLoad;
  18315. private _delayedOnError;
  18316. /**
  18317. * Observable triggered once the texture has been loaded.
  18318. */
  18319. onLoadObservable: Observable<Texture>;
  18320. protected _isBlocking: boolean;
  18321. /**
  18322. * Is the texture preventing material to render while loading.
  18323. * If false, a default texture will be used instead of the loading one during the preparation step.
  18324. */
  18325. isBlocking: boolean;
  18326. /**
  18327. * Get the current sampling mode associated with the texture.
  18328. */
  18329. readonly samplingMode: number;
  18330. /**
  18331. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18332. */
  18333. readonly invertY: boolean;
  18334. /**
  18335. * Instantiates a new texture.
  18336. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18337. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18338. * @param url define the url of the picture to load as a texture
  18339. * @param scene define the scene the texture will belong to
  18340. * @param noMipmap define if the texture will require mip maps or not
  18341. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18342. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18343. * @param onLoad define a callback triggered when the texture has been loaded
  18344. * @param onError define a callback triggered when an error occurred during the loading session
  18345. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18346. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18347. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18348. */
  18349. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  18350. /**
  18351. * Update the url (and optional buffer) of this texture if url was null during construction.
  18352. * @param url the url of the texture
  18353. * @param buffer the buffer of the texture (defaults to null)
  18354. * @param onLoad callback called when the texture is loaded (defaults to null)
  18355. */
  18356. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18357. /**
  18358. * Finish the loading sequence of a texture flagged as delayed load.
  18359. * @hidden
  18360. */
  18361. delayLoad(): void;
  18362. private _prepareRowForTextureGeneration;
  18363. /**
  18364. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18365. * @returns the transform matrix of the texture.
  18366. */
  18367. getTextureMatrix(): Matrix;
  18368. /**
  18369. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18370. * @returns The reflection texture transform
  18371. */
  18372. getReflectionTextureMatrix(): Matrix;
  18373. /**
  18374. * Clones the texture.
  18375. * @returns the cloned texture
  18376. */
  18377. clone(): Texture;
  18378. /**
  18379. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18380. * @returns The JSON representation of the texture
  18381. */
  18382. serialize(): any;
  18383. /**
  18384. * Get the current class name of the texture useful for serialization or dynamic coding.
  18385. * @returns "Texture"
  18386. */
  18387. getClassName(): string;
  18388. /**
  18389. * Dispose the texture and release its associated resources.
  18390. */
  18391. dispose(): void;
  18392. /**
  18393. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18394. * @param parsedTexture Define the JSON representation of the texture
  18395. * @param scene Define the scene the parsed texture should be instantiated in
  18396. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18397. * @returns The parsed texture if successful
  18398. */
  18399. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18400. /**
  18401. * Creates a texture from its base 64 representation.
  18402. * @param data Define the base64 payload without the data: prefix
  18403. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18404. * @param scene Define the scene the texture should belong to
  18405. * @param noMipmap Forces the texture to not create mip map information if true
  18406. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18407. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18408. * @param onLoad define a callback triggered when the texture has been loaded
  18409. * @param onError define a callback triggered when an error occurred during the loading session
  18410. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18411. * @returns the created texture
  18412. */
  18413. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18414. /**
  18415. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18416. * @param data Define the base64 payload without the data: prefix
  18417. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18418. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18419. * @param scene Define the scene the texture should belong to
  18420. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18421. * @param noMipmap Forces the texture to not create mip map information if true
  18422. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18423. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18424. * @param onLoad define a callback triggered when the texture has been loaded
  18425. * @param onError define a callback triggered when an error occurred during the loading session
  18426. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18427. * @returns the created texture
  18428. */
  18429. 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;
  18430. }
  18431. }
  18432. declare module BABYLON {
  18433. interface Engine {
  18434. /**
  18435. * Creates a raw texture
  18436. * @param data defines the data to store in the texture
  18437. * @param width defines the width of the texture
  18438. * @param height defines the height of the texture
  18439. * @param format defines the format of the data
  18440. * @param generateMipMaps defines if the engine should generate the mip levels
  18441. * @param invertY defines if data must be stored with Y axis inverted
  18442. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18443. * @param compression defines the compression used (null by default)
  18444. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18445. * @returns the raw texture inside an InternalTexture
  18446. */
  18447. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18448. /**
  18449. * Update a raw texture
  18450. * @param texture defines the texture to update
  18451. * @param data defines the data to store in the texture
  18452. * @param format defines the format of the data
  18453. * @param invertY defines if data must be stored with Y axis inverted
  18454. */
  18455. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18456. /**
  18457. * Update a raw texture
  18458. * @param texture defines the texture to update
  18459. * @param data defines the data to store in the texture
  18460. * @param format defines the format of the data
  18461. * @param invertY defines if data must be stored with Y axis inverted
  18462. * @param compression defines the compression used (null by default)
  18463. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18464. */
  18465. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18466. /**
  18467. * Creates a new raw cube texture
  18468. * @param data defines the array of data to use to create each face
  18469. * @param size defines the size of the textures
  18470. * @param format defines the format of the data
  18471. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18472. * @param generateMipMaps defines if the engine should generate the mip levels
  18473. * @param invertY defines if data must be stored with Y axis inverted
  18474. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18475. * @param compression defines the compression used (null by default)
  18476. * @returns the cube texture as an InternalTexture
  18477. */
  18478. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18479. /**
  18480. * Update a raw cube texture
  18481. * @param texture defines the texture to udpdate
  18482. * @param data defines the data to store
  18483. * @param format defines the data format
  18484. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18485. * @param invertY defines if data must be stored with Y axis inverted
  18486. */
  18487. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18488. /**
  18489. * Update a raw cube texture
  18490. * @param texture defines the texture to udpdate
  18491. * @param data defines the data to store
  18492. * @param format defines the data format
  18493. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18494. * @param invertY defines if data must be stored with Y axis inverted
  18495. * @param compression defines the compression used (null by default)
  18496. */
  18497. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18498. /**
  18499. * Update a raw cube texture
  18500. * @param texture defines the texture to udpdate
  18501. * @param data defines the data to store
  18502. * @param format defines the data format
  18503. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18504. * @param invertY defines if data must be stored with Y axis inverted
  18505. * @param compression defines the compression used (null by default)
  18506. * @param level defines which level of the texture to update
  18507. */
  18508. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18509. /**
  18510. * Creates a new raw cube texture from a specified url
  18511. * @param url defines the url where the data is located
  18512. * @param scene defines the current scene
  18513. * @param size defines the size of the textures
  18514. * @param format defines the format of the data
  18515. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18516. * @param noMipmap defines if the engine should avoid generating the mip levels
  18517. * @param callback defines a callback used to extract texture data from loaded data
  18518. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18519. * @param onLoad defines a callback called when texture is loaded
  18520. * @param onError defines a callback called if there is an error
  18521. * @returns the cube texture as an InternalTexture
  18522. */
  18523. 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;
  18524. /**
  18525. * Creates a new raw cube texture from a specified url
  18526. * @param url defines the url where the data is located
  18527. * @param scene defines the current scene
  18528. * @param size defines the size of the textures
  18529. * @param format defines the format of the data
  18530. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18531. * @param noMipmap defines if the engine should avoid generating the mip levels
  18532. * @param callback defines a callback used to extract texture data from loaded data
  18533. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18534. * @param onLoad defines a callback called when texture is loaded
  18535. * @param onError defines a callback called if there is an error
  18536. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18537. * @param invertY defines if data must be stored with Y axis inverted
  18538. * @returns the cube texture as an InternalTexture
  18539. */
  18540. 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;
  18541. /**
  18542. * Creates a new raw 3D texture
  18543. * @param data defines the data used to create the texture
  18544. * @param width defines the width of the texture
  18545. * @param height defines the height of the texture
  18546. * @param depth defines the depth of the texture
  18547. * @param format defines the format of the texture
  18548. * @param generateMipMaps defines if the engine must generate mip levels
  18549. * @param invertY defines if data must be stored with Y axis inverted
  18550. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18551. * @param compression defines the compressed used (can be null)
  18552. * @param textureType defines the compressed used (can be null)
  18553. * @returns a new raw 3D texture (stored in an InternalTexture)
  18554. */
  18555. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18556. /**
  18557. * Update a raw 3D texture
  18558. * @param texture defines the texture to update
  18559. * @param data defines the data to store
  18560. * @param format defines the data format
  18561. * @param invertY defines if data must be stored with Y axis inverted
  18562. */
  18563. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18564. /**
  18565. * Update a raw 3D texture
  18566. * @param texture defines the texture to update
  18567. * @param data defines the data to store
  18568. * @param format defines the data format
  18569. * @param invertY defines if data must be stored with Y axis inverted
  18570. * @param compression defines the used compression (can be null)
  18571. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18572. */
  18573. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18574. }
  18575. }
  18576. declare module BABYLON {
  18577. /**
  18578. * Raw texture can help creating a texture directly from an array of data.
  18579. * This can be super useful if you either get the data from an uncompressed source or
  18580. * if you wish to create your texture pixel by pixel.
  18581. */
  18582. export class RawTexture extends Texture {
  18583. /**
  18584. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18585. */
  18586. format: number;
  18587. private _engine;
  18588. /**
  18589. * Instantiates a new RawTexture.
  18590. * Raw texture can help creating a texture directly from an array of data.
  18591. * This can be super useful if you either get the data from an uncompressed source or
  18592. * if you wish to create your texture pixel by pixel.
  18593. * @param data define the array of data to use to create the texture
  18594. * @param width define the width of the texture
  18595. * @param height define the height of the texture
  18596. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18597. * @param scene define the scene the texture belongs to
  18598. * @param generateMipMaps define whether mip maps should be generated or not
  18599. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18600. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18601. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18602. */
  18603. constructor(data: ArrayBufferView, width: number, height: number,
  18604. /**
  18605. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18606. */
  18607. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18608. /**
  18609. * Updates the texture underlying data.
  18610. * @param data Define the new data of the texture
  18611. */
  18612. update(data: ArrayBufferView): void;
  18613. /**
  18614. * Creates a luminance texture from some data.
  18615. * @param data Define the texture data
  18616. * @param width Define the width of the texture
  18617. * @param height Define the height of the texture
  18618. * @param scene Define the scene the texture belongs to
  18619. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18620. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18621. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18622. * @returns the luminance texture
  18623. */
  18624. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18625. /**
  18626. * Creates a luminance alpha texture from some data.
  18627. * @param data Define the texture data
  18628. * @param width Define the width of the texture
  18629. * @param height Define the height of the texture
  18630. * @param scene Define the scene the texture belongs to
  18631. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18632. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18633. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18634. * @returns the luminance alpha texture
  18635. */
  18636. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18637. /**
  18638. * Creates an alpha texture from some data.
  18639. * @param data Define the texture data
  18640. * @param width Define the width of the texture
  18641. * @param height Define the height of the texture
  18642. * @param scene Define the scene the texture belongs to
  18643. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18644. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18645. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18646. * @returns the alpha texture
  18647. */
  18648. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18649. /**
  18650. * Creates a RGB texture from some data.
  18651. * @param data Define the texture data
  18652. * @param width Define the width of the texture
  18653. * @param height Define the height of the texture
  18654. * @param scene Define the scene the texture belongs to
  18655. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18656. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18657. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18658. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18659. * @returns the RGB alpha texture
  18660. */
  18661. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18662. /**
  18663. * Creates a RGBA texture from some data.
  18664. * @param data Define the texture data
  18665. * @param width Define the width of the texture
  18666. * @param height Define the height of the texture
  18667. * @param scene Define the scene the texture belongs to
  18668. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18669. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18670. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18671. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18672. * @returns the RGBA texture
  18673. */
  18674. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18675. /**
  18676. * Creates a R texture from some data.
  18677. * @param data Define the texture data
  18678. * @param width Define the width of the texture
  18679. * @param height Define the height of the texture
  18680. * @param scene Define the scene the texture belongs to
  18681. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18682. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18683. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18684. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18685. * @returns the R texture
  18686. */
  18687. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18688. }
  18689. }
  18690. declare module BABYLON {
  18691. /**
  18692. * Defines a runtime animation
  18693. */
  18694. export class RuntimeAnimation {
  18695. private _events;
  18696. /**
  18697. * The current frame of the runtime animation
  18698. */
  18699. private _currentFrame;
  18700. /**
  18701. * The animation used by the runtime animation
  18702. */
  18703. private _animation;
  18704. /**
  18705. * The target of the runtime animation
  18706. */
  18707. private _target;
  18708. /**
  18709. * The initiating animatable
  18710. */
  18711. private _host;
  18712. /**
  18713. * The original value of the runtime animation
  18714. */
  18715. private _originalValue;
  18716. /**
  18717. * The original blend value of the runtime animation
  18718. */
  18719. private _originalBlendValue;
  18720. /**
  18721. * The offsets cache of the runtime animation
  18722. */
  18723. private _offsetsCache;
  18724. /**
  18725. * The high limits cache of the runtime animation
  18726. */
  18727. private _highLimitsCache;
  18728. /**
  18729. * Specifies if the runtime animation has been stopped
  18730. */
  18731. private _stopped;
  18732. /**
  18733. * The blending factor of the runtime animation
  18734. */
  18735. private _blendingFactor;
  18736. /**
  18737. * The BabylonJS scene
  18738. */
  18739. private _scene;
  18740. /**
  18741. * The current value of the runtime animation
  18742. */
  18743. private _currentValue;
  18744. /** @hidden */
  18745. _animationState: _IAnimationState;
  18746. /**
  18747. * The active target of the runtime animation
  18748. */
  18749. private _activeTargets;
  18750. private _currentActiveTarget;
  18751. private _directTarget;
  18752. /**
  18753. * The target path of the runtime animation
  18754. */
  18755. private _targetPath;
  18756. /**
  18757. * The weight of the runtime animation
  18758. */
  18759. private _weight;
  18760. /**
  18761. * The ratio offset of the runtime animation
  18762. */
  18763. private _ratioOffset;
  18764. /**
  18765. * The previous delay of the runtime animation
  18766. */
  18767. private _previousDelay;
  18768. /**
  18769. * The previous ratio of the runtime animation
  18770. */
  18771. private _previousRatio;
  18772. private _enableBlending;
  18773. private _keys;
  18774. private _minFrame;
  18775. private _maxFrame;
  18776. private _minValue;
  18777. private _maxValue;
  18778. private _targetIsArray;
  18779. /**
  18780. * Gets the current frame of the runtime animation
  18781. */
  18782. readonly currentFrame: number;
  18783. /**
  18784. * Gets the weight of the runtime animation
  18785. */
  18786. readonly weight: number;
  18787. /**
  18788. * Gets the current value of the runtime animation
  18789. */
  18790. readonly currentValue: any;
  18791. /**
  18792. * Gets the target path of the runtime animation
  18793. */
  18794. readonly targetPath: string;
  18795. /**
  18796. * Gets the actual target of the runtime animation
  18797. */
  18798. readonly target: any;
  18799. /** @hidden */
  18800. _onLoop: () => void;
  18801. /**
  18802. * Create a new RuntimeAnimation object
  18803. * @param target defines the target of the animation
  18804. * @param animation defines the source animation object
  18805. * @param scene defines the hosting scene
  18806. * @param host defines the initiating Animatable
  18807. */
  18808. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18809. private _preparePath;
  18810. /**
  18811. * Gets the animation from the runtime animation
  18812. */
  18813. readonly animation: Animation;
  18814. /**
  18815. * Resets the runtime animation to the beginning
  18816. * @param restoreOriginal defines whether to restore the target property to the original value
  18817. */
  18818. reset(restoreOriginal?: boolean): void;
  18819. /**
  18820. * Specifies if the runtime animation is stopped
  18821. * @returns Boolean specifying if the runtime animation is stopped
  18822. */
  18823. isStopped(): boolean;
  18824. /**
  18825. * Disposes of the runtime animation
  18826. */
  18827. dispose(): void;
  18828. /**
  18829. * Apply the interpolated value to the target
  18830. * @param currentValue defines the value computed by the animation
  18831. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18832. */
  18833. setValue(currentValue: any, weight: number): void;
  18834. private _getOriginalValues;
  18835. private _setValue;
  18836. /**
  18837. * Gets the loop pmode of the runtime animation
  18838. * @returns Loop Mode
  18839. */
  18840. private _getCorrectLoopMode;
  18841. /**
  18842. * Move the current animation to a given frame
  18843. * @param frame defines the frame to move to
  18844. */
  18845. goToFrame(frame: number): void;
  18846. /**
  18847. * @hidden Internal use only
  18848. */
  18849. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18850. /**
  18851. * Execute the current animation
  18852. * @param delay defines the delay to add to the current frame
  18853. * @param from defines the lower bound of the animation range
  18854. * @param to defines the upper bound of the animation range
  18855. * @param loop defines if the current animation must loop
  18856. * @param speedRatio defines the current speed ratio
  18857. * @param weight defines the weight of the animation (default is -1 so no weight)
  18858. * @param onLoop optional callback called when animation loops
  18859. * @returns a boolean indicating if the animation is running
  18860. */
  18861. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  18862. }
  18863. }
  18864. declare module BABYLON {
  18865. /**
  18866. * Class used to store an actual running animation
  18867. */
  18868. export class Animatable {
  18869. /** defines the target object */
  18870. target: any;
  18871. /** defines the starting frame number (default is 0) */
  18872. fromFrame: number;
  18873. /** defines the ending frame number (default is 100) */
  18874. toFrame: number;
  18875. /** defines if the animation must loop (default is false) */
  18876. loopAnimation: boolean;
  18877. /** defines a callback to call when animation ends if it is not looping */
  18878. onAnimationEnd?: (() => void) | null | undefined;
  18879. /** defines a callback to call when animation loops */
  18880. onAnimationLoop?: (() => void) | null | undefined;
  18881. private _localDelayOffset;
  18882. private _pausedDelay;
  18883. private _runtimeAnimations;
  18884. private _paused;
  18885. private _scene;
  18886. private _speedRatio;
  18887. private _weight;
  18888. private _syncRoot;
  18889. /**
  18890. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18891. * This will only apply for non looping animation (default is true)
  18892. */
  18893. disposeOnEnd: boolean;
  18894. /**
  18895. * Gets a boolean indicating if the animation has started
  18896. */
  18897. animationStarted: boolean;
  18898. /**
  18899. * Observer raised when the animation ends
  18900. */
  18901. onAnimationEndObservable: Observable<Animatable>;
  18902. /**
  18903. * Observer raised when the animation loops
  18904. */
  18905. onAnimationLoopObservable: Observable<Animatable>;
  18906. /**
  18907. * Gets the root Animatable used to synchronize and normalize animations
  18908. */
  18909. readonly syncRoot: Nullable<Animatable>;
  18910. /**
  18911. * Gets the current frame of the first RuntimeAnimation
  18912. * Used to synchronize Animatables
  18913. */
  18914. readonly masterFrame: number;
  18915. /**
  18916. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18917. */
  18918. weight: number;
  18919. /**
  18920. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18921. */
  18922. speedRatio: number;
  18923. /**
  18924. * Creates a new Animatable
  18925. * @param scene defines the hosting scene
  18926. * @param target defines the target object
  18927. * @param fromFrame defines the starting frame number (default is 0)
  18928. * @param toFrame defines the ending frame number (default is 100)
  18929. * @param loopAnimation defines if the animation must loop (default is false)
  18930. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18931. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18932. * @param animations defines a group of animation to add to the new Animatable
  18933. * @param onAnimationLoop defines a callback to call when animation loops
  18934. */
  18935. constructor(scene: Scene,
  18936. /** defines the target object */
  18937. target: any,
  18938. /** defines the starting frame number (default is 0) */
  18939. fromFrame?: number,
  18940. /** defines the ending frame number (default is 100) */
  18941. toFrame?: number,
  18942. /** defines if the animation must loop (default is false) */
  18943. loopAnimation?: boolean, speedRatio?: number,
  18944. /** defines a callback to call when animation ends if it is not looping */
  18945. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18946. /** defines a callback to call when animation loops */
  18947. onAnimationLoop?: (() => void) | null | undefined);
  18948. /**
  18949. * Synchronize and normalize current Animatable with a source Animatable
  18950. * This is useful when using animation weights and when animations are not of the same length
  18951. * @param root defines the root Animatable to synchronize with
  18952. * @returns the current Animatable
  18953. */
  18954. syncWith(root: Animatable): Animatable;
  18955. /**
  18956. * Gets the list of runtime animations
  18957. * @returns an array of RuntimeAnimation
  18958. */
  18959. getAnimations(): RuntimeAnimation[];
  18960. /**
  18961. * Adds more animations to the current animatable
  18962. * @param target defines the target of the animations
  18963. * @param animations defines the new animations to add
  18964. */
  18965. appendAnimations(target: any, animations: Animation[]): void;
  18966. /**
  18967. * Gets the source animation for a specific property
  18968. * @param property defines the propertyu to look for
  18969. * @returns null or the source animation for the given property
  18970. */
  18971. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18972. /**
  18973. * Gets the runtime animation for a specific property
  18974. * @param property defines the propertyu to look for
  18975. * @returns null or the runtime animation for the given property
  18976. */
  18977. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18978. /**
  18979. * Resets the animatable to its original state
  18980. */
  18981. reset(): void;
  18982. /**
  18983. * Allows the animatable to blend with current running animations
  18984. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18985. * @param blendingSpeed defines the blending speed to use
  18986. */
  18987. enableBlending(blendingSpeed: number): void;
  18988. /**
  18989. * Disable animation blending
  18990. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18991. */
  18992. disableBlending(): void;
  18993. /**
  18994. * Jump directly to a given frame
  18995. * @param frame defines the frame to jump to
  18996. */
  18997. goToFrame(frame: number): void;
  18998. /**
  18999. * Pause the animation
  19000. */
  19001. pause(): void;
  19002. /**
  19003. * Restart the animation
  19004. */
  19005. restart(): void;
  19006. private _raiseOnAnimationEnd;
  19007. /**
  19008. * Stop and delete the current animation
  19009. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19010. * @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)
  19011. */
  19012. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19013. /**
  19014. * Wait asynchronously for the animation to end
  19015. * @returns a promise which will be fullfilled when the animation ends
  19016. */
  19017. waitAsync(): Promise<Animatable>;
  19018. /** @hidden */
  19019. _animate(delay: number): boolean;
  19020. }
  19021. interface Scene {
  19022. /** @hidden */
  19023. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19024. /** @hidden */
  19025. _processLateAnimationBindingsForMatrices(holder: {
  19026. totalWeight: number;
  19027. animations: RuntimeAnimation[];
  19028. originalValue: Matrix;
  19029. }): any;
  19030. /** @hidden */
  19031. _processLateAnimationBindingsForQuaternions(holder: {
  19032. totalWeight: number;
  19033. animations: RuntimeAnimation[];
  19034. originalValue: Quaternion;
  19035. }, refQuaternion: Quaternion): Quaternion;
  19036. /** @hidden */
  19037. _processLateAnimationBindings(): void;
  19038. /**
  19039. * Will start the animation sequence of a given target
  19040. * @param target defines the target
  19041. * @param from defines from which frame should animation start
  19042. * @param to defines until which frame should animation run.
  19043. * @param weight defines the weight to apply to the animation (1.0 by default)
  19044. * @param loop defines if the animation loops
  19045. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19046. * @param onAnimationEnd defines the function to be executed when the animation ends
  19047. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19048. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19049. * @param onAnimationLoop defines the callback to call when an animation loops
  19050. * @returns the animatable object created for this animation
  19051. */
  19052. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19053. /**
  19054. * Will start the animation sequence of a given target
  19055. * @param target defines the target
  19056. * @param from defines from which frame should animation start
  19057. * @param to defines until which frame should animation run.
  19058. * @param loop defines if the animation loops
  19059. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19060. * @param onAnimationEnd defines the function to be executed when the animation ends
  19061. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19062. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19063. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19064. * @param onAnimationLoop defines the callback to call when an animation loops
  19065. * @returns the animatable object created for this animation
  19066. */
  19067. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19068. /**
  19069. * Will start the animation sequence of a given target and its hierarchy
  19070. * @param target defines the target
  19071. * @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.
  19072. * @param from defines from which frame should animation start
  19073. * @param to defines until which frame should animation run.
  19074. * @param loop defines if the animation loops
  19075. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19076. * @param onAnimationEnd defines the function to be executed when the animation ends
  19077. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19078. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19079. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19080. * @param onAnimationLoop defines the callback to call when an animation loops
  19081. * @returns the list of created animatables
  19082. */
  19083. 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[];
  19084. /**
  19085. * Begin a new animation on a given node
  19086. * @param target defines the target where the animation will take place
  19087. * @param animations defines the list of animations to start
  19088. * @param from defines the initial value
  19089. * @param to defines the final value
  19090. * @param loop defines if you want animation to loop (off by default)
  19091. * @param speedRatio defines the speed ratio to apply to all animations
  19092. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19093. * @param onAnimationLoop defines the callback to call when an animation loops
  19094. * @returns the list of created animatables
  19095. */
  19096. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19097. /**
  19098. * Begin a new animation on a given node and its hierarchy
  19099. * @param target defines the root node where the animation will take place
  19100. * @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.
  19101. * @param animations defines the list of animations to start
  19102. * @param from defines the initial value
  19103. * @param to defines the final value
  19104. * @param loop defines if you want animation to loop (off by default)
  19105. * @param speedRatio defines the speed ratio to apply to all animations
  19106. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19107. * @param onAnimationLoop defines the callback to call when an animation loops
  19108. * @returns the list of animatables created for all nodes
  19109. */
  19110. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19111. /**
  19112. * Gets the animatable associated with a specific target
  19113. * @param target defines the target of the animatable
  19114. * @returns the required animatable if found
  19115. */
  19116. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19117. /**
  19118. * Gets all animatables associated with a given target
  19119. * @param target defines the target to look animatables for
  19120. * @returns an array of Animatables
  19121. */
  19122. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19123. /**
  19124. * Stops and removes all animations that have been applied to the scene
  19125. */
  19126. stopAllAnimations(): void;
  19127. }
  19128. interface Bone {
  19129. /**
  19130. * Copy an animation range from another bone
  19131. * @param source defines the source bone
  19132. * @param rangeName defines the range name to copy
  19133. * @param frameOffset defines the frame offset
  19134. * @param rescaleAsRequired defines if rescaling must be applied if required
  19135. * @param skelDimensionsRatio defines the scaling ratio
  19136. * @returns true if operation was successful
  19137. */
  19138. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19139. }
  19140. }
  19141. declare module BABYLON {
  19142. /**
  19143. * Class used to handle skinning animations
  19144. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19145. */
  19146. export class Skeleton implements IAnimatable {
  19147. /** defines the skeleton name */
  19148. name: string;
  19149. /** defines the skeleton Id */
  19150. id: string;
  19151. /**
  19152. * Defines the list of child bones
  19153. */
  19154. bones: Bone[];
  19155. /**
  19156. * Defines an estimate of the dimension of the skeleton at rest
  19157. */
  19158. dimensionsAtRest: Vector3;
  19159. /**
  19160. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19161. */
  19162. needInitialSkinMatrix: boolean;
  19163. /**
  19164. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19165. */
  19166. overrideMesh: Nullable<AbstractMesh>;
  19167. /**
  19168. * Gets the list of animations attached to this skeleton
  19169. */
  19170. animations: Array<Animation>;
  19171. private _scene;
  19172. private _isDirty;
  19173. private _transformMatrices;
  19174. private _transformMatrixTexture;
  19175. private _meshesWithPoseMatrix;
  19176. private _animatables;
  19177. private _identity;
  19178. private _synchronizedWithMesh;
  19179. private _ranges;
  19180. private _lastAbsoluteTransformsUpdateId;
  19181. private _canUseTextureForBones;
  19182. private _uniqueId;
  19183. /** @hidden */
  19184. _numBonesWithLinkedTransformNode: number;
  19185. /** @hidden */
  19186. _hasWaitingData: Nullable<boolean>;
  19187. /**
  19188. * Specifies if the skeleton should be serialized
  19189. */
  19190. doNotSerialize: boolean;
  19191. private _useTextureToStoreBoneMatrices;
  19192. /**
  19193. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19194. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19195. */
  19196. useTextureToStoreBoneMatrices: boolean;
  19197. private _animationPropertiesOverride;
  19198. /**
  19199. * Gets or sets the animation properties override
  19200. */
  19201. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19202. /**
  19203. * List of inspectable custom properties (used by the Inspector)
  19204. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19205. */
  19206. inspectableCustomProperties: IInspectable[];
  19207. /**
  19208. * An observable triggered before computing the skeleton's matrices
  19209. */
  19210. onBeforeComputeObservable: Observable<Skeleton>;
  19211. /**
  19212. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19213. */
  19214. readonly isUsingTextureForMatrices: boolean;
  19215. /**
  19216. * Gets the unique ID of this skeleton
  19217. */
  19218. readonly uniqueId: number;
  19219. /**
  19220. * Creates a new skeleton
  19221. * @param name defines the skeleton name
  19222. * @param id defines the skeleton Id
  19223. * @param scene defines the hosting scene
  19224. */
  19225. constructor(
  19226. /** defines the skeleton name */
  19227. name: string,
  19228. /** defines the skeleton Id */
  19229. id: string, scene: Scene);
  19230. /**
  19231. * Gets the current object class name.
  19232. * @return the class name
  19233. */
  19234. getClassName(): string;
  19235. /**
  19236. * Returns an array containing the root bones
  19237. * @returns an array containing the root bones
  19238. */
  19239. getChildren(): Array<Bone>;
  19240. /**
  19241. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19242. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19243. * @returns a Float32Array containing matrices data
  19244. */
  19245. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19246. /**
  19247. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19248. * @returns a raw texture containing the data
  19249. */
  19250. getTransformMatrixTexture(): Nullable<RawTexture>;
  19251. /**
  19252. * Gets the current hosting scene
  19253. * @returns a scene object
  19254. */
  19255. getScene(): Scene;
  19256. /**
  19257. * Gets a string representing the current skeleton data
  19258. * @param fullDetails defines a boolean indicating if we want a verbose version
  19259. * @returns a string representing the current skeleton data
  19260. */
  19261. toString(fullDetails?: boolean): string;
  19262. /**
  19263. * Get bone's index searching by name
  19264. * @param name defines bone's name to search for
  19265. * @return the indice of the bone. Returns -1 if not found
  19266. */
  19267. getBoneIndexByName(name: string): number;
  19268. /**
  19269. * Creater a new animation range
  19270. * @param name defines the name of the range
  19271. * @param from defines the start key
  19272. * @param to defines the end key
  19273. */
  19274. createAnimationRange(name: string, from: number, to: number): void;
  19275. /**
  19276. * Delete a specific animation range
  19277. * @param name defines the name of the range
  19278. * @param deleteFrames defines if frames must be removed as well
  19279. */
  19280. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19281. /**
  19282. * Gets a specific animation range
  19283. * @param name defines the name of the range to look for
  19284. * @returns the requested animation range or null if not found
  19285. */
  19286. getAnimationRange(name: string): Nullable<AnimationRange>;
  19287. /**
  19288. * Gets the list of all animation ranges defined on this skeleton
  19289. * @returns an array
  19290. */
  19291. getAnimationRanges(): Nullable<AnimationRange>[];
  19292. /**
  19293. * Copy animation range from a source skeleton.
  19294. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19295. * @param source defines the source skeleton
  19296. * @param name defines the name of the range to copy
  19297. * @param rescaleAsRequired defines if rescaling must be applied if required
  19298. * @returns true if operation was successful
  19299. */
  19300. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19301. /**
  19302. * Forces the skeleton to go to rest pose
  19303. */
  19304. returnToRest(): void;
  19305. private _getHighestAnimationFrame;
  19306. /**
  19307. * Begin a specific animation range
  19308. * @param name defines the name of the range to start
  19309. * @param loop defines if looping must be turned on (false by default)
  19310. * @param speedRatio defines the speed ratio to apply (1 by default)
  19311. * @param onAnimationEnd defines a callback which will be called when animation will end
  19312. * @returns a new animatable
  19313. */
  19314. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19315. /** @hidden */
  19316. _markAsDirty(): void;
  19317. /** @hidden */
  19318. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19319. /** @hidden */
  19320. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19321. private _computeTransformMatrices;
  19322. /**
  19323. * Build all resources required to render a skeleton
  19324. */
  19325. prepare(): void;
  19326. /**
  19327. * Gets the list of animatables currently running for this skeleton
  19328. * @returns an array of animatables
  19329. */
  19330. getAnimatables(): IAnimatable[];
  19331. /**
  19332. * Clone the current skeleton
  19333. * @param name defines the name of the new skeleton
  19334. * @param id defines the id of the new skeleton
  19335. * @returns the new skeleton
  19336. */
  19337. clone(name: string, id: string): Skeleton;
  19338. /**
  19339. * Enable animation blending for this skeleton
  19340. * @param blendingSpeed defines the blending speed to apply
  19341. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19342. */
  19343. enableBlending(blendingSpeed?: number): void;
  19344. /**
  19345. * Releases all resources associated with the current skeleton
  19346. */
  19347. dispose(): void;
  19348. /**
  19349. * Serialize the skeleton in a JSON object
  19350. * @returns a JSON object
  19351. */
  19352. serialize(): any;
  19353. /**
  19354. * Creates a new skeleton from serialized data
  19355. * @param parsedSkeleton defines the serialized data
  19356. * @param scene defines the hosting scene
  19357. * @returns a new skeleton
  19358. */
  19359. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19360. /**
  19361. * Compute all node absolute transforms
  19362. * @param forceUpdate defines if computation must be done even if cache is up to date
  19363. */
  19364. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19365. /**
  19366. * Gets the root pose matrix
  19367. * @returns a matrix
  19368. */
  19369. getPoseMatrix(): Nullable<Matrix>;
  19370. /**
  19371. * Sorts bones per internal index
  19372. */
  19373. sortBones(): void;
  19374. private _sortBones;
  19375. }
  19376. }
  19377. declare module BABYLON {
  19378. /**
  19379. * Defines a target to use with MorphTargetManager
  19380. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19381. */
  19382. export class MorphTarget implements IAnimatable {
  19383. /** defines the name of the target */
  19384. name: string;
  19385. /**
  19386. * Gets or sets the list of animations
  19387. */
  19388. animations: Animation[];
  19389. private _scene;
  19390. private _positions;
  19391. private _normals;
  19392. private _tangents;
  19393. private _influence;
  19394. /**
  19395. * Observable raised when the influence changes
  19396. */
  19397. onInfluenceChanged: Observable<boolean>;
  19398. /** @hidden */
  19399. _onDataLayoutChanged: Observable<void>;
  19400. /**
  19401. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19402. */
  19403. influence: number;
  19404. /**
  19405. * Gets or sets the id of the morph Target
  19406. */
  19407. id: string;
  19408. private _animationPropertiesOverride;
  19409. /**
  19410. * Gets or sets the animation properties override
  19411. */
  19412. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19413. /**
  19414. * Creates a new MorphTarget
  19415. * @param name defines the name of the target
  19416. * @param influence defines the influence to use
  19417. * @param scene defines the scene the morphtarget belongs to
  19418. */
  19419. constructor(
  19420. /** defines the name of the target */
  19421. name: string, influence?: number, scene?: Nullable<Scene>);
  19422. /**
  19423. * Gets a boolean defining if the target contains position data
  19424. */
  19425. readonly hasPositions: boolean;
  19426. /**
  19427. * Gets a boolean defining if the target contains normal data
  19428. */
  19429. readonly hasNormals: boolean;
  19430. /**
  19431. * Gets a boolean defining if the target contains tangent data
  19432. */
  19433. readonly hasTangents: boolean;
  19434. /**
  19435. * Affects position data to this target
  19436. * @param data defines the position data to use
  19437. */
  19438. setPositions(data: Nullable<FloatArray>): void;
  19439. /**
  19440. * Gets the position data stored in this target
  19441. * @returns a FloatArray containing the position data (or null if not present)
  19442. */
  19443. getPositions(): Nullable<FloatArray>;
  19444. /**
  19445. * Affects normal data to this target
  19446. * @param data defines the normal data to use
  19447. */
  19448. setNormals(data: Nullable<FloatArray>): void;
  19449. /**
  19450. * Gets the normal data stored in this target
  19451. * @returns a FloatArray containing the normal data (or null if not present)
  19452. */
  19453. getNormals(): Nullable<FloatArray>;
  19454. /**
  19455. * Affects tangent data to this target
  19456. * @param data defines the tangent data to use
  19457. */
  19458. setTangents(data: Nullable<FloatArray>): void;
  19459. /**
  19460. * Gets the tangent data stored in this target
  19461. * @returns a FloatArray containing the tangent data (or null if not present)
  19462. */
  19463. getTangents(): Nullable<FloatArray>;
  19464. /**
  19465. * Serializes the current target into a Serialization object
  19466. * @returns the serialized object
  19467. */
  19468. serialize(): any;
  19469. /**
  19470. * Returns the string "MorphTarget"
  19471. * @returns "MorphTarget"
  19472. */
  19473. getClassName(): string;
  19474. /**
  19475. * Creates a new target from serialized data
  19476. * @param serializationObject defines the serialized data to use
  19477. * @returns a new MorphTarget
  19478. */
  19479. static Parse(serializationObject: any): MorphTarget;
  19480. /**
  19481. * Creates a MorphTarget from mesh data
  19482. * @param mesh defines the source mesh
  19483. * @param name defines the name to use for the new target
  19484. * @param influence defines the influence to attach to the target
  19485. * @returns a new MorphTarget
  19486. */
  19487. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19488. }
  19489. }
  19490. declare module BABYLON {
  19491. /**
  19492. * This class is used to deform meshes using morphing between different targets
  19493. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19494. */
  19495. export class MorphTargetManager {
  19496. private _targets;
  19497. private _targetInfluenceChangedObservers;
  19498. private _targetDataLayoutChangedObservers;
  19499. private _activeTargets;
  19500. private _scene;
  19501. private _influences;
  19502. private _supportsNormals;
  19503. private _supportsTangents;
  19504. private _vertexCount;
  19505. private _uniqueId;
  19506. private _tempInfluences;
  19507. /**
  19508. * Creates a new MorphTargetManager
  19509. * @param scene defines the current scene
  19510. */
  19511. constructor(scene?: Nullable<Scene>);
  19512. /**
  19513. * Gets the unique ID of this manager
  19514. */
  19515. readonly uniqueId: number;
  19516. /**
  19517. * Gets the number of vertices handled by this manager
  19518. */
  19519. readonly vertexCount: number;
  19520. /**
  19521. * Gets a boolean indicating if this manager supports morphing of normals
  19522. */
  19523. readonly supportsNormals: boolean;
  19524. /**
  19525. * Gets a boolean indicating if this manager supports morphing of tangents
  19526. */
  19527. readonly supportsTangents: boolean;
  19528. /**
  19529. * Gets the number of targets stored in this manager
  19530. */
  19531. readonly numTargets: number;
  19532. /**
  19533. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19534. */
  19535. readonly numInfluencers: number;
  19536. /**
  19537. * Gets the list of influences (one per target)
  19538. */
  19539. readonly influences: Float32Array;
  19540. /**
  19541. * Gets the active target at specified index. An active target is a target with an influence > 0
  19542. * @param index defines the index to check
  19543. * @returns the requested target
  19544. */
  19545. getActiveTarget(index: number): MorphTarget;
  19546. /**
  19547. * Gets the target at specified index
  19548. * @param index defines the index to check
  19549. * @returns the requested target
  19550. */
  19551. getTarget(index: number): MorphTarget;
  19552. /**
  19553. * Add a new target to this manager
  19554. * @param target defines the target to add
  19555. */
  19556. addTarget(target: MorphTarget): void;
  19557. /**
  19558. * Removes a target from the manager
  19559. * @param target defines the target to remove
  19560. */
  19561. removeTarget(target: MorphTarget): void;
  19562. /**
  19563. * Serializes the current manager into a Serialization object
  19564. * @returns the serialized object
  19565. */
  19566. serialize(): any;
  19567. private _syncActiveTargets;
  19568. /**
  19569. * Syncrhonize the targets with all the meshes using this morph target manager
  19570. */
  19571. synchronize(): void;
  19572. /**
  19573. * Creates a new MorphTargetManager from serialized data
  19574. * @param serializationObject defines the serialized data
  19575. * @param scene defines the hosting scene
  19576. * @returns the new MorphTargetManager
  19577. */
  19578. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19579. }
  19580. }
  19581. declare module BABYLON {
  19582. /**
  19583. * Class used to represent a specific level of detail of a mesh
  19584. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19585. */
  19586. export class MeshLODLevel {
  19587. /** Defines the distance where this level should star being displayed */
  19588. distance: number;
  19589. /** Defines the mesh to use to render this level */
  19590. mesh: Nullable<Mesh>;
  19591. /**
  19592. * Creates a new LOD level
  19593. * @param distance defines the distance where this level should star being displayed
  19594. * @param mesh defines the mesh to use to render this level
  19595. */
  19596. constructor(
  19597. /** Defines the distance where this level should star being displayed */
  19598. distance: number,
  19599. /** Defines the mesh to use to render this level */
  19600. mesh: Nullable<Mesh>);
  19601. }
  19602. }
  19603. declare module BABYLON {
  19604. /**
  19605. * Mesh representing the gorund
  19606. */
  19607. export class GroundMesh extends Mesh {
  19608. /** If octree should be generated */
  19609. generateOctree: boolean;
  19610. private _heightQuads;
  19611. /** @hidden */
  19612. _subdivisionsX: number;
  19613. /** @hidden */
  19614. _subdivisionsY: number;
  19615. /** @hidden */
  19616. _width: number;
  19617. /** @hidden */
  19618. _height: number;
  19619. /** @hidden */
  19620. _minX: number;
  19621. /** @hidden */
  19622. _maxX: number;
  19623. /** @hidden */
  19624. _minZ: number;
  19625. /** @hidden */
  19626. _maxZ: number;
  19627. constructor(name: string, scene: Scene);
  19628. /**
  19629. * "GroundMesh"
  19630. * @returns "GroundMesh"
  19631. */
  19632. getClassName(): string;
  19633. /**
  19634. * The minimum of x and y subdivisions
  19635. */
  19636. readonly subdivisions: number;
  19637. /**
  19638. * X subdivisions
  19639. */
  19640. readonly subdivisionsX: number;
  19641. /**
  19642. * Y subdivisions
  19643. */
  19644. readonly subdivisionsY: number;
  19645. /**
  19646. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19647. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19648. * @param chunksCount the number of subdivisions for x and y
  19649. * @param octreeBlocksSize (Default: 32)
  19650. */
  19651. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19652. /**
  19653. * Returns a height (y) value in the Worl system :
  19654. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19655. * @param x x coordinate
  19656. * @param z z coordinate
  19657. * @returns the ground y position if (x, z) are outside the ground surface.
  19658. */
  19659. getHeightAtCoordinates(x: number, z: number): number;
  19660. /**
  19661. * Returns a normalized vector (Vector3) orthogonal to the ground
  19662. * at the ground coordinates (x, z) expressed in the World system.
  19663. * @param x x coordinate
  19664. * @param z z coordinate
  19665. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19666. */
  19667. getNormalAtCoordinates(x: number, z: number): Vector3;
  19668. /**
  19669. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19670. * at the ground coordinates (x, z) expressed in the World system.
  19671. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19672. * @param x x coordinate
  19673. * @param z z coordinate
  19674. * @param ref vector to store the result
  19675. * @returns the GroundMesh.
  19676. */
  19677. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19678. /**
  19679. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19680. * if the ground has been updated.
  19681. * This can be used in the render loop.
  19682. * @returns the GroundMesh.
  19683. */
  19684. updateCoordinateHeights(): GroundMesh;
  19685. private _getFacetAt;
  19686. private _initHeightQuads;
  19687. private _computeHeightQuads;
  19688. /**
  19689. * Serializes this ground mesh
  19690. * @param serializationObject object to write serialization to
  19691. */
  19692. serialize(serializationObject: any): void;
  19693. /**
  19694. * Parses a serialized ground mesh
  19695. * @param parsedMesh the serialized mesh
  19696. * @param scene the scene to create the ground mesh in
  19697. * @returns the created ground mesh
  19698. */
  19699. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19700. }
  19701. }
  19702. declare module BABYLON {
  19703. /**
  19704. * Interface for Physics-Joint data
  19705. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19706. */
  19707. export interface PhysicsJointData {
  19708. /**
  19709. * The main pivot of the joint
  19710. */
  19711. mainPivot?: Vector3;
  19712. /**
  19713. * The connected pivot of the joint
  19714. */
  19715. connectedPivot?: Vector3;
  19716. /**
  19717. * The main axis of the joint
  19718. */
  19719. mainAxis?: Vector3;
  19720. /**
  19721. * The connected axis of the joint
  19722. */
  19723. connectedAxis?: Vector3;
  19724. /**
  19725. * The collision of the joint
  19726. */
  19727. collision?: boolean;
  19728. /**
  19729. * Native Oimo/Cannon/Energy data
  19730. */
  19731. nativeParams?: any;
  19732. }
  19733. /**
  19734. * This is a holder class for the physics joint created by the physics plugin
  19735. * It holds a set of functions to control the underlying joint
  19736. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19737. */
  19738. export class PhysicsJoint {
  19739. /**
  19740. * The type of the physics joint
  19741. */
  19742. type: number;
  19743. /**
  19744. * The data for the physics joint
  19745. */
  19746. jointData: PhysicsJointData;
  19747. private _physicsJoint;
  19748. protected _physicsPlugin: IPhysicsEnginePlugin;
  19749. /**
  19750. * Initializes the physics joint
  19751. * @param type The type of the physics joint
  19752. * @param jointData The data for the physics joint
  19753. */
  19754. constructor(
  19755. /**
  19756. * The type of the physics joint
  19757. */
  19758. type: number,
  19759. /**
  19760. * The data for the physics joint
  19761. */
  19762. jointData: PhysicsJointData);
  19763. /**
  19764. * Gets the physics joint
  19765. */
  19766. /**
  19767. * Sets the physics joint
  19768. */
  19769. physicsJoint: any;
  19770. /**
  19771. * Sets the physics plugin
  19772. */
  19773. physicsPlugin: IPhysicsEnginePlugin;
  19774. /**
  19775. * Execute a function that is physics-plugin specific.
  19776. * @param {Function} func the function that will be executed.
  19777. * It accepts two parameters: the physics world and the physics joint
  19778. */
  19779. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19780. /**
  19781. * Distance-Joint type
  19782. */
  19783. static DistanceJoint: number;
  19784. /**
  19785. * Hinge-Joint type
  19786. */
  19787. static HingeJoint: number;
  19788. /**
  19789. * Ball-and-Socket joint type
  19790. */
  19791. static BallAndSocketJoint: number;
  19792. /**
  19793. * Wheel-Joint type
  19794. */
  19795. static WheelJoint: number;
  19796. /**
  19797. * Slider-Joint type
  19798. */
  19799. static SliderJoint: number;
  19800. /**
  19801. * Prismatic-Joint type
  19802. */
  19803. static PrismaticJoint: number;
  19804. /**
  19805. * Universal-Joint type
  19806. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19807. */
  19808. static UniversalJoint: number;
  19809. /**
  19810. * Hinge-Joint 2 type
  19811. */
  19812. static Hinge2Joint: number;
  19813. /**
  19814. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19815. */
  19816. static PointToPointJoint: number;
  19817. /**
  19818. * Spring-Joint type
  19819. */
  19820. static SpringJoint: number;
  19821. /**
  19822. * Lock-Joint type
  19823. */
  19824. static LockJoint: number;
  19825. }
  19826. /**
  19827. * A class representing a physics distance joint
  19828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19829. */
  19830. export class DistanceJoint extends PhysicsJoint {
  19831. /**
  19832. *
  19833. * @param jointData The data for the Distance-Joint
  19834. */
  19835. constructor(jointData: DistanceJointData);
  19836. /**
  19837. * Update the predefined distance.
  19838. * @param maxDistance The maximum preferred distance
  19839. * @param minDistance The minimum preferred distance
  19840. */
  19841. updateDistance(maxDistance: number, minDistance?: number): void;
  19842. }
  19843. /**
  19844. * Represents a Motor-Enabled Joint
  19845. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19846. */
  19847. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19848. /**
  19849. * Initializes the Motor-Enabled Joint
  19850. * @param type The type of the joint
  19851. * @param jointData The physica joint data for the joint
  19852. */
  19853. constructor(type: number, jointData: PhysicsJointData);
  19854. /**
  19855. * Set the motor values.
  19856. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19857. * @param force the force to apply
  19858. * @param maxForce max force for this motor.
  19859. */
  19860. setMotor(force?: number, maxForce?: number): void;
  19861. /**
  19862. * Set the motor's limits.
  19863. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19864. * @param upperLimit The upper limit of the motor
  19865. * @param lowerLimit The lower limit of the motor
  19866. */
  19867. setLimit(upperLimit: number, lowerLimit?: number): void;
  19868. }
  19869. /**
  19870. * This class represents a single physics Hinge-Joint
  19871. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19872. */
  19873. export class HingeJoint extends MotorEnabledJoint {
  19874. /**
  19875. * Initializes the Hinge-Joint
  19876. * @param jointData The joint data for the Hinge-Joint
  19877. */
  19878. constructor(jointData: PhysicsJointData);
  19879. /**
  19880. * Set the motor values.
  19881. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19882. * @param {number} force the force to apply
  19883. * @param {number} maxForce max force for this motor.
  19884. */
  19885. setMotor(force?: number, maxForce?: number): void;
  19886. /**
  19887. * Set the motor's limits.
  19888. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19889. * @param upperLimit The upper limit of the motor
  19890. * @param lowerLimit The lower limit of the motor
  19891. */
  19892. setLimit(upperLimit: number, lowerLimit?: number): void;
  19893. }
  19894. /**
  19895. * This class represents a dual hinge physics joint (same as wheel joint)
  19896. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19897. */
  19898. export class Hinge2Joint extends MotorEnabledJoint {
  19899. /**
  19900. * Initializes the Hinge2-Joint
  19901. * @param jointData The joint data for the Hinge2-Joint
  19902. */
  19903. constructor(jointData: PhysicsJointData);
  19904. /**
  19905. * Set the motor values.
  19906. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19907. * @param {number} targetSpeed the speed the motor is to reach
  19908. * @param {number} maxForce max force for this motor.
  19909. * @param {motorIndex} the motor's index, 0 or 1.
  19910. */
  19911. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19912. /**
  19913. * Set the motor limits.
  19914. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19915. * @param {number} upperLimit the upper limit
  19916. * @param {number} lowerLimit lower limit
  19917. * @param {motorIndex} the motor's index, 0 or 1.
  19918. */
  19919. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19920. }
  19921. /**
  19922. * Interface for a motor enabled joint
  19923. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19924. */
  19925. export interface IMotorEnabledJoint {
  19926. /**
  19927. * Physics joint
  19928. */
  19929. physicsJoint: any;
  19930. /**
  19931. * Sets the motor of the motor-enabled joint
  19932. * @param force The force of the motor
  19933. * @param maxForce The maximum force of the motor
  19934. * @param motorIndex The index of the motor
  19935. */
  19936. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19937. /**
  19938. * Sets the limit of the motor
  19939. * @param upperLimit The upper limit of the motor
  19940. * @param lowerLimit The lower limit of the motor
  19941. * @param motorIndex The index of the motor
  19942. */
  19943. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19944. }
  19945. /**
  19946. * Joint data for a Distance-Joint
  19947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19948. */
  19949. export interface DistanceJointData extends PhysicsJointData {
  19950. /**
  19951. * Max distance the 2 joint objects can be apart
  19952. */
  19953. maxDistance: number;
  19954. }
  19955. /**
  19956. * Joint data from a spring joint
  19957. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19958. */
  19959. export interface SpringJointData extends PhysicsJointData {
  19960. /**
  19961. * Length of the spring
  19962. */
  19963. length: number;
  19964. /**
  19965. * Stiffness of the spring
  19966. */
  19967. stiffness: number;
  19968. /**
  19969. * Damping of the spring
  19970. */
  19971. damping: number;
  19972. /** this callback will be called when applying the force to the impostors. */
  19973. forceApplicationCallback: () => void;
  19974. }
  19975. }
  19976. declare module BABYLON {
  19977. /**
  19978. * Holds the data for the raycast result
  19979. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19980. */
  19981. export class PhysicsRaycastResult {
  19982. private _hasHit;
  19983. private _hitDistance;
  19984. private _hitNormalWorld;
  19985. private _hitPointWorld;
  19986. private _rayFromWorld;
  19987. private _rayToWorld;
  19988. /**
  19989. * Gets if there was a hit
  19990. */
  19991. readonly hasHit: boolean;
  19992. /**
  19993. * Gets the distance from the hit
  19994. */
  19995. readonly hitDistance: number;
  19996. /**
  19997. * Gets the hit normal/direction in the world
  19998. */
  19999. readonly hitNormalWorld: Vector3;
  20000. /**
  20001. * Gets the hit point in the world
  20002. */
  20003. readonly hitPointWorld: Vector3;
  20004. /**
  20005. * Gets the ray "start point" of the ray in the world
  20006. */
  20007. readonly rayFromWorld: Vector3;
  20008. /**
  20009. * Gets the ray "end point" of the ray in the world
  20010. */
  20011. readonly rayToWorld: Vector3;
  20012. /**
  20013. * Sets the hit data (normal & point in world space)
  20014. * @param hitNormalWorld defines the normal in world space
  20015. * @param hitPointWorld defines the point in world space
  20016. */
  20017. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20018. /**
  20019. * Sets the distance from the start point to the hit point
  20020. * @param distance
  20021. */
  20022. setHitDistance(distance: number): void;
  20023. /**
  20024. * Calculates the distance manually
  20025. */
  20026. calculateHitDistance(): void;
  20027. /**
  20028. * Resets all the values to default
  20029. * @param from The from point on world space
  20030. * @param to The to point on world space
  20031. */
  20032. reset(from?: Vector3, to?: Vector3): void;
  20033. }
  20034. /**
  20035. * Interface for the size containing width and height
  20036. */
  20037. interface IXYZ {
  20038. /**
  20039. * X
  20040. */
  20041. x: number;
  20042. /**
  20043. * Y
  20044. */
  20045. y: number;
  20046. /**
  20047. * Z
  20048. */
  20049. z: number;
  20050. }
  20051. }
  20052. declare module BABYLON {
  20053. /**
  20054. * Interface used to describe a physics joint
  20055. */
  20056. export interface PhysicsImpostorJoint {
  20057. /** Defines the main impostor to which the joint is linked */
  20058. mainImpostor: PhysicsImpostor;
  20059. /** Defines the impostor that is connected to the main impostor using this joint */
  20060. connectedImpostor: PhysicsImpostor;
  20061. /** Defines the joint itself */
  20062. joint: PhysicsJoint;
  20063. }
  20064. /** @hidden */
  20065. export interface IPhysicsEnginePlugin {
  20066. world: any;
  20067. name: string;
  20068. setGravity(gravity: Vector3): void;
  20069. setTimeStep(timeStep: number): void;
  20070. getTimeStep(): number;
  20071. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20072. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20073. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20074. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20075. removePhysicsBody(impostor: PhysicsImpostor): void;
  20076. generateJoint(joint: PhysicsImpostorJoint): void;
  20077. removeJoint(joint: PhysicsImpostorJoint): void;
  20078. isSupported(): boolean;
  20079. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20080. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20081. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20082. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20083. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20084. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20085. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20086. getBodyMass(impostor: PhysicsImpostor): number;
  20087. getBodyFriction(impostor: PhysicsImpostor): number;
  20088. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20089. getBodyRestitution(impostor: PhysicsImpostor): number;
  20090. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20091. getBodyPressure?(impostor: PhysicsImpostor): number;
  20092. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20093. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20094. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20095. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20096. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20097. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20098. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20099. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20100. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20101. sleepBody(impostor: PhysicsImpostor): void;
  20102. wakeUpBody(impostor: PhysicsImpostor): void;
  20103. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20104. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20105. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20106. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20107. getRadius(impostor: PhysicsImpostor): number;
  20108. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20109. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20110. dispose(): void;
  20111. }
  20112. /**
  20113. * Interface used to define a physics engine
  20114. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20115. */
  20116. export interface IPhysicsEngine {
  20117. /**
  20118. * Gets the gravity vector used by the simulation
  20119. */
  20120. gravity: Vector3;
  20121. /**
  20122. * Sets the gravity vector used by the simulation
  20123. * @param gravity defines the gravity vector to use
  20124. */
  20125. setGravity(gravity: Vector3): void;
  20126. /**
  20127. * Set the time step of the physics engine.
  20128. * Default is 1/60.
  20129. * To slow it down, enter 1/600 for example.
  20130. * To speed it up, 1/30
  20131. * @param newTimeStep the new timestep to apply to this world.
  20132. */
  20133. setTimeStep(newTimeStep: number): void;
  20134. /**
  20135. * Get the time step of the physics engine.
  20136. * @returns the current time step
  20137. */
  20138. getTimeStep(): number;
  20139. /**
  20140. * Release all resources
  20141. */
  20142. dispose(): void;
  20143. /**
  20144. * Gets the name of the current physics plugin
  20145. * @returns the name of the plugin
  20146. */
  20147. getPhysicsPluginName(): string;
  20148. /**
  20149. * Adding a new impostor for the impostor tracking.
  20150. * This will be done by the impostor itself.
  20151. * @param impostor the impostor to add
  20152. */
  20153. addImpostor(impostor: PhysicsImpostor): void;
  20154. /**
  20155. * Remove an impostor from the engine.
  20156. * This impostor and its mesh will not longer be updated by the physics engine.
  20157. * @param impostor the impostor to remove
  20158. */
  20159. removeImpostor(impostor: PhysicsImpostor): void;
  20160. /**
  20161. * Add a joint to the physics engine
  20162. * @param mainImpostor defines the main impostor to which the joint is added.
  20163. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20164. * @param joint defines the joint that will connect both impostors.
  20165. */
  20166. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20167. /**
  20168. * Removes a joint from the simulation
  20169. * @param mainImpostor defines the impostor used with the joint
  20170. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20171. * @param joint defines the joint to remove
  20172. */
  20173. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20174. /**
  20175. * Gets the current plugin used to run the simulation
  20176. * @returns current plugin
  20177. */
  20178. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20179. /**
  20180. * Gets the list of physic impostors
  20181. * @returns an array of PhysicsImpostor
  20182. */
  20183. getImpostors(): Array<PhysicsImpostor>;
  20184. /**
  20185. * Gets the impostor for a physics enabled object
  20186. * @param object defines the object impersonated by the impostor
  20187. * @returns the PhysicsImpostor or null if not found
  20188. */
  20189. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20190. /**
  20191. * Gets the impostor for a physics body object
  20192. * @param body defines physics body used by the impostor
  20193. * @returns the PhysicsImpostor or null if not found
  20194. */
  20195. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20196. /**
  20197. * Does a raycast in the physics world
  20198. * @param from when should the ray start?
  20199. * @param to when should the ray end?
  20200. * @returns PhysicsRaycastResult
  20201. */
  20202. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20203. /**
  20204. * Called by the scene. No need to call it.
  20205. * @param delta defines the timespam between frames
  20206. */
  20207. _step(delta: number): void;
  20208. }
  20209. }
  20210. declare module BABYLON {
  20211. /**
  20212. * The interface for the physics imposter parameters
  20213. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20214. */
  20215. export interface PhysicsImpostorParameters {
  20216. /**
  20217. * The mass of the physics imposter
  20218. */
  20219. mass: number;
  20220. /**
  20221. * The friction of the physics imposter
  20222. */
  20223. friction?: number;
  20224. /**
  20225. * The coefficient of restitution of the physics imposter
  20226. */
  20227. restitution?: number;
  20228. /**
  20229. * The native options of the physics imposter
  20230. */
  20231. nativeOptions?: any;
  20232. /**
  20233. * Specifies if the parent should be ignored
  20234. */
  20235. ignoreParent?: boolean;
  20236. /**
  20237. * Specifies if bi-directional transformations should be disabled
  20238. */
  20239. disableBidirectionalTransformation?: boolean;
  20240. /**
  20241. * The pressure inside the physics imposter, soft object only
  20242. */
  20243. pressure?: number;
  20244. /**
  20245. * The stiffness the physics imposter, soft object only
  20246. */
  20247. stiffness?: number;
  20248. /**
  20249. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20250. */
  20251. velocityIterations?: number;
  20252. /**
  20253. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20254. */
  20255. positionIterations?: number;
  20256. /**
  20257. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20258. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20259. * Add to fix multiple points
  20260. */
  20261. fixedPoints?: number;
  20262. /**
  20263. * The collision margin around a soft object
  20264. */
  20265. margin?: number;
  20266. /**
  20267. * The collision margin around a soft object
  20268. */
  20269. damping?: number;
  20270. /**
  20271. * The path for a rope based on an extrusion
  20272. */
  20273. path?: any;
  20274. /**
  20275. * The shape of an extrusion used for a rope based on an extrusion
  20276. */
  20277. shape?: any;
  20278. }
  20279. /**
  20280. * Interface for a physics-enabled object
  20281. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20282. */
  20283. export interface IPhysicsEnabledObject {
  20284. /**
  20285. * The position of the physics-enabled object
  20286. */
  20287. position: Vector3;
  20288. /**
  20289. * The rotation of the physics-enabled object
  20290. */
  20291. rotationQuaternion: Nullable<Quaternion>;
  20292. /**
  20293. * The scale of the physics-enabled object
  20294. */
  20295. scaling: Vector3;
  20296. /**
  20297. * The rotation of the physics-enabled object
  20298. */
  20299. rotation?: Vector3;
  20300. /**
  20301. * The parent of the physics-enabled object
  20302. */
  20303. parent?: any;
  20304. /**
  20305. * The bounding info of the physics-enabled object
  20306. * @returns The bounding info of the physics-enabled object
  20307. */
  20308. getBoundingInfo(): BoundingInfo;
  20309. /**
  20310. * Computes the world matrix
  20311. * @param force Specifies if the world matrix should be computed by force
  20312. * @returns A world matrix
  20313. */
  20314. computeWorldMatrix(force: boolean): Matrix;
  20315. /**
  20316. * Gets the world matrix
  20317. * @returns A world matrix
  20318. */
  20319. getWorldMatrix?(): Matrix;
  20320. /**
  20321. * Gets the child meshes
  20322. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20323. * @returns An array of abstract meshes
  20324. */
  20325. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20326. /**
  20327. * Gets the vertex data
  20328. * @param kind The type of vertex data
  20329. * @returns A nullable array of numbers, or a float32 array
  20330. */
  20331. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20332. /**
  20333. * Gets the indices from the mesh
  20334. * @returns A nullable array of index arrays
  20335. */
  20336. getIndices?(): Nullable<IndicesArray>;
  20337. /**
  20338. * Gets the scene from the mesh
  20339. * @returns the indices array or null
  20340. */
  20341. getScene?(): Scene;
  20342. /**
  20343. * Gets the absolute position from the mesh
  20344. * @returns the absolute position
  20345. */
  20346. getAbsolutePosition(): Vector3;
  20347. /**
  20348. * Gets the absolute pivot point from the mesh
  20349. * @returns the absolute pivot point
  20350. */
  20351. getAbsolutePivotPoint(): Vector3;
  20352. /**
  20353. * Rotates the mesh
  20354. * @param axis The axis of rotation
  20355. * @param amount The amount of rotation
  20356. * @param space The space of the rotation
  20357. * @returns The rotation transform node
  20358. */
  20359. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20360. /**
  20361. * Translates the mesh
  20362. * @param axis The axis of translation
  20363. * @param distance The distance of translation
  20364. * @param space The space of the translation
  20365. * @returns The transform node
  20366. */
  20367. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20368. /**
  20369. * Sets the absolute position of the mesh
  20370. * @param absolutePosition The absolute position of the mesh
  20371. * @returns The transform node
  20372. */
  20373. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20374. /**
  20375. * Gets the class name of the mesh
  20376. * @returns The class name
  20377. */
  20378. getClassName(): string;
  20379. }
  20380. /**
  20381. * Represents a physics imposter
  20382. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20383. */
  20384. export class PhysicsImpostor {
  20385. /**
  20386. * The physics-enabled object used as the physics imposter
  20387. */
  20388. object: IPhysicsEnabledObject;
  20389. /**
  20390. * The type of the physics imposter
  20391. */
  20392. type: number;
  20393. private _options;
  20394. private _scene?;
  20395. /**
  20396. * The default object size of the imposter
  20397. */
  20398. static DEFAULT_OBJECT_SIZE: Vector3;
  20399. /**
  20400. * The identity quaternion of the imposter
  20401. */
  20402. static IDENTITY_QUATERNION: Quaternion;
  20403. /** @hidden */
  20404. _pluginData: any;
  20405. private _physicsEngine;
  20406. private _physicsBody;
  20407. private _bodyUpdateRequired;
  20408. private _onBeforePhysicsStepCallbacks;
  20409. private _onAfterPhysicsStepCallbacks;
  20410. /** @hidden */
  20411. _onPhysicsCollideCallbacks: Array<{
  20412. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20413. otherImpostors: Array<PhysicsImpostor>;
  20414. }>;
  20415. private _deltaPosition;
  20416. private _deltaRotation;
  20417. private _deltaRotationConjugated;
  20418. /** hidden */
  20419. _isFromLine: boolean;
  20420. private _parent;
  20421. private _isDisposed;
  20422. private static _tmpVecs;
  20423. private static _tmpQuat;
  20424. /**
  20425. * Specifies if the physics imposter is disposed
  20426. */
  20427. readonly isDisposed: boolean;
  20428. /**
  20429. * Gets the mass of the physics imposter
  20430. */
  20431. mass: number;
  20432. /**
  20433. * Gets the coefficient of friction
  20434. */
  20435. /**
  20436. * Sets the coefficient of friction
  20437. */
  20438. friction: number;
  20439. /**
  20440. * Gets the coefficient of restitution
  20441. */
  20442. /**
  20443. * Sets the coefficient of restitution
  20444. */
  20445. restitution: number;
  20446. /**
  20447. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20448. */
  20449. /**
  20450. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20451. */
  20452. pressure: number;
  20453. /**
  20454. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20455. */
  20456. /**
  20457. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20458. */
  20459. stiffness: number;
  20460. /**
  20461. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20462. */
  20463. /**
  20464. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20465. */
  20466. velocityIterations: number;
  20467. /**
  20468. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20469. */
  20470. /**
  20471. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20472. */
  20473. positionIterations: number;
  20474. /**
  20475. * The unique id of the physics imposter
  20476. * set by the physics engine when adding this impostor to the array
  20477. */
  20478. uniqueId: number;
  20479. /**
  20480. * @hidden
  20481. */
  20482. soft: boolean;
  20483. /**
  20484. * @hidden
  20485. */
  20486. segments: number;
  20487. private _joints;
  20488. /**
  20489. * Initializes the physics imposter
  20490. * @param object The physics-enabled object used as the physics imposter
  20491. * @param type The type of the physics imposter
  20492. * @param _options The options for the physics imposter
  20493. * @param _scene The Babylon scene
  20494. */
  20495. constructor(
  20496. /**
  20497. * The physics-enabled object used as the physics imposter
  20498. */
  20499. object: IPhysicsEnabledObject,
  20500. /**
  20501. * The type of the physics imposter
  20502. */
  20503. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20504. /**
  20505. * This function will completly initialize this impostor.
  20506. * It will create a new body - but only if this mesh has no parent.
  20507. * If it has, this impostor will not be used other than to define the impostor
  20508. * of the child mesh.
  20509. * @hidden
  20510. */
  20511. _init(): void;
  20512. private _getPhysicsParent;
  20513. /**
  20514. * Should a new body be generated.
  20515. * @returns boolean specifying if body initialization is required
  20516. */
  20517. isBodyInitRequired(): boolean;
  20518. /**
  20519. * Sets the updated scaling
  20520. * @param updated Specifies if the scaling is updated
  20521. */
  20522. setScalingUpdated(): void;
  20523. /**
  20524. * Force a regeneration of this or the parent's impostor's body.
  20525. * Use under cautious - This will remove all joints already implemented.
  20526. */
  20527. forceUpdate(): void;
  20528. /**
  20529. * Gets the body that holds this impostor. Either its own, or its parent.
  20530. */
  20531. /**
  20532. * Set the physics body. Used mainly by the physics engine/plugin
  20533. */
  20534. physicsBody: any;
  20535. /**
  20536. * Get the parent of the physics imposter
  20537. * @returns Physics imposter or null
  20538. */
  20539. /**
  20540. * Sets the parent of the physics imposter
  20541. */
  20542. parent: Nullable<PhysicsImpostor>;
  20543. /**
  20544. * Resets the update flags
  20545. */
  20546. resetUpdateFlags(): void;
  20547. /**
  20548. * Gets the object extend size
  20549. * @returns the object extend size
  20550. */
  20551. getObjectExtendSize(): Vector3;
  20552. /**
  20553. * Gets the object center
  20554. * @returns The object center
  20555. */
  20556. getObjectCenter(): Vector3;
  20557. /**
  20558. * Get a specific parametes from the options parameter
  20559. * @param paramName The object parameter name
  20560. * @returns The object parameter
  20561. */
  20562. getParam(paramName: string): any;
  20563. /**
  20564. * Sets a specific parameter in the options given to the physics plugin
  20565. * @param paramName The parameter name
  20566. * @param value The value of the parameter
  20567. */
  20568. setParam(paramName: string, value: number): void;
  20569. /**
  20570. * Specifically change the body's mass option. Won't recreate the physics body object
  20571. * @param mass The mass of the physics imposter
  20572. */
  20573. setMass(mass: number): void;
  20574. /**
  20575. * Gets the linear velocity
  20576. * @returns linear velocity or null
  20577. */
  20578. getLinearVelocity(): Nullable<Vector3>;
  20579. /**
  20580. * Sets the linear velocity
  20581. * @param velocity linear velocity or null
  20582. */
  20583. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20584. /**
  20585. * Gets the angular velocity
  20586. * @returns angular velocity or null
  20587. */
  20588. getAngularVelocity(): Nullable<Vector3>;
  20589. /**
  20590. * Sets the angular velocity
  20591. * @param velocity The velocity or null
  20592. */
  20593. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20594. /**
  20595. * Execute a function with the physics plugin native code
  20596. * Provide a function the will have two variables - the world object and the physics body object
  20597. * @param func The function to execute with the physics plugin native code
  20598. */
  20599. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20600. /**
  20601. * Register a function that will be executed before the physics world is stepping forward
  20602. * @param func The function to execute before the physics world is stepped forward
  20603. */
  20604. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20605. /**
  20606. * Unregister a function that will be executed before the physics world is stepping forward
  20607. * @param func The function to execute before the physics world is stepped forward
  20608. */
  20609. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20610. /**
  20611. * Register a function that will be executed after the physics step
  20612. * @param func The function to execute after physics step
  20613. */
  20614. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20615. /**
  20616. * Unregisters a function that will be executed after the physics step
  20617. * @param func The function to execute after physics step
  20618. */
  20619. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20620. /**
  20621. * register a function that will be executed when this impostor collides against a different body
  20622. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20623. * @param func Callback that is executed on collision
  20624. */
  20625. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20626. /**
  20627. * Unregisters the physics imposter on contact
  20628. * @param collideAgainst The physics object to collide against
  20629. * @param func Callback to execute on collision
  20630. */
  20631. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20632. private _tmpQuat;
  20633. private _tmpQuat2;
  20634. /**
  20635. * Get the parent rotation
  20636. * @returns The parent rotation
  20637. */
  20638. getParentsRotation(): Quaternion;
  20639. /**
  20640. * this function is executed by the physics engine.
  20641. */
  20642. beforeStep: () => void;
  20643. /**
  20644. * this function is executed by the physics engine
  20645. */
  20646. afterStep: () => void;
  20647. /**
  20648. * Legacy collision detection event support
  20649. */
  20650. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20651. /**
  20652. * event and body object due to cannon's event-based architecture.
  20653. */
  20654. onCollide: (e: {
  20655. body: any;
  20656. }) => void;
  20657. /**
  20658. * Apply a force
  20659. * @param force The force to apply
  20660. * @param contactPoint The contact point for the force
  20661. * @returns The physics imposter
  20662. */
  20663. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20664. /**
  20665. * Apply an impulse
  20666. * @param force The impulse force
  20667. * @param contactPoint The contact point for the impulse force
  20668. * @returns The physics imposter
  20669. */
  20670. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20671. /**
  20672. * A help function to create a joint
  20673. * @param otherImpostor A physics imposter used to create a joint
  20674. * @param jointType The type of joint
  20675. * @param jointData The data for the joint
  20676. * @returns The physics imposter
  20677. */
  20678. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20679. /**
  20680. * Add a joint to this impostor with a different impostor
  20681. * @param otherImpostor A physics imposter used to add a joint
  20682. * @param joint The joint to add
  20683. * @returns The physics imposter
  20684. */
  20685. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20686. /**
  20687. * Add an anchor to a cloth impostor
  20688. * @param otherImpostor rigid impostor to anchor to
  20689. * @param width ratio across width from 0 to 1
  20690. * @param height ratio up height from 0 to 1
  20691. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20692. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20693. * @returns impostor the soft imposter
  20694. */
  20695. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20696. /**
  20697. * Add a hook to a rope impostor
  20698. * @param otherImpostor rigid impostor to anchor to
  20699. * @param length ratio across rope from 0 to 1
  20700. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20701. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20702. * @returns impostor the rope imposter
  20703. */
  20704. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20705. /**
  20706. * Will keep this body still, in a sleep mode.
  20707. * @returns the physics imposter
  20708. */
  20709. sleep(): PhysicsImpostor;
  20710. /**
  20711. * Wake the body up.
  20712. * @returns The physics imposter
  20713. */
  20714. wakeUp(): PhysicsImpostor;
  20715. /**
  20716. * Clones the physics imposter
  20717. * @param newObject The physics imposter clones to this physics-enabled object
  20718. * @returns A nullable physics imposter
  20719. */
  20720. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20721. /**
  20722. * Disposes the physics imposter
  20723. */
  20724. dispose(): void;
  20725. /**
  20726. * Sets the delta position
  20727. * @param position The delta position amount
  20728. */
  20729. setDeltaPosition(position: Vector3): void;
  20730. /**
  20731. * Sets the delta rotation
  20732. * @param rotation The delta rotation amount
  20733. */
  20734. setDeltaRotation(rotation: Quaternion): void;
  20735. /**
  20736. * Gets the box size of the physics imposter and stores the result in the input parameter
  20737. * @param result Stores the box size
  20738. * @returns The physics imposter
  20739. */
  20740. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20741. /**
  20742. * Gets the radius of the physics imposter
  20743. * @returns Radius of the physics imposter
  20744. */
  20745. getRadius(): number;
  20746. /**
  20747. * Sync a bone with this impostor
  20748. * @param bone The bone to sync to the impostor.
  20749. * @param boneMesh The mesh that the bone is influencing.
  20750. * @param jointPivot The pivot of the joint / bone in local space.
  20751. * @param distToJoint Optional distance from the impostor to the joint.
  20752. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20753. */
  20754. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20755. /**
  20756. * Sync impostor to a bone
  20757. * @param bone The bone that the impostor will be synced to.
  20758. * @param boneMesh The mesh that the bone is influencing.
  20759. * @param jointPivot The pivot of the joint / bone in local space.
  20760. * @param distToJoint Optional distance from the impostor to the joint.
  20761. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20762. * @param boneAxis Optional vector3 axis the bone is aligned with
  20763. */
  20764. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20765. /**
  20766. * No-Imposter type
  20767. */
  20768. static NoImpostor: number;
  20769. /**
  20770. * Sphere-Imposter type
  20771. */
  20772. static SphereImpostor: number;
  20773. /**
  20774. * Box-Imposter type
  20775. */
  20776. static BoxImpostor: number;
  20777. /**
  20778. * Plane-Imposter type
  20779. */
  20780. static PlaneImpostor: number;
  20781. /**
  20782. * Mesh-imposter type
  20783. */
  20784. static MeshImpostor: number;
  20785. /**
  20786. * Cylinder-Imposter type
  20787. */
  20788. static CylinderImpostor: number;
  20789. /**
  20790. * Particle-Imposter type
  20791. */
  20792. static ParticleImpostor: number;
  20793. /**
  20794. * Heightmap-Imposter type
  20795. */
  20796. static HeightmapImpostor: number;
  20797. /**
  20798. * ConvexHull-Impostor type (Ammo.js plugin only)
  20799. */
  20800. static ConvexHullImpostor: number;
  20801. /**
  20802. * Rope-Imposter type
  20803. */
  20804. static RopeImpostor: number;
  20805. /**
  20806. * Cloth-Imposter type
  20807. */
  20808. static ClothImpostor: number;
  20809. /**
  20810. * Softbody-Imposter type
  20811. */
  20812. static SoftbodyImpostor: number;
  20813. }
  20814. }
  20815. declare module BABYLON {
  20816. /**
  20817. * @hidden
  20818. **/
  20819. export class _CreationDataStorage {
  20820. closePath?: boolean;
  20821. closeArray?: boolean;
  20822. idx: number[];
  20823. dashSize: number;
  20824. gapSize: number;
  20825. path3D: Path3D;
  20826. pathArray: Vector3[][];
  20827. arc: number;
  20828. radius: number;
  20829. cap: number;
  20830. tessellation: number;
  20831. }
  20832. /**
  20833. * @hidden
  20834. **/
  20835. class _InstanceDataStorage {
  20836. visibleInstances: any;
  20837. batchCache: _InstancesBatch;
  20838. instancesBufferSize: number;
  20839. instancesBuffer: Nullable<Buffer>;
  20840. instancesData: Float32Array;
  20841. overridenInstanceCount: number;
  20842. isFrozen: boolean;
  20843. previousBatch: _InstancesBatch;
  20844. hardwareInstancedRendering: boolean;
  20845. sideOrientation: number;
  20846. }
  20847. /**
  20848. * @hidden
  20849. **/
  20850. export class _InstancesBatch {
  20851. mustReturn: boolean;
  20852. visibleInstances: Nullable<InstancedMesh[]>[];
  20853. renderSelf: boolean[];
  20854. hardwareInstancedRendering: boolean[];
  20855. }
  20856. /**
  20857. * Class used to represent renderable models
  20858. */
  20859. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20860. /**
  20861. * Mesh side orientation : usually the external or front surface
  20862. */
  20863. static readonly FRONTSIDE: number;
  20864. /**
  20865. * Mesh side orientation : usually the internal or back surface
  20866. */
  20867. static readonly BACKSIDE: number;
  20868. /**
  20869. * Mesh side orientation : both internal and external or front and back surfaces
  20870. */
  20871. static readonly DOUBLESIDE: number;
  20872. /**
  20873. * Mesh side orientation : by default, `FRONTSIDE`
  20874. */
  20875. static readonly DEFAULTSIDE: number;
  20876. /**
  20877. * Mesh cap setting : no cap
  20878. */
  20879. static readonly NO_CAP: number;
  20880. /**
  20881. * Mesh cap setting : one cap at the beginning of the mesh
  20882. */
  20883. static readonly CAP_START: number;
  20884. /**
  20885. * Mesh cap setting : one cap at the end of the mesh
  20886. */
  20887. static readonly CAP_END: number;
  20888. /**
  20889. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20890. */
  20891. static readonly CAP_ALL: number;
  20892. /**
  20893. * Gets the default side orientation.
  20894. * @param orientation the orientation to value to attempt to get
  20895. * @returns the default orientation
  20896. * @hidden
  20897. */
  20898. static _GetDefaultSideOrientation(orientation?: number): number;
  20899. private _onBeforeRenderObservable;
  20900. private _onBeforeBindObservable;
  20901. private _onAfterRenderObservable;
  20902. private _onBeforeDrawObservable;
  20903. /**
  20904. * An event triggered before rendering the mesh
  20905. */
  20906. readonly onBeforeRenderObservable: Observable<Mesh>;
  20907. /**
  20908. * An event triggered before binding the mesh
  20909. */
  20910. readonly onBeforeBindObservable: Observable<Mesh>;
  20911. /**
  20912. * An event triggered after rendering the mesh
  20913. */
  20914. readonly onAfterRenderObservable: Observable<Mesh>;
  20915. /**
  20916. * An event triggered before drawing the mesh
  20917. */
  20918. readonly onBeforeDrawObservable: Observable<Mesh>;
  20919. private _onBeforeDrawObserver;
  20920. /**
  20921. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20922. */
  20923. onBeforeDraw: () => void;
  20924. /**
  20925. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20926. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20927. */
  20928. delayLoadState: number;
  20929. /**
  20930. * Gets the list of instances created from this mesh
  20931. * it is not supposed to be modified manually.
  20932. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20933. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20934. */
  20935. instances: InstancedMesh[];
  20936. /**
  20937. * Gets the file containing delay loading data for this mesh
  20938. */
  20939. delayLoadingFile: string;
  20940. /** @hidden */
  20941. _binaryInfo: any;
  20942. private _LODLevels;
  20943. /**
  20944. * User defined function used to change how LOD level selection is done
  20945. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20946. */
  20947. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20948. private _morphTargetManager;
  20949. /**
  20950. * Gets or sets the morph target manager
  20951. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20952. */
  20953. morphTargetManager: Nullable<MorphTargetManager>;
  20954. /** @hidden */
  20955. _creationDataStorage: Nullable<_CreationDataStorage>;
  20956. /** @hidden */
  20957. _geometry: Nullable<Geometry>;
  20958. /** @hidden */
  20959. _delayInfo: Array<string>;
  20960. /** @hidden */
  20961. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20962. /** @hidden */
  20963. _instanceDataStorage: _InstanceDataStorage;
  20964. private _effectiveMaterial;
  20965. /** @hidden */
  20966. _shouldGenerateFlatShading: boolean;
  20967. private _preActivateId;
  20968. /** @hidden */
  20969. _originalBuilderSideOrientation: number;
  20970. /**
  20971. * Use this property to change the original side orientation defined at construction time
  20972. */
  20973. overrideMaterialSideOrientation: Nullable<number>;
  20974. private _areNormalsFrozen;
  20975. private _sourcePositions;
  20976. private _sourceNormals;
  20977. private _source;
  20978. private meshMap;
  20979. /**
  20980. * Gets the source mesh (the one used to clone this one from)
  20981. */
  20982. readonly source: Nullable<Mesh>;
  20983. /**
  20984. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20985. */
  20986. isUnIndexed: boolean;
  20987. /**
  20988. * @constructor
  20989. * @param name The value used by scene.getMeshByName() to do a lookup.
  20990. * @param scene The scene to add this mesh to.
  20991. * @param parent The parent of this mesh, if it has one
  20992. * @param source An optional Mesh from which geometry is shared, cloned.
  20993. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20994. * When false, achieved by calling a clone(), also passing False.
  20995. * This will make creation of children, recursive.
  20996. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20997. */
  20998. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20999. /**
  21000. * Gets the class name
  21001. * @returns the string "Mesh".
  21002. */
  21003. getClassName(): string;
  21004. /** @hidden */
  21005. readonly _isMesh: boolean;
  21006. /**
  21007. * Returns a description of this mesh
  21008. * @param fullDetails define if full details about this mesh must be used
  21009. * @returns a descriptive string representing this mesh
  21010. */
  21011. toString(fullDetails?: boolean): string;
  21012. /** @hidden */
  21013. _unBindEffect(): void;
  21014. /**
  21015. * Gets a boolean indicating if this mesh has LOD
  21016. */
  21017. readonly hasLODLevels: boolean;
  21018. /**
  21019. * Gets the list of MeshLODLevel associated with the current mesh
  21020. * @returns an array of MeshLODLevel
  21021. */
  21022. getLODLevels(): MeshLODLevel[];
  21023. private _sortLODLevels;
  21024. /**
  21025. * Add a mesh as LOD level triggered at the given distance.
  21026. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21027. * @param distance The distance from the center of the object to show this level
  21028. * @param mesh The mesh to be added as LOD level (can be null)
  21029. * @return This mesh (for chaining)
  21030. */
  21031. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21032. /**
  21033. * Returns the LOD level mesh at the passed distance or null if not found.
  21034. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21035. * @param distance The distance from the center of the object to show this level
  21036. * @returns a Mesh or `null`
  21037. */
  21038. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21039. /**
  21040. * Remove a mesh from the LOD array
  21041. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21042. * @param mesh defines the mesh to be removed
  21043. * @return This mesh (for chaining)
  21044. */
  21045. removeLODLevel(mesh: Mesh): Mesh;
  21046. /**
  21047. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21048. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21049. * @param camera defines the camera to use to compute distance
  21050. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21051. * @return This mesh (for chaining)
  21052. */
  21053. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21054. /**
  21055. * Gets the mesh internal Geometry object
  21056. */
  21057. readonly geometry: Nullable<Geometry>;
  21058. /**
  21059. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21060. * @returns the total number of vertices
  21061. */
  21062. getTotalVertices(): number;
  21063. /**
  21064. * Returns the content of an associated vertex buffer
  21065. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21066. * - VertexBuffer.PositionKind
  21067. * - VertexBuffer.UVKind
  21068. * - VertexBuffer.UV2Kind
  21069. * - VertexBuffer.UV3Kind
  21070. * - VertexBuffer.UV4Kind
  21071. * - VertexBuffer.UV5Kind
  21072. * - VertexBuffer.UV6Kind
  21073. * - VertexBuffer.ColorKind
  21074. * - VertexBuffer.MatricesIndicesKind
  21075. * - VertexBuffer.MatricesIndicesExtraKind
  21076. * - VertexBuffer.MatricesWeightsKind
  21077. * - VertexBuffer.MatricesWeightsExtraKind
  21078. * @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
  21079. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21080. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21081. */
  21082. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21083. /**
  21084. * Returns the mesh VertexBuffer object from the requested `kind`
  21085. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21086. * - VertexBuffer.PositionKind
  21087. * - VertexBuffer.UVKind
  21088. * - VertexBuffer.UV2Kind
  21089. * - VertexBuffer.UV3Kind
  21090. * - VertexBuffer.UV4Kind
  21091. * - VertexBuffer.UV5Kind
  21092. * - VertexBuffer.UV6Kind
  21093. * - VertexBuffer.ColorKind
  21094. * - VertexBuffer.MatricesIndicesKind
  21095. * - VertexBuffer.MatricesIndicesExtraKind
  21096. * - VertexBuffer.MatricesWeightsKind
  21097. * - VertexBuffer.MatricesWeightsExtraKind
  21098. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21099. */
  21100. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21101. /**
  21102. * Tests if a specific vertex buffer is associated with this mesh
  21103. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21104. * - VertexBuffer.PositionKind
  21105. * - VertexBuffer.UVKind
  21106. * - VertexBuffer.UV2Kind
  21107. * - VertexBuffer.UV3Kind
  21108. * - VertexBuffer.UV4Kind
  21109. * - VertexBuffer.UV5Kind
  21110. * - VertexBuffer.UV6Kind
  21111. * - VertexBuffer.ColorKind
  21112. * - VertexBuffer.MatricesIndicesKind
  21113. * - VertexBuffer.MatricesIndicesExtraKind
  21114. * - VertexBuffer.MatricesWeightsKind
  21115. * - VertexBuffer.MatricesWeightsExtraKind
  21116. * @returns a boolean
  21117. */
  21118. isVerticesDataPresent(kind: string): boolean;
  21119. /**
  21120. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21121. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21122. * - VertexBuffer.PositionKind
  21123. * - VertexBuffer.UVKind
  21124. * - VertexBuffer.UV2Kind
  21125. * - VertexBuffer.UV3Kind
  21126. * - VertexBuffer.UV4Kind
  21127. * - VertexBuffer.UV5Kind
  21128. * - VertexBuffer.UV6Kind
  21129. * - VertexBuffer.ColorKind
  21130. * - VertexBuffer.MatricesIndicesKind
  21131. * - VertexBuffer.MatricesIndicesExtraKind
  21132. * - VertexBuffer.MatricesWeightsKind
  21133. * - VertexBuffer.MatricesWeightsExtraKind
  21134. * @returns a boolean
  21135. */
  21136. isVertexBufferUpdatable(kind: string): boolean;
  21137. /**
  21138. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21139. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21140. * - VertexBuffer.PositionKind
  21141. * - VertexBuffer.UVKind
  21142. * - VertexBuffer.UV2Kind
  21143. * - VertexBuffer.UV3Kind
  21144. * - VertexBuffer.UV4Kind
  21145. * - VertexBuffer.UV5Kind
  21146. * - VertexBuffer.UV6Kind
  21147. * - VertexBuffer.ColorKind
  21148. * - VertexBuffer.MatricesIndicesKind
  21149. * - VertexBuffer.MatricesIndicesExtraKind
  21150. * - VertexBuffer.MatricesWeightsKind
  21151. * - VertexBuffer.MatricesWeightsExtraKind
  21152. * @returns an array of strings
  21153. */
  21154. getVerticesDataKinds(): string[];
  21155. /**
  21156. * Returns a positive integer : the total number of indices in this mesh geometry.
  21157. * @returns the numner of indices or zero if the mesh has no geometry.
  21158. */
  21159. getTotalIndices(): number;
  21160. /**
  21161. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21162. * @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.
  21163. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21164. * @returns the indices array or an empty array if the mesh has no geometry
  21165. */
  21166. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21167. readonly isBlocked: boolean;
  21168. /**
  21169. * Determine if the current mesh is ready to be rendered
  21170. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21171. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21172. * @returns true if all associated assets are ready (material, textures, shaders)
  21173. */
  21174. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21175. /**
  21176. * 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.
  21177. */
  21178. readonly areNormalsFrozen: boolean;
  21179. /**
  21180. * 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.
  21181. * @returns the current mesh
  21182. */
  21183. freezeNormals(): Mesh;
  21184. /**
  21185. * 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
  21186. * @returns the current mesh
  21187. */
  21188. unfreezeNormals(): Mesh;
  21189. /**
  21190. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21191. */
  21192. overridenInstanceCount: number;
  21193. /** @hidden */
  21194. _preActivate(): Mesh;
  21195. /** @hidden */
  21196. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21197. /** @hidden */
  21198. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21199. /**
  21200. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21201. * This means the mesh underlying bounding box and sphere are recomputed.
  21202. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21203. * @returns the current mesh
  21204. */
  21205. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21206. /** @hidden */
  21207. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21208. /**
  21209. * This function will subdivide the mesh into multiple submeshes
  21210. * @param count defines the expected number of submeshes
  21211. */
  21212. subdivide(count: number): void;
  21213. /**
  21214. * Copy a FloatArray into a specific associated vertex buffer
  21215. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21216. * - VertexBuffer.PositionKind
  21217. * - VertexBuffer.UVKind
  21218. * - VertexBuffer.UV2Kind
  21219. * - VertexBuffer.UV3Kind
  21220. * - VertexBuffer.UV4Kind
  21221. * - VertexBuffer.UV5Kind
  21222. * - VertexBuffer.UV6Kind
  21223. * - VertexBuffer.ColorKind
  21224. * - VertexBuffer.MatricesIndicesKind
  21225. * - VertexBuffer.MatricesIndicesExtraKind
  21226. * - VertexBuffer.MatricesWeightsKind
  21227. * - VertexBuffer.MatricesWeightsExtraKind
  21228. * @param data defines the data source
  21229. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21230. * @param stride defines the data stride size (can be null)
  21231. * @returns the current mesh
  21232. */
  21233. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21234. /**
  21235. * Flags an associated vertex buffer as updatable
  21236. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21237. * - VertexBuffer.PositionKind
  21238. * - VertexBuffer.UVKind
  21239. * - VertexBuffer.UV2Kind
  21240. * - VertexBuffer.UV3Kind
  21241. * - VertexBuffer.UV4Kind
  21242. * - VertexBuffer.UV5Kind
  21243. * - VertexBuffer.UV6Kind
  21244. * - VertexBuffer.ColorKind
  21245. * - VertexBuffer.MatricesIndicesKind
  21246. * - VertexBuffer.MatricesIndicesExtraKind
  21247. * - VertexBuffer.MatricesWeightsKind
  21248. * - VertexBuffer.MatricesWeightsExtraKind
  21249. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21250. */
  21251. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21252. /**
  21253. * Sets the mesh global Vertex Buffer
  21254. * @param buffer defines the buffer to use
  21255. * @returns the current mesh
  21256. */
  21257. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21258. /**
  21259. * Update a specific associated vertex buffer
  21260. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21261. * - VertexBuffer.PositionKind
  21262. * - VertexBuffer.UVKind
  21263. * - VertexBuffer.UV2Kind
  21264. * - VertexBuffer.UV3Kind
  21265. * - VertexBuffer.UV4Kind
  21266. * - VertexBuffer.UV5Kind
  21267. * - VertexBuffer.UV6Kind
  21268. * - VertexBuffer.ColorKind
  21269. * - VertexBuffer.MatricesIndicesKind
  21270. * - VertexBuffer.MatricesIndicesExtraKind
  21271. * - VertexBuffer.MatricesWeightsKind
  21272. * - VertexBuffer.MatricesWeightsExtraKind
  21273. * @param data defines the data source
  21274. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21275. * @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)
  21276. * @returns the current mesh
  21277. */
  21278. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21279. /**
  21280. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21281. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21282. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21283. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21284. * @returns the current mesh
  21285. */
  21286. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21287. /**
  21288. * Creates a un-shared specific occurence of the geometry for the mesh.
  21289. * @returns the current mesh
  21290. */
  21291. makeGeometryUnique(): Mesh;
  21292. /**
  21293. * Set the index buffer of this mesh
  21294. * @param indices defines the source data
  21295. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21296. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21297. * @returns the current mesh
  21298. */
  21299. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21300. /**
  21301. * Update the current index buffer
  21302. * @param indices defines the source data
  21303. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21304. * @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)
  21305. * @returns the current mesh
  21306. */
  21307. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21308. /**
  21309. * Invert the geometry to move from a right handed system to a left handed one.
  21310. * @returns the current mesh
  21311. */
  21312. toLeftHanded(): Mesh;
  21313. /** @hidden */
  21314. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21315. /** @hidden */
  21316. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21317. /**
  21318. * Registers for this mesh a javascript function called just before the rendering process
  21319. * @param func defines the function to call before rendering this mesh
  21320. * @returns the current mesh
  21321. */
  21322. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21323. /**
  21324. * Disposes a previously registered javascript function called before the rendering
  21325. * @param func defines the function to remove
  21326. * @returns the current mesh
  21327. */
  21328. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21329. /**
  21330. * Registers for this mesh a javascript function called just after the rendering is complete
  21331. * @param func defines the function to call after rendering this mesh
  21332. * @returns the current mesh
  21333. */
  21334. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21335. /**
  21336. * Disposes a previously registered javascript function called after the rendering.
  21337. * @param func defines the function to remove
  21338. * @returns the current mesh
  21339. */
  21340. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21341. /** @hidden */
  21342. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21343. /** @hidden */
  21344. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21345. /** @hidden */
  21346. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21347. /** @hidden */
  21348. _freeze(): void;
  21349. /** @hidden */
  21350. _unFreeze(): void;
  21351. /**
  21352. * 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
  21353. * @param subMesh defines the subMesh to render
  21354. * @param enableAlphaMode defines if alpha mode can be changed
  21355. * @returns the current mesh
  21356. */
  21357. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21358. private _onBeforeDraw;
  21359. /**
  21360. * Renormalize the mesh and patch it up if there are no weights
  21361. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21362. * However in the case of zero weights then we set just a single influence to 1.
  21363. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21364. */
  21365. cleanMatrixWeights(): void;
  21366. private normalizeSkinFourWeights;
  21367. private normalizeSkinWeightsAndExtra;
  21368. /**
  21369. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21370. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21371. * the user know there was an issue with importing the mesh
  21372. * @returns a validation object with skinned, valid and report string
  21373. */
  21374. validateSkinning(): {
  21375. skinned: boolean;
  21376. valid: boolean;
  21377. report: string;
  21378. };
  21379. /** @hidden */
  21380. _checkDelayState(): Mesh;
  21381. private _queueLoad;
  21382. /**
  21383. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21384. * A mesh is in the frustum if its bounding box intersects the frustum
  21385. * @param frustumPlanes defines the frustum to test
  21386. * @returns true if the mesh is in the frustum planes
  21387. */
  21388. isInFrustum(frustumPlanes: Plane[]): boolean;
  21389. /**
  21390. * Sets the mesh material by the material or multiMaterial `id` property
  21391. * @param id is a string identifying the material or the multiMaterial
  21392. * @returns the current mesh
  21393. */
  21394. setMaterialByID(id: string): Mesh;
  21395. /**
  21396. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21397. * @returns an array of IAnimatable
  21398. */
  21399. getAnimatables(): IAnimatable[];
  21400. /**
  21401. * Modifies the mesh geometry according to the passed transformation matrix.
  21402. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21403. * The mesh normals are modified using the same transformation.
  21404. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21405. * @param transform defines the transform matrix to use
  21406. * @see http://doc.babylonjs.com/resources/baking_transformations
  21407. * @returns the current mesh
  21408. */
  21409. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21410. /**
  21411. * Modifies the mesh geometry according to its own current World Matrix.
  21412. * The mesh World Matrix is then reset.
  21413. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21414. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21415. * @see http://doc.babylonjs.com/resources/baking_transformations
  21416. * @returns the current mesh
  21417. */
  21418. bakeCurrentTransformIntoVertices(): Mesh;
  21419. /** @hidden */
  21420. readonly _positions: Nullable<Vector3[]>;
  21421. /** @hidden */
  21422. _resetPointsArrayCache(): Mesh;
  21423. /** @hidden */
  21424. _generatePointsArray(): boolean;
  21425. /**
  21426. * Returns a new Mesh object generated from the current mesh properties.
  21427. * This method must not get confused with createInstance()
  21428. * @param name is a string, the name given to the new mesh
  21429. * @param newParent can be any Node object (default `null`)
  21430. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21431. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21432. * @returns a new mesh
  21433. */
  21434. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21435. /**
  21436. * Releases resources associated with this mesh.
  21437. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21438. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21439. */
  21440. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21441. /**
  21442. * Modifies the mesh geometry according to a displacement map.
  21443. * 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.
  21444. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21445. * @param url is a string, the URL from the image file is to be downloaded.
  21446. * @param minHeight is the lower limit of the displacement.
  21447. * @param maxHeight is the upper limit of the displacement.
  21448. * @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.
  21449. * @param uvOffset is an optional vector2 used to offset UV.
  21450. * @param uvScale is an optional vector2 used to scale UV.
  21451. * @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.
  21452. * @returns the Mesh.
  21453. */
  21454. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21455. /**
  21456. * Modifies the mesh geometry according to a displacementMap buffer.
  21457. * 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.
  21458. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21459. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21460. * @param heightMapWidth is the width of the buffer image.
  21461. * @param heightMapHeight is the height of the buffer image.
  21462. * @param minHeight is the lower limit of the displacement.
  21463. * @param maxHeight is the upper limit of the displacement.
  21464. * @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.
  21465. * @param uvOffset is an optional vector2 used to offset UV.
  21466. * @param uvScale is an optional vector2 used to scale UV.
  21467. * @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.
  21468. * @returns the Mesh.
  21469. */
  21470. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21471. /**
  21472. * Modify the mesh to get a flat shading rendering.
  21473. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21474. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21475. * @returns current mesh
  21476. */
  21477. convertToFlatShadedMesh(): Mesh;
  21478. /**
  21479. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21480. * In other words, more vertices, no more indices and a single bigger VBO.
  21481. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21482. * @returns current mesh
  21483. */
  21484. convertToUnIndexedMesh(): Mesh;
  21485. /**
  21486. * Inverses facet orientations.
  21487. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21488. * @param flipNormals will also inverts the normals
  21489. * @returns current mesh
  21490. */
  21491. flipFaces(flipNormals?: boolean): Mesh;
  21492. /**
  21493. * Increase the number of facets and hence vertices in a mesh
  21494. * Vertex normals are interpolated from existing vertex normals
  21495. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21496. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21497. */
  21498. increaseVertices(numberPerEdge: number): void;
  21499. /**
  21500. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21501. * This will undo any application of covertToFlatShadedMesh
  21502. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21503. */
  21504. forceSharedVertices(): void;
  21505. /** @hidden */
  21506. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21507. /** @hidden */
  21508. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21509. /**
  21510. * Creates a new InstancedMesh object from the mesh model.
  21511. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21512. * @param name defines the name of the new instance
  21513. * @returns a new InstancedMesh
  21514. */
  21515. createInstance(name: string): InstancedMesh;
  21516. /**
  21517. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21518. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21519. * @returns the current mesh
  21520. */
  21521. synchronizeInstances(): Mesh;
  21522. /**
  21523. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21524. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21525. * This should be used together with the simplification to avoid disappearing triangles.
  21526. * @param successCallback an optional success callback to be called after the optimization finished.
  21527. * @returns the current mesh
  21528. */
  21529. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21530. /**
  21531. * Serialize current mesh
  21532. * @param serializationObject defines the object which will receive the serialization data
  21533. */
  21534. serialize(serializationObject: any): void;
  21535. /** @hidden */
  21536. _syncGeometryWithMorphTargetManager(): void;
  21537. /** @hidden */
  21538. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21539. /**
  21540. * Returns a new Mesh object parsed from the source provided.
  21541. * @param parsedMesh is the source
  21542. * @param scene defines the hosting scene
  21543. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21544. * @returns a new Mesh
  21545. */
  21546. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21547. /**
  21548. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21549. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21550. * @param name defines the name of the mesh to create
  21551. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21552. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21553. * @param closePath creates a seam between the first and the last points of each path of the path array
  21554. * @param offset is taken in account only if the `pathArray` is containing a single path
  21555. * @param scene defines the hosting scene
  21556. * @param updatable defines if the mesh must be flagged as updatable
  21557. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21558. * @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)
  21559. * @returns a new Mesh
  21560. */
  21561. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21562. /**
  21563. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21564. * @param name defines the name of the mesh to create
  21565. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21566. * @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
  21567. * @param scene defines the hosting scene
  21568. * @param updatable defines if the mesh must be flagged as updatable
  21569. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21570. * @returns a new Mesh
  21571. */
  21572. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21573. /**
  21574. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21575. * @param name defines the name of the mesh to create
  21576. * @param size sets the size (float) of each box side (default 1)
  21577. * @param scene defines the hosting scene
  21578. * @param updatable defines if the mesh must be flagged as updatable
  21579. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21580. * @returns a new Mesh
  21581. */
  21582. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21583. /**
  21584. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21585. * @param name defines the name of the mesh to create
  21586. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21587. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21588. * @param scene defines the hosting scene
  21589. * @param updatable defines if the mesh must be flagged as updatable
  21590. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21591. * @returns a new Mesh
  21592. */
  21593. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21594. /**
  21595. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21596. * @param name defines the name of the mesh to create
  21597. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21598. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21599. * @param scene defines the hosting scene
  21600. * @returns a new Mesh
  21601. */
  21602. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21603. /**
  21604. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21605. * @param name defines the name of the mesh to create
  21606. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21607. * @param diameterTop set the top cap diameter (floats, default 1)
  21608. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21609. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21610. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21611. * @param scene defines the hosting scene
  21612. * @param updatable defines if the mesh must be flagged as updatable
  21613. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21614. * @returns a new Mesh
  21615. */
  21616. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21617. /**
  21618. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21619. * @param name defines the name of the mesh to create
  21620. * @param diameter sets the diameter size (float) of the torus (default 1)
  21621. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21622. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21623. * @param scene defines the hosting scene
  21624. * @param updatable defines if the mesh must be flagged as updatable
  21625. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21626. * @returns a new Mesh
  21627. */
  21628. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21629. /**
  21630. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21631. * @param name defines the name of the mesh to create
  21632. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21633. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21634. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21635. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21636. * @param p the number of windings on X axis (positive integers, default 2)
  21637. * @param q the number of windings on Y axis (positive integers, default 3)
  21638. * @param scene defines the hosting scene
  21639. * @param updatable defines if the mesh must be flagged as updatable
  21640. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21641. * @returns a new Mesh
  21642. */
  21643. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21644. /**
  21645. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21646. * @param name defines the name of the mesh to create
  21647. * @param points is an array successive Vector3
  21648. * @param scene defines the hosting scene
  21649. * @param updatable defines if the mesh must be flagged as updatable
  21650. * @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).
  21651. * @returns a new Mesh
  21652. */
  21653. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21654. /**
  21655. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21656. * @param name defines the name of the mesh to create
  21657. * @param points is an array successive Vector3
  21658. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21659. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21660. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21661. * @param scene defines the hosting scene
  21662. * @param updatable defines if the mesh must be flagged as updatable
  21663. * @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)
  21664. * @returns a new Mesh
  21665. */
  21666. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21667. /**
  21668. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21669. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21670. * 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.
  21671. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21672. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21673. * Remember you can only change the shape positions, not their number when updating a polygon.
  21674. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21675. * @param name defines the name of the mesh to create
  21676. * @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
  21677. * @param scene defines the hosting scene
  21678. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21679. * @param updatable defines if the mesh must be flagged as updatable
  21680. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21681. * @param earcutInjection can be used to inject your own earcut reference
  21682. * @returns a new Mesh
  21683. */
  21684. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21685. /**
  21686. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21687. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21688. * @param name defines the name of the mesh to create
  21689. * @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
  21690. * @param depth defines the height of extrusion
  21691. * @param scene defines the hosting scene
  21692. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21693. * @param updatable defines if the mesh must be flagged as updatable
  21694. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21695. * @param earcutInjection can be used to inject your own earcut reference
  21696. * @returns a new Mesh
  21697. */
  21698. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21699. /**
  21700. * Creates an extruded shape mesh.
  21701. * 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
  21702. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21703. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21704. * @param name defines the name of the mesh to create
  21705. * @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
  21706. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21707. * @param scale is the value to scale the shape
  21708. * @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
  21709. * @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
  21710. * @param scene defines the hosting scene
  21711. * @param updatable defines if the mesh must be flagged as updatable
  21712. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21713. * @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)
  21714. * @returns a new Mesh
  21715. */
  21716. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21717. /**
  21718. * Creates an custom extruded shape mesh.
  21719. * The custom extrusion is a parametric shape.
  21720. * It has no predefined shape. Its final shape will depend on the input parameters.
  21721. * Please consider using the same method from the MeshBuilder class instead
  21722. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21723. * @param name defines the name of the mesh to create
  21724. * @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
  21725. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21726. * @param scaleFunction is a custom Javascript function called on each path point
  21727. * @param rotationFunction is a custom Javascript function called on each path point
  21728. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21729. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21730. * @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
  21731. * @param scene defines the hosting scene
  21732. * @param updatable defines if the mesh must be flagged as updatable
  21733. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21734. * @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)
  21735. * @returns a new Mesh
  21736. */
  21737. 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;
  21738. /**
  21739. * Creates lathe mesh.
  21740. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21741. * Please consider using the same method from the MeshBuilder class instead
  21742. * @param name defines the name of the mesh to create
  21743. * @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
  21744. * @param radius is the radius value of the lathe
  21745. * @param tessellation is the side number of the lathe.
  21746. * @param scene defines the hosting scene
  21747. * @param updatable defines if the mesh must be flagged as updatable
  21748. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21749. * @returns a new Mesh
  21750. */
  21751. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21752. /**
  21753. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21754. * @param name defines the name of the mesh to create
  21755. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21756. * @param scene defines the hosting scene
  21757. * @param updatable defines if the mesh must be flagged as updatable
  21758. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21759. * @returns a new Mesh
  21760. */
  21761. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21762. /**
  21763. * Creates a ground mesh.
  21764. * Please consider using the same method from the MeshBuilder class instead
  21765. * @param name defines the name of the mesh to create
  21766. * @param width set the width of the ground
  21767. * @param height set the height of the ground
  21768. * @param subdivisions sets the number of subdivisions per side
  21769. * @param scene defines the hosting scene
  21770. * @param updatable defines if the mesh must be flagged as updatable
  21771. * @returns a new Mesh
  21772. */
  21773. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21774. /**
  21775. * Creates a tiled ground mesh.
  21776. * Please consider using the same method from the MeshBuilder class instead
  21777. * @param name defines the name of the mesh to create
  21778. * @param xmin set the ground minimum X coordinate
  21779. * @param zmin set the ground minimum Y coordinate
  21780. * @param xmax set the ground maximum X coordinate
  21781. * @param zmax set the ground maximum Z coordinate
  21782. * @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
  21783. * @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
  21784. * @param scene defines the hosting scene
  21785. * @param updatable defines if the mesh must be flagged as updatable
  21786. * @returns a new Mesh
  21787. */
  21788. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21789. w: number;
  21790. h: number;
  21791. }, precision: {
  21792. w: number;
  21793. h: number;
  21794. }, scene: Scene, updatable?: boolean): Mesh;
  21795. /**
  21796. * Creates a ground mesh from a height map.
  21797. * Please consider using the same method from the MeshBuilder class instead
  21798. * @see http://doc.babylonjs.com/babylon101/height_map
  21799. * @param name defines the name of the mesh to create
  21800. * @param url sets the URL of the height map image resource
  21801. * @param width set the ground width size
  21802. * @param height set the ground height size
  21803. * @param subdivisions sets the number of subdivision per side
  21804. * @param minHeight is the minimum altitude on the ground
  21805. * @param maxHeight is the maximum altitude on the ground
  21806. * @param scene defines the hosting scene
  21807. * @param updatable defines if the mesh must be flagged as updatable
  21808. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21809. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21810. * @returns a new Mesh
  21811. */
  21812. 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;
  21813. /**
  21814. * Creates a tube mesh.
  21815. * The tube is a parametric shape.
  21816. * It has no predefined shape. Its final shape will depend on the input parameters.
  21817. * Please consider using the same method from the MeshBuilder class instead
  21818. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21819. * @param name defines the name of the mesh to create
  21820. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21821. * @param radius sets the tube radius size
  21822. * @param tessellation is the number of sides on the tubular surface
  21823. * @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
  21824. * @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
  21825. * @param scene defines the hosting scene
  21826. * @param updatable defines if the mesh must be flagged as updatable
  21827. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21828. * @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)
  21829. * @returns a new Mesh
  21830. */
  21831. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21832. (i: number, distance: number): number;
  21833. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21834. /**
  21835. * Creates a polyhedron mesh.
  21836. * Please consider using the same method from the MeshBuilder class instead.
  21837. * * 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
  21838. * * The parameter `size` (positive float, default 1) sets the polygon size
  21839. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21840. * * 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`
  21841. * * 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
  21842. * * 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)`)
  21843. * * 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
  21844. * * 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
  21845. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21846. * * 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
  21847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21848. * @param name defines the name of the mesh to create
  21849. * @param options defines the options used to create the mesh
  21850. * @param scene defines the hosting scene
  21851. * @returns a new Mesh
  21852. */
  21853. static CreatePolyhedron(name: string, options: {
  21854. type?: number;
  21855. size?: number;
  21856. sizeX?: number;
  21857. sizeY?: number;
  21858. sizeZ?: number;
  21859. custom?: any;
  21860. faceUV?: Vector4[];
  21861. faceColors?: Color4[];
  21862. updatable?: boolean;
  21863. sideOrientation?: number;
  21864. }, scene: Scene): Mesh;
  21865. /**
  21866. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21867. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21868. * * 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`)
  21869. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21870. * * 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
  21871. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21872. * * 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
  21873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21874. * @param name defines the name of the mesh
  21875. * @param options defines the options used to create the mesh
  21876. * @param scene defines the hosting scene
  21877. * @returns a new Mesh
  21878. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21879. */
  21880. static CreateIcoSphere(name: string, options: {
  21881. radius?: number;
  21882. flat?: boolean;
  21883. subdivisions?: number;
  21884. sideOrientation?: number;
  21885. updatable?: boolean;
  21886. }, scene: Scene): Mesh;
  21887. /**
  21888. * Creates a decal mesh.
  21889. * Please consider using the same method from the MeshBuilder class instead.
  21890. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21891. * @param name defines the name of the mesh
  21892. * @param sourceMesh defines the mesh receiving the decal
  21893. * @param position sets the position of the decal in world coordinates
  21894. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21895. * @param size sets the decal scaling
  21896. * @param angle sets the angle to rotate the decal
  21897. * @returns a new Mesh
  21898. */
  21899. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21900. /**
  21901. * Prepare internal position array for software CPU skinning
  21902. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21903. */
  21904. setPositionsForCPUSkinning(): Float32Array;
  21905. /**
  21906. * Prepare internal normal array for software CPU skinning
  21907. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21908. */
  21909. setNormalsForCPUSkinning(): Float32Array;
  21910. /**
  21911. * Updates the vertex buffer by applying transformation from the bones
  21912. * @param skeleton defines the skeleton to apply to current mesh
  21913. * @returns the current mesh
  21914. */
  21915. applySkeleton(skeleton: Skeleton): Mesh;
  21916. /**
  21917. * 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
  21918. * @param meshes defines the list of meshes to scan
  21919. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21920. */
  21921. static MinMax(meshes: AbstractMesh[]): {
  21922. min: Vector3;
  21923. max: Vector3;
  21924. };
  21925. /**
  21926. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21927. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21928. * @returns a vector3
  21929. */
  21930. static Center(meshesOrMinMaxVector: {
  21931. min: Vector3;
  21932. max: Vector3;
  21933. } | AbstractMesh[]): Vector3;
  21934. /**
  21935. * Merge the array of meshes into a single mesh for performance reasons.
  21936. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21937. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21938. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21939. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21940. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21941. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21942. * @returns a new mesh
  21943. */
  21944. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21945. /** @hidden */
  21946. addInstance(instance: InstancedMesh): void;
  21947. /** @hidden */
  21948. removeInstance(instance: InstancedMesh): void;
  21949. }
  21950. }
  21951. declare module BABYLON {
  21952. /**
  21953. * Base class for the main features of a material in Babylon.js
  21954. */
  21955. export class Material implements IAnimatable {
  21956. /**
  21957. * Returns the triangle fill mode
  21958. */
  21959. static readonly TriangleFillMode: number;
  21960. /**
  21961. * Returns the wireframe mode
  21962. */
  21963. static readonly WireFrameFillMode: number;
  21964. /**
  21965. * Returns the point fill mode
  21966. */
  21967. static readonly PointFillMode: number;
  21968. /**
  21969. * Returns the point list draw mode
  21970. */
  21971. static readonly PointListDrawMode: number;
  21972. /**
  21973. * Returns the line list draw mode
  21974. */
  21975. static readonly LineListDrawMode: number;
  21976. /**
  21977. * Returns the line loop draw mode
  21978. */
  21979. static readonly LineLoopDrawMode: number;
  21980. /**
  21981. * Returns the line strip draw mode
  21982. */
  21983. static readonly LineStripDrawMode: number;
  21984. /**
  21985. * Returns the triangle strip draw mode
  21986. */
  21987. static readonly TriangleStripDrawMode: number;
  21988. /**
  21989. * Returns the triangle fan draw mode
  21990. */
  21991. static readonly TriangleFanDrawMode: number;
  21992. /**
  21993. * Stores the clock-wise side orientation
  21994. */
  21995. static readonly ClockWiseSideOrientation: number;
  21996. /**
  21997. * Stores the counter clock-wise side orientation
  21998. */
  21999. static readonly CounterClockWiseSideOrientation: number;
  22000. /**
  22001. * The dirty texture flag value
  22002. */
  22003. static readonly TextureDirtyFlag: number;
  22004. /**
  22005. * The dirty light flag value
  22006. */
  22007. static readonly LightDirtyFlag: number;
  22008. /**
  22009. * The dirty fresnel flag value
  22010. */
  22011. static readonly FresnelDirtyFlag: number;
  22012. /**
  22013. * The dirty attribute flag value
  22014. */
  22015. static readonly AttributesDirtyFlag: number;
  22016. /**
  22017. * The dirty misc flag value
  22018. */
  22019. static readonly MiscDirtyFlag: number;
  22020. /**
  22021. * The all dirty flag value
  22022. */
  22023. static readonly AllDirtyFlag: number;
  22024. /**
  22025. * The ID of the material
  22026. */
  22027. id: string;
  22028. /**
  22029. * Gets or sets the unique id of the material
  22030. */
  22031. uniqueId: number;
  22032. /**
  22033. * The name of the material
  22034. */
  22035. name: string;
  22036. /**
  22037. * Gets or sets user defined metadata
  22038. */
  22039. metadata: any;
  22040. /**
  22041. * For internal use only. Please do not use.
  22042. */
  22043. reservedDataStore: any;
  22044. /**
  22045. * Specifies if the ready state should be checked on each call
  22046. */
  22047. checkReadyOnEveryCall: boolean;
  22048. /**
  22049. * Specifies if the ready state should be checked once
  22050. */
  22051. checkReadyOnlyOnce: boolean;
  22052. /**
  22053. * The state of the material
  22054. */
  22055. state: string;
  22056. /**
  22057. * The alpha value of the material
  22058. */
  22059. protected _alpha: number;
  22060. /**
  22061. * List of inspectable custom properties (used by the Inspector)
  22062. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22063. */
  22064. inspectableCustomProperties: IInspectable[];
  22065. /**
  22066. * Sets the alpha value of the material
  22067. */
  22068. /**
  22069. * Gets the alpha value of the material
  22070. */
  22071. alpha: number;
  22072. /**
  22073. * Specifies if back face culling is enabled
  22074. */
  22075. protected _backFaceCulling: boolean;
  22076. /**
  22077. * Sets the back-face culling state
  22078. */
  22079. /**
  22080. * Gets the back-face culling state
  22081. */
  22082. backFaceCulling: boolean;
  22083. /**
  22084. * Stores the value for side orientation
  22085. */
  22086. sideOrientation: number;
  22087. /**
  22088. * Callback triggered when the material is compiled
  22089. */
  22090. onCompiled: Nullable<(effect: Effect) => void>;
  22091. /**
  22092. * Callback triggered when an error occurs
  22093. */
  22094. onError: Nullable<(effect: Effect, errors: string) => void>;
  22095. /**
  22096. * Callback triggered to get the render target textures
  22097. */
  22098. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22099. /**
  22100. * Gets a boolean indicating that current material needs to register RTT
  22101. */
  22102. readonly hasRenderTargetTextures: boolean;
  22103. /**
  22104. * Specifies if the material should be serialized
  22105. */
  22106. doNotSerialize: boolean;
  22107. /**
  22108. * @hidden
  22109. */
  22110. _storeEffectOnSubMeshes: boolean;
  22111. /**
  22112. * Stores the animations for the material
  22113. */
  22114. animations: Nullable<Array<Animation>>;
  22115. /**
  22116. * An event triggered when the material is disposed
  22117. */
  22118. onDisposeObservable: Observable<Material>;
  22119. /**
  22120. * An observer which watches for dispose events
  22121. */
  22122. private _onDisposeObserver;
  22123. private _onUnBindObservable;
  22124. /**
  22125. * Called during a dispose event
  22126. */
  22127. onDispose: () => void;
  22128. private _onBindObservable;
  22129. /**
  22130. * An event triggered when the material is bound
  22131. */
  22132. readonly onBindObservable: Observable<AbstractMesh>;
  22133. /**
  22134. * An observer which watches for bind events
  22135. */
  22136. private _onBindObserver;
  22137. /**
  22138. * Called during a bind event
  22139. */
  22140. onBind: (Mesh: AbstractMesh) => void;
  22141. /**
  22142. * An event triggered when the material is unbound
  22143. */
  22144. readonly onUnBindObservable: Observable<Material>;
  22145. /**
  22146. * Stores the value of the alpha mode
  22147. */
  22148. private _alphaMode;
  22149. /**
  22150. * Sets the value of the alpha mode.
  22151. *
  22152. * | Value | Type | Description |
  22153. * | --- | --- | --- |
  22154. * | 0 | ALPHA_DISABLE | |
  22155. * | 1 | ALPHA_ADD | |
  22156. * | 2 | ALPHA_COMBINE | |
  22157. * | 3 | ALPHA_SUBTRACT | |
  22158. * | 4 | ALPHA_MULTIPLY | |
  22159. * | 5 | ALPHA_MAXIMIZED | |
  22160. * | 6 | ALPHA_ONEONE | |
  22161. * | 7 | ALPHA_PREMULTIPLIED | |
  22162. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22163. * | 9 | ALPHA_INTERPOLATE | |
  22164. * | 10 | ALPHA_SCREENMODE | |
  22165. *
  22166. */
  22167. /**
  22168. * Gets the value of the alpha mode
  22169. */
  22170. alphaMode: number;
  22171. /**
  22172. * Stores the state of the need depth pre-pass value
  22173. */
  22174. private _needDepthPrePass;
  22175. /**
  22176. * Sets the need depth pre-pass value
  22177. */
  22178. /**
  22179. * Gets the depth pre-pass value
  22180. */
  22181. needDepthPrePass: boolean;
  22182. /**
  22183. * Specifies if depth writing should be disabled
  22184. */
  22185. disableDepthWrite: boolean;
  22186. /**
  22187. * Specifies if depth writing should be forced
  22188. */
  22189. forceDepthWrite: boolean;
  22190. /**
  22191. * Specifies if there should be a separate pass for culling
  22192. */
  22193. separateCullingPass: boolean;
  22194. /**
  22195. * Stores the state specifing if fog should be enabled
  22196. */
  22197. private _fogEnabled;
  22198. /**
  22199. * Sets the state for enabling fog
  22200. */
  22201. /**
  22202. * Gets the value of the fog enabled state
  22203. */
  22204. fogEnabled: boolean;
  22205. /**
  22206. * Stores the size of points
  22207. */
  22208. pointSize: number;
  22209. /**
  22210. * Stores the z offset value
  22211. */
  22212. zOffset: number;
  22213. /**
  22214. * Gets a value specifying if wireframe mode is enabled
  22215. */
  22216. /**
  22217. * Sets the state of wireframe mode
  22218. */
  22219. wireframe: boolean;
  22220. /**
  22221. * Gets the value specifying if point clouds are enabled
  22222. */
  22223. /**
  22224. * Sets the state of point cloud mode
  22225. */
  22226. pointsCloud: boolean;
  22227. /**
  22228. * Gets the material fill mode
  22229. */
  22230. /**
  22231. * Sets the material fill mode
  22232. */
  22233. fillMode: number;
  22234. /**
  22235. * @hidden
  22236. * Stores the effects for the material
  22237. */
  22238. _effect: Nullable<Effect>;
  22239. /**
  22240. * @hidden
  22241. * Specifies if the material was previously ready
  22242. */
  22243. _wasPreviouslyReady: boolean;
  22244. /**
  22245. * Specifies if uniform buffers should be used
  22246. */
  22247. private _useUBO;
  22248. /**
  22249. * Stores a reference to the scene
  22250. */
  22251. private _scene;
  22252. /**
  22253. * Stores the fill mode state
  22254. */
  22255. private _fillMode;
  22256. /**
  22257. * Specifies if the depth write state should be cached
  22258. */
  22259. private _cachedDepthWriteState;
  22260. /**
  22261. * Stores the uniform buffer
  22262. */
  22263. protected _uniformBuffer: UniformBuffer;
  22264. /** @hidden */
  22265. _indexInSceneMaterialArray: number;
  22266. /** @hidden */
  22267. meshMap: Nullable<{
  22268. [id: string]: AbstractMesh | undefined;
  22269. }>;
  22270. /**
  22271. * Creates a material instance
  22272. * @param name defines the name of the material
  22273. * @param scene defines the scene to reference
  22274. * @param doNotAdd specifies if the material should be added to the scene
  22275. */
  22276. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22277. /**
  22278. * Returns a string representation of the current material
  22279. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22280. * @returns a string with material information
  22281. */
  22282. toString(fullDetails?: boolean): string;
  22283. /**
  22284. * Gets the class name of the material
  22285. * @returns a string with the class name of the material
  22286. */
  22287. getClassName(): string;
  22288. /**
  22289. * Specifies if updates for the material been locked
  22290. */
  22291. readonly isFrozen: boolean;
  22292. /**
  22293. * Locks updates for the material
  22294. */
  22295. freeze(): void;
  22296. /**
  22297. * Unlocks updates for the material
  22298. */
  22299. unfreeze(): void;
  22300. /**
  22301. * Specifies if the material is ready to be used
  22302. * @param mesh defines the mesh to check
  22303. * @param useInstances specifies if instances should be used
  22304. * @returns a boolean indicating if the material is ready to be used
  22305. */
  22306. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22307. /**
  22308. * Specifies that the submesh is ready to be used
  22309. * @param mesh defines the mesh to check
  22310. * @param subMesh defines which submesh to check
  22311. * @param useInstances specifies that instances should be used
  22312. * @returns a boolean indicating that the submesh is ready or not
  22313. */
  22314. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22315. /**
  22316. * Returns the material effect
  22317. * @returns the effect associated with the material
  22318. */
  22319. getEffect(): Nullable<Effect>;
  22320. /**
  22321. * Returns the current scene
  22322. * @returns a Scene
  22323. */
  22324. getScene(): Scene;
  22325. /**
  22326. * Specifies if the material will require alpha blending
  22327. * @returns a boolean specifying if alpha blending is needed
  22328. */
  22329. needAlphaBlending(): boolean;
  22330. /**
  22331. * Specifies if the mesh will require alpha blending
  22332. * @param mesh defines the mesh to check
  22333. * @returns a boolean specifying if alpha blending is needed for the mesh
  22334. */
  22335. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22336. /**
  22337. * Specifies if this material should be rendered in alpha test mode
  22338. * @returns a boolean specifying if an alpha test is needed.
  22339. */
  22340. needAlphaTesting(): boolean;
  22341. /**
  22342. * Gets the texture used for the alpha test
  22343. * @returns the texture to use for alpha testing
  22344. */
  22345. getAlphaTestTexture(): Nullable<BaseTexture>;
  22346. /**
  22347. * Marks the material to indicate that it needs to be re-calculated
  22348. */
  22349. markDirty(): void;
  22350. /** @hidden */
  22351. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22352. /**
  22353. * Binds the material to the mesh
  22354. * @param world defines the world transformation matrix
  22355. * @param mesh defines the mesh to bind the material to
  22356. */
  22357. bind(world: Matrix, mesh?: Mesh): void;
  22358. /**
  22359. * Binds the submesh to the material
  22360. * @param world defines the world transformation matrix
  22361. * @param mesh defines the mesh containing the submesh
  22362. * @param subMesh defines the submesh to bind the material to
  22363. */
  22364. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22365. /**
  22366. * Binds the world matrix to the material
  22367. * @param world defines the world transformation matrix
  22368. */
  22369. bindOnlyWorldMatrix(world: Matrix): void;
  22370. /**
  22371. * Binds the scene's uniform buffer to the effect.
  22372. * @param effect defines the effect to bind to the scene uniform buffer
  22373. * @param sceneUbo defines the uniform buffer storing scene data
  22374. */
  22375. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22376. /**
  22377. * Binds the view matrix to the effect
  22378. * @param effect defines the effect to bind the view matrix to
  22379. */
  22380. bindView(effect: Effect): void;
  22381. /**
  22382. * Binds the view projection matrix to the effect
  22383. * @param effect defines the effect to bind the view projection matrix to
  22384. */
  22385. bindViewProjection(effect: Effect): void;
  22386. /**
  22387. * Specifies if material alpha testing should be turned on for the mesh
  22388. * @param mesh defines the mesh to check
  22389. */
  22390. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22391. /**
  22392. * Processes to execute after binding the material to a mesh
  22393. * @param mesh defines the rendered mesh
  22394. */
  22395. protected _afterBind(mesh?: Mesh): void;
  22396. /**
  22397. * Unbinds the material from the mesh
  22398. */
  22399. unbind(): void;
  22400. /**
  22401. * Gets the active textures from the material
  22402. * @returns an array of textures
  22403. */
  22404. getActiveTextures(): BaseTexture[];
  22405. /**
  22406. * Specifies if the material uses a texture
  22407. * @param texture defines the texture to check against the material
  22408. * @returns a boolean specifying if the material uses the texture
  22409. */
  22410. hasTexture(texture: BaseTexture): boolean;
  22411. /**
  22412. * Makes a duplicate of the material, and gives it a new name
  22413. * @param name defines the new name for the duplicated material
  22414. * @returns the cloned material
  22415. */
  22416. clone(name: string): Nullable<Material>;
  22417. /**
  22418. * Gets the meshes bound to the material
  22419. * @returns an array of meshes bound to the material
  22420. */
  22421. getBindedMeshes(): AbstractMesh[];
  22422. /**
  22423. * Force shader compilation
  22424. * @param mesh defines the mesh associated with this material
  22425. * @param onCompiled defines a function to execute once the material is compiled
  22426. * @param options defines the options to configure the compilation
  22427. */
  22428. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22429. clipPlane: boolean;
  22430. }>): void;
  22431. /**
  22432. * Force shader compilation
  22433. * @param mesh defines the mesh that will use this material
  22434. * @param options defines additional options for compiling the shaders
  22435. * @returns a promise that resolves when the compilation completes
  22436. */
  22437. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22438. clipPlane: boolean;
  22439. }>): Promise<void>;
  22440. private static readonly _ImageProcessingDirtyCallBack;
  22441. private static readonly _TextureDirtyCallBack;
  22442. private static readonly _FresnelDirtyCallBack;
  22443. private static readonly _MiscDirtyCallBack;
  22444. private static readonly _LightsDirtyCallBack;
  22445. private static readonly _AttributeDirtyCallBack;
  22446. private static _FresnelAndMiscDirtyCallBack;
  22447. private static _TextureAndMiscDirtyCallBack;
  22448. private static readonly _DirtyCallbackArray;
  22449. private static readonly _RunDirtyCallBacks;
  22450. /**
  22451. * Marks a define in the material to indicate that it needs to be re-computed
  22452. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22453. */
  22454. markAsDirty(flag: number): void;
  22455. /**
  22456. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22457. * @param func defines a function which checks material defines against the submeshes
  22458. */
  22459. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22460. /**
  22461. * Indicates that image processing needs to be re-calculated for all submeshes
  22462. */
  22463. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22464. /**
  22465. * Indicates that textures need to be re-calculated for all submeshes
  22466. */
  22467. protected _markAllSubMeshesAsTexturesDirty(): void;
  22468. /**
  22469. * Indicates that fresnel needs to be re-calculated for all submeshes
  22470. */
  22471. protected _markAllSubMeshesAsFresnelDirty(): void;
  22472. /**
  22473. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22474. */
  22475. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22476. /**
  22477. * Indicates that lights need to be re-calculated for all submeshes
  22478. */
  22479. protected _markAllSubMeshesAsLightsDirty(): void;
  22480. /**
  22481. * Indicates that attributes need to be re-calculated for all submeshes
  22482. */
  22483. protected _markAllSubMeshesAsAttributesDirty(): void;
  22484. /**
  22485. * Indicates that misc needs to be re-calculated for all submeshes
  22486. */
  22487. protected _markAllSubMeshesAsMiscDirty(): void;
  22488. /**
  22489. * Indicates that textures and misc need to be re-calculated for all submeshes
  22490. */
  22491. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22492. /**
  22493. * Disposes the material
  22494. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22495. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22496. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22497. */
  22498. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22499. /** @hidden */
  22500. private releaseVertexArrayObject;
  22501. /**
  22502. * Serializes this material
  22503. * @returns the serialized material object
  22504. */
  22505. serialize(): any;
  22506. /**
  22507. * Creates a material from parsed material data
  22508. * @param parsedMaterial defines parsed material data
  22509. * @param scene defines the hosting scene
  22510. * @param rootUrl defines the root URL to use to load textures
  22511. * @returns a new material
  22512. */
  22513. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22514. }
  22515. }
  22516. declare module BABYLON {
  22517. /**
  22518. * Base class for submeshes
  22519. */
  22520. export class BaseSubMesh {
  22521. /** @hidden */
  22522. _materialDefines: Nullable<MaterialDefines>;
  22523. /** @hidden */
  22524. _materialEffect: Nullable<Effect>;
  22525. /**
  22526. * Gets associated effect
  22527. */
  22528. readonly effect: Nullable<Effect>;
  22529. /**
  22530. * Sets associated effect (effect used to render this submesh)
  22531. * @param effect defines the effect to associate with
  22532. * @param defines defines the set of defines used to compile this effect
  22533. */
  22534. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22535. }
  22536. /**
  22537. * Defines a subdivision inside a mesh
  22538. */
  22539. export class SubMesh extends BaseSubMesh implements ICullable {
  22540. /** the material index to use */
  22541. materialIndex: number;
  22542. /** vertex index start */
  22543. verticesStart: number;
  22544. /** vertices count */
  22545. verticesCount: number;
  22546. /** index start */
  22547. indexStart: number;
  22548. /** indices count */
  22549. indexCount: number;
  22550. /** @hidden */
  22551. _linesIndexCount: number;
  22552. private _mesh;
  22553. private _renderingMesh;
  22554. private _boundingInfo;
  22555. private _linesIndexBuffer;
  22556. /** @hidden */
  22557. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22558. /** @hidden */
  22559. _trianglePlanes: Plane[];
  22560. /** @hidden */
  22561. _lastColliderTransformMatrix: Nullable<Matrix>;
  22562. /** @hidden */
  22563. _renderId: number;
  22564. /** @hidden */
  22565. _alphaIndex: number;
  22566. /** @hidden */
  22567. _distanceToCamera: number;
  22568. /** @hidden */
  22569. _id: number;
  22570. private _currentMaterial;
  22571. /**
  22572. * Add a new submesh to a mesh
  22573. * @param materialIndex defines the material index to use
  22574. * @param verticesStart defines vertex index start
  22575. * @param verticesCount defines vertices count
  22576. * @param indexStart defines index start
  22577. * @param indexCount defines indices count
  22578. * @param mesh defines the parent mesh
  22579. * @param renderingMesh defines an optional rendering mesh
  22580. * @param createBoundingBox defines if bounding box should be created for this submesh
  22581. * @returns the new submesh
  22582. */
  22583. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22584. /**
  22585. * Creates a new submesh
  22586. * @param materialIndex defines the material index to use
  22587. * @param verticesStart defines vertex index start
  22588. * @param verticesCount defines vertices count
  22589. * @param indexStart defines index start
  22590. * @param indexCount defines indices count
  22591. * @param mesh defines the parent mesh
  22592. * @param renderingMesh defines an optional rendering mesh
  22593. * @param createBoundingBox defines if bounding box should be created for this submesh
  22594. */
  22595. constructor(
  22596. /** the material index to use */
  22597. materialIndex: number,
  22598. /** vertex index start */
  22599. verticesStart: number,
  22600. /** vertices count */
  22601. verticesCount: number,
  22602. /** index start */
  22603. indexStart: number,
  22604. /** indices count */
  22605. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22606. /**
  22607. * Returns true if this submesh covers the entire parent mesh
  22608. * @ignorenaming
  22609. */
  22610. readonly IsGlobal: boolean;
  22611. /**
  22612. * Returns the submesh BoudingInfo object
  22613. * @returns current bounding info (or mesh's one if the submesh is global)
  22614. */
  22615. getBoundingInfo(): BoundingInfo;
  22616. /**
  22617. * Sets the submesh BoundingInfo
  22618. * @param boundingInfo defines the new bounding info to use
  22619. * @returns the SubMesh
  22620. */
  22621. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22622. /**
  22623. * Returns the mesh of the current submesh
  22624. * @return the parent mesh
  22625. */
  22626. getMesh(): AbstractMesh;
  22627. /**
  22628. * Returns the rendering mesh of the submesh
  22629. * @returns the rendering mesh (could be different from parent mesh)
  22630. */
  22631. getRenderingMesh(): Mesh;
  22632. /**
  22633. * Returns the submesh material
  22634. * @returns null or the current material
  22635. */
  22636. getMaterial(): Nullable<Material>;
  22637. /**
  22638. * Sets a new updated BoundingInfo object to the submesh
  22639. * @param data defines an optional position array to use to determine the bounding info
  22640. * @returns the SubMesh
  22641. */
  22642. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22643. /** @hidden */
  22644. _checkCollision(collider: Collider): boolean;
  22645. /**
  22646. * Updates the submesh BoundingInfo
  22647. * @param world defines the world matrix to use to update the bounding info
  22648. * @returns the submesh
  22649. */
  22650. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22651. /**
  22652. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22653. * @param frustumPlanes defines the frustum planes
  22654. * @returns true if the submesh is intersecting with the frustum
  22655. */
  22656. isInFrustum(frustumPlanes: Plane[]): boolean;
  22657. /**
  22658. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22659. * @param frustumPlanes defines the frustum planes
  22660. * @returns true if the submesh is inside the frustum
  22661. */
  22662. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22663. /**
  22664. * Renders the submesh
  22665. * @param enableAlphaMode defines if alpha needs to be used
  22666. * @returns the submesh
  22667. */
  22668. render(enableAlphaMode: boolean): SubMesh;
  22669. /**
  22670. * @hidden
  22671. */
  22672. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22673. /**
  22674. * Checks if the submesh intersects with a ray
  22675. * @param ray defines the ray to test
  22676. * @returns true is the passed ray intersects the submesh bounding box
  22677. */
  22678. canIntersects(ray: Ray): boolean;
  22679. /**
  22680. * Intersects current submesh with a ray
  22681. * @param ray defines the ray to test
  22682. * @param positions defines mesh's positions array
  22683. * @param indices defines mesh's indices array
  22684. * @param fastCheck defines if only bounding info should be used
  22685. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22686. * @returns intersection info or null if no intersection
  22687. */
  22688. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22689. /** @hidden */
  22690. private _intersectLines;
  22691. /** @hidden */
  22692. private _intersectTriangles;
  22693. /** @hidden */
  22694. private _intersectUnIndexedTriangles;
  22695. /** @hidden */
  22696. _rebuild(): void;
  22697. /**
  22698. * Creates a new submesh from the passed mesh
  22699. * @param newMesh defines the new hosting mesh
  22700. * @param newRenderingMesh defines an optional rendering mesh
  22701. * @returns the new submesh
  22702. */
  22703. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22704. /**
  22705. * Release associated resources
  22706. */
  22707. dispose(): void;
  22708. /**
  22709. * Gets the class name
  22710. * @returns the string "SubMesh".
  22711. */
  22712. getClassName(): string;
  22713. /**
  22714. * Creates a new submesh from indices data
  22715. * @param materialIndex the index of the main mesh material
  22716. * @param startIndex the index where to start the copy in the mesh indices array
  22717. * @param indexCount the number of indices to copy then from the startIndex
  22718. * @param mesh the main mesh to create the submesh from
  22719. * @param renderingMesh the optional rendering mesh
  22720. * @returns a new submesh
  22721. */
  22722. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22723. }
  22724. }
  22725. declare module BABYLON {
  22726. /**
  22727. * Class used to store geometry data (vertex buffers + index buffer)
  22728. */
  22729. export class Geometry implements IGetSetVerticesData {
  22730. /**
  22731. * Gets or sets the ID of the geometry
  22732. */
  22733. id: string;
  22734. /**
  22735. * Gets or sets the unique ID of the geometry
  22736. */
  22737. uniqueId: number;
  22738. /**
  22739. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22740. */
  22741. delayLoadState: number;
  22742. /**
  22743. * Gets the file containing the data to load when running in delay load state
  22744. */
  22745. delayLoadingFile: Nullable<string>;
  22746. /**
  22747. * Callback called when the geometry is updated
  22748. */
  22749. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22750. private _scene;
  22751. private _engine;
  22752. private _meshes;
  22753. private _totalVertices;
  22754. /** @hidden */
  22755. _indices: IndicesArray;
  22756. /** @hidden */
  22757. _vertexBuffers: {
  22758. [key: string]: VertexBuffer;
  22759. };
  22760. private _isDisposed;
  22761. private _extend;
  22762. private _boundingBias;
  22763. /** @hidden */
  22764. _delayInfo: Array<string>;
  22765. private _indexBuffer;
  22766. private _indexBufferIsUpdatable;
  22767. /** @hidden */
  22768. _boundingInfo: Nullable<BoundingInfo>;
  22769. /** @hidden */
  22770. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22771. /** @hidden */
  22772. _softwareSkinningFrameId: number;
  22773. private _vertexArrayObjects;
  22774. private _updatable;
  22775. /** @hidden */
  22776. _positions: Nullable<Vector3[]>;
  22777. /**
  22778. * 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
  22779. */
  22780. /**
  22781. * 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
  22782. */
  22783. boundingBias: Vector2;
  22784. /**
  22785. * Static function used to attach a new empty geometry to a mesh
  22786. * @param mesh defines the mesh to attach the geometry to
  22787. * @returns the new Geometry
  22788. */
  22789. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22790. /**
  22791. * Creates a new geometry
  22792. * @param id defines the unique ID
  22793. * @param scene defines the hosting scene
  22794. * @param vertexData defines the VertexData used to get geometry data
  22795. * @param updatable defines if geometry must be updatable (false by default)
  22796. * @param mesh defines the mesh that will be associated with the geometry
  22797. */
  22798. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22799. /**
  22800. * Gets the current extend of the geometry
  22801. */
  22802. readonly extend: {
  22803. minimum: Vector3;
  22804. maximum: Vector3;
  22805. };
  22806. /**
  22807. * Gets the hosting scene
  22808. * @returns the hosting Scene
  22809. */
  22810. getScene(): Scene;
  22811. /**
  22812. * Gets the hosting engine
  22813. * @returns the hosting Engine
  22814. */
  22815. getEngine(): Engine;
  22816. /**
  22817. * Defines if the geometry is ready to use
  22818. * @returns true if the geometry is ready to be used
  22819. */
  22820. isReady(): boolean;
  22821. /**
  22822. * Gets a value indicating that the geometry should not be serialized
  22823. */
  22824. readonly doNotSerialize: boolean;
  22825. /** @hidden */
  22826. _rebuild(): void;
  22827. /**
  22828. * Affects all geometry data in one call
  22829. * @param vertexData defines the geometry data
  22830. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22831. */
  22832. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22833. /**
  22834. * Set specific vertex data
  22835. * @param kind defines the data kind (Position, normal, etc...)
  22836. * @param data defines the vertex data to use
  22837. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22838. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22839. */
  22840. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22841. /**
  22842. * Removes a specific vertex data
  22843. * @param kind defines the data kind (Position, normal, etc...)
  22844. */
  22845. removeVerticesData(kind: string): void;
  22846. /**
  22847. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22848. * @param buffer defines the vertex buffer to use
  22849. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22850. */
  22851. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22852. /**
  22853. * Update a specific vertex buffer
  22854. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22855. * It will do nothing if the buffer is not updatable
  22856. * @param kind defines the data kind (Position, normal, etc...)
  22857. * @param data defines the data to use
  22858. * @param offset defines the offset in the target buffer where to store the data
  22859. * @param useBytes set to true if the offset is in bytes
  22860. */
  22861. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22862. /**
  22863. * Update a specific vertex buffer
  22864. * This function will create a new buffer if the current one is not updatable
  22865. * @param kind defines the data kind (Position, normal, etc...)
  22866. * @param data defines the data to use
  22867. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22868. */
  22869. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22870. private _updateBoundingInfo;
  22871. /** @hidden */
  22872. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22873. /**
  22874. * Gets total number of vertices
  22875. * @returns the total number of vertices
  22876. */
  22877. getTotalVertices(): number;
  22878. /**
  22879. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22880. * @param kind defines the data kind (Position, normal, etc...)
  22881. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22882. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22883. * @returns a float array containing vertex data
  22884. */
  22885. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22886. /**
  22887. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22888. * @param kind defines the data kind (Position, normal, etc...)
  22889. * @returns true if the vertex buffer with the specified kind is updatable
  22890. */
  22891. isVertexBufferUpdatable(kind: string): boolean;
  22892. /**
  22893. * Gets a specific vertex buffer
  22894. * @param kind defines the data kind (Position, normal, etc...)
  22895. * @returns a VertexBuffer
  22896. */
  22897. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22898. /**
  22899. * Returns all vertex buffers
  22900. * @return an object holding all vertex buffers indexed by kind
  22901. */
  22902. getVertexBuffers(): Nullable<{
  22903. [key: string]: VertexBuffer;
  22904. }>;
  22905. /**
  22906. * Gets a boolean indicating if specific vertex buffer is present
  22907. * @param kind defines the data kind (Position, normal, etc...)
  22908. * @returns true if data is present
  22909. */
  22910. isVerticesDataPresent(kind: string): boolean;
  22911. /**
  22912. * Gets a list of all attached data kinds (Position, normal, etc...)
  22913. * @returns a list of string containing all kinds
  22914. */
  22915. getVerticesDataKinds(): string[];
  22916. /**
  22917. * Update index buffer
  22918. * @param indices defines the indices to store in the index buffer
  22919. * @param offset defines the offset in the target buffer where to store the data
  22920. * @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)
  22921. */
  22922. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22923. /**
  22924. * Creates a new index buffer
  22925. * @param indices defines the indices to store in the index buffer
  22926. * @param totalVertices defines the total number of vertices (could be null)
  22927. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22928. */
  22929. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22930. /**
  22931. * Return the total number of indices
  22932. * @returns the total number of indices
  22933. */
  22934. getTotalIndices(): number;
  22935. /**
  22936. * Gets the index buffer array
  22937. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22938. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22939. * @returns the index buffer array
  22940. */
  22941. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22942. /**
  22943. * Gets the index buffer
  22944. * @return the index buffer
  22945. */
  22946. getIndexBuffer(): Nullable<DataBuffer>;
  22947. /** @hidden */
  22948. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22949. /**
  22950. * Release the associated resources for a specific mesh
  22951. * @param mesh defines the source mesh
  22952. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22953. */
  22954. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22955. /**
  22956. * Apply current geometry to a given mesh
  22957. * @param mesh defines the mesh to apply geometry to
  22958. */
  22959. applyToMesh(mesh: Mesh): void;
  22960. private _updateExtend;
  22961. private _applyToMesh;
  22962. private notifyUpdate;
  22963. /**
  22964. * Load the geometry if it was flagged as delay loaded
  22965. * @param scene defines the hosting scene
  22966. * @param onLoaded defines a callback called when the geometry is loaded
  22967. */
  22968. load(scene: Scene, onLoaded?: () => void): void;
  22969. private _queueLoad;
  22970. /**
  22971. * Invert the geometry to move from a right handed system to a left handed one.
  22972. */
  22973. toLeftHanded(): void;
  22974. /** @hidden */
  22975. _resetPointsArrayCache(): void;
  22976. /** @hidden */
  22977. _generatePointsArray(): boolean;
  22978. /**
  22979. * Gets a value indicating if the geometry is disposed
  22980. * @returns true if the geometry was disposed
  22981. */
  22982. isDisposed(): boolean;
  22983. private _disposeVertexArrayObjects;
  22984. /**
  22985. * Free all associated resources
  22986. */
  22987. dispose(): void;
  22988. /**
  22989. * Clone the current geometry into a new geometry
  22990. * @param id defines the unique ID of the new geometry
  22991. * @returns a new geometry object
  22992. */
  22993. copy(id: string): Geometry;
  22994. /**
  22995. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22996. * @return a JSON representation of the current geometry data (without the vertices data)
  22997. */
  22998. serialize(): any;
  22999. private toNumberArray;
  23000. /**
  23001. * Serialize all vertices data into a JSON oject
  23002. * @returns a JSON representation of the current geometry data
  23003. */
  23004. serializeVerticeData(): any;
  23005. /**
  23006. * Extracts a clone of a mesh geometry
  23007. * @param mesh defines the source mesh
  23008. * @param id defines the unique ID of the new geometry object
  23009. * @returns the new geometry object
  23010. */
  23011. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23012. /**
  23013. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23014. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23015. * Be aware Math.random() could cause collisions, but:
  23016. * "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"
  23017. * @returns a string containing a new GUID
  23018. */
  23019. static RandomId(): string;
  23020. /** @hidden */
  23021. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23022. private static _CleanMatricesWeights;
  23023. /**
  23024. * Create a new geometry from persisted data (Using .babylon file format)
  23025. * @param parsedVertexData defines the persisted data
  23026. * @param scene defines the hosting scene
  23027. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23028. * @returns the new geometry object
  23029. */
  23030. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23031. }
  23032. }
  23033. declare module BABYLON {
  23034. /**
  23035. * Define an interface for all classes that will get and set the data on vertices
  23036. */
  23037. export interface IGetSetVerticesData {
  23038. /**
  23039. * Gets a boolean indicating if specific vertex data is present
  23040. * @param kind defines the vertex data kind to use
  23041. * @returns true is data kind is present
  23042. */
  23043. isVerticesDataPresent(kind: string): boolean;
  23044. /**
  23045. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23046. * @param kind defines the data kind (Position, normal, etc...)
  23047. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23048. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23049. * @returns a float array containing vertex data
  23050. */
  23051. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23052. /**
  23053. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23054. * @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.
  23055. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23056. * @returns the indices array or an empty array if the mesh has no geometry
  23057. */
  23058. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23059. /**
  23060. * Set specific vertex data
  23061. * @param kind defines the data kind (Position, normal, etc...)
  23062. * @param data defines the vertex data to use
  23063. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23064. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23065. */
  23066. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23067. /**
  23068. * Update a specific associated vertex buffer
  23069. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23070. * - VertexBuffer.PositionKind
  23071. * - VertexBuffer.UVKind
  23072. * - VertexBuffer.UV2Kind
  23073. * - VertexBuffer.UV3Kind
  23074. * - VertexBuffer.UV4Kind
  23075. * - VertexBuffer.UV5Kind
  23076. * - VertexBuffer.UV6Kind
  23077. * - VertexBuffer.ColorKind
  23078. * - VertexBuffer.MatricesIndicesKind
  23079. * - VertexBuffer.MatricesIndicesExtraKind
  23080. * - VertexBuffer.MatricesWeightsKind
  23081. * - VertexBuffer.MatricesWeightsExtraKind
  23082. * @param data defines the data source
  23083. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23084. * @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)
  23085. */
  23086. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23087. /**
  23088. * Creates a new index buffer
  23089. * @param indices defines the indices to store in the index buffer
  23090. * @param totalVertices defines the total number of vertices (could be null)
  23091. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23092. */
  23093. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23094. }
  23095. /**
  23096. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23097. */
  23098. export class VertexData {
  23099. /**
  23100. * Mesh side orientation : usually the external or front surface
  23101. */
  23102. static readonly FRONTSIDE: number;
  23103. /**
  23104. * Mesh side orientation : usually the internal or back surface
  23105. */
  23106. static readonly BACKSIDE: number;
  23107. /**
  23108. * Mesh side orientation : both internal and external or front and back surfaces
  23109. */
  23110. static readonly DOUBLESIDE: number;
  23111. /**
  23112. * Mesh side orientation : by default, `FRONTSIDE`
  23113. */
  23114. static readonly DEFAULTSIDE: number;
  23115. /**
  23116. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23117. */
  23118. positions: Nullable<FloatArray>;
  23119. /**
  23120. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23121. */
  23122. normals: Nullable<FloatArray>;
  23123. /**
  23124. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23125. */
  23126. tangents: Nullable<FloatArray>;
  23127. /**
  23128. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23129. */
  23130. uvs: Nullable<FloatArray>;
  23131. /**
  23132. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23133. */
  23134. uvs2: Nullable<FloatArray>;
  23135. /**
  23136. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23137. */
  23138. uvs3: Nullable<FloatArray>;
  23139. /**
  23140. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23141. */
  23142. uvs4: Nullable<FloatArray>;
  23143. /**
  23144. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23145. */
  23146. uvs5: Nullable<FloatArray>;
  23147. /**
  23148. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23149. */
  23150. uvs6: Nullable<FloatArray>;
  23151. /**
  23152. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23153. */
  23154. colors: Nullable<FloatArray>;
  23155. /**
  23156. * 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).
  23157. */
  23158. matricesIndices: Nullable<FloatArray>;
  23159. /**
  23160. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23161. */
  23162. matricesWeights: Nullable<FloatArray>;
  23163. /**
  23164. * An array extending the number of possible indices
  23165. */
  23166. matricesIndicesExtra: Nullable<FloatArray>;
  23167. /**
  23168. * An array extending the number of possible weights when the number of indices is extended
  23169. */
  23170. matricesWeightsExtra: Nullable<FloatArray>;
  23171. /**
  23172. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23173. */
  23174. indices: Nullable<IndicesArray>;
  23175. /**
  23176. * Uses the passed data array to set the set the values for the specified kind of data
  23177. * @param data a linear array of floating numbers
  23178. * @param kind the type of data that is being set, eg positions, colors etc
  23179. */
  23180. set(data: FloatArray, kind: string): void;
  23181. /**
  23182. * Associates the vertexData to the passed Mesh.
  23183. * Sets it as updatable or not (default `false`)
  23184. * @param mesh the mesh the vertexData is applied to
  23185. * @param updatable when used and having the value true allows new data to update the vertexData
  23186. * @returns the VertexData
  23187. */
  23188. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23189. /**
  23190. * Associates the vertexData to the passed Geometry.
  23191. * Sets it as updatable or not (default `false`)
  23192. * @param geometry the geometry the vertexData is applied to
  23193. * @param updatable when used and having the value true allows new data to update the vertexData
  23194. * @returns VertexData
  23195. */
  23196. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23197. /**
  23198. * Updates the associated mesh
  23199. * @param mesh the mesh to be updated
  23200. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23201. * @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
  23202. * @returns VertexData
  23203. */
  23204. updateMesh(mesh: Mesh): VertexData;
  23205. /**
  23206. * Updates the associated geometry
  23207. * @param geometry the geometry to be updated
  23208. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23209. * @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
  23210. * @returns VertexData.
  23211. */
  23212. updateGeometry(geometry: Geometry): VertexData;
  23213. private _applyTo;
  23214. private _update;
  23215. /**
  23216. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23217. * @param matrix the transforming matrix
  23218. * @returns the VertexData
  23219. */
  23220. transform(matrix: Matrix): VertexData;
  23221. /**
  23222. * Merges the passed VertexData into the current one
  23223. * @param other the VertexData to be merged into the current one
  23224. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23225. * @returns the modified VertexData
  23226. */
  23227. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23228. private _mergeElement;
  23229. private _validate;
  23230. /**
  23231. * Serializes the VertexData
  23232. * @returns a serialized object
  23233. */
  23234. serialize(): any;
  23235. /**
  23236. * Extracts the vertexData from a mesh
  23237. * @param mesh the mesh from which to extract the VertexData
  23238. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23239. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23240. * @returns the object VertexData associated to the passed mesh
  23241. */
  23242. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23243. /**
  23244. * Extracts the vertexData from the geometry
  23245. * @param geometry the geometry from which to extract the VertexData
  23246. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23247. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23248. * @returns the object VertexData associated to the passed mesh
  23249. */
  23250. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23251. private static _ExtractFrom;
  23252. /**
  23253. * Creates the VertexData for a Ribbon
  23254. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23255. * * pathArray array of paths, each of which an array of successive Vector3
  23256. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23257. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23258. * * 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
  23259. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23260. * * 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)
  23261. * * 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)
  23262. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23263. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23264. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23265. * @returns the VertexData of the ribbon
  23266. */
  23267. static CreateRibbon(options: {
  23268. pathArray: Vector3[][];
  23269. closeArray?: boolean;
  23270. closePath?: boolean;
  23271. offset?: number;
  23272. sideOrientation?: number;
  23273. frontUVs?: Vector4;
  23274. backUVs?: Vector4;
  23275. invertUV?: boolean;
  23276. uvs?: Vector2[];
  23277. colors?: Color4[];
  23278. }): VertexData;
  23279. /**
  23280. * Creates the VertexData for a box
  23281. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23282. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23283. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23284. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23285. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23286. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23287. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23288. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23289. * * 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)
  23290. * * 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)
  23291. * @returns the VertexData of the box
  23292. */
  23293. static CreateBox(options: {
  23294. size?: number;
  23295. width?: number;
  23296. height?: number;
  23297. depth?: number;
  23298. faceUV?: Vector4[];
  23299. faceColors?: Color4[];
  23300. sideOrientation?: number;
  23301. frontUVs?: Vector4;
  23302. backUVs?: Vector4;
  23303. }): VertexData;
  23304. /**
  23305. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23306. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23307. * * segments sets the number of horizontal strips optional, default 32
  23308. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23309. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23310. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23311. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23312. * * 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
  23313. * * 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
  23314. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23315. * * 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)
  23316. * * 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)
  23317. * @returns the VertexData of the ellipsoid
  23318. */
  23319. static CreateSphere(options: {
  23320. segments?: number;
  23321. diameter?: number;
  23322. diameterX?: number;
  23323. diameterY?: number;
  23324. diameterZ?: number;
  23325. arc?: number;
  23326. slice?: number;
  23327. sideOrientation?: number;
  23328. frontUVs?: Vector4;
  23329. backUVs?: Vector4;
  23330. }): VertexData;
  23331. /**
  23332. * Creates the VertexData for a cylinder, cone or prism
  23333. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23334. * * height sets the height (y direction) of the cylinder, optional, default 2
  23335. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23336. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23337. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23338. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23339. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23340. * * 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
  23341. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23342. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23343. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23344. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23345. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23346. * * 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)
  23347. * * 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)
  23348. * @returns the VertexData of the cylinder, cone or prism
  23349. */
  23350. static CreateCylinder(options: {
  23351. height?: number;
  23352. diameterTop?: number;
  23353. diameterBottom?: number;
  23354. diameter?: number;
  23355. tessellation?: number;
  23356. subdivisions?: number;
  23357. arc?: number;
  23358. faceColors?: Color4[];
  23359. faceUV?: Vector4[];
  23360. hasRings?: boolean;
  23361. enclose?: boolean;
  23362. sideOrientation?: number;
  23363. frontUVs?: Vector4;
  23364. backUVs?: Vector4;
  23365. }): VertexData;
  23366. /**
  23367. * Creates the VertexData for a torus
  23368. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23369. * * diameter the diameter of the torus, optional default 1
  23370. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23371. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23372. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23373. * * 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)
  23374. * * 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)
  23375. * @returns the VertexData of the torus
  23376. */
  23377. static CreateTorus(options: {
  23378. diameter?: number;
  23379. thickness?: number;
  23380. tessellation?: number;
  23381. sideOrientation?: number;
  23382. frontUVs?: Vector4;
  23383. backUVs?: Vector4;
  23384. }): VertexData;
  23385. /**
  23386. * Creates the VertexData of the LineSystem
  23387. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23388. * - lines an array of lines, each line being an array of successive Vector3
  23389. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23390. * @returns the VertexData of the LineSystem
  23391. */
  23392. static CreateLineSystem(options: {
  23393. lines: Vector3[][];
  23394. colors?: Nullable<Color4[][]>;
  23395. }): VertexData;
  23396. /**
  23397. * Create the VertexData for a DashedLines
  23398. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23399. * - points an array successive Vector3
  23400. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23401. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23402. * - dashNb the intended total number of dashes, optional, default 200
  23403. * @returns the VertexData for the DashedLines
  23404. */
  23405. static CreateDashedLines(options: {
  23406. points: Vector3[];
  23407. dashSize?: number;
  23408. gapSize?: number;
  23409. dashNb?: number;
  23410. }): VertexData;
  23411. /**
  23412. * Creates the VertexData for a Ground
  23413. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23414. * - width the width (x direction) of the ground, optional, default 1
  23415. * - height the height (z direction) of the ground, optional, default 1
  23416. * - subdivisions the number of subdivisions per side, optional, default 1
  23417. * @returns the VertexData of the Ground
  23418. */
  23419. static CreateGround(options: {
  23420. width?: number;
  23421. height?: number;
  23422. subdivisions?: number;
  23423. subdivisionsX?: number;
  23424. subdivisionsY?: number;
  23425. }): VertexData;
  23426. /**
  23427. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23428. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23429. * * xmin the ground minimum X coordinate, optional, default -1
  23430. * * zmin the ground minimum Z coordinate, optional, default -1
  23431. * * xmax the ground maximum X coordinate, optional, default 1
  23432. * * zmax the ground maximum Z coordinate, optional, default 1
  23433. * * 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}
  23434. * * 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}
  23435. * @returns the VertexData of the TiledGround
  23436. */
  23437. static CreateTiledGround(options: {
  23438. xmin: number;
  23439. zmin: number;
  23440. xmax: number;
  23441. zmax: number;
  23442. subdivisions?: {
  23443. w: number;
  23444. h: number;
  23445. };
  23446. precision?: {
  23447. w: number;
  23448. h: number;
  23449. };
  23450. }): VertexData;
  23451. /**
  23452. * Creates the VertexData of the Ground designed from a heightmap
  23453. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23454. * * width the width (x direction) of the ground
  23455. * * height the height (z direction) of the ground
  23456. * * subdivisions the number of subdivisions per side
  23457. * * minHeight the minimum altitude on the ground, optional, default 0
  23458. * * maxHeight the maximum altitude on the ground, optional default 1
  23459. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23460. * * buffer the array holding the image color data
  23461. * * bufferWidth the width of image
  23462. * * bufferHeight the height of image
  23463. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23464. * @returns the VertexData of the Ground designed from a heightmap
  23465. */
  23466. static CreateGroundFromHeightMap(options: {
  23467. width: number;
  23468. height: number;
  23469. subdivisions: number;
  23470. minHeight: number;
  23471. maxHeight: number;
  23472. colorFilter: Color3;
  23473. buffer: Uint8Array;
  23474. bufferWidth: number;
  23475. bufferHeight: number;
  23476. alphaFilter: number;
  23477. }): VertexData;
  23478. /**
  23479. * Creates the VertexData for a Plane
  23480. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23481. * * size sets the width and height of the plane to the value of size, optional default 1
  23482. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23483. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23484. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23485. * * 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)
  23486. * * 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)
  23487. * @returns the VertexData of the box
  23488. */
  23489. static CreatePlane(options: {
  23490. size?: number;
  23491. width?: number;
  23492. height?: number;
  23493. sideOrientation?: number;
  23494. frontUVs?: Vector4;
  23495. backUVs?: Vector4;
  23496. }): VertexData;
  23497. /**
  23498. * Creates the VertexData of the Disc or regular Polygon
  23499. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23500. * * radius the radius of the disc, optional default 0.5
  23501. * * tessellation the number of polygon sides, optional, default 64
  23502. * * 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
  23503. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23504. * * 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)
  23505. * * 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)
  23506. * @returns the VertexData of the box
  23507. */
  23508. static CreateDisc(options: {
  23509. radius?: number;
  23510. tessellation?: number;
  23511. arc?: number;
  23512. sideOrientation?: number;
  23513. frontUVs?: Vector4;
  23514. backUVs?: Vector4;
  23515. }): VertexData;
  23516. /**
  23517. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23518. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23519. * @param polygon a mesh built from polygonTriangulation.build()
  23520. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23521. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23522. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23523. * @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)
  23524. * @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)
  23525. * @returns the VertexData of the Polygon
  23526. */
  23527. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23528. /**
  23529. * Creates the VertexData of the IcoSphere
  23530. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23531. * * radius the radius of the IcoSphere, optional default 1
  23532. * * radiusX allows stretching in the x direction, optional, default radius
  23533. * * radiusY allows stretching in the y direction, optional, default radius
  23534. * * radiusZ allows stretching in the z direction, optional, default radius
  23535. * * flat when true creates a flat shaded mesh, optional, default true
  23536. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23537. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23538. * * 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)
  23539. * * 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)
  23540. * @returns the VertexData of the IcoSphere
  23541. */
  23542. static CreateIcoSphere(options: {
  23543. radius?: number;
  23544. radiusX?: number;
  23545. radiusY?: number;
  23546. radiusZ?: number;
  23547. flat?: boolean;
  23548. subdivisions?: number;
  23549. sideOrientation?: number;
  23550. frontUVs?: Vector4;
  23551. backUVs?: Vector4;
  23552. }): VertexData;
  23553. /**
  23554. * Creates the VertexData for a Polyhedron
  23555. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23556. * * type provided types are:
  23557. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23558. * * 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)
  23559. * * size the size of the IcoSphere, optional default 1
  23560. * * sizeX allows stretching in the x direction, optional, default size
  23561. * * sizeY allows stretching in the y direction, optional, default size
  23562. * * sizeZ allows stretching in the z direction, optional, default size
  23563. * * 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
  23564. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23565. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23566. * * flat when true creates a flat shaded mesh, optional, default true
  23567. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23568. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23569. * * 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)
  23570. * * 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)
  23571. * @returns the VertexData of the Polyhedron
  23572. */
  23573. static CreatePolyhedron(options: {
  23574. type?: number;
  23575. size?: number;
  23576. sizeX?: number;
  23577. sizeY?: number;
  23578. sizeZ?: number;
  23579. custom?: any;
  23580. faceUV?: Vector4[];
  23581. faceColors?: Color4[];
  23582. flat?: boolean;
  23583. sideOrientation?: number;
  23584. frontUVs?: Vector4;
  23585. backUVs?: Vector4;
  23586. }): VertexData;
  23587. /**
  23588. * Creates the VertexData for a TorusKnot
  23589. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23590. * * radius the radius of the torus knot, optional, default 2
  23591. * * tube the thickness of the tube, optional, default 0.5
  23592. * * radialSegments the number of sides on each tube segments, optional, default 32
  23593. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23594. * * p the number of windings around the z axis, optional, default 2
  23595. * * q the number of windings around the x axis, optional, default 3
  23596. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23597. * * 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)
  23598. * * 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)
  23599. * @returns the VertexData of the Torus Knot
  23600. */
  23601. static CreateTorusKnot(options: {
  23602. radius?: number;
  23603. tube?: number;
  23604. radialSegments?: number;
  23605. tubularSegments?: number;
  23606. p?: number;
  23607. q?: number;
  23608. sideOrientation?: number;
  23609. frontUVs?: Vector4;
  23610. backUVs?: Vector4;
  23611. }): VertexData;
  23612. /**
  23613. * Compute normals for given positions and indices
  23614. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23615. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23616. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23617. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23618. * * facetNormals : optional array of facet normals (vector3)
  23619. * * facetPositions : optional array of facet positions (vector3)
  23620. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23621. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23622. * * bInfo : optional bounding info, required for facetPartitioning computation
  23623. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23624. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23625. * * useRightHandedSystem: optional boolean to for right handed system computation
  23626. * * depthSort : optional boolean to enable the facet depth sort computation
  23627. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23628. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23629. */
  23630. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23631. facetNormals?: any;
  23632. facetPositions?: any;
  23633. facetPartitioning?: any;
  23634. ratio?: number;
  23635. bInfo?: any;
  23636. bbSize?: Vector3;
  23637. subDiv?: any;
  23638. useRightHandedSystem?: boolean;
  23639. depthSort?: boolean;
  23640. distanceTo?: Vector3;
  23641. depthSortedFacets?: any;
  23642. }): void;
  23643. /** @hidden */
  23644. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23645. /**
  23646. * Applies VertexData created from the imported parameters to the geometry
  23647. * @param parsedVertexData the parsed data from an imported file
  23648. * @param geometry the geometry to apply the VertexData to
  23649. */
  23650. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23651. }
  23652. }
  23653. declare module BABYLON {
  23654. /**
  23655. * Class containing static functions to help procedurally build meshes
  23656. */
  23657. export class DiscBuilder {
  23658. /**
  23659. * Creates a plane polygonal mesh. By default, this is a disc
  23660. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23661. * * 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
  23662. * * 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
  23663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23664. * * 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
  23665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23666. * @param name defines the name of the mesh
  23667. * @param options defines the options used to create the mesh
  23668. * @param scene defines the hosting scene
  23669. * @returns the plane polygonal mesh
  23670. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23671. */
  23672. static CreateDisc(name: string, options: {
  23673. radius?: number;
  23674. tessellation?: number;
  23675. arc?: number;
  23676. updatable?: boolean;
  23677. sideOrientation?: number;
  23678. frontUVs?: Vector4;
  23679. backUVs?: Vector4;
  23680. }, scene?: Nullable<Scene>): Mesh;
  23681. }
  23682. }
  23683. declare module BABYLON {
  23684. /**
  23685. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23686. *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.
  23687. * The SPS is also a particle system. It provides some methods to manage the particles.
  23688. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23689. *
  23690. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23691. */
  23692. export class SolidParticleSystem implements IDisposable {
  23693. /**
  23694. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23695. * Example : var p = SPS.particles[i];
  23696. */
  23697. particles: SolidParticle[];
  23698. /**
  23699. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23700. */
  23701. nbParticles: number;
  23702. /**
  23703. * If the particles must ever face the camera (default false). Useful for planar particles.
  23704. */
  23705. billboard: boolean;
  23706. /**
  23707. * Recompute normals when adding a shape
  23708. */
  23709. recomputeNormals: boolean;
  23710. /**
  23711. * This a counter ofr your own usage. It's not set by any SPS functions.
  23712. */
  23713. counter: number;
  23714. /**
  23715. * The SPS name. This name is also given to the underlying mesh.
  23716. */
  23717. name: string;
  23718. /**
  23719. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23720. */
  23721. mesh: Mesh;
  23722. /**
  23723. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23724. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23725. */
  23726. vars: any;
  23727. /**
  23728. * This array is populated when the SPS is set as 'pickable'.
  23729. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23730. * Each element of this array is an object `{idx: int, faceId: int}`.
  23731. * `idx` is the picked particle index in the `SPS.particles` array
  23732. * `faceId` is the picked face index counted within this particle.
  23733. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23734. */
  23735. pickedParticles: {
  23736. idx: number;
  23737. faceId: number;
  23738. }[];
  23739. /**
  23740. * This array is populated when `enableDepthSort` is set to true.
  23741. * Each element of this array is an instance of the class DepthSortedParticle.
  23742. */
  23743. depthSortedParticles: DepthSortedParticle[];
  23744. /**
  23745. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23746. * @hidden
  23747. */
  23748. _bSphereOnly: boolean;
  23749. /**
  23750. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23751. * @hidden
  23752. */
  23753. _bSphereRadiusFactor: number;
  23754. private _scene;
  23755. private _positions;
  23756. private _indices;
  23757. private _normals;
  23758. private _colors;
  23759. private _uvs;
  23760. private _indices32;
  23761. private _positions32;
  23762. private _normals32;
  23763. private _fixedNormal32;
  23764. private _colors32;
  23765. private _uvs32;
  23766. private _index;
  23767. private _updatable;
  23768. private _pickable;
  23769. private _isVisibilityBoxLocked;
  23770. private _alwaysVisible;
  23771. private _depthSort;
  23772. private _shapeCounter;
  23773. private _copy;
  23774. private _color;
  23775. private _computeParticleColor;
  23776. private _computeParticleTexture;
  23777. private _computeParticleRotation;
  23778. private _computeParticleVertex;
  23779. private _computeBoundingBox;
  23780. private _depthSortParticles;
  23781. private _camera;
  23782. private _mustUnrotateFixedNormals;
  23783. private _particlesIntersect;
  23784. private _needs32Bits;
  23785. /**
  23786. * Creates a SPS (Solid Particle System) object.
  23787. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23788. * @param scene (Scene) is the scene in which the SPS is added.
  23789. * @param options defines the options of the sps e.g.
  23790. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23791. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23792. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23793. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23794. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23795. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23796. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23797. */
  23798. constructor(name: string, scene: Scene, options?: {
  23799. updatable?: boolean;
  23800. isPickable?: boolean;
  23801. enableDepthSort?: boolean;
  23802. particleIntersection?: boolean;
  23803. boundingSphereOnly?: boolean;
  23804. bSphereRadiusFactor?: number;
  23805. });
  23806. /**
  23807. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23808. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23809. * @returns the created mesh
  23810. */
  23811. buildMesh(): Mesh;
  23812. /**
  23813. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23814. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23815. * Thus the particles generated from `digest()` have their property `position` set yet.
  23816. * @param mesh ( Mesh ) is the mesh to be digested
  23817. * @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
  23818. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23819. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23820. * @returns the current SPS
  23821. */
  23822. digest(mesh: Mesh, options?: {
  23823. facetNb?: number;
  23824. number?: number;
  23825. delta?: number;
  23826. }): SolidParticleSystem;
  23827. private _unrotateFixedNormals;
  23828. private _resetCopy;
  23829. private _meshBuilder;
  23830. private _posToShape;
  23831. private _uvsToShapeUV;
  23832. private _addParticle;
  23833. /**
  23834. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23835. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23836. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23837. * @param nb (positive integer) the number of particles to be created from this model
  23838. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23839. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23840. * @returns the number of shapes in the system
  23841. */
  23842. addShape(mesh: Mesh, nb: number, options?: {
  23843. positionFunction?: any;
  23844. vertexFunction?: any;
  23845. }): number;
  23846. private _rebuildParticle;
  23847. /**
  23848. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23849. * @returns the SPS.
  23850. */
  23851. rebuildMesh(): SolidParticleSystem;
  23852. /**
  23853. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23854. * This method calls `updateParticle()` for each particle of the SPS.
  23855. * For an animated SPS, it is usually called within the render loop.
  23856. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23857. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23858. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23859. * @returns the SPS.
  23860. */
  23861. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23862. /**
  23863. * Disposes the SPS.
  23864. */
  23865. dispose(): void;
  23866. /**
  23867. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23868. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23869. * @returns the SPS.
  23870. */
  23871. refreshVisibleSize(): SolidParticleSystem;
  23872. /**
  23873. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23874. * @param size the size (float) of the visibility box
  23875. * note : this doesn't lock the SPS mesh bounding box.
  23876. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23877. */
  23878. setVisibilityBox(size: number): void;
  23879. /**
  23880. * Gets whether the SPS as always visible or not
  23881. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23882. */
  23883. /**
  23884. * Sets the SPS as always visible or not
  23885. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23886. */
  23887. isAlwaysVisible: boolean;
  23888. /**
  23889. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23890. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23891. */
  23892. /**
  23893. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23894. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23895. */
  23896. isVisibilityBoxLocked: boolean;
  23897. /**
  23898. * Tells to `setParticles()` to compute the particle rotations or not.
  23899. * Default value : true. The SPS is faster when it's set to false.
  23900. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23901. */
  23902. /**
  23903. * Gets if `setParticles()` computes the particle rotations or not.
  23904. * Default value : true. The SPS is faster when it's set to false.
  23905. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23906. */
  23907. computeParticleRotation: boolean;
  23908. /**
  23909. * Tells to `setParticles()` to compute the particle colors or not.
  23910. * Default value : true. The SPS is faster when it's set to false.
  23911. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23912. */
  23913. /**
  23914. * Gets if `setParticles()` computes the particle colors or not.
  23915. * Default value : true. The SPS is faster when it's set to false.
  23916. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23917. */
  23918. computeParticleColor: boolean;
  23919. /**
  23920. * Gets if `setParticles()` computes the particle textures or not.
  23921. * Default value : true. The SPS is faster when it's set to false.
  23922. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23923. */
  23924. computeParticleTexture: boolean;
  23925. /**
  23926. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23927. * Default value : false. The SPS is faster when it's set to false.
  23928. * Note : the particle custom vertex positions aren't stored values.
  23929. */
  23930. /**
  23931. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23932. * Default value : false. The SPS is faster when it's set to false.
  23933. * Note : the particle custom vertex positions aren't stored values.
  23934. */
  23935. computeParticleVertex: boolean;
  23936. /**
  23937. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23938. */
  23939. /**
  23940. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23941. */
  23942. computeBoundingBox: boolean;
  23943. /**
  23944. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23945. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23946. * Default : `true`
  23947. */
  23948. /**
  23949. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23950. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23951. * Default : `true`
  23952. */
  23953. depthSortParticles: boolean;
  23954. /**
  23955. * This function does nothing. It may be overwritten to set all the particle first values.
  23956. * The SPS doesn't call this function, you may have to call it by your own.
  23957. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23958. */
  23959. initParticles(): void;
  23960. /**
  23961. * This function does nothing. It may be overwritten to recycle a particle.
  23962. * The SPS doesn't call this function, you may have to call it by your own.
  23963. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23964. * @param particle The particle to recycle
  23965. * @returns the recycled particle
  23966. */
  23967. recycleParticle(particle: SolidParticle): SolidParticle;
  23968. /**
  23969. * Updates a particle : this function should be overwritten by the user.
  23970. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23971. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23972. * @example : just set a particle position or velocity and recycle conditions
  23973. * @param particle The particle to update
  23974. * @returns the updated particle
  23975. */
  23976. updateParticle(particle: SolidParticle): SolidParticle;
  23977. /**
  23978. * Updates a vertex of a particle : it can be overwritten by the user.
  23979. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23980. * @param particle the current particle
  23981. * @param vertex the current index of the current particle
  23982. * @param pt the index of the current vertex in the particle shape
  23983. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23984. * @example : just set a vertex particle position
  23985. * @returns the updated vertex
  23986. */
  23987. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23988. /**
  23989. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23990. * This does nothing and may be overwritten by the user.
  23991. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23992. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23993. * @param update the boolean update value actually passed to setParticles()
  23994. */
  23995. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23996. /**
  23997. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23998. * This will be passed three parameters.
  23999. * This does nothing and may be overwritten by the user.
  24000. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24001. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24002. * @param update the boolean update value actually passed to setParticles()
  24003. */
  24004. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24005. }
  24006. }
  24007. declare module BABYLON {
  24008. /**
  24009. * Represents one particle of a solid particle system.
  24010. */
  24011. export class SolidParticle {
  24012. /**
  24013. * particle global index
  24014. */
  24015. idx: number;
  24016. /**
  24017. * The color of the particle
  24018. */
  24019. color: Nullable<Color4>;
  24020. /**
  24021. * The world space position of the particle.
  24022. */
  24023. position: Vector3;
  24024. /**
  24025. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24026. */
  24027. rotation: Vector3;
  24028. /**
  24029. * The world space rotation quaternion of the particle.
  24030. */
  24031. rotationQuaternion: Nullable<Quaternion>;
  24032. /**
  24033. * The scaling of the particle.
  24034. */
  24035. scaling: Vector3;
  24036. /**
  24037. * The uvs of the particle.
  24038. */
  24039. uvs: Vector4;
  24040. /**
  24041. * The current speed of the particle.
  24042. */
  24043. velocity: Vector3;
  24044. /**
  24045. * The pivot point in the particle local space.
  24046. */
  24047. pivot: Vector3;
  24048. /**
  24049. * Must the particle be translated from its pivot point in its local space ?
  24050. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24051. * Default : false
  24052. */
  24053. translateFromPivot: boolean;
  24054. /**
  24055. * Is the particle active or not ?
  24056. */
  24057. alive: boolean;
  24058. /**
  24059. * Is the particle visible or not ?
  24060. */
  24061. isVisible: boolean;
  24062. /**
  24063. * Index of this particle in the global "positions" array (Internal use)
  24064. * @hidden
  24065. */
  24066. _pos: number;
  24067. /**
  24068. * @hidden Index of this particle in the global "indices" array (Internal use)
  24069. */
  24070. _ind: number;
  24071. /**
  24072. * @hidden ModelShape of this particle (Internal use)
  24073. */
  24074. _model: ModelShape;
  24075. /**
  24076. * ModelShape id of this particle
  24077. */
  24078. shapeId: number;
  24079. /**
  24080. * Index of the particle in its shape id (Internal use)
  24081. */
  24082. idxInShape: number;
  24083. /**
  24084. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24085. */
  24086. _modelBoundingInfo: BoundingInfo;
  24087. /**
  24088. * @hidden Particle BoundingInfo object (Internal use)
  24089. */
  24090. _boundingInfo: BoundingInfo;
  24091. /**
  24092. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24093. */
  24094. _sps: SolidParticleSystem;
  24095. /**
  24096. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24097. */
  24098. _stillInvisible: boolean;
  24099. /**
  24100. * @hidden Last computed particle rotation matrix
  24101. */
  24102. _rotationMatrix: number[];
  24103. /**
  24104. * Parent particle Id, if any.
  24105. * Default null.
  24106. */
  24107. parentId: Nullable<number>;
  24108. /**
  24109. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24110. * The possible values are :
  24111. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24112. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24113. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24114. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24115. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24116. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24117. * */
  24118. cullingStrategy: number;
  24119. /**
  24120. * @hidden Internal global position in the SPS.
  24121. */
  24122. _globalPosition: Vector3;
  24123. /**
  24124. * Creates a Solid Particle object.
  24125. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24126. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24127. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24128. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24129. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24130. * @param shapeId (integer) is the model shape identifier in the SPS.
  24131. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24132. * @param sps defines the sps it is associated to
  24133. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24134. */
  24135. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24136. /**
  24137. * Legacy support, changed scale to scaling
  24138. */
  24139. /**
  24140. * Legacy support, changed scale to scaling
  24141. */
  24142. scale: Vector3;
  24143. /**
  24144. * Legacy support, changed quaternion to rotationQuaternion
  24145. */
  24146. /**
  24147. * Legacy support, changed quaternion to rotationQuaternion
  24148. */
  24149. quaternion: Nullable<Quaternion>;
  24150. /**
  24151. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24152. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24153. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24154. * @returns true if it intersects
  24155. */
  24156. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24157. /**
  24158. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24159. * A particle is in the frustum if its bounding box intersects the frustum
  24160. * @param frustumPlanes defines the frustum to test
  24161. * @returns true if the particle is in the frustum planes
  24162. */
  24163. isInFrustum(frustumPlanes: Plane[]): boolean;
  24164. /**
  24165. * get the rotation matrix of the particle
  24166. * @hidden
  24167. */
  24168. getRotationMatrix(m: Matrix): void;
  24169. }
  24170. /**
  24171. * Represents the shape of the model used by one particle of a solid particle system.
  24172. * SPS internal tool, don't use it manually.
  24173. */
  24174. export class ModelShape {
  24175. /**
  24176. * The shape id
  24177. * @hidden
  24178. */
  24179. shapeID: number;
  24180. /**
  24181. * flat array of model positions (internal use)
  24182. * @hidden
  24183. */
  24184. _shape: Vector3[];
  24185. /**
  24186. * flat array of model UVs (internal use)
  24187. * @hidden
  24188. */
  24189. _shapeUV: number[];
  24190. /**
  24191. * length of the shape in the model indices array (internal use)
  24192. * @hidden
  24193. */
  24194. _indicesLength: number;
  24195. /**
  24196. * Custom position function (internal use)
  24197. * @hidden
  24198. */
  24199. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24200. /**
  24201. * Custom vertex function (internal use)
  24202. * @hidden
  24203. */
  24204. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24205. /**
  24206. * 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.
  24207. * SPS internal tool, don't use it manually.
  24208. * @hidden
  24209. */
  24210. 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>);
  24211. }
  24212. /**
  24213. * Represents a Depth Sorted Particle in the solid particle system.
  24214. */
  24215. export class DepthSortedParticle {
  24216. /**
  24217. * Index of the particle in the "indices" array
  24218. */
  24219. ind: number;
  24220. /**
  24221. * Length of the particle shape in the "indices" array
  24222. */
  24223. indicesLength: number;
  24224. /**
  24225. * Squared distance from the particle to the camera
  24226. */
  24227. sqDistance: number;
  24228. }
  24229. }
  24230. declare module BABYLON {
  24231. /**
  24232. * Class used to store all common mesh properties
  24233. */
  24234. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24235. /** No occlusion */
  24236. static OCCLUSION_TYPE_NONE: number;
  24237. /** Occlusion set to optimisitic */
  24238. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24239. /** Occlusion set to strict */
  24240. static OCCLUSION_TYPE_STRICT: number;
  24241. /** Use an accurante occlusion algorithm */
  24242. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24243. /** Use a conservative occlusion algorithm */
  24244. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24245. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24246. * Test order :
  24247. * Is the bounding sphere outside the frustum ?
  24248. * If not, are the bounding box vertices outside the frustum ?
  24249. * It not, then the cullable object is in the frustum.
  24250. */
  24251. static readonly CULLINGSTRATEGY_STANDARD: number;
  24252. /** Culling strategy : Bounding Sphere Only.
  24253. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24254. * It's also less accurate than the standard because some not visible objects can still be selected.
  24255. * Test : is the bounding sphere outside the frustum ?
  24256. * If not, then the cullable object is in the frustum.
  24257. */
  24258. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24259. /** Culling strategy : Optimistic Inclusion.
  24260. * This in an inclusion test first, then the standard exclusion test.
  24261. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24262. * 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.
  24263. * Anyway, it's as accurate as the standard strategy.
  24264. * Test :
  24265. * Is the cullable object bounding sphere center in the frustum ?
  24266. * If not, apply the default culling strategy.
  24267. */
  24268. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24269. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24270. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24271. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24272. * 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.
  24273. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24274. * Test :
  24275. * Is the cullable object bounding sphere center in the frustum ?
  24276. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24277. */
  24278. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24279. /**
  24280. * No billboard
  24281. */
  24282. static readonly BILLBOARDMODE_NONE: number;
  24283. /** Billboard on X axis */
  24284. static readonly BILLBOARDMODE_X: number;
  24285. /** Billboard on Y axis */
  24286. static readonly BILLBOARDMODE_Y: number;
  24287. /** Billboard on Z axis */
  24288. static readonly BILLBOARDMODE_Z: number;
  24289. /** Billboard on all axes */
  24290. static readonly BILLBOARDMODE_ALL: number;
  24291. private _facetData;
  24292. /**
  24293. * The culling strategy to use to check whether the mesh must be rendered or not.
  24294. * This value can be changed at any time and will be used on the next render mesh selection.
  24295. * The possible values are :
  24296. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24297. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24298. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24299. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24300. * Please read each static variable documentation to get details about the culling process.
  24301. * */
  24302. cullingStrategy: number;
  24303. /**
  24304. * Gets the number of facets in the mesh
  24305. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24306. */
  24307. readonly facetNb: number;
  24308. /**
  24309. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24310. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24311. */
  24312. partitioningSubdivisions: number;
  24313. /**
  24314. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24315. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24316. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24317. */
  24318. partitioningBBoxRatio: number;
  24319. /**
  24320. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24321. * Works only for updatable meshes.
  24322. * Doesn't work with multi-materials
  24323. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24324. */
  24325. mustDepthSortFacets: boolean;
  24326. /**
  24327. * The location (Vector3) where the facet depth sort must be computed from.
  24328. * By default, the active camera position.
  24329. * Used only when facet depth sort is enabled
  24330. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24331. */
  24332. facetDepthSortFrom: Vector3;
  24333. /**
  24334. * gets a boolean indicating if facetData is enabled
  24335. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24336. */
  24337. readonly isFacetDataEnabled: boolean;
  24338. /** @hidden */
  24339. _updateNonUniformScalingState(value: boolean): boolean;
  24340. /**
  24341. * An event triggered when this mesh collides with another one
  24342. */
  24343. onCollideObservable: Observable<AbstractMesh>;
  24344. private _onCollideObserver;
  24345. /** Set a function to call when this mesh collides with another one */
  24346. onCollide: () => void;
  24347. /**
  24348. * An event triggered when the collision's position changes
  24349. */
  24350. onCollisionPositionChangeObservable: Observable<Vector3>;
  24351. private _onCollisionPositionChangeObserver;
  24352. /** Set a function to call when the collision's position changes */
  24353. onCollisionPositionChange: () => void;
  24354. /**
  24355. * An event triggered when material is changed
  24356. */
  24357. onMaterialChangedObservable: Observable<AbstractMesh>;
  24358. /**
  24359. * Gets or sets the orientation for POV movement & rotation
  24360. */
  24361. definedFacingForward: boolean;
  24362. /** @hidden */
  24363. _occlusionQuery: Nullable<WebGLQuery>;
  24364. private _visibility;
  24365. /** @hidden */
  24366. _isActive: boolean;
  24367. /** @hidden */
  24368. _onlyForInstances: boolean;
  24369. /** @hidden */
  24370. _renderingGroup: Nullable<RenderingGroup>;
  24371. /**
  24372. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24373. */
  24374. /**
  24375. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24376. */
  24377. visibility: number;
  24378. /** Gets or sets the alpha index used to sort transparent meshes
  24379. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24380. */
  24381. alphaIndex: number;
  24382. /**
  24383. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24384. */
  24385. isVisible: boolean;
  24386. /**
  24387. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24388. */
  24389. isPickable: boolean;
  24390. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24391. showSubMeshesBoundingBox: boolean;
  24392. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24393. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24394. */
  24395. isBlocker: boolean;
  24396. /**
  24397. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24398. */
  24399. enablePointerMoveEvents: boolean;
  24400. /**
  24401. * Specifies the rendering group id for this mesh (0 by default)
  24402. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24403. */
  24404. renderingGroupId: number;
  24405. private _material;
  24406. /** Gets or sets current material */
  24407. material: Nullable<Material>;
  24408. private _receiveShadows;
  24409. /**
  24410. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24411. * @see http://doc.babylonjs.com/babylon101/shadows
  24412. */
  24413. receiveShadows: boolean;
  24414. /** Defines color to use when rendering outline */
  24415. outlineColor: Color3;
  24416. /** Define width to use when rendering outline */
  24417. outlineWidth: number;
  24418. /** Defines color to use when rendering overlay */
  24419. overlayColor: Color3;
  24420. /** Defines alpha to use when rendering overlay */
  24421. overlayAlpha: number;
  24422. private _hasVertexAlpha;
  24423. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24424. hasVertexAlpha: boolean;
  24425. private _useVertexColors;
  24426. /** 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) */
  24427. useVertexColors: boolean;
  24428. private _computeBonesUsingShaders;
  24429. /**
  24430. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24431. */
  24432. computeBonesUsingShaders: boolean;
  24433. private _numBoneInfluencers;
  24434. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24435. numBoneInfluencers: number;
  24436. private _applyFog;
  24437. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24438. applyFog: boolean;
  24439. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24440. useOctreeForRenderingSelection: boolean;
  24441. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24442. useOctreeForPicking: boolean;
  24443. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24444. useOctreeForCollisions: boolean;
  24445. private _layerMask;
  24446. /**
  24447. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24448. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24449. */
  24450. layerMask: number;
  24451. /**
  24452. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24453. */
  24454. alwaysSelectAsActiveMesh: boolean;
  24455. /**
  24456. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24457. */
  24458. doNotSyncBoundingInfo: boolean;
  24459. /**
  24460. * Gets or sets the current action manager
  24461. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24462. */
  24463. actionManager: Nullable<AbstractActionManager>;
  24464. private _checkCollisions;
  24465. private _collisionMask;
  24466. private _collisionGroup;
  24467. /**
  24468. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24469. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24470. */
  24471. ellipsoid: Vector3;
  24472. /**
  24473. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24474. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24475. */
  24476. ellipsoidOffset: Vector3;
  24477. private _collider;
  24478. private _oldPositionForCollisions;
  24479. private _diffPositionForCollisions;
  24480. /**
  24481. * Gets or sets a collision mask used to mask collisions (default is -1).
  24482. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24483. */
  24484. collisionMask: number;
  24485. /**
  24486. * Gets or sets the current collision group mask (-1 by default).
  24487. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24488. */
  24489. collisionGroup: number;
  24490. /**
  24491. * Defines edge width used when edgesRenderer is enabled
  24492. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24493. */
  24494. edgesWidth: number;
  24495. /**
  24496. * Defines edge color used when edgesRenderer is enabled
  24497. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24498. */
  24499. edgesColor: Color4;
  24500. /** @hidden */
  24501. _edgesRenderer: Nullable<IEdgesRenderer>;
  24502. /** @hidden */
  24503. _masterMesh: Nullable<AbstractMesh>;
  24504. /** @hidden */
  24505. _boundingInfo: Nullable<BoundingInfo>;
  24506. /** @hidden */
  24507. _renderId: number;
  24508. /**
  24509. * Gets or sets the list of subMeshes
  24510. * @see http://doc.babylonjs.com/how_to/multi_materials
  24511. */
  24512. subMeshes: SubMesh[];
  24513. /** @hidden */
  24514. _intersectionsInProgress: AbstractMesh[];
  24515. /** @hidden */
  24516. _unIndexed: boolean;
  24517. /** @hidden */
  24518. _lightSources: Light[];
  24519. /** Gets the list of lights affecting that mesh */
  24520. readonly lightSources: Light[];
  24521. /** @hidden */
  24522. readonly _positions: Nullable<Vector3[]>;
  24523. /** @hidden */
  24524. _waitingData: {
  24525. lods: Nullable<any>;
  24526. actions: Nullable<any>;
  24527. freezeWorldMatrix: Nullable<boolean>;
  24528. };
  24529. private _skeleton;
  24530. /** @hidden */
  24531. _bonesTransformMatrices: Nullable<Float32Array>;
  24532. /**
  24533. * Gets or sets a skeleton to apply skining transformations
  24534. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24535. */
  24536. skeleton: Nullable<Skeleton>;
  24537. /**
  24538. * An event triggered when the mesh is rebuilt.
  24539. */
  24540. onRebuildObservable: Observable<AbstractMesh>;
  24541. /**
  24542. * Creates a new AbstractMesh
  24543. * @param name defines the name of the mesh
  24544. * @param scene defines the hosting scene
  24545. */
  24546. constructor(name: string, scene?: Nullable<Scene>);
  24547. /**
  24548. * Returns the string "AbstractMesh"
  24549. * @returns "AbstractMesh"
  24550. */
  24551. getClassName(): string;
  24552. /**
  24553. * Gets a string representation of the current mesh
  24554. * @param fullDetails defines a boolean indicating if full details must be included
  24555. * @returns a string representation of the current mesh
  24556. */
  24557. toString(fullDetails?: boolean): string;
  24558. /**
  24559. * @hidden
  24560. */
  24561. protected _getEffectiveParent(): Nullable<Node>;
  24562. /** @hidden */
  24563. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24564. /** @hidden */
  24565. _rebuild(): void;
  24566. /** @hidden */
  24567. _resyncLightSources(): void;
  24568. /** @hidden */
  24569. _resyncLighSource(light: Light): void;
  24570. /** @hidden */
  24571. _unBindEffect(): void;
  24572. /** @hidden */
  24573. _removeLightSource(light: Light): void;
  24574. private _markSubMeshesAsDirty;
  24575. /** @hidden */
  24576. _markSubMeshesAsLightDirty(): void;
  24577. /** @hidden */
  24578. _markSubMeshesAsAttributesDirty(): void;
  24579. /** @hidden */
  24580. _markSubMeshesAsMiscDirty(): void;
  24581. /**
  24582. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24583. */
  24584. scaling: Vector3;
  24585. /**
  24586. * Returns true if the mesh is blocked. Implemented by child classes
  24587. */
  24588. readonly isBlocked: boolean;
  24589. /**
  24590. * Returns the mesh itself by default. Implemented by child classes
  24591. * @param camera defines the camera to use to pick the right LOD level
  24592. * @returns the currentAbstractMesh
  24593. */
  24594. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24595. /**
  24596. * Returns 0 by default. Implemented by child classes
  24597. * @returns an integer
  24598. */
  24599. getTotalVertices(): number;
  24600. /**
  24601. * Returns a positive integer : the total number of indices in this mesh geometry.
  24602. * @returns the numner of indices or zero if the mesh has no geometry.
  24603. */
  24604. getTotalIndices(): number;
  24605. /**
  24606. * Returns null by default. Implemented by child classes
  24607. * @returns null
  24608. */
  24609. getIndices(): Nullable<IndicesArray>;
  24610. /**
  24611. * Returns the array of the requested vertex data kind. Implemented by child classes
  24612. * @param kind defines the vertex data kind to use
  24613. * @returns null
  24614. */
  24615. getVerticesData(kind: string): Nullable<FloatArray>;
  24616. /**
  24617. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24618. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24619. * Note that a new underlying VertexBuffer object is created each call.
  24620. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24621. * @param kind defines vertex data kind:
  24622. * * VertexBuffer.PositionKind
  24623. * * VertexBuffer.UVKind
  24624. * * VertexBuffer.UV2Kind
  24625. * * VertexBuffer.UV3Kind
  24626. * * VertexBuffer.UV4Kind
  24627. * * VertexBuffer.UV5Kind
  24628. * * VertexBuffer.UV6Kind
  24629. * * VertexBuffer.ColorKind
  24630. * * VertexBuffer.MatricesIndicesKind
  24631. * * VertexBuffer.MatricesIndicesExtraKind
  24632. * * VertexBuffer.MatricesWeightsKind
  24633. * * VertexBuffer.MatricesWeightsExtraKind
  24634. * @param data defines the data source
  24635. * @param updatable defines if the data must be flagged as updatable (or static)
  24636. * @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
  24637. * @returns the current mesh
  24638. */
  24639. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24640. /**
  24641. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24642. * If the mesh has no geometry, it is simply returned as it is.
  24643. * @param kind defines vertex data kind:
  24644. * * VertexBuffer.PositionKind
  24645. * * VertexBuffer.UVKind
  24646. * * VertexBuffer.UV2Kind
  24647. * * VertexBuffer.UV3Kind
  24648. * * VertexBuffer.UV4Kind
  24649. * * VertexBuffer.UV5Kind
  24650. * * VertexBuffer.UV6Kind
  24651. * * VertexBuffer.ColorKind
  24652. * * VertexBuffer.MatricesIndicesKind
  24653. * * VertexBuffer.MatricesIndicesExtraKind
  24654. * * VertexBuffer.MatricesWeightsKind
  24655. * * VertexBuffer.MatricesWeightsExtraKind
  24656. * @param data defines the data source
  24657. * @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
  24658. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24659. * @returns the current mesh
  24660. */
  24661. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24662. /**
  24663. * Sets the mesh indices,
  24664. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24665. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24666. * @param totalVertices Defines the total number of vertices
  24667. * @returns the current mesh
  24668. */
  24669. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24670. /**
  24671. * Gets a boolean indicating if specific vertex data is present
  24672. * @param kind defines the vertex data kind to use
  24673. * @returns true is data kind is present
  24674. */
  24675. isVerticesDataPresent(kind: string): boolean;
  24676. /**
  24677. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24678. * @returns a BoundingInfo
  24679. */
  24680. getBoundingInfo(): BoundingInfo;
  24681. /**
  24682. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24683. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24684. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24685. * @returns the current mesh
  24686. */
  24687. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24688. /**
  24689. * Overwrite the current bounding info
  24690. * @param boundingInfo defines the new bounding info
  24691. * @returns the current mesh
  24692. */
  24693. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24694. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24695. readonly useBones: boolean;
  24696. /** @hidden */
  24697. _preActivate(): void;
  24698. /** @hidden */
  24699. _preActivateForIntermediateRendering(renderId: number): void;
  24700. /** @hidden */
  24701. _activate(renderId: number): boolean;
  24702. /** @hidden */
  24703. _postActivate(): void;
  24704. /** @hidden */
  24705. _freeze(): void;
  24706. /** @hidden */
  24707. _unFreeze(): void;
  24708. /**
  24709. * Gets the current world matrix
  24710. * @returns a Matrix
  24711. */
  24712. getWorldMatrix(): Matrix;
  24713. /** @hidden */
  24714. _getWorldMatrixDeterminant(): number;
  24715. /**
  24716. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  24717. */
  24718. readonly isAnInstance: boolean;
  24719. /**
  24720. * Perform relative position change from the point of view of behind the front of the mesh.
  24721. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24722. * Supports definition of mesh facing forward or backward
  24723. * @param amountRight defines the distance on the right axis
  24724. * @param amountUp defines the distance on the up axis
  24725. * @param amountForward defines the distance on the forward axis
  24726. * @returns the current mesh
  24727. */
  24728. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24729. /**
  24730. * Calculate relative position change from the point of view of behind the front of the mesh.
  24731. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24732. * Supports definition of mesh facing forward or backward
  24733. * @param amountRight defines the distance on the right axis
  24734. * @param amountUp defines the distance on the up axis
  24735. * @param amountForward defines the distance on the forward axis
  24736. * @returns the new displacement vector
  24737. */
  24738. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24739. /**
  24740. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24741. * Supports definition of mesh facing forward or backward
  24742. * @param flipBack defines the flip
  24743. * @param twirlClockwise defines the twirl
  24744. * @param tiltRight defines the tilt
  24745. * @returns the current mesh
  24746. */
  24747. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24748. /**
  24749. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24750. * Supports definition of mesh facing forward or backward.
  24751. * @param flipBack defines the flip
  24752. * @param twirlClockwise defines the twirl
  24753. * @param tiltRight defines the tilt
  24754. * @returns the new rotation vector
  24755. */
  24756. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24757. /**
  24758. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24759. * This means the mesh underlying bounding box and sphere are recomputed.
  24760. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24761. * @returns the current mesh
  24762. */
  24763. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24764. /** @hidden */
  24765. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24766. /** @hidden */
  24767. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24768. /** @hidden */
  24769. _updateBoundingInfo(): AbstractMesh;
  24770. /** @hidden */
  24771. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24772. /** @hidden */
  24773. protected _afterComputeWorldMatrix(): void;
  24774. /** @hidden */
  24775. readonly _effectiveMesh: AbstractMesh;
  24776. /**
  24777. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24778. * A mesh is in the frustum if its bounding box intersects the frustum
  24779. * @param frustumPlanes defines the frustum to test
  24780. * @returns true if the mesh is in the frustum planes
  24781. */
  24782. isInFrustum(frustumPlanes: Plane[]): boolean;
  24783. /**
  24784. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24785. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24786. * @param frustumPlanes defines the frustum to test
  24787. * @returns true if the mesh is completely in the frustum planes
  24788. */
  24789. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24790. /**
  24791. * True if the mesh intersects another mesh or a SolidParticle object
  24792. * @param mesh defines a target mesh or SolidParticle to test
  24793. * @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)
  24794. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24795. * @returns true if there is an intersection
  24796. */
  24797. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24798. /**
  24799. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24800. * @param point defines the point to test
  24801. * @returns true if there is an intersection
  24802. */
  24803. intersectsPoint(point: Vector3): boolean;
  24804. /**
  24805. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24806. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24807. */
  24808. checkCollisions: boolean;
  24809. /**
  24810. * Gets Collider object used to compute collisions (not physics)
  24811. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24812. */
  24813. readonly collider: Nullable<Collider>;
  24814. /**
  24815. * Move the mesh using collision engine
  24816. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24817. * @param displacement defines the requested displacement vector
  24818. * @returns the current mesh
  24819. */
  24820. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24821. private _onCollisionPositionChange;
  24822. /** @hidden */
  24823. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24824. /** @hidden */
  24825. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24826. /** @hidden */
  24827. _checkCollision(collider: Collider): AbstractMesh;
  24828. /** @hidden */
  24829. _generatePointsArray(): boolean;
  24830. /**
  24831. * Checks if the passed Ray intersects with the mesh
  24832. * @param ray defines the ray to use
  24833. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24834. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24835. * @returns the picking info
  24836. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24837. */
  24838. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24839. /**
  24840. * Clones the current mesh
  24841. * @param name defines the mesh name
  24842. * @param newParent defines the new mesh parent
  24843. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24844. * @returns the new mesh
  24845. */
  24846. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24847. /**
  24848. * Disposes all the submeshes of the current meshnp
  24849. * @returns the current mesh
  24850. */
  24851. releaseSubMeshes(): AbstractMesh;
  24852. /**
  24853. * Releases resources associated with this abstract mesh.
  24854. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24855. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24856. */
  24857. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24858. /**
  24859. * Adds the passed mesh as a child to the current mesh
  24860. * @param mesh defines the child mesh
  24861. * @returns the current mesh
  24862. */
  24863. addChild(mesh: AbstractMesh): AbstractMesh;
  24864. /**
  24865. * Removes the passed mesh from the current mesh children list
  24866. * @param mesh defines the child mesh
  24867. * @returns the current mesh
  24868. */
  24869. removeChild(mesh: AbstractMesh): AbstractMesh;
  24870. /** @hidden */
  24871. private _initFacetData;
  24872. /**
  24873. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24874. * This method can be called within the render loop.
  24875. * 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
  24876. * @returns the current mesh
  24877. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24878. */
  24879. updateFacetData(): AbstractMesh;
  24880. /**
  24881. * Returns the facetLocalNormals array.
  24882. * The normals are expressed in the mesh local spac
  24883. * @returns an array of Vector3
  24884. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24885. */
  24886. getFacetLocalNormals(): Vector3[];
  24887. /**
  24888. * Returns the facetLocalPositions array.
  24889. * The facet positions are expressed in the mesh local space
  24890. * @returns an array of Vector3
  24891. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24892. */
  24893. getFacetLocalPositions(): Vector3[];
  24894. /**
  24895. * Returns the facetLocalPartioning array
  24896. * @returns an array of array of numbers
  24897. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24898. */
  24899. getFacetLocalPartitioning(): number[][];
  24900. /**
  24901. * Returns the i-th facet position in the world system.
  24902. * This method allocates a new Vector3 per call
  24903. * @param i defines the facet index
  24904. * @returns a new Vector3
  24905. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24906. */
  24907. getFacetPosition(i: number): Vector3;
  24908. /**
  24909. * Sets the reference Vector3 with the i-th facet position in the world system
  24910. * @param i defines the facet index
  24911. * @param ref defines the target vector
  24912. * @returns the current mesh
  24913. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24914. */
  24915. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24916. /**
  24917. * Returns the i-th facet normal in the world system.
  24918. * This method allocates a new Vector3 per call
  24919. * @param i defines the facet index
  24920. * @returns a new Vector3
  24921. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24922. */
  24923. getFacetNormal(i: number): Vector3;
  24924. /**
  24925. * Sets the reference Vector3 with the i-th facet normal in the world system
  24926. * @param i defines the facet index
  24927. * @param ref defines the target vector
  24928. * @returns the current mesh
  24929. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24930. */
  24931. getFacetNormalToRef(i: number, ref: Vector3): this;
  24932. /**
  24933. * 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)
  24934. * @param x defines x coordinate
  24935. * @param y defines y coordinate
  24936. * @param z defines z coordinate
  24937. * @returns the array of facet indexes
  24938. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24939. */
  24940. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24941. /**
  24942. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24943. * @param projected sets as the (x,y,z) world projection on the facet
  24944. * @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
  24945. * @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
  24946. * @param x defines x coordinate
  24947. * @param y defines y coordinate
  24948. * @param z defines z coordinate
  24949. * @returns the face index if found (or null instead)
  24950. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24951. */
  24952. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24953. /**
  24954. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24955. * @param projected sets as the (x,y,z) local projection on the facet
  24956. * @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
  24957. * @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
  24958. * @param x defines x coordinate
  24959. * @param y defines y coordinate
  24960. * @param z defines z coordinate
  24961. * @returns the face index if found (or null instead)
  24962. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24963. */
  24964. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24965. /**
  24966. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24967. * @returns the parameters
  24968. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24969. */
  24970. getFacetDataParameters(): any;
  24971. /**
  24972. * Disables the feature FacetData and frees the related memory
  24973. * @returns the current mesh
  24974. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24975. */
  24976. disableFacetData(): AbstractMesh;
  24977. /**
  24978. * Updates the AbstractMesh indices array
  24979. * @param indices defines the data source
  24980. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24981. * @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)
  24982. * @returns the current mesh
  24983. */
  24984. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24985. /**
  24986. * Creates new normals data for the mesh
  24987. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24988. * @returns the current mesh
  24989. */
  24990. createNormals(updatable: boolean): AbstractMesh;
  24991. /**
  24992. * Align the mesh with a normal
  24993. * @param normal defines the normal to use
  24994. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24995. * @returns the current mesh
  24996. */
  24997. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24998. /** @hidden */
  24999. _checkOcclusionQuery(): boolean;
  25000. }
  25001. }
  25002. declare module BABYLON {
  25003. /**
  25004. * Interface used to define ActionEvent
  25005. */
  25006. export interface IActionEvent {
  25007. /** The mesh or sprite that triggered the action */
  25008. source: any;
  25009. /** The X mouse cursor position at the time of the event */
  25010. pointerX: number;
  25011. /** The Y mouse cursor position at the time of the event */
  25012. pointerY: number;
  25013. /** The mesh that is currently pointed at (can be null) */
  25014. meshUnderPointer: Nullable<AbstractMesh>;
  25015. /** the original (browser) event that triggered the ActionEvent */
  25016. sourceEvent?: any;
  25017. /** additional data for the event */
  25018. additionalData?: any;
  25019. }
  25020. /**
  25021. * ActionEvent is the event being sent when an action is triggered.
  25022. */
  25023. export class ActionEvent implements IActionEvent {
  25024. /** The mesh or sprite that triggered the action */
  25025. source: any;
  25026. /** The X mouse cursor position at the time of the event */
  25027. pointerX: number;
  25028. /** The Y mouse cursor position at the time of the event */
  25029. pointerY: number;
  25030. /** The mesh that is currently pointed at (can be null) */
  25031. meshUnderPointer: Nullable<AbstractMesh>;
  25032. /** the original (browser) event that triggered the ActionEvent */
  25033. sourceEvent?: any;
  25034. /** additional data for the event */
  25035. additionalData?: any;
  25036. /**
  25037. * Creates a new ActionEvent
  25038. * @param source The mesh or sprite that triggered the action
  25039. * @param pointerX The X mouse cursor position at the time of the event
  25040. * @param pointerY The Y mouse cursor position at the time of the event
  25041. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25042. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25043. * @param additionalData additional data for the event
  25044. */
  25045. constructor(
  25046. /** The mesh or sprite that triggered the action */
  25047. source: any,
  25048. /** The X mouse cursor position at the time of the event */
  25049. pointerX: number,
  25050. /** The Y mouse cursor position at the time of the event */
  25051. pointerY: number,
  25052. /** The mesh that is currently pointed at (can be null) */
  25053. meshUnderPointer: Nullable<AbstractMesh>,
  25054. /** the original (browser) event that triggered the ActionEvent */
  25055. sourceEvent?: any,
  25056. /** additional data for the event */
  25057. additionalData?: any);
  25058. /**
  25059. * Helper function to auto-create an ActionEvent from a source mesh.
  25060. * @param source The source mesh that triggered the event
  25061. * @param evt The original (browser) event
  25062. * @param additionalData additional data for the event
  25063. * @returns the new ActionEvent
  25064. */
  25065. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25066. /**
  25067. * Helper function to auto-create an ActionEvent from a source sprite
  25068. * @param source The source sprite that triggered the event
  25069. * @param scene Scene associated with the sprite
  25070. * @param evt The original (browser) event
  25071. * @param additionalData additional data for the event
  25072. * @returns the new ActionEvent
  25073. */
  25074. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25075. /**
  25076. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25077. * @param scene the scene where the event occurred
  25078. * @param evt The original (browser) event
  25079. * @returns the new ActionEvent
  25080. */
  25081. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25082. /**
  25083. * Helper function to auto-create an ActionEvent from a primitive
  25084. * @param prim defines the target primitive
  25085. * @param pointerPos defines the pointer position
  25086. * @param evt The original (browser) event
  25087. * @param additionalData additional data for the event
  25088. * @returns the new ActionEvent
  25089. */
  25090. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25091. }
  25092. }
  25093. declare module BABYLON {
  25094. /**
  25095. * Abstract class used to decouple action Manager from scene and meshes.
  25096. * Do not instantiate.
  25097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25098. */
  25099. export abstract class AbstractActionManager implements IDisposable {
  25100. /** Gets the list of active triggers */
  25101. static Triggers: {
  25102. [key: string]: number;
  25103. };
  25104. /** Gets the cursor to use when hovering items */
  25105. hoverCursor: string;
  25106. /** Gets the list of actions */
  25107. actions: IAction[];
  25108. /**
  25109. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25110. */
  25111. isRecursive: boolean;
  25112. /**
  25113. * Releases all associated resources
  25114. */
  25115. abstract dispose(): void;
  25116. /**
  25117. * Does this action manager has pointer triggers
  25118. */
  25119. abstract readonly hasPointerTriggers: boolean;
  25120. /**
  25121. * Does this action manager has pick triggers
  25122. */
  25123. abstract readonly hasPickTriggers: boolean;
  25124. /**
  25125. * Process a specific trigger
  25126. * @param trigger defines the trigger to process
  25127. * @param evt defines the event details to be processed
  25128. */
  25129. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25130. /**
  25131. * Does this action manager handles actions of any of the given triggers
  25132. * @param triggers defines the triggers to be tested
  25133. * @return a boolean indicating whether one (or more) of the triggers is handled
  25134. */
  25135. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25136. /**
  25137. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25138. * speed.
  25139. * @param triggerA defines the trigger to be tested
  25140. * @param triggerB defines the trigger to be tested
  25141. * @return a boolean indicating whether one (or more) of the triggers is handled
  25142. */
  25143. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25144. /**
  25145. * Does this action manager handles actions of a given trigger
  25146. * @param trigger defines the trigger to be tested
  25147. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25148. * @return whether the trigger is handled
  25149. */
  25150. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25151. /**
  25152. * Serialize this manager to a JSON object
  25153. * @param name defines the property name to store this manager
  25154. * @returns a JSON representation of this manager
  25155. */
  25156. abstract serialize(name: string): any;
  25157. /**
  25158. * Registers an action to this action manager
  25159. * @param action defines the action to be registered
  25160. * @return the action amended (prepared) after registration
  25161. */
  25162. abstract registerAction(action: IAction): Nullable<IAction>;
  25163. /**
  25164. * Unregisters an action to this action manager
  25165. * @param action defines the action to be unregistered
  25166. * @return a boolean indicating whether the action has been unregistered
  25167. */
  25168. abstract unregisterAction(action: IAction): Boolean;
  25169. /**
  25170. * Does exist one action manager with at least one trigger
  25171. **/
  25172. static readonly HasTriggers: boolean;
  25173. /**
  25174. * Does exist one action manager with at least one pick trigger
  25175. **/
  25176. static readonly HasPickTriggers: boolean;
  25177. /**
  25178. * Does exist one action manager that handles actions of a given trigger
  25179. * @param trigger defines the trigger to be tested
  25180. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25181. **/
  25182. static HasSpecificTrigger(trigger: number): boolean;
  25183. }
  25184. }
  25185. declare module BABYLON {
  25186. /**
  25187. * Defines how a node can be built from a string name.
  25188. */
  25189. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25190. /**
  25191. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25192. */
  25193. export class Node implements IBehaviorAware<Node> {
  25194. /** @hidden */
  25195. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  25196. private static _NodeConstructors;
  25197. /**
  25198. * Add a new node constructor
  25199. * @param type defines the type name of the node to construct
  25200. * @param constructorFunc defines the constructor function
  25201. */
  25202. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25203. /**
  25204. * Returns a node constructor based on type name
  25205. * @param type defines the type name
  25206. * @param name defines the new node name
  25207. * @param scene defines the hosting scene
  25208. * @param options defines optional options to transmit to constructors
  25209. * @returns the new constructor or null
  25210. */
  25211. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25212. /**
  25213. * Gets or sets the name of the node
  25214. */
  25215. name: string;
  25216. /**
  25217. * Gets or sets the id of the node
  25218. */
  25219. id: string;
  25220. /**
  25221. * Gets or sets the unique id of the node
  25222. */
  25223. uniqueId: number;
  25224. /**
  25225. * Gets or sets a string used to store user defined state for the node
  25226. */
  25227. state: string;
  25228. /**
  25229. * Gets or sets an object used to store user defined information for the node
  25230. */
  25231. metadata: any;
  25232. /**
  25233. * For internal use only. Please do not use.
  25234. */
  25235. reservedDataStore: any;
  25236. /**
  25237. * List of inspectable custom properties (used by the Inspector)
  25238. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25239. */
  25240. inspectableCustomProperties: IInspectable[];
  25241. /**
  25242. * Gets or sets a boolean used to define if the node must be serialized
  25243. */
  25244. doNotSerialize: boolean;
  25245. /** @hidden */
  25246. _isDisposed: boolean;
  25247. /**
  25248. * Gets a list of Animations associated with the node
  25249. */
  25250. animations: Animation[];
  25251. protected _ranges: {
  25252. [name: string]: Nullable<AnimationRange>;
  25253. };
  25254. /**
  25255. * Callback raised when the node is ready to be used
  25256. */
  25257. onReady: Nullable<(node: Node) => void>;
  25258. private _isEnabled;
  25259. private _isParentEnabled;
  25260. private _isReady;
  25261. /** @hidden */
  25262. _currentRenderId: number;
  25263. private _parentUpdateId;
  25264. /** @hidden */
  25265. _childUpdateId: number;
  25266. /** @hidden */
  25267. _waitingParentId: Nullable<string>;
  25268. /** @hidden */
  25269. _scene: Scene;
  25270. /** @hidden */
  25271. _cache: any;
  25272. private _parentNode;
  25273. private _children;
  25274. /** @hidden */
  25275. _worldMatrix: Matrix;
  25276. /** @hidden */
  25277. _worldMatrixDeterminant: number;
  25278. /** @hidden */
  25279. _worldMatrixDeterminantIsDirty: boolean;
  25280. /** @hidden */
  25281. private _sceneRootNodesIndex;
  25282. /**
  25283. * Gets a boolean indicating if the node has been disposed
  25284. * @returns true if the node was disposed
  25285. */
  25286. isDisposed(): boolean;
  25287. /**
  25288. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25289. * @see https://doc.babylonjs.com/how_to/parenting
  25290. */
  25291. parent: Nullable<Node>;
  25292. private addToSceneRootNodes;
  25293. private removeFromSceneRootNodes;
  25294. private _animationPropertiesOverride;
  25295. /**
  25296. * Gets or sets the animation properties override
  25297. */
  25298. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25299. /**
  25300. * Gets a string idenfifying the name of the class
  25301. * @returns "Node" string
  25302. */
  25303. getClassName(): string;
  25304. /** @hidden */
  25305. readonly _isNode: boolean;
  25306. /**
  25307. * An event triggered when the mesh is disposed
  25308. */
  25309. onDisposeObservable: Observable<Node>;
  25310. private _onDisposeObserver;
  25311. /**
  25312. * Sets a callback that will be raised when the node will be disposed
  25313. */
  25314. onDispose: () => void;
  25315. /**
  25316. * Creates a new Node
  25317. * @param name the name and id to be given to this node
  25318. * @param scene the scene this node will be added to
  25319. * @param addToRootNodes the node will be added to scene.rootNodes
  25320. */
  25321. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25322. /**
  25323. * Gets the scene of the node
  25324. * @returns a scene
  25325. */
  25326. getScene(): Scene;
  25327. /**
  25328. * Gets the engine of the node
  25329. * @returns a Engine
  25330. */
  25331. getEngine(): Engine;
  25332. private _behaviors;
  25333. /**
  25334. * Attach a behavior to the node
  25335. * @see http://doc.babylonjs.com/features/behaviour
  25336. * @param behavior defines the behavior to attach
  25337. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25338. * @returns the current Node
  25339. */
  25340. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25341. /**
  25342. * Remove an attached behavior
  25343. * @see http://doc.babylonjs.com/features/behaviour
  25344. * @param behavior defines the behavior to attach
  25345. * @returns the current Node
  25346. */
  25347. removeBehavior(behavior: Behavior<Node>): Node;
  25348. /**
  25349. * Gets the list of attached behaviors
  25350. * @see http://doc.babylonjs.com/features/behaviour
  25351. */
  25352. readonly behaviors: Behavior<Node>[];
  25353. /**
  25354. * Gets an attached behavior by name
  25355. * @param name defines the name of the behavior to look for
  25356. * @see http://doc.babylonjs.com/features/behaviour
  25357. * @returns null if behavior was not found else the requested behavior
  25358. */
  25359. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25360. /**
  25361. * Returns the latest update of the World matrix
  25362. * @returns a Matrix
  25363. */
  25364. getWorldMatrix(): Matrix;
  25365. /** @hidden */
  25366. _getWorldMatrixDeterminant(): number;
  25367. /**
  25368. * Returns directly the latest state of the mesh World matrix.
  25369. * A Matrix is returned.
  25370. */
  25371. readonly worldMatrixFromCache: Matrix;
  25372. /** @hidden */
  25373. _initCache(): void;
  25374. /** @hidden */
  25375. updateCache(force?: boolean): void;
  25376. /** @hidden */
  25377. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25378. /** @hidden */
  25379. _updateCache(ignoreParentClass?: boolean): void;
  25380. /** @hidden */
  25381. _isSynchronized(): boolean;
  25382. /** @hidden */
  25383. _markSyncedWithParent(): void;
  25384. /** @hidden */
  25385. isSynchronizedWithParent(): boolean;
  25386. /** @hidden */
  25387. isSynchronized(): boolean;
  25388. /**
  25389. * Is this node ready to be used/rendered
  25390. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25391. * @return true if the node is ready
  25392. */
  25393. isReady(completeCheck?: boolean): boolean;
  25394. /**
  25395. * Is this node enabled?
  25396. * 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
  25397. * @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
  25398. * @return whether this node (and its parent) is enabled
  25399. */
  25400. isEnabled(checkAncestors?: boolean): boolean;
  25401. /** @hidden */
  25402. protected _syncParentEnabledState(): void;
  25403. /**
  25404. * Set the enabled state of this node
  25405. * @param value defines the new enabled state
  25406. */
  25407. setEnabled(value: boolean): void;
  25408. /**
  25409. * Is this node a descendant of the given node?
  25410. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25411. * @param ancestor defines the parent node to inspect
  25412. * @returns a boolean indicating if this node is a descendant of the given node
  25413. */
  25414. isDescendantOf(ancestor: Node): boolean;
  25415. /** @hidden */
  25416. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25417. /**
  25418. * Will return all nodes that have this node as ascendant
  25419. * @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
  25420. * @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
  25421. * @return all children nodes of all types
  25422. */
  25423. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25424. /**
  25425. * Get all child-meshes of this node
  25426. * @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)
  25427. * @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
  25428. * @returns an array of AbstractMesh
  25429. */
  25430. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25431. /**
  25432. * Get all direct children of this node
  25433. * @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
  25434. * @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)
  25435. * @returns an array of Node
  25436. */
  25437. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25438. /** @hidden */
  25439. _setReady(state: boolean): void;
  25440. /**
  25441. * Get an animation by name
  25442. * @param name defines the name of the animation to look for
  25443. * @returns null if not found else the requested animation
  25444. */
  25445. getAnimationByName(name: string): Nullable<Animation>;
  25446. /**
  25447. * Creates an animation range for this node
  25448. * @param name defines the name of the range
  25449. * @param from defines the starting key
  25450. * @param to defines the end key
  25451. */
  25452. createAnimationRange(name: string, from: number, to: number): void;
  25453. /**
  25454. * Delete a specific animation range
  25455. * @param name defines the name of the range to delete
  25456. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25457. */
  25458. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25459. /**
  25460. * Get an animation range by name
  25461. * @param name defines the name of the animation range to look for
  25462. * @returns null if not found else the requested animation range
  25463. */
  25464. getAnimationRange(name: string): Nullable<AnimationRange>;
  25465. /**
  25466. * Gets the list of all animation ranges defined on this node
  25467. * @returns an array
  25468. */
  25469. getAnimationRanges(): Nullable<AnimationRange>[];
  25470. /**
  25471. * Will start the animation sequence
  25472. * @param name defines the range frames for animation sequence
  25473. * @param loop defines if the animation should loop (false by default)
  25474. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25475. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25476. * @returns the object created for this animation. If range does not exist, it will return null
  25477. */
  25478. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25479. /**
  25480. * Serialize animation ranges into a JSON compatible object
  25481. * @returns serialization object
  25482. */
  25483. serializeAnimationRanges(): any;
  25484. /**
  25485. * Computes the world matrix of the node
  25486. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25487. * @returns the world matrix
  25488. */
  25489. computeWorldMatrix(force?: boolean): Matrix;
  25490. /**
  25491. * Releases resources associated with this node.
  25492. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25493. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25494. */
  25495. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25496. /**
  25497. * Parse animation range data from a serialization object and store them into a given node
  25498. * @param node defines where to store the animation ranges
  25499. * @param parsedNode defines the serialization object to read data from
  25500. * @param scene defines the hosting scene
  25501. */
  25502. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25503. /**
  25504. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25505. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25506. * @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
  25507. * @returns the new bounding vectors
  25508. */
  25509. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25510. min: Vector3;
  25511. max: Vector3;
  25512. };
  25513. }
  25514. }
  25515. declare module BABYLON {
  25516. /**
  25517. * @hidden
  25518. */
  25519. export class _IAnimationState {
  25520. key: number;
  25521. repeatCount: number;
  25522. workValue?: any;
  25523. loopMode?: number;
  25524. offsetValue?: any;
  25525. highLimitValue?: any;
  25526. }
  25527. /**
  25528. * Class used to store any kind of animation
  25529. */
  25530. export class Animation {
  25531. /**Name of the animation */
  25532. name: string;
  25533. /**Property to animate */
  25534. targetProperty: string;
  25535. /**The frames per second of the animation */
  25536. framePerSecond: number;
  25537. /**The data type of the animation */
  25538. dataType: number;
  25539. /**The loop mode of the animation */
  25540. loopMode?: number | undefined;
  25541. /**Specifies if blending should be enabled */
  25542. enableBlending?: boolean | undefined;
  25543. /**
  25544. * Use matrix interpolation instead of using direct key value when animating matrices
  25545. */
  25546. static AllowMatricesInterpolation: boolean;
  25547. /**
  25548. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25549. */
  25550. static AllowMatrixDecomposeForInterpolation: boolean;
  25551. /**
  25552. * Stores the key frames of the animation
  25553. */
  25554. private _keys;
  25555. /**
  25556. * Stores the easing function of the animation
  25557. */
  25558. private _easingFunction;
  25559. /**
  25560. * @hidden Internal use only
  25561. */
  25562. _runtimeAnimations: RuntimeAnimation[];
  25563. /**
  25564. * The set of event that will be linked to this animation
  25565. */
  25566. private _events;
  25567. /**
  25568. * Stores an array of target property paths
  25569. */
  25570. targetPropertyPath: string[];
  25571. /**
  25572. * Stores the blending speed of the animation
  25573. */
  25574. blendingSpeed: number;
  25575. /**
  25576. * Stores the animation ranges for the animation
  25577. */
  25578. private _ranges;
  25579. /**
  25580. * @hidden Internal use
  25581. */
  25582. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25583. /**
  25584. * Sets up an animation
  25585. * @param property The property to animate
  25586. * @param animationType The animation type to apply
  25587. * @param framePerSecond The frames per second of the animation
  25588. * @param easingFunction The easing function used in the animation
  25589. * @returns The created animation
  25590. */
  25591. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25592. /**
  25593. * Create and start an animation on a node
  25594. * @param name defines the name of the global animation that will be run on all nodes
  25595. * @param node defines the root node where the animation will take place
  25596. * @param targetProperty defines property to animate
  25597. * @param framePerSecond defines the number of frame per second yo use
  25598. * @param totalFrame defines the number of frames in total
  25599. * @param from defines the initial value
  25600. * @param to defines the final value
  25601. * @param loopMode defines which loop mode you want to use (off by default)
  25602. * @param easingFunction defines the easing function to use (linear by default)
  25603. * @param onAnimationEnd defines the callback to call when animation end
  25604. * @returns the animatable created for this animation
  25605. */
  25606. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25607. /**
  25608. * Create and start an animation on a node and its descendants
  25609. * @param name defines the name of the global animation that will be run on all nodes
  25610. * @param node defines the root node where the animation will take place
  25611. * @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
  25612. * @param targetProperty defines property to animate
  25613. * @param framePerSecond defines the number of frame per second to use
  25614. * @param totalFrame defines the number of frames in total
  25615. * @param from defines the initial value
  25616. * @param to defines the final value
  25617. * @param loopMode defines which loop mode you want to use (off by default)
  25618. * @param easingFunction defines the easing function to use (linear by default)
  25619. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25620. * @returns the list of animatables created for all nodes
  25621. * @example https://www.babylonjs-playground.com/#MH0VLI
  25622. */
  25623. 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[]>;
  25624. /**
  25625. * Creates a new animation, merges it with the existing animations and starts it
  25626. * @param name Name of the animation
  25627. * @param node Node which contains the scene that begins the animations
  25628. * @param targetProperty Specifies which property to animate
  25629. * @param framePerSecond The frames per second of the animation
  25630. * @param totalFrame The total number of frames
  25631. * @param from The frame at the beginning of the animation
  25632. * @param to The frame at the end of the animation
  25633. * @param loopMode Specifies the loop mode of the animation
  25634. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25635. * @param onAnimationEnd Callback to run once the animation is complete
  25636. * @returns Nullable animation
  25637. */
  25638. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25639. /**
  25640. * Transition property of an host to the target Value
  25641. * @param property The property to transition
  25642. * @param targetValue The target Value of the property
  25643. * @param host The object where the property to animate belongs
  25644. * @param scene Scene used to run the animation
  25645. * @param frameRate Framerate (in frame/s) to use
  25646. * @param transition The transition type we want to use
  25647. * @param duration The duration of the animation, in milliseconds
  25648. * @param onAnimationEnd Callback trigger at the end of the animation
  25649. * @returns Nullable animation
  25650. */
  25651. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25652. /**
  25653. * Return the array of runtime animations currently using this animation
  25654. */
  25655. readonly runtimeAnimations: RuntimeAnimation[];
  25656. /**
  25657. * Specifies if any of the runtime animations are currently running
  25658. */
  25659. readonly hasRunningRuntimeAnimations: boolean;
  25660. /**
  25661. * Initializes the animation
  25662. * @param name Name of the animation
  25663. * @param targetProperty Property to animate
  25664. * @param framePerSecond The frames per second of the animation
  25665. * @param dataType The data type of the animation
  25666. * @param loopMode The loop mode of the animation
  25667. * @param enableBlending Specifies if blending should be enabled
  25668. */
  25669. constructor(
  25670. /**Name of the animation */
  25671. name: string,
  25672. /**Property to animate */
  25673. targetProperty: string,
  25674. /**The frames per second of the animation */
  25675. framePerSecond: number,
  25676. /**The data type of the animation */
  25677. dataType: number,
  25678. /**The loop mode of the animation */
  25679. loopMode?: number | undefined,
  25680. /**Specifies if blending should be enabled */
  25681. enableBlending?: boolean | undefined);
  25682. /**
  25683. * Converts the animation to a string
  25684. * @param fullDetails support for multiple levels of logging within scene loading
  25685. * @returns String form of the animation
  25686. */
  25687. toString(fullDetails?: boolean): string;
  25688. /**
  25689. * Add an event to this animation
  25690. * @param event Event to add
  25691. */
  25692. addEvent(event: AnimationEvent): void;
  25693. /**
  25694. * Remove all events found at the given frame
  25695. * @param frame The frame to remove events from
  25696. */
  25697. removeEvents(frame: number): void;
  25698. /**
  25699. * Retrieves all the events from the animation
  25700. * @returns Events from the animation
  25701. */
  25702. getEvents(): AnimationEvent[];
  25703. /**
  25704. * Creates an animation range
  25705. * @param name Name of the animation range
  25706. * @param from Starting frame of the animation range
  25707. * @param to Ending frame of the animation
  25708. */
  25709. createRange(name: string, from: number, to: number): void;
  25710. /**
  25711. * Deletes an animation range by name
  25712. * @param name Name of the animation range to delete
  25713. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25714. */
  25715. deleteRange(name: string, deleteFrames?: boolean): void;
  25716. /**
  25717. * Gets the animation range by name, or null if not defined
  25718. * @param name Name of the animation range
  25719. * @returns Nullable animation range
  25720. */
  25721. getRange(name: string): Nullable<AnimationRange>;
  25722. /**
  25723. * Gets the key frames from the animation
  25724. * @returns The key frames of the animation
  25725. */
  25726. getKeys(): Array<IAnimationKey>;
  25727. /**
  25728. * Gets the highest frame rate of the animation
  25729. * @returns Highest frame rate of the animation
  25730. */
  25731. getHighestFrame(): number;
  25732. /**
  25733. * Gets the easing function of the animation
  25734. * @returns Easing function of the animation
  25735. */
  25736. getEasingFunction(): IEasingFunction;
  25737. /**
  25738. * Sets the easing function of the animation
  25739. * @param easingFunction A custom mathematical formula for animation
  25740. */
  25741. setEasingFunction(easingFunction: EasingFunction): void;
  25742. /**
  25743. * Interpolates a scalar linearly
  25744. * @param startValue Start value of the animation curve
  25745. * @param endValue End value of the animation curve
  25746. * @param gradient Scalar amount to interpolate
  25747. * @returns Interpolated scalar value
  25748. */
  25749. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25750. /**
  25751. * Interpolates a scalar cubically
  25752. * @param startValue Start value of the animation curve
  25753. * @param outTangent End tangent of the animation
  25754. * @param endValue End value of the animation curve
  25755. * @param inTangent Start tangent of the animation curve
  25756. * @param gradient Scalar amount to interpolate
  25757. * @returns Interpolated scalar value
  25758. */
  25759. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25760. /**
  25761. * Interpolates a quaternion using a spherical linear interpolation
  25762. * @param startValue Start value of the animation curve
  25763. * @param endValue End value of the animation curve
  25764. * @param gradient Scalar amount to interpolate
  25765. * @returns Interpolated quaternion value
  25766. */
  25767. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25768. /**
  25769. * Interpolates a quaternion cubically
  25770. * @param startValue Start value of the animation curve
  25771. * @param outTangent End tangent of the animation curve
  25772. * @param endValue End value of the animation curve
  25773. * @param inTangent Start tangent of the animation curve
  25774. * @param gradient Scalar amount to interpolate
  25775. * @returns Interpolated quaternion value
  25776. */
  25777. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25778. /**
  25779. * Interpolates a Vector3 linearl
  25780. * @param startValue Start value of the animation curve
  25781. * @param endValue End value of the animation curve
  25782. * @param gradient Scalar amount to interpolate
  25783. * @returns Interpolated scalar value
  25784. */
  25785. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25786. /**
  25787. * Interpolates a Vector3 cubically
  25788. * @param startValue Start value of the animation curve
  25789. * @param outTangent End tangent of the animation
  25790. * @param endValue End value of the animation curve
  25791. * @param inTangent Start tangent of the animation curve
  25792. * @param gradient Scalar amount to interpolate
  25793. * @returns InterpolatedVector3 value
  25794. */
  25795. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25796. /**
  25797. * Interpolates a Vector2 linearly
  25798. * @param startValue Start value of the animation curve
  25799. * @param endValue End value of the animation curve
  25800. * @param gradient Scalar amount to interpolate
  25801. * @returns Interpolated Vector2 value
  25802. */
  25803. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25804. /**
  25805. * Interpolates a Vector2 cubically
  25806. * @param startValue Start value of the animation curve
  25807. * @param outTangent End tangent of the animation
  25808. * @param endValue End value of the animation curve
  25809. * @param inTangent Start tangent of the animation curve
  25810. * @param gradient Scalar amount to interpolate
  25811. * @returns Interpolated Vector2 value
  25812. */
  25813. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25814. /**
  25815. * Interpolates a size linearly
  25816. * @param startValue Start value of the animation curve
  25817. * @param endValue End value of the animation curve
  25818. * @param gradient Scalar amount to interpolate
  25819. * @returns Interpolated Size value
  25820. */
  25821. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25822. /**
  25823. * Interpolates a Color3 linearly
  25824. * @param startValue Start value of the animation curve
  25825. * @param endValue End value of the animation curve
  25826. * @param gradient Scalar amount to interpolate
  25827. * @returns Interpolated Color3 value
  25828. */
  25829. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25830. /**
  25831. * @hidden Internal use only
  25832. */
  25833. _getKeyValue(value: any): any;
  25834. /**
  25835. * @hidden Internal use only
  25836. */
  25837. _interpolate(currentFrame: number, state: _IAnimationState): any;
  25838. /**
  25839. * Defines the function to use to interpolate matrices
  25840. * @param startValue defines the start matrix
  25841. * @param endValue defines the end matrix
  25842. * @param gradient defines the gradient between both matrices
  25843. * @param result defines an optional target matrix where to store the interpolation
  25844. * @returns the interpolated matrix
  25845. */
  25846. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25847. /**
  25848. * Makes a copy of the animation
  25849. * @returns Cloned animation
  25850. */
  25851. clone(): Animation;
  25852. /**
  25853. * Sets the key frames of the animation
  25854. * @param values The animation key frames to set
  25855. */
  25856. setKeys(values: Array<IAnimationKey>): void;
  25857. /**
  25858. * Serializes the animation to an object
  25859. * @returns Serialized object
  25860. */
  25861. serialize(): any;
  25862. /**
  25863. * Float animation type
  25864. */
  25865. private static _ANIMATIONTYPE_FLOAT;
  25866. /**
  25867. * Vector3 animation type
  25868. */
  25869. private static _ANIMATIONTYPE_VECTOR3;
  25870. /**
  25871. * Quaternion animation type
  25872. */
  25873. private static _ANIMATIONTYPE_QUATERNION;
  25874. /**
  25875. * Matrix animation type
  25876. */
  25877. private static _ANIMATIONTYPE_MATRIX;
  25878. /**
  25879. * Color3 animation type
  25880. */
  25881. private static _ANIMATIONTYPE_COLOR3;
  25882. /**
  25883. * Vector2 animation type
  25884. */
  25885. private static _ANIMATIONTYPE_VECTOR2;
  25886. /**
  25887. * Size animation type
  25888. */
  25889. private static _ANIMATIONTYPE_SIZE;
  25890. /**
  25891. * Relative Loop Mode
  25892. */
  25893. private static _ANIMATIONLOOPMODE_RELATIVE;
  25894. /**
  25895. * Cycle Loop Mode
  25896. */
  25897. private static _ANIMATIONLOOPMODE_CYCLE;
  25898. /**
  25899. * Constant Loop Mode
  25900. */
  25901. private static _ANIMATIONLOOPMODE_CONSTANT;
  25902. /**
  25903. * Get the float animation type
  25904. */
  25905. static readonly ANIMATIONTYPE_FLOAT: number;
  25906. /**
  25907. * Get the Vector3 animation type
  25908. */
  25909. static readonly ANIMATIONTYPE_VECTOR3: number;
  25910. /**
  25911. * Get the Vector2 animation type
  25912. */
  25913. static readonly ANIMATIONTYPE_VECTOR2: number;
  25914. /**
  25915. * Get the Size animation type
  25916. */
  25917. static readonly ANIMATIONTYPE_SIZE: number;
  25918. /**
  25919. * Get the Quaternion animation type
  25920. */
  25921. static readonly ANIMATIONTYPE_QUATERNION: number;
  25922. /**
  25923. * Get the Matrix animation type
  25924. */
  25925. static readonly ANIMATIONTYPE_MATRIX: number;
  25926. /**
  25927. * Get the Color3 animation type
  25928. */
  25929. static readonly ANIMATIONTYPE_COLOR3: number;
  25930. /**
  25931. * Get the Relative Loop Mode
  25932. */
  25933. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25934. /**
  25935. * Get the Cycle Loop Mode
  25936. */
  25937. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25938. /**
  25939. * Get the Constant Loop Mode
  25940. */
  25941. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25942. /** @hidden */
  25943. static _UniversalLerp(left: any, right: any, amount: number): any;
  25944. /**
  25945. * Parses an animation object and creates an animation
  25946. * @param parsedAnimation Parsed animation object
  25947. * @returns Animation object
  25948. */
  25949. static Parse(parsedAnimation: any): Animation;
  25950. /**
  25951. * Appends the serialized animations from the source animations
  25952. * @param source Source containing the animations
  25953. * @param destination Target to store the animations
  25954. */
  25955. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25956. }
  25957. }
  25958. declare module BABYLON {
  25959. /**
  25960. * Base class of all the textures in babylon.
  25961. * It groups all the common properties the materials, post process, lights... might need
  25962. * in order to make a correct use of the texture.
  25963. */
  25964. export class BaseTexture implements IAnimatable {
  25965. /**
  25966. * Default anisotropic filtering level for the application.
  25967. * It is set to 4 as a good tradeoff between perf and quality.
  25968. */
  25969. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25970. /**
  25971. * Gets or sets the unique id of the texture
  25972. */
  25973. uniqueId: number;
  25974. /**
  25975. * Define the name of the texture.
  25976. */
  25977. name: string;
  25978. /**
  25979. * Gets or sets an object used to store user defined information.
  25980. */
  25981. metadata: any;
  25982. /**
  25983. * For internal use only. Please do not use.
  25984. */
  25985. reservedDataStore: any;
  25986. private _hasAlpha;
  25987. /**
  25988. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25989. */
  25990. hasAlpha: boolean;
  25991. /**
  25992. * Defines if the alpha value should be determined via the rgb values.
  25993. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25994. */
  25995. getAlphaFromRGB: boolean;
  25996. /**
  25997. * Intensity or strength of the texture.
  25998. * It is commonly used by materials to fine tune the intensity of the texture
  25999. */
  26000. level: number;
  26001. /**
  26002. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26003. * This is part of the texture as textures usually maps to one uv set.
  26004. */
  26005. coordinatesIndex: number;
  26006. private _coordinatesMode;
  26007. /**
  26008. * How a texture is mapped.
  26009. *
  26010. * | Value | Type | Description |
  26011. * | ----- | ----------------------------------- | ----------- |
  26012. * | 0 | EXPLICIT_MODE | |
  26013. * | 1 | SPHERICAL_MODE | |
  26014. * | 2 | PLANAR_MODE | |
  26015. * | 3 | CUBIC_MODE | |
  26016. * | 4 | PROJECTION_MODE | |
  26017. * | 5 | SKYBOX_MODE | |
  26018. * | 6 | INVCUBIC_MODE | |
  26019. * | 7 | EQUIRECTANGULAR_MODE | |
  26020. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26021. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26022. */
  26023. coordinatesMode: number;
  26024. /**
  26025. * | Value | Type | Description |
  26026. * | ----- | ------------------ | ----------- |
  26027. * | 0 | CLAMP_ADDRESSMODE | |
  26028. * | 1 | WRAP_ADDRESSMODE | |
  26029. * | 2 | MIRROR_ADDRESSMODE | |
  26030. */
  26031. wrapU: number;
  26032. /**
  26033. * | Value | Type | Description |
  26034. * | ----- | ------------------ | ----------- |
  26035. * | 0 | CLAMP_ADDRESSMODE | |
  26036. * | 1 | WRAP_ADDRESSMODE | |
  26037. * | 2 | MIRROR_ADDRESSMODE | |
  26038. */
  26039. wrapV: number;
  26040. /**
  26041. * | Value | Type | Description |
  26042. * | ----- | ------------------ | ----------- |
  26043. * | 0 | CLAMP_ADDRESSMODE | |
  26044. * | 1 | WRAP_ADDRESSMODE | |
  26045. * | 2 | MIRROR_ADDRESSMODE | |
  26046. */
  26047. wrapR: number;
  26048. /**
  26049. * With compliant hardware and browser (supporting anisotropic filtering)
  26050. * this defines the level of anisotropic filtering in the texture.
  26051. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26052. */
  26053. anisotropicFilteringLevel: number;
  26054. /**
  26055. * Define if the texture is a cube texture or if false a 2d texture.
  26056. */
  26057. isCube: boolean;
  26058. /**
  26059. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26060. */
  26061. is3D: boolean;
  26062. /**
  26063. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26064. * HDR texture are usually stored in linear space.
  26065. * This only impacts the PBR and Background materials
  26066. */
  26067. gammaSpace: boolean;
  26068. /**
  26069. * Gets whether or not the texture contains RGBD data.
  26070. */
  26071. readonly isRGBD: boolean;
  26072. /**
  26073. * Is Z inverted in the texture (useful in a cube texture).
  26074. */
  26075. invertZ: boolean;
  26076. /**
  26077. * Are mip maps generated for this texture or not.
  26078. */
  26079. readonly noMipmap: boolean;
  26080. /**
  26081. * @hidden
  26082. */
  26083. lodLevelInAlpha: boolean;
  26084. /**
  26085. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26086. */
  26087. lodGenerationOffset: number;
  26088. /**
  26089. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26090. */
  26091. lodGenerationScale: number;
  26092. /**
  26093. * Define if the texture is a render target.
  26094. */
  26095. isRenderTarget: boolean;
  26096. /**
  26097. * Define the unique id of the texture in the scene.
  26098. */
  26099. readonly uid: string;
  26100. /**
  26101. * Return a string representation of the texture.
  26102. * @returns the texture as a string
  26103. */
  26104. toString(): string;
  26105. /**
  26106. * Get the class name of the texture.
  26107. * @returns "BaseTexture"
  26108. */
  26109. getClassName(): string;
  26110. /**
  26111. * Define the list of animation attached to the texture.
  26112. */
  26113. animations: Animation[];
  26114. /**
  26115. * An event triggered when the texture is disposed.
  26116. */
  26117. onDisposeObservable: Observable<BaseTexture>;
  26118. private _onDisposeObserver;
  26119. /**
  26120. * Callback triggered when the texture has been disposed.
  26121. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26122. */
  26123. onDispose: () => void;
  26124. /**
  26125. * Define the current state of the loading sequence when in delayed load mode.
  26126. */
  26127. delayLoadState: number;
  26128. private _scene;
  26129. /** @hidden */
  26130. _texture: Nullable<InternalTexture>;
  26131. private _uid;
  26132. /**
  26133. * Define if the texture is preventinga material to render or not.
  26134. * If not and the texture is not ready, the engine will use a default black texture instead.
  26135. */
  26136. readonly isBlocking: boolean;
  26137. /**
  26138. * Instantiates a new BaseTexture.
  26139. * Base class of all the textures in babylon.
  26140. * It groups all the common properties the materials, post process, lights... might need
  26141. * in order to make a correct use of the texture.
  26142. * @param scene Define the scene the texture blongs to
  26143. */
  26144. constructor(scene: Nullable<Scene>);
  26145. /**
  26146. * Get the scene the texture belongs to.
  26147. * @returns the scene or null if undefined
  26148. */
  26149. getScene(): Nullable<Scene>;
  26150. /**
  26151. * Get the texture transform matrix used to offset tile the texture for istance.
  26152. * @returns the transformation matrix
  26153. */
  26154. getTextureMatrix(): Matrix;
  26155. /**
  26156. * Get the texture reflection matrix used to rotate/transform the reflection.
  26157. * @returns the reflection matrix
  26158. */
  26159. getReflectionTextureMatrix(): Matrix;
  26160. /**
  26161. * Get the underlying lower level texture from Babylon.
  26162. * @returns the insternal texture
  26163. */
  26164. getInternalTexture(): Nullable<InternalTexture>;
  26165. /**
  26166. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26167. * @returns true if ready or not blocking
  26168. */
  26169. isReadyOrNotBlocking(): boolean;
  26170. /**
  26171. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26172. * @returns true if fully ready
  26173. */
  26174. isReady(): boolean;
  26175. private _cachedSize;
  26176. /**
  26177. * Get the size of the texture.
  26178. * @returns the texture size.
  26179. */
  26180. getSize(): ISize;
  26181. /**
  26182. * Get the base size of the texture.
  26183. * It can be different from the size if the texture has been resized for POT for instance
  26184. * @returns the base size
  26185. */
  26186. getBaseSize(): ISize;
  26187. /**
  26188. * Update the sampling mode of the texture.
  26189. * Default is Trilinear mode.
  26190. *
  26191. * | Value | Type | Description |
  26192. * | ----- | ------------------ | ----------- |
  26193. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26194. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26195. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26196. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26197. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26198. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26199. * | 7 | NEAREST_LINEAR | |
  26200. * | 8 | NEAREST_NEAREST | |
  26201. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26202. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26203. * | 11 | LINEAR_LINEAR | |
  26204. * | 12 | LINEAR_NEAREST | |
  26205. *
  26206. * > _mag_: magnification filter (close to the viewer)
  26207. * > _min_: minification filter (far from the viewer)
  26208. * > _mip_: filter used between mip map levels
  26209. *@param samplingMode Define the new sampling mode of the texture
  26210. */
  26211. updateSamplingMode(samplingMode: number): void;
  26212. /**
  26213. * Scales the texture if is `canRescale()`
  26214. * @param ratio the resize factor we want to use to rescale
  26215. */
  26216. scale(ratio: number): void;
  26217. /**
  26218. * Get if the texture can rescale.
  26219. */
  26220. readonly canRescale: boolean;
  26221. /** @hidden */
  26222. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26223. /** @hidden */
  26224. _rebuild(): void;
  26225. /**
  26226. * Triggers the load sequence in delayed load mode.
  26227. */
  26228. delayLoad(): void;
  26229. /**
  26230. * Clones the texture.
  26231. * @returns the cloned texture
  26232. */
  26233. clone(): Nullable<BaseTexture>;
  26234. /**
  26235. * Get the texture underlying type (INT, FLOAT...)
  26236. */
  26237. readonly textureType: number;
  26238. /**
  26239. * Get the texture underlying format (RGB, RGBA...)
  26240. */
  26241. readonly textureFormat: number;
  26242. /**
  26243. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26244. * This will returns an RGBA array buffer containing either in values (0-255) or
  26245. * float values (0-1) depending of the underlying buffer type.
  26246. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26247. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26248. * @param buffer defines a user defined buffer to fill with data (can be null)
  26249. * @returns The Array buffer containing the pixels data.
  26250. */
  26251. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26252. /**
  26253. * Release and destroy the underlying lower level texture aka internalTexture.
  26254. */
  26255. releaseInternalTexture(): void;
  26256. /**
  26257. * Get the polynomial representation of the texture data.
  26258. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26259. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26260. */
  26261. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26262. /** @hidden */
  26263. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26264. /** @hidden */
  26265. readonly _lodTextureMid: Nullable<BaseTexture>;
  26266. /** @hidden */
  26267. readonly _lodTextureLow: Nullable<BaseTexture>;
  26268. /**
  26269. * Dispose the texture and release its associated resources.
  26270. */
  26271. dispose(): void;
  26272. /**
  26273. * Serialize the texture into a JSON representation that can be parsed later on.
  26274. * @returns the JSON representation of the texture
  26275. */
  26276. serialize(): any;
  26277. /**
  26278. * Helper function to be called back once a list of texture contains only ready textures.
  26279. * @param textures Define the list of textures to wait for
  26280. * @param callback Define the callback triggered once the entire list will be ready
  26281. */
  26282. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26283. }
  26284. }
  26285. declare module BABYLON {
  26286. /**
  26287. * Uniform buffer objects.
  26288. *
  26289. * Handles blocks of uniform on the GPU.
  26290. *
  26291. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26292. *
  26293. * For more information, please refer to :
  26294. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26295. */
  26296. export class UniformBuffer {
  26297. private _engine;
  26298. private _buffer;
  26299. private _data;
  26300. private _bufferData;
  26301. private _dynamic?;
  26302. private _uniformLocations;
  26303. private _uniformSizes;
  26304. private _uniformLocationPointer;
  26305. private _needSync;
  26306. private _noUBO;
  26307. private _currentEffect;
  26308. private static _MAX_UNIFORM_SIZE;
  26309. private static _tempBuffer;
  26310. /**
  26311. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26312. * This is dynamic to allow compat with webgl 1 and 2.
  26313. * You will need to pass the name of the uniform as well as the value.
  26314. */
  26315. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26316. /**
  26317. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26318. * This is dynamic to allow compat with webgl 1 and 2.
  26319. * You will need to pass the name of the uniform as well as the value.
  26320. */
  26321. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26322. /**
  26323. * Lambda to Update a single float in a uniform buffer.
  26324. * This is dynamic to allow compat with webgl 1 and 2.
  26325. * You will need to pass the name of the uniform as well as the value.
  26326. */
  26327. updateFloat: (name: string, x: number) => void;
  26328. /**
  26329. * Lambda to Update a vec2 of float in a uniform buffer.
  26330. * This is dynamic to allow compat with webgl 1 and 2.
  26331. * You will need to pass the name of the uniform as well as the value.
  26332. */
  26333. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26334. /**
  26335. * Lambda to Update a vec3 of float in a uniform buffer.
  26336. * This is dynamic to allow compat with webgl 1 and 2.
  26337. * You will need to pass the name of the uniform as well as the value.
  26338. */
  26339. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26340. /**
  26341. * Lambda to Update a vec4 of float in a uniform buffer.
  26342. * This is dynamic to allow compat with webgl 1 and 2.
  26343. * You will need to pass the name of the uniform as well as the value.
  26344. */
  26345. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26346. /**
  26347. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26348. * This is dynamic to allow compat with webgl 1 and 2.
  26349. * You will need to pass the name of the uniform as well as the value.
  26350. */
  26351. updateMatrix: (name: string, mat: Matrix) => void;
  26352. /**
  26353. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26354. * This is dynamic to allow compat with webgl 1 and 2.
  26355. * You will need to pass the name of the uniform as well as the value.
  26356. */
  26357. updateVector3: (name: string, vector: Vector3) => void;
  26358. /**
  26359. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26360. * This is dynamic to allow compat with webgl 1 and 2.
  26361. * You will need to pass the name of the uniform as well as the value.
  26362. */
  26363. updateVector4: (name: string, vector: Vector4) => void;
  26364. /**
  26365. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26366. * This is dynamic to allow compat with webgl 1 and 2.
  26367. * You will need to pass the name of the uniform as well as the value.
  26368. */
  26369. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26370. /**
  26371. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26372. * This is dynamic to allow compat with webgl 1 and 2.
  26373. * You will need to pass the name of the uniform as well as the value.
  26374. */
  26375. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26376. /**
  26377. * Instantiates a new Uniform buffer objects.
  26378. *
  26379. * Handles blocks of uniform on the GPU.
  26380. *
  26381. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26382. *
  26383. * For more information, please refer to :
  26384. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26385. * @param engine Define the engine the buffer is associated with
  26386. * @param data Define the data contained in the buffer
  26387. * @param dynamic Define if the buffer is updatable
  26388. */
  26389. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26390. /**
  26391. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26392. * or just falling back on setUniformXXX calls.
  26393. */
  26394. readonly useUbo: boolean;
  26395. /**
  26396. * Indicates if the WebGL underlying uniform buffer is in sync
  26397. * with the javascript cache data.
  26398. */
  26399. readonly isSync: boolean;
  26400. /**
  26401. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26402. * Also, a dynamic UniformBuffer will disable cache verification and always
  26403. * update the underlying WebGL uniform buffer to the GPU.
  26404. * @returns if Dynamic, otherwise false
  26405. */
  26406. isDynamic(): boolean;
  26407. /**
  26408. * The data cache on JS side.
  26409. * @returns the underlying data as a float array
  26410. */
  26411. getData(): Float32Array;
  26412. /**
  26413. * The underlying WebGL Uniform buffer.
  26414. * @returns the webgl buffer
  26415. */
  26416. getBuffer(): Nullable<DataBuffer>;
  26417. /**
  26418. * std140 layout specifies how to align data within an UBO structure.
  26419. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26420. * for specs.
  26421. */
  26422. private _fillAlignment;
  26423. /**
  26424. * Adds an uniform in the buffer.
  26425. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26426. * for the layout to be correct !
  26427. * @param name Name of the uniform, as used in the uniform block in the shader.
  26428. * @param size Data size, or data directly.
  26429. */
  26430. addUniform(name: string, size: number | number[]): void;
  26431. /**
  26432. * Adds a Matrix 4x4 to the uniform buffer.
  26433. * @param name Name of the uniform, as used in the uniform block in the shader.
  26434. * @param mat A 4x4 matrix.
  26435. */
  26436. addMatrix(name: string, mat: Matrix): void;
  26437. /**
  26438. * Adds a vec2 to the uniform buffer.
  26439. * @param name Name of the uniform, as used in the uniform block in the shader.
  26440. * @param x Define the x component value of the vec2
  26441. * @param y Define the y component value of the vec2
  26442. */
  26443. addFloat2(name: string, x: number, y: number): void;
  26444. /**
  26445. * Adds a vec3 to the uniform buffer.
  26446. * @param name Name of the uniform, as used in the uniform block in the shader.
  26447. * @param x Define the x component value of the vec3
  26448. * @param y Define the y component value of the vec3
  26449. * @param z Define the z component value of the vec3
  26450. */
  26451. addFloat3(name: string, x: number, y: number, z: number): void;
  26452. /**
  26453. * Adds a vec3 to the uniform buffer.
  26454. * @param name Name of the uniform, as used in the uniform block in the shader.
  26455. * @param color Define the vec3 from a Color
  26456. */
  26457. addColor3(name: string, color: Color3): void;
  26458. /**
  26459. * Adds a vec4 to the uniform buffer.
  26460. * @param name Name of the uniform, as used in the uniform block in the shader.
  26461. * @param color Define the rgb components from a Color
  26462. * @param alpha Define the a component of the vec4
  26463. */
  26464. addColor4(name: string, color: Color3, alpha: number): void;
  26465. /**
  26466. * Adds a vec3 to the uniform buffer.
  26467. * @param name Name of the uniform, as used in the uniform block in the shader.
  26468. * @param vector Define the vec3 components from a Vector
  26469. */
  26470. addVector3(name: string, vector: Vector3): void;
  26471. /**
  26472. * Adds a Matrix 3x3 to the uniform buffer.
  26473. * @param name Name of the uniform, as used in the uniform block in the shader.
  26474. */
  26475. addMatrix3x3(name: string): void;
  26476. /**
  26477. * Adds a Matrix 2x2 to the uniform buffer.
  26478. * @param name Name of the uniform, as used in the uniform block in the shader.
  26479. */
  26480. addMatrix2x2(name: string): void;
  26481. /**
  26482. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26483. */
  26484. create(): void;
  26485. /** @hidden */
  26486. _rebuild(): void;
  26487. /**
  26488. * Updates the WebGL Uniform Buffer on the GPU.
  26489. * If the `dynamic` flag is set to true, no cache comparison is done.
  26490. * Otherwise, the buffer will be updated only if the cache differs.
  26491. */
  26492. update(): void;
  26493. /**
  26494. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26495. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26496. * @param data Define the flattened data
  26497. * @param size Define the size of the data.
  26498. */
  26499. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26500. private _updateMatrix3x3ForUniform;
  26501. private _updateMatrix3x3ForEffect;
  26502. private _updateMatrix2x2ForEffect;
  26503. private _updateMatrix2x2ForUniform;
  26504. private _updateFloatForEffect;
  26505. private _updateFloatForUniform;
  26506. private _updateFloat2ForEffect;
  26507. private _updateFloat2ForUniform;
  26508. private _updateFloat3ForEffect;
  26509. private _updateFloat3ForUniform;
  26510. private _updateFloat4ForEffect;
  26511. private _updateFloat4ForUniform;
  26512. private _updateMatrixForEffect;
  26513. private _updateMatrixForUniform;
  26514. private _updateVector3ForEffect;
  26515. private _updateVector3ForUniform;
  26516. private _updateVector4ForEffect;
  26517. private _updateVector4ForUniform;
  26518. private _updateColor3ForEffect;
  26519. private _updateColor3ForUniform;
  26520. private _updateColor4ForEffect;
  26521. private _updateColor4ForUniform;
  26522. /**
  26523. * Sets a sampler uniform on the effect.
  26524. * @param name Define the name of the sampler.
  26525. * @param texture Define the texture to set in the sampler
  26526. */
  26527. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26528. /**
  26529. * Directly updates the value of the uniform in the cache AND on the GPU.
  26530. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26531. * @param data Define the flattened data
  26532. */
  26533. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26534. /**
  26535. * Binds this uniform buffer to an effect.
  26536. * @param effect Define the effect to bind the buffer to
  26537. * @param name Name of the uniform block in the shader.
  26538. */
  26539. bindToEffect(effect: Effect, name: string): void;
  26540. /**
  26541. * Disposes the uniform buffer.
  26542. */
  26543. dispose(): void;
  26544. }
  26545. }
  26546. declare module BABYLON {
  26547. /**
  26548. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26549. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26550. */
  26551. export class Analyser {
  26552. /**
  26553. * Gets or sets the smoothing
  26554. * @ignorenaming
  26555. */
  26556. SMOOTHING: number;
  26557. /**
  26558. * Gets or sets the FFT table size
  26559. * @ignorenaming
  26560. */
  26561. FFT_SIZE: number;
  26562. /**
  26563. * Gets or sets the bar graph amplitude
  26564. * @ignorenaming
  26565. */
  26566. BARGRAPHAMPLITUDE: number;
  26567. /**
  26568. * Gets or sets the position of the debug canvas
  26569. * @ignorenaming
  26570. */
  26571. DEBUGCANVASPOS: {
  26572. x: number;
  26573. y: number;
  26574. };
  26575. /**
  26576. * Gets or sets the debug canvas size
  26577. * @ignorenaming
  26578. */
  26579. DEBUGCANVASSIZE: {
  26580. width: number;
  26581. height: number;
  26582. };
  26583. private _byteFreqs;
  26584. private _byteTime;
  26585. private _floatFreqs;
  26586. private _webAudioAnalyser;
  26587. private _debugCanvas;
  26588. private _debugCanvasContext;
  26589. private _scene;
  26590. private _registerFunc;
  26591. private _audioEngine;
  26592. /**
  26593. * Creates a new analyser
  26594. * @param scene defines hosting scene
  26595. */
  26596. constructor(scene: Scene);
  26597. /**
  26598. * Get the number of data values you will have to play with for the visualization
  26599. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26600. * @returns a number
  26601. */
  26602. getFrequencyBinCount(): number;
  26603. /**
  26604. * Gets the current frequency data as a byte array
  26605. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26606. * @returns a Uint8Array
  26607. */
  26608. getByteFrequencyData(): Uint8Array;
  26609. /**
  26610. * Gets the current waveform as a byte array
  26611. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26612. * @returns a Uint8Array
  26613. */
  26614. getByteTimeDomainData(): Uint8Array;
  26615. /**
  26616. * Gets the current frequency data as a float array
  26617. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26618. * @returns a Float32Array
  26619. */
  26620. getFloatFrequencyData(): Float32Array;
  26621. /**
  26622. * Renders the debug canvas
  26623. */
  26624. drawDebugCanvas(): void;
  26625. /**
  26626. * Stops rendering the debug canvas and removes it
  26627. */
  26628. stopDebugCanvas(): void;
  26629. /**
  26630. * Connects two audio nodes
  26631. * @param inputAudioNode defines first node to connect
  26632. * @param outputAudioNode defines second node to connect
  26633. */
  26634. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26635. /**
  26636. * Releases all associated resources
  26637. */
  26638. dispose(): void;
  26639. }
  26640. }
  26641. declare module BABYLON {
  26642. /**
  26643. * This represents an audio engine and it is responsible
  26644. * to play, synchronize and analyse sounds throughout the application.
  26645. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26646. */
  26647. export interface IAudioEngine extends IDisposable {
  26648. /**
  26649. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26650. */
  26651. readonly canUseWebAudio: boolean;
  26652. /**
  26653. * Gets the current AudioContext if available.
  26654. */
  26655. readonly audioContext: Nullable<AudioContext>;
  26656. /**
  26657. * The master gain node defines the global audio volume of your audio engine.
  26658. */
  26659. readonly masterGain: GainNode;
  26660. /**
  26661. * Gets whether or not mp3 are supported by your browser.
  26662. */
  26663. readonly isMP3supported: boolean;
  26664. /**
  26665. * Gets whether or not ogg are supported by your browser.
  26666. */
  26667. readonly isOGGsupported: boolean;
  26668. /**
  26669. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26670. * @ignoreNaming
  26671. */
  26672. WarnedWebAudioUnsupported: boolean;
  26673. /**
  26674. * Defines if the audio engine relies on a custom unlocked button.
  26675. * In this case, the embedded button will not be displayed.
  26676. */
  26677. useCustomUnlockedButton: boolean;
  26678. /**
  26679. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26680. */
  26681. readonly unlocked: boolean;
  26682. /**
  26683. * Event raised when audio has been unlocked on the browser.
  26684. */
  26685. onAudioUnlockedObservable: Observable<AudioEngine>;
  26686. /**
  26687. * Event raised when audio has been locked on the browser.
  26688. */
  26689. onAudioLockedObservable: Observable<AudioEngine>;
  26690. /**
  26691. * Flags the audio engine in Locked state.
  26692. * This happens due to new browser policies preventing audio to autoplay.
  26693. */
  26694. lock(): void;
  26695. /**
  26696. * Unlocks the audio engine once a user action has been done on the dom.
  26697. * This is helpful to resume play once browser policies have been satisfied.
  26698. */
  26699. unlock(): void;
  26700. }
  26701. /**
  26702. * This represents the default audio engine used in babylon.
  26703. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26704. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26705. */
  26706. export class AudioEngine implements IAudioEngine {
  26707. private _audioContext;
  26708. private _audioContextInitialized;
  26709. private _muteButton;
  26710. private _hostElement;
  26711. /**
  26712. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26713. */
  26714. canUseWebAudio: boolean;
  26715. /**
  26716. * The master gain node defines the global audio volume of your audio engine.
  26717. */
  26718. masterGain: GainNode;
  26719. /**
  26720. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26721. * @ignoreNaming
  26722. */
  26723. WarnedWebAudioUnsupported: boolean;
  26724. /**
  26725. * Gets whether or not mp3 are supported by your browser.
  26726. */
  26727. isMP3supported: boolean;
  26728. /**
  26729. * Gets whether or not ogg are supported by your browser.
  26730. */
  26731. isOGGsupported: boolean;
  26732. /**
  26733. * Gets whether audio has been unlocked on the device.
  26734. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26735. * a user interaction has happened.
  26736. */
  26737. unlocked: boolean;
  26738. /**
  26739. * Defines if the audio engine relies on a custom unlocked button.
  26740. * In this case, the embedded button will not be displayed.
  26741. */
  26742. useCustomUnlockedButton: boolean;
  26743. /**
  26744. * Event raised when audio has been unlocked on the browser.
  26745. */
  26746. onAudioUnlockedObservable: Observable<AudioEngine>;
  26747. /**
  26748. * Event raised when audio has been locked on the browser.
  26749. */
  26750. onAudioLockedObservable: Observable<AudioEngine>;
  26751. /**
  26752. * Gets the current AudioContext if available.
  26753. */
  26754. readonly audioContext: Nullable<AudioContext>;
  26755. private _connectedAnalyser;
  26756. /**
  26757. * Instantiates a new audio engine.
  26758. *
  26759. * There should be only one per page as some browsers restrict the number
  26760. * of audio contexts you can create.
  26761. * @param hostElement defines the host element where to display the mute icon if necessary
  26762. */
  26763. constructor(hostElement?: Nullable<HTMLElement>);
  26764. /**
  26765. * Flags the audio engine in Locked state.
  26766. * This happens due to new browser policies preventing audio to autoplay.
  26767. */
  26768. lock(): void;
  26769. /**
  26770. * Unlocks the audio engine once a user action has been done on the dom.
  26771. * This is helpful to resume play once browser policies have been satisfied.
  26772. */
  26773. unlock(): void;
  26774. private _resumeAudioContext;
  26775. private _initializeAudioContext;
  26776. private _tryToRun;
  26777. private _triggerRunningState;
  26778. private _triggerSuspendedState;
  26779. private _displayMuteButton;
  26780. private _moveButtonToTopLeft;
  26781. private _onResize;
  26782. private _hideMuteButton;
  26783. /**
  26784. * Destroy and release the resources associated with the audio ccontext.
  26785. */
  26786. dispose(): void;
  26787. /**
  26788. * Gets the global volume sets on the master gain.
  26789. * @returns the global volume if set or -1 otherwise
  26790. */
  26791. getGlobalVolume(): number;
  26792. /**
  26793. * Sets the global volume of your experience (sets on the master gain).
  26794. * @param newVolume Defines the new global volume of the application
  26795. */
  26796. setGlobalVolume(newVolume: number): void;
  26797. /**
  26798. * Connect the audio engine to an audio analyser allowing some amazing
  26799. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26800. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26801. * @param analyser The analyser to connect to the engine
  26802. */
  26803. connectToAnalyser(analyser: Analyser): void;
  26804. }
  26805. }
  26806. declare module BABYLON {
  26807. /**
  26808. * Interface used to present a loading screen while loading a scene
  26809. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26810. */
  26811. export interface ILoadingScreen {
  26812. /**
  26813. * Function called to display the loading screen
  26814. */
  26815. displayLoadingUI: () => void;
  26816. /**
  26817. * Function called to hide the loading screen
  26818. */
  26819. hideLoadingUI: () => void;
  26820. /**
  26821. * Gets or sets the color to use for the background
  26822. */
  26823. loadingUIBackgroundColor: string;
  26824. /**
  26825. * Gets or sets the text to display while loading
  26826. */
  26827. loadingUIText: string;
  26828. }
  26829. /**
  26830. * Class used for the default loading screen
  26831. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26832. */
  26833. export class DefaultLoadingScreen implements ILoadingScreen {
  26834. private _renderingCanvas;
  26835. private _loadingText;
  26836. private _loadingDivBackgroundColor;
  26837. private _loadingDiv;
  26838. private _loadingTextDiv;
  26839. /**
  26840. * Creates a new default loading screen
  26841. * @param _renderingCanvas defines the canvas used to render the scene
  26842. * @param _loadingText defines the default text to display
  26843. * @param _loadingDivBackgroundColor defines the default background color
  26844. */
  26845. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26846. /**
  26847. * Function called to display the loading screen
  26848. */
  26849. displayLoadingUI(): void;
  26850. /**
  26851. * Function called to hide the loading screen
  26852. */
  26853. hideLoadingUI(): void;
  26854. /**
  26855. * Gets or sets the text to display while loading
  26856. */
  26857. loadingUIText: string;
  26858. /**
  26859. * Gets or sets the color to use for the background
  26860. */
  26861. loadingUIBackgroundColor: string;
  26862. private _resizeLoadingUI;
  26863. }
  26864. }
  26865. declare module BABYLON {
  26866. /** @hidden */
  26867. export class WebGLPipelineContext implements IPipelineContext {
  26868. engine: Engine;
  26869. program: Nullable<WebGLProgram>;
  26870. context?: WebGLRenderingContext;
  26871. vertexShader?: WebGLShader;
  26872. fragmentShader?: WebGLShader;
  26873. isParallelCompiled: boolean;
  26874. onCompiled?: () => void;
  26875. transformFeedback?: WebGLTransformFeedback | null;
  26876. readonly isAsync: boolean;
  26877. readonly isReady: boolean;
  26878. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  26879. }
  26880. }
  26881. declare module BABYLON {
  26882. /** @hidden */
  26883. export class WebGLDataBuffer extends DataBuffer {
  26884. private _buffer;
  26885. constructor(resource: WebGLBuffer);
  26886. readonly underlyingResource: any;
  26887. }
  26888. }
  26889. declare module BABYLON {
  26890. /**
  26891. * Settings for finer control over video usage
  26892. */
  26893. export interface VideoTextureSettings {
  26894. /**
  26895. * Applies `autoplay` to video, if specified
  26896. */
  26897. autoPlay?: boolean;
  26898. /**
  26899. * Applies `loop` to video, if specified
  26900. */
  26901. loop?: boolean;
  26902. /**
  26903. * Automatically updates internal texture from video at every frame in the render loop
  26904. */
  26905. autoUpdateTexture: boolean;
  26906. /**
  26907. * Image src displayed during the video loading or until the user interacts with the video.
  26908. */
  26909. poster?: string;
  26910. }
  26911. /**
  26912. * If you want to display a video in your scene, this is the special texture for that.
  26913. * This special texture works similar to other textures, with the exception of a few parameters.
  26914. * @see https://doc.babylonjs.com/how_to/video_texture
  26915. */
  26916. export class VideoTexture extends Texture {
  26917. /**
  26918. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26919. */
  26920. readonly autoUpdateTexture: boolean;
  26921. /**
  26922. * The video instance used by the texture internally
  26923. */
  26924. readonly video: HTMLVideoElement;
  26925. private _onUserActionRequestedObservable;
  26926. /**
  26927. * Event triggerd when a dom action is required by the user to play the video.
  26928. * This happens due to recent changes in browser policies preventing video to auto start.
  26929. */
  26930. readonly onUserActionRequestedObservable: Observable<Texture>;
  26931. private _generateMipMaps;
  26932. private _engine;
  26933. private _stillImageCaptured;
  26934. private _displayingPosterTexture;
  26935. private _settings;
  26936. private _createInternalTextureOnEvent;
  26937. /**
  26938. * Creates a video texture.
  26939. * If you want to display a video in your scene, this is the special texture for that.
  26940. * This special texture works similar to other textures, with the exception of a few parameters.
  26941. * @see https://doc.babylonjs.com/how_to/video_texture
  26942. * @param name optional name, will detect from video source, if not defined
  26943. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26944. * @param scene is obviously the current scene.
  26945. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26946. * @param invertY is false by default but can be used to invert video on Y axis
  26947. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26948. * @param settings allows finer control over video usage
  26949. */
  26950. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26951. private _getName;
  26952. private _getVideo;
  26953. private _createInternalTexture;
  26954. private reset;
  26955. /**
  26956. * @hidden Internal method to initiate `update`.
  26957. */
  26958. _rebuild(): void;
  26959. /**
  26960. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26961. */
  26962. update(): void;
  26963. /**
  26964. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26965. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26966. */
  26967. updateTexture(isVisible: boolean): void;
  26968. protected _updateInternalTexture: () => void;
  26969. /**
  26970. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26971. * @param url New url.
  26972. */
  26973. updateURL(url: string): void;
  26974. /**
  26975. * Dispose the texture and release its associated resources.
  26976. */
  26977. dispose(): void;
  26978. /**
  26979. * Creates a video texture straight from a stream.
  26980. * @param scene Define the scene the texture should be created in
  26981. * @param stream Define the stream the texture should be created from
  26982. * @returns The created video texture as a promise
  26983. */
  26984. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26985. /**
  26986. * Creates a video texture straight from your WebCam video feed.
  26987. * @param scene Define the scene the texture should be created in
  26988. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26989. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26990. * @returns The created video texture as a promise
  26991. */
  26992. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26993. minWidth: number;
  26994. maxWidth: number;
  26995. minHeight: number;
  26996. maxHeight: number;
  26997. deviceId: string;
  26998. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26999. /**
  27000. * Creates a video texture straight from your WebCam video feed.
  27001. * @param scene Define the scene the texture should be created in
  27002. * @param onReady Define a callback to triggered once the texture will be ready
  27003. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27004. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27005. */
  27006. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27007. minWidth: number;
  27008. maxWidth: number;
  27009. minHeight: number;
  27010. maxHeight: number;
  27011. deviceId: string;
  27012. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27013. }
  27014. }
  27015. declare module BABYLON {
  27016. /**
  27017. * Interface for attribute information associated with buffer instanciation
  27018. */
  27019. export class InstancingAttributeInfo {
  27020. /**
  27021. * Index/offset of the attribute in the vertex shader
  27022. */
  27023. index: number;
  27024. /**
  27025. * size of the attribute, 1, 2, 3 or 4
  27026. */
  27027. attributeSize: number;
  27028. /**
  27029. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27030. * default is FLOAT
  27031. */
  27032. attribyteType: number;
  27033. /**
  27034. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27035. */
  27036. normalized: boolean;
  27037. /**
  27038. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27039. */
  27040. offset: number;
  27041. /**
  27042. * Name of the GLSL attribute, for debugging purpose only
  27043. */
  27044. attributeName: string;
  27045. }
  27046. /**
  27047. * Define options used to create a depth texture
  27048. */
  27049. export class DepthTextureCreationOptions {
  27050. /** Specifies whether or not a stencil should be allocated in the texture */
  27051. generateStencil?: boolean;
  27052. /** Specifies whether or not bilinear filtering is enable on the texture */
  27053. bilinearFiltering?: boolean;
  27054. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27055. comparisonFunction?: number;
  27056. /** Specifies if the created texture is a cube texture */
  27057. isCube?: boolean;
  27058. }
  27059. /**
  27060. * Class used to describe the capabilities of the engine relatively to the current browser
  27061. */
  27062. export class EngineCapabilities {
  27063. /** Maximum textures units per fragment shader */
  27064. maxTexturesImageUnits: number;
  27065. /** Maximum texture units per vertex shader */
  27066. maxVertexTextureImageUnits: number;
  27067. /** Maximum textures units in the entire pipeline */
  27068. maxCombinedTexturesImageUnits: number;
  27069. /** Maximum texture size */
  27070. maxTextureSize: number;
  27071. /** Maximum cube texture size */
  27072. maxCubemapTextureSize: number;
  27073. /** Maximum render texture size */
  27074. maxRenderTextureSize: number;
  27075. /** Maximum number of vertex attributes */
  27076. maxVertexAttribs: number;
  27077. /** Maximum number of varyings */
  27078. maxVaryingVectors: number;
  27079. /** Maximum number of uniforms per vertex shader */
  27080. maxVertexUniformVectors: number;
  27081. /** Maximum number of uniforms per fragment shader */
  27082. maxFragmentUniformVectors: number;
  27083. /** Defines if standard derivates (dx/dy) are supported */
  27084. standardDerivatives: boolean;
  27085. /** Defines if s3tc texture compression is supported */
  27086. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27087. /** Defines if pvrtc texture compression is supported */
  27088. pvrtc: any;
  27089. /** Defines if etc1 texture compression is supported */
  27090. etc1: any;
  27091. /** Defines if etc2 texture compression is supported */
  27092. etc2: any;
  27093. /** Defines if astc texture compression is supported */
  27094. astc: any;
  27095. /** Defines if float textures are supported */
  27096. textureFloat: boolean;
  27097. /** Defines if vertex array objects are supported */
  27098. vertexArrayObject: boolean;
  27099. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27100. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27101. /** Gets the maximum level of anisotropy supported */
  27102. maxAnisotropy: number;
  27103. /** Defines if instancing is supported */
  27104. instancedArrays: boolean;
  27105. /** Defines if 32 bits indices are supported */
  27106. uintIndices: boolean;
  27107. /** Defines if high precision shaders are supported */
  27108. highPrecisionShaderSupported: boolean;
  27109. /** Defines if depth reading in the fragment shader is supported */
  27110. fragmentDepthSupported: boolean;
  27111. /** Defines if float texture linear filtering is supported*/
  27112. textureFloatLinearFiltering: boolean;
  27113. /** Defines if rendering to float textures is supported */
  27114. textureFloatRender: boolean;
  27115. /** Defines if half float textures are supported*/
  27116. textureHalfFloat: boolean;
  27117. /** Defines if half float texture linear filtering is supported*/
  27118. textureHalfFloatLinearFiltering: boolean;
  27119. /** Defines if rendering to half float textures is supported */
  27120. textureHalfFloatRender: boolean;
  27121. /** Defines if textureLOD shader command is supported */
  27122. textureLOD: boolean;
  27123. /** Defines if draw buffers extension is supported */
  27124. drawBuffersExtension: boolean;
  27125. /** Defines if depth textures are supported */
  27126. depthTextureExtension: boolean;
  27127. /** Defines if float color buffer are supported */
  27128. colorBufferFloat: boolean;
  27129. /** Gets disjoint timer query extension (null if not supported) */
  27130. timerQuery: EXT_disjoint_timer_query;
  27131. /** Defines if timestamp can be used with timer query */
  27132. canUseTimestampForTimerQuery: boolean;
  27133. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27134. multiview: any;
  27135. /** Function used to let the system compiles shaders in background */
  27136. parallelShaderCompile: {
  27137. COMPLETION_STATUS_KHR: number;
  27138. };
  27139. }
  27140. /** Interface defining initialization parameters for Engine class */
  27141. export interface EngineOptions extends WebGLContextAttributes {
  27142. /**
  27143. * Defines if the engine should no exceed a specified device ratio
  27144. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27145. */
  27146. limitDeviceRatio?: number;
  27147. /**
  27148. * Defines if webvr should be enabled automatically
  27149. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27150. */
  27151. autoEnableWebVR?: boolean;
  27152. /**
  27153. * Defines if webgl2 should be turned off even if supported
  27154. * @see http://doc.babylonjs.com/features/webgl2
  27155. */
  27156. disableWebGL2Support?: boolean;
  27157. /**
  27158. * Defines if webaudio should be initialized as well
  27159. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27160. */
  27161. audioEngine?: boolean;
  27162. /**
  27163. * Defines if animations should run using a deterministic lock step
  27164. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27165. */
  27166. deterministicLockstep?: boolean;
  27167. /** Defines the maximum steps to use with deterministic lock step mode */
  27168. lockstepMaxSteps?: number;
  27169. /**
  27170. * Defines that engine should ignore context lost events
  27171. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27172. */
  27173. doNotHandleContextLost?: boolean;
  27174. /**
  27175. * Defines that engine should ignore modifying touch action attribute and style
  27176. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27177. */
  27178. doNotHandleTouchAction?: boolean;
  27179. /**
  27180. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27181. */
  27182. useHighPrecisionFloats?: boolean;
  27183. }
  27184. /**
  27185. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27186. */
  27187. export class Engine {
  27188. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27189. static ExceptionList: ({
  27190. key: string;
  27191. capture: string;
  27192. captureConstraint: number;
  27193. targets: string[];
  27194. } | {
  27195. key: string;
  27196. capture: null;
  27197. captureConstraint: null;
  27198. targets: string[];
  27199. })[];
  27200. /** Gets the list of created engines */
  27201. static readonly Instances: Engine[];
  27202. /**
  27203. * Gets the latest created engine
  27204. */
  27205. static readonly LastCreatedEngine: Nullable<Engine>;
  27206. /**
  27207. * Gets the latest created scene
  27208. */
  27209. static readonly LastCreatedScene: Nullable<Scene>;
  27210. /**
  27211. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27212. * @param flag defines which part of the materials must be marked as dirty
  27213. * @param predicate defines a predicate used to filter which materials should be affected
  27214. */
  27215. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27216. /**
  27217. * Hidden
  27218. */
  27219. static _TextureLoaders: IInternalTextureLoader[];
  27220. /** Defines that alpha blending is disabled */
  27221. static readonly ALPHA_DISABLE: number;
  27222. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27223. static readonly ALPHA_ADD: number;
  27224. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27225. static readonly ALPHA_COMBINE: number;
  27226. /** Defines that alpha blending to DEST - SRC * DEST */
  27227. static readonly ALPHA_SUBTRACT: number;
  27228. /** Defines that alpha blending to SRC * DEST */
  27229. static readonly ALPHA_MULTIPLY: number;
  27230. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27231. static readonly ALPHA_MAXIMIZED: number;
  27232. /** Defines that alpha blending to SRC + DEST */
  27233. static readonly ALPHA_ONEONE: number;
  27234. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27235. static readonly ALPHA_PREMULTIPLIED: number;
  27236. /**
  27237. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27238. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27239. */
  27240. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27241. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27242. static readonly ALPHA_INTERPOLATE: number;
  27243. /**
  27244. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27245. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27246. */
  27247. static readonly ALPHA_SCREENMODE: number;
  27248. /** Defines that the ressource is not delayed*/
  27249. static readonly DELAYLOADSTATE_NONE: number;
  27250. /** Defines that the ressource was successfully delay loaded */
  27251. static readonly DELAYLOADSTATE_LOADED: number;
  27252. /** Defines that the ressource is currently delay loading */
  27253. static readonly DELAYLOADSTATE_LOADING: number;
  27254. /** Defines that the ressource is delayed and has not started loading */
  27255. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27256. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27257. static readonly NEVER: number;
  27258. /** 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 */
  27259. static readonly ALWAYS: number;
  27260. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27261. static readonly LESS: number;
  27262. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27263. static readonly EQUAL: number;
  27264. /** 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 */
  27265. static readonly LEQUAL: number;
  27266. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27267. static readonly GREATER: number;
  27268. /** 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 */
  27269. static readonly GEQUAL: number;
  27270. /** 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 */
  27271. static readonly NOTEQUAL: number;
  27272. /** Passed to stencilOperation to specify that stencil value must be kept */
  27273. static readonly KEEP: number;
  27274. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27275. static readonly REPLACE: number;
  27276. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27277. static readonly INCR: number;
  27278. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27279. static readonly DECR: number;
  27280. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27281. static readonly INVERT: number;
  27282. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27283. static readonly INCR_WRAP: number;
  27284. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27285. static readonly DECR_WRAP: number;
  27286. /** Texture is not repeating outside of 0..1 UVs */
  27287. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27288. /** Texture is repeating outside of 0..1 UVs */
  27289. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27290. /** Texture is repeating and mirrored */
  27291. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27292. /** ALPHA */
  27293. static readonly TEXTUREFORMAT_ALPHA: number;
  27294. /** LUMINANCE */
  27295. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27296. /** LUMINANCE_ALPHA */
  27297. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27298. /** RGB */
  27299. static readonly TEXTUREFORMAT_RGB: number;
  27300. /** RGBA */
  27301. static readonly TEXTUREFORMAT_RGBA: number;
  27302. /** RED */
  27303. static readonly TEXTUREFORMAT_RED: number;
  27304. /** RED (2nd reference) */
  27305. static readonly TEXTUREFORMAT_R: number;
  27306. /** RG */
  27307. static readonly TEXTUREFORMAT_RG: number;
  27308. /** RED_INTEGER */
  27309. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27310. /** RED_INTEGER (2nd reference) */
  27311. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27312. /** RG_INTEGER */
  27313. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27314. /** RGB_INTEGER */
  27315. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27316. /** RGBA_INTEGER */
  27317. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27318. /** UNSIGNED_BYTE */
  27319. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27320. /** UNSIGNED_BYTE (2nd reference) */
  27321. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27322. /** FLOAT */
  27323. static readonly TEXTURETYPE_FLOAT: number;
  27324. /** HALF_FLOAT */
  27325. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27326. /** BYTE */
  27327. static readonly TEXTURETYPE_BYTE: number;
  27328. /** SHORT */
  27329. static readonly TEXTURETYPE_SHORT: number;
  27330. /** UNSIGNED_SHORT */
  27331. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27332. /** INT */
  27333. static readonly TEXTURETYPE_INT: number;
  27334. /** UNSIGNED_INT */
  27335. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27336. /** UNSIGNED_SHORT_4_4_4_4 */
  27337. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27338. /** UNSIGNED_SHORT_5_5_5_1 */
  27339. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27340. /** UNSIGNED_SHORT_5_6_5 */
  27341. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27342. /** UNSIGNED_INT_2_10_10_10_REV */
  27343. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27344. /** UNSIGNED_INT_24_8 */
  27345. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27346. /** UNSIGNED_INT_10F_11F_11F_REV */
  27347. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27348. /** UNSIGNED_INT_5_9_9_9_REV */
  27349. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27350. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27351. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27352. /** nearest is mag = nearest and min = nearest and mip = linear */
  27353. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27354. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27355. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27356. /** Trilinear is mag = linear and min = linear and mip = linear */
  27357. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27358. /** nearest is mag = nearest and min = nearest and mip = linear */
  27359. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27360. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27361. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27362. /** Trilinear is mag = linear and min = linear and mip = linear */
  27363. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27364. /** mag = nearest and min = nearest and mip = nearest */
  27365. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27366. /** mag = nearest and min = linear and mip = nearest */
  27367. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27368. /** mag = nearest and min = linear and mip = linear */
  27369. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27370. /** mag = nearest and min = linear and mip = none */
  27371. static readonly TEXTURE_NEAREST_LINEAR: number;
  27372. /** mag = nearest and min = nearest and mip = none */
  27373. static readonly TEXTURE_NEAREST_NEAREST: number;
  27374. /** mag = linear and min = nearest and mip = nearest */
  27375. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27376. /** mag = linear and min = nearest and mip = linear */
  27377. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27378. /** mag = linear and min = linear and mip = none */
  27379. static readonly TEXTURE_LINEAR_LINEAR: number;
  27380. /** mag = linear and min = nearest and mip = none */
  27381. static readonly TEXTURE_LINEAR_NEAREST: number;
  27382. /** Explicit coordinates mode */
  27383. static readonly TEXTURE_EXPLICIT_MODE: number;
  27384. /** Spherical coordinates mode */
  27385. static readonly TEXTURE_SPHERICAL_MODE: number;
  27386. /** Planar coordinates mode */
  27387. static readonly TEXTURE_PLANAR_MODE: number;
  27388. /** Cubic coordinates mode */
  27389. static readonly TEXTURE_CUBIC_MODE: number;
  27390. /** Projection coordinates mode */
  27391. static readonly TEXTURE_PROJECTION_MODE: number;
  27392. /** Skybox coordinates mode */
  27393. static readonly TEXTURE_SKYBOX_MODE: number;
  27394. /** Inverse Cubic coordinates mode */
  27395. static readonly TEXTURE_INVCUBIC_MODE: number;
  27396. /** Equirectangular coordinates mode */
  27397. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27398. /** Equirectangular Fixed coordinates mode */
  27399. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27400. /** Equirectangular Fixed Mirrored coordinates mode */
  27401. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27402. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27403. static readonly SCALEMODE_FLOOR: number;
  27404. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27405. static readonly SCALEMODE_NEAREST: number;
  27406. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27407. static readonly SCALEMODE_CEILING: number;
  27408. /**
  27409. * Returns the current npm package of the sdk
  27410. */
  27411. static readonly NpmPackage: string;
  27412. /**
  27413. * Returns the current version of the framework
  27414. */
  27415. static readonly Version: string;
  27416. /**
  27417. * Returns a string describing the current engine
  27418. */
  27419. readonly description: string;
  27420. /**
  27421. * Gets or sets the epsilon value used by collision engine
  27422. */
  27423. static CollisionsEpsilon: number;
  27424. /**
  27425. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27426. */
  27427. static ShadersRepository: string;
  27428. /**
  27429. * Method called to create the default loading screen.
  27430. * This can be overriden in your own app.
  27431. * @param canvas The rendering canvas element
  27432. * @returns The loading screen
  27433. */
  27434. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27435. /**
  27436. * Method called to create the default rescale post process on each engine.
  27437. */
  27438. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27439. /**
  27440. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27441. */
  27442. forcePOTTextures: boolean;
  27443. /**
  27444. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27445. */
  27446. isFullscreen: boolean;
  27447. /**
  27448. * Gets a boolean indicating if the pointer is currently locked
  27449. */
  27450. isPointerLock: boolean;
  27451. /**
  27452. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27453. */
  27454. cullBackFaces: boolean;
  27455. /**
  27456. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27457. */
  27458. renderEvenInBackground: boolean;
  27459. /**
  27460. * Gets or sets a boolean indicating that cache can be kept between frames
  27461. */
  27462. preventCacheWipeBetweenFrames: boolean;
  27463. /**
  27464. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27465. **/
  27466. enableOfflineSupport: boolean;
  27467. /**
  27468. * 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)
  27469. **/
  27470. disableManifestCheck: boolean;
  27471. /**
  27472. * Gets the list of created scenes
  27473. */
  27474. scenes: Scene[];
  27475. /**
  27476. * Event raised when a new scene is created
  27477. */
  27478. onNewSceneAddedObservable: Observable<Scene>;
  27479. /**
  27480. * Gets the list of created postprocesses
  27481. */
  27482. postProcesses: PostProcess[];
  27483. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27484. validateShaderPrograms: boolean;
  27485. /**
  27486. * Observable event triggered each time the rendering canvas is resized
  27487. */
  27488. onResizeObservable: Observable<Engine>;
  27489. /**
  27490. * Observable event triggered each time the canvas loses focus
  27491. */
  27492. onCanvasBlurObservable: Observable<Engine>;
  27493. /**
  27494. * Observable event triggered each time the canvas gains focus
  27495. */
  27496. onCanvasFocusObservable: Observable<Engine>;
  27497. /**
  27498. * Observable event triggered each time the canvas receives pointerout event
  27499. */
  27500. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27501. /**
  27502. * Observable event triggered before each texture is initialized
  27503. */
  27504. onBeforeTextureInitObservable: Observable<Texture>;
  27505. /**
  27506. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27507. */
  27508. disableUniformBuffers: boolean;
  27509. /** @hidden */
  27510. _uniformBuffers: UniformBuffer[];
  27511. /**
  27512. * Gets a boolean indicating that the engine supports uniform buffers
  27513. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27514. */
  27515. readonly supportsUniformBuffers: boolean;
  27516. /**
  27517. * Observable raised when the engine begins a new frame
  27518. */
  27519. onBeginFrameObservable: Observable<Engine>;
  27520. /**
  27521. * If set, will be used to request the next animation frame for the render loop
  27522. */
  27523. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27524. /**
  27525. * Observable raised when the engine ends the current frame
  27526. */
  27527. onEndFrameObservable: Observable<Engine>;
  27528. /**
  27529. * Observable raised when the engine is about to compile a shader
  27530. */
  27531. onBeforeShaderCompilationObservable: Observable<Engine>;
  27532. /**
  27533. * Observable raised when the engine has jsut compiled a shader
  27534. */
  27535. onAfterShaderCompilationObservable: Observable<Engine>;
  27536. /** @hidden */
  27537. _gl: WebGLRenderingContext;
  27538. private _renderingCanvas;
  27539. private _windowIsBackground;
  27540. private _webGLVersion;
  27541. protected _highPrecisionShadersAllowed: boolean;
  27542. /** @hidden */
  27543. readonly _shouldUseHighPrecisionShader: boolean;
  27544. /**
  27545. * Gets a boolean indicating that only power of 2 textures are supported
  27546. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27547. */
  27548. readonly needPOTTextures: boolean;
  27549. /** @hidden */
  27550. _badOS: boolean;
  27551. /** @hidden */
  27552. _badDesktopOS: boolean;
  27553. /**
  27554. * Gets the audio engine
  27555. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27556. * @ignorenaming
  27557. */
  27558. static audioEngine: IAudioEngine;
  27559. /**
  27560. * Default AudioEngine factory responsible of creating the Audio Engine.
  27561. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27562. */
  27563. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27564. /**
  27565. * Default offline support factory responsible of creating a tool used to store data locally.
  27566. * By default, this will create a Database object if the workload has been embedded.
  27567. */
  27568. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27569. private _onFocus;
  27570. private _onBlur;
  27571. private _onCanvasPointerOut;
  27572. private _onCanvasBlur;
  27573. private _onCanvasFocus;
  27574. private _onFullscreenChange;
  27575. private _onPointerLockChange;
  27576. private _hardwareScalingLevel;
  27577. /** @hidden */
  27578. _caps: EngineCapabilities;
  27579. private _pointerLockRequested;
  27580. private _isStencilEnable;
  27581. private _colorWrite;
  27582. private _loadingScreen;
  27583. /** @hidden */
  27584. _drawCalls: PerfCounter;
  27585. private _glVersion;
  27586. private _glRenderer;
  27587. private _glVendor;
  27588. private _videoTextureSupported;
  27589. private _renderingQueueLaunched;
  27590. private _activeRenderLoops;
  27591. private _deterministicLockstep;
  27592. private _lockstepMaxSteps;
  27593. /**
  27594. * Observable signaled when a context lost event is raised
  27595. */
  27596. onContextLostObservable: Observable<Engine>;
  27597. /**
  27598. * Observable signaled when a context restored event is raised
  27599. */
  27600. onContextRestoredObservable: Observable<Engine>;
  27601. private _onContextLost;
  27602. private _onContextRestored;
  27603. private _contextWasLost;
  27604. /** @hidden */
  27605. _doNotHandleContextLost: boolean;
  27606. /**
  27607. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27608. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27609. */
  27610. doNotHandleContextLost: boolean;
  27611. private _performanceMonitor;
  27612. private _fps;
  27613. private _deltaTime;
  27614. /**
  27615. * Turn this value on if you want to pause FPS computation when in background
  27616. */
  27617. disablePerformanceMonitorInBackground: boolean;
  27618. /**
  27619. * Gets the performance monitor attached to this engine
  27620. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27621. */
  27622. readonly performanceMonitor: PerformanceMonitor;
  27623. /**
  27624. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27625. */
  27626. disableVertexArrayObjects: boolean;
  27627. /** @hidden */
  27628. protected _depthCullingState: _DepthCullingState;
  27629. /** @hidden */
  27630. protected _stencilState: _StencilState;
  27631. /** @hidden */
  27632. protected _alphaState: _AlphaState;
  27633. /** @hidden */
  27634. protected _alphaMode: number;
  27635. /** @hidden */
  27636. _internalTexturesCache: InternalTexture[];
  27637. /** @hidden */
  27638. protected _activeChannel: number;
  27639. private _currentTextureChannel;
  27640. /** @hidden */
  27641. protected _boundTexturesCache: {
  27642. [key: string]: Nullable<InternalTexture>;
  27643. };
  27644. /** @hidden */
  27645. protected _currentEffect: Nullable<Effect>;
  27646. /** @hidden */
  27647. protected _currentProgram: Nullable<WebGLProgram>;
  27648. private _compiledEffects;
  27649. private _vertexAttribArraysEnabled;
  27650. /** @hidden */
  27651. protected _cachedViewport: Nullable<Viewport>;
  27652. private _cachedVertexArrayObject;
  27653. /** @hidden */
  27654. protected _cachedVertexBuffers: any;
  27655. /** @hidden */
  27656. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27657. /** @hidden */
  27658. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27659. /** @hidden */
  27660. _currentRenderTarget: Nullable<InternalTexture>;
  27661. private _uintIndicesCurrentlySet;
  27662. private _currentBoundBuffer;
  27663. /** @hidden */
  27664. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27665. private _currentBufferPointers;
  27666. private _currentInstanceLocations;
  27667. private _currentInstanceBuffers;
  27668. private _textureUnits;
  27669. /** @hidden */
  27670. _workingCanvas: Nullable<HTMLCanvasElement>;
  27671. /** @hidden */
  27672. _workingContext: Nullable<CanvasRenderingContext2D>;
  27673. private _rescalePostProcess;
  27674. private _dummyFramebuffer;
  27675. private _externalData;
  27676. /** @hidden */
  27677. _bindedRenderFunction: any;
  27678. private _vaoRecordInProgress;
  27679. private _mustWipeVertexAttributes;
  27680. private _emptyTexture;
  27681. private _emptyCubeTexture;
  27682. private _emptyTexture3D;
  27683. /** @hidden */
  27684. _frameHandler: number;
  27685. private _nextFreeTextureSlots;
  27686. private _maxSimultaneousTextures;
  27687. private _activeRequests;
  27688. private _texturesSupported;
  27689. /** @hidden */
  27690. _textureFormatInUse: Nullable<string>;
  27691. /**
  27692. * Gets the list of texture formats supported
  27693. */
  27694. readonly texturesSupported: Array<string>;
  27695. /**
  27696. * Gets the list of texture formats in use
  27697. */
  27698. readonly textureFormatInUse: Nullable<string>;
  27699. /**
  27700. * Gets the current viewport
  27701. */
  27702. readonly currentViewport: Nullable<Viewport>;
  27703. /**
  27704. * Gets the default empty texture
  27705. */
  27706. readonly emptyTexture: InternalTexture;
  27707. /**
  27708. * Gets the default empty 3D texture
  27709. */
  27710. readonly emptyTexture3D: InternalTexture;
  27711. /**
  27712. * Gets the default empty cube texture
  27713. */
  27714. readonly emptyCubeTexture: InternalTexture;
  27715. /**
  27716. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27717. */
  27718. readonly premultipliedAlpha: boolean;
  27719. /**
  27720. * Creates a new engine
  27721. * @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
  27722. * @param antialias defines enable antialiasing (default: false)
  27723. * @param options defines further options to be sent to the getContext() function
  27724. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27725. */
  27726. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27727. /**
  27728. * Initializes a webVR display and starts listening to display change events
  27729. * The onVRDisplayChangedObservable will be notified upon these changes
  27730. * @returns The onVRDisplayChangedObservable
  27731. */
  27732. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27733. /** @hidden */
  27734. _prepareVRComponent(): void;
  27735. /** @hidden */
  27736. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  27737. /** @hidden */
  27738. _submitVRFrame(): void;
  27739. /**
  27740. * Call this function to leave webVR mode
  27741. * Will do nothing if webVR is not supported or if there is no webVR device
  27742. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27743. */
  27744. disableVR(): void;
  27745. /**
  27746. * Gets a boolean indicating that the system is in VR mode and is presenting
  27747. * @returns true if VR mode is engaged
  27748. */
  27749. isVRPresenting(): boolean;
  27750. /** @hidden */
  27751. _requestVRFrame(): void;
  27752. private _disableTouchAction;
  27753. private _rebuildInternalTextures;
  27754. private _rebuildEffects;
  27755. /**
  27756. * Gets a boolean indicating if all created effects are ready
  27757. * @returns true if all effects are ready
  27758. */
  27759. areAllEffectsReady(): boolean;
  27760. private _rebuildBuffers;
  27761. private _initGLContext;
  27762. /**
  27763. * Gets version of the current webGL context
  27764. */
  27765. readonly webGLVersion: number;
  27766. /**
  27767. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27768. */
  27769. readonly isStencilEnable: boolean;
  27770. /** @hidden */
  27771. _prepareWorkingCanvas(): void;
  27772. /**
  27773. * Reset the texture cache to empty state
  27774. */
  27775. resetTextureCache(): void;
  27776. /**
  27777. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27778. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27779. * @returns true if engine is in deterministic lock step mode
  27780. */
  27781. isDeterministicLockStep(): boolean;
  27782. /**
  27783. * Gets the max steps when engine is running in deterministic lock step
  27784. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27785. * @returns the max steps
  27786. */
  27787. getLockstepMaxSteps(): number;
  27788. /**
  27789. * Gets an object containing information about the current webGL context
  27790. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27791. */
  27792. getGlInfo(): {
  27793. vendor: string;
  27794. renderer: string;
  27795. version: string;
  27796. };
  27797. /**
  27798. * Gets current aspect ratio
  27799. * @param camera defines the camera to use to get the aspect ratio
  27800. * @param useScreen defines if screen size must be used (or the current render target if any)
  27801. * @returns a number defining the aspect ratio
  27802. */
  27803. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27804. /**
  27805. * Gets current screen aspect ratio
  27806. * @returns a number defining the aspect ratio
  27807. */
  27808. getScreenAspectRatio(): number;
  27809. /**
  27810. * Gets the current render width
  27811. * @param useScreen defines if screen size must be used (or the current render target if any)
  27812. * @returns a number defining the current render width
  27813. */
  27814. getRenderWidth(useScreen?: boolean): number;
  27815. /**
  27816. * Gets the current render height
  27817. * @param useScreen defines if screen size must be used (or the current render target if any)
  27818. * @returns a number defining the current render height
  27819. */
  27820. getRenderHeight(useScreen?: boolean): number;
  27821. /**
  27822. * Gets the HTML canvas attached with the current webGL context
  27823. * @returns a HTML canvas
  27824. */
  27825. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27826. /**
  27827. * Gets the client rect of the HTML canvas attached with the current webGL context
  27828. * @returns a client rectanglee
  27829. */
  27830. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27831. /**
  27832. * Defines the hardware scaling level.
  27833. * By default the hardware scaling level is computed from the window device ratio.
  27834. * 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.
  27835. * @param level defines the level to use
  27836. */
  27837. setHardwareScalingLevel(level: number): void;
  27838. /**
  27839. * Gets the current hardware scaling level.
  27840. * By default the hardware scaling level is computed from the window device ratio.
  27841. * 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.
  27842. * @returns a number indicating the current hardware scaling level
  27843. */
  27844. getHardwareScalingLevel(): number;
  27845. /**
  27846. * Gets the list of loaded textures
  27847. * @returns an array containing all loaded textures
  27848. */
  27849. getLoadedTexturesCache(): InternalTexture[];
  27850. /**
  27851. * Gets the object containing all engine capabilities
  27852. * @returns the EngineCapabilities object
  27853. */
  27854. getCaps(): EngineCapabilities;
  27855. /**
  27856. * Gets the current depth function
  27857. * @returns a number defining the depth function
  27858. */
  27859. getDepthFunction(): Nullable<number>;
  27860. /**
  27861. * Sets the current depth function
  27862. * @param depthFunc defines the function to use
  27863. */
  27864. setDepthFunction(depthFunc: number): void;
  27865. /**
  27866. * Sets the current depth function to GREATER
  27867. */
  27868. setDepthFunctionToGreater(): void;
  27869. /**
  27870. * Sets the current depth function to GEQUAL
  27871. */
  27872. setDepthFunctionToGreaterOrEqual(): void;
  27873. /**
  27874. * Sets the current depth function to LESS
  27875. */
  27876. setDepthFunctionToLess(): void;
  27877. private _cachedStencilBuffer;
  27878. private _cachedStencilFunction;
  27879. private _cachedStencilMask;
  27880. private _cachedStencilOperationPass;
  27881. private _cachedStencilOperationFail;
  27882. private _cachedStencilOperationDepthFail;
  27883. private _cachedStencilReference;
  27884. /**
  27885. * Caches the the state of the stencil buffer
  27886. */
  27887. cacheStencilState(): void;
  27888. /**
  27889. * Restores the state of the stencil buffer
  27890. */
  27891. restoreStencilState(): void;
  27892. /**
  27893. * Sets the current depth function to LEQUAL
  27894. */
  27895. setDepthFunctionToLessOrEqual(): void;
  27896. /**
  27897. * Gets a boolean indicating if stencil buffer is enabled
  27898. * @returns the current stencil buffer state
  27899. */
  27900. getStencilBuffer(): boolean;
  27901. /**
  27902. * Enable or disable the stencil buffer
  27903. * @param enable defines if the stencil buffer must be enabled or disabled
  27904. */
  27905. setStencilBuffer(enable: boolean): void;
  27906. /**
  27907. * Gets the current stencil mask
  27908. * @returns a number defining the new stencil mask to use
  27909. */
  27910. getStencilMask(): number;
  27911. /**
  27912. * Sets the current stencil mask
  27913. * @param mask defines the new stencil mask to use
  27914. */
  27915. setStencilMask(mask: number): void;
  27916. /**
  27917. * Gets the current stencil function
  27918. * @returns a number defining the stencil function to use
  27919. */
  27920. getStencilFunction(): number;
  27921. /**
  27922. * Gets the current stencil reference value
  27923. * @returns a number defining the stencil reference value to use
  27924. */
  27925. getStencilFunctionReference(): number;
  27926. /**
  27927. * Gets the current stencil mask
  27928. * @returns a number defining the stencil mask to use
  27929. */
  27930. getStencilFunctionMask(): number;
  27931. /**
  27932. * Sets the current stencil function
  27933. * @param stencilFunc defines the new stencil function to use
  27934. */
  27935. setStencilFunction(stencilFunc: number): void;
  27936. /**
  27937. * Sets the current stencil reference
  27938. * @param reference defines the new stencil reference to use
  27939. */
  27940. setStencilFunctionReference(reference: number): void;
  27941. /**
  27942. * Sets the current stencil mask
  27943. * @param mask defines the new stencil mask to use
  27944. */
  27945. setStencilFunctionMask(mask: number): void;
  27946. /**
  27947. * Gets the current stencil operation when stencil fails
  27948. * @returns a number defining stencil operation to use when stencil fails
  27949. */
  27950. getStencilOperationFail(): number;
  27951. /**
  27952. * Gets the current stencil operation when depth fails
  27953. * @returns a number defining stencil operation to use when depth fails
  27954. */
  27955. getStencilOperationDepthFail(): number;
  27956. /**
  27957. * Gets the current stencil operation when stencil passes
  27958. * @returns a number defining stencil operation to use when stencil passes
  27959. */
  27960. getStencilOperationPass(): number;
  27961. /**
  27962. * Sets the stencil operation to use when stencil fails
  27963. * @param operation defines the stencil operation to use when stencil fails
  27964. */
  27965. setStencilOperationFail(operation: number): void;
  27966. /**
  27967. * Sets the stencil operation to use when depth fails
  27968. * @param operation defines the stencil operation to use when depth fails
  27969. */
  27970. setStencilOperationDepthFail(operation: number): void;
  27971. /**
  27972. * Sets the stencil operation to use when stencil passes
  27973. * @param operation defines the stencil operation to use when stencil passes
  27974. */
  27975. setStencilOperationPass(operation: number): void;
  27976. /**
  27977. * Sets a boolean indicating if the dithering state is enabled or disabled
  27978. * @param value defines the dithering state
  27979. */
  27980. setDitheringState(value: boolean): void;
  27981. /**
  27982. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27983. * @param value defines the rasterizer state
  27984. */
  27985. setRasterizerState(value: boolean): void;
  27986. /**
  27987. * stop executing a render loop function and remove it from the execution array
  27988. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27989. */
  27990. stopRenderLoop(renderFunction?: () => void): void;
  27991. /** @hidden */
  27992. _renderLoop(): void;
  27993. /**
  27994. * Register and execute a render loop. The engine can have more than one render function
  27995. * @param renderFunction defines the function to continuously execute
  27996. */
  27997. runRenderLoop(renderFunction: () => void): void;
  27998. /**
  27999. * Toggle full screen mode
  28000. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28001. */
  28002. switchFullscreen(requestPointerLock: boolean): void;
  28003. /**
  28004. * Enters full screen mode
  28005. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28006. */
  28007. enterFullscreen(requestPointerLock: boolean): void;
  28008. /**
  28009. * Exits full screen mode
  28010. */
  28011. exitFullscreen(): void;
  28012. /**
  28013. * Clear the current render buffer or the current render target (if any is set up)
  28014. * @param color defines the color to use
  28015. * @param backBuffer defines if the back buffer must be cleared
  28016. * @param depth defines if the depth buffer must be cleared
  28017. * @param stencil defines if the stencil buffer must be cleared
  28018. */
  28019. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28020. /**
  28021. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28022. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28023. * @param y defines the y-coordinate of the corner of the clear rectangle
  28024. * @param width defines the width of the clear rectangle
  28025. * @param height defines the height of the clear rectangle
  28026. * @param clearColor defines the clear color
  28027. */
  28028. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28029. /**
  28030. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28031. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28032. * @param y defines the y-coordinate of the corner of the clear rectangle
  28033. * @param width defines the width of the clear rectangle
  28034. * @param height defines the height of the clear rectangle
  28035. */
  28036. enableScissor(x: number, y: number, width: number, height: number): void;
  28037. /**
  28038. * Disable previously set scissor test rectangle
  28039. */
  28040. disableScissor(): void;
  28041. private _viewportCached;
  28042. /** @hidden */
  28043. _viewport(x: number, y: number, width: number, height: number): void;
  28044. /**
  28045. * Set the WebGL's viewport
  28046. * @param viewport defines the viewport element to be used
  28047. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28048. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28049. */
  28050. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28051. /**
  28052. * Directly set the WebGL Viewport
  28053. * @param x defines the x coordinate of the viewport (in screen space)
  28054. * @param y defines the y coordinate of the viewport (in screen space)
  28055. * @param width defines the width of the viewport (in screen space)
  28056. * @param height defines the height of the viewport (in screen space)
  28057. * @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
  28058. */
  28059. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28060. /**
  28061. * Begin a new frame
  28062. */
  28063. beginFrame(): void;
  28064. /**
  28065. * Enf the current frame
  28066. */
  28067. endFrame(): void;
  28068. /**
  28069. * Resize the view according to the canvas' size
  28070. */
  28071. resize(): void;
  28072. /**
  28073. * Force a specific size of the canvas
  28074. * @param width defines the new canvas' width
  28075. * @param height defines the new canvas' height
  28076. */
  28077. setSize(width: number, height: number): void;
  28078. /**
  28079. * Binds the frame buffer to the specified texture.
  28080. * @param texture The texture to render to or null for the default canvas
  28081. * @param faceIndex The face of the texture to render to in case of cube texture
  28082. * @param requiredWidth The width of the target to render to
  28083. * @param requiredHeight The height of the target to render to
  28084. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28085. * @param depthStencilTexture The depth stencil texture to use to render
  28086. * @param lodLevel defines le lod level to bind to the frame buffer
  28087. */
  28088. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28089. /** @hidden */
  28090. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28091. /**
  28092. * Unbind the current render target texture from the webGL context
  28093. * @param texture defines the render target texture to unbind
  28094. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28095. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28096. */
  28097. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28098. /**
  28099. * Force the mipmap generation for the given render target texture
  28100. * @param texture defines the render target texture to use
  28101. */
  28102. generateMipMapsForCubemap(texture: InternalTexture): void;
  28103. /**
  28104. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28105. */
  28106. flushFramebuffer(): void;
  28107. /**
  28108. * Unbind the current render target and bind the default framebuffer
  28109. */
  28110. restoreDefaultFramebuffer(): void;
  28111. /**
  28112. * Create an uniform buffer
  28113. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28114. * @param elements defines the content of the uniform buffer
  28115. * @returns the webGL uniform buffer
  28116. */
  28117. createUniformBuffer(elements: FloatArray): DataBuffer;
  28118. /**
  28119. * Create a dynamic uniform buffer
  28120. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28121. * @param elements defines the content of the uniform buffer
  28122. * @returns the webGL uniform buffer
  28123. */
  28124. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28125. /**
  28126. * Update an existing uniform buffer
  28127. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28128. * @param uniformBuffer defines the target uniform buffer
  28129. * @param elements defines the content to update
  28130. * @param offset defines the offset in the uniform buffer where update should start
  28131. * @param count defines the size of the data to update
  28132. */
  28133. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28134. private _resetVertexBufferBinding;
  28135. /**
  28136. * Creates a vertex buffer
  28137. * @param data the data for the vertex buffer
  28138. * @returns the new WebGL static buffer
  28139. */
  28140. createVertexBuffer(data: DataArray): DataBuffer;
  28141. /**
  28142. * Creates a dynamic vertex buffer
  28143. * @param data the data for the dynamic vertex buffer
  28144. * @returns the new WebGL dynamic buffer
  28145. */
  28146. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28147. /**
  28148. * Update a dynamic index buffer
  28149. * @param indexBuffer defines the target index buffer
  28150. * @param indices defines the data to update
  28151. * @param offset defines the offset in the target index buffer where update should start
  28152. */
  28153. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28154. /**
  28155. * Updates a dynamic vertex buffer.
  28156. * @param vertexBuffer the vertex buffer to update
  28157. * @param data the data used to update the vertex buffer
  28158. * @param byteOffset the byte offset of the data
  28159. * @param byteLength the byte length of the data
  28160. */
  28161. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28162. private _resetIndexBufferBinding;
  28163. /**
  28164. * Creates a new index buffer
  28165. * @param indices defines the content of the index buffer
  28166. * @param updatable defines if the index buffer must be updatable
  28167. * @returns a new webGL buffer
  28168. */
  28169. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28170. /**
  28171. * Bind a webGL buffer to the webGL context
  28172. * @param buffer defines the buffer to bind
  28173. */
  28174. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28175. /**
  28176. * Bind an uniform buffer to the current webGL context
  28177. * @param buffer defines the buffer to bind
  28178. */
  28179. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28180. /**
  28181. * Bind a buffer to the current webGL context at a given location
  28182. * @param buffer defines the buffer to bind
  28183. * @param location defines the index where to bind the buffer
  28184. */
  28185. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28186. /**
  28187. * Bind a specific block at a given index in a specific shader program
  28188. * @param pipelineContext defines the pipeline context to use
  28189. * @param blockName defines the block name
  28190. * @param index defines the index where to bind the block
  28191. */
  28192. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28193. private bindIndexBuffer;
  28194. private bindBuffer;
  28195. /**
  28196. * update the bound buffer with the given data
  28197. * @param data defines the data to update
  28198. */
  28199. updateArrayBuffer(data: Float32Array): void;
  28200. private _vertexAttribPointer;
  28201. private _bindIndexBufferWithCache;
  28202. private _bindVertexBuffersAttributes;
  28203. /**
  28204. * Records a vertex array object
  28205. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28206. * @param vertexBuffers defines the list of vertex buffers to store
  28207. * @param indexBuffer defines the index buffer to store
  28208. * @param effect defines the effect to store
  28209. * @returns the new vertex array object
  28210. */
  28211. recordVertexArrayObject(vertexBuffers: {
  28212. [key: string]: VertexBuffer;
  28213. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28214. /**
  28215. * Bind a specific vertex array object
  28216. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28217. * @param vertexArrayObject defines the vertex array object to bind
  28218. * @param indexBuffer defines the index buffer to bind
  28219. */
  28220. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28221. /**
  28222. * Bind webGl buffers directly to the webGL context
  28223. * @param vertexBuffer defines the vertex buffer to bind
  28224. * @param indexBuffer defines the index buffer to bind
  28225. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28226. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28227. * @param effect defines the effect associated with the vertex buffer
  28228. */
  28229. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28230. private _unbindVertexArrayObject;
  28231. /**
  28232. * Bind a list of vertex buffers to the webGL context
  28233. * @param vertexBuffers defines the list of vertex buffers to bind
  28234. * @param indexBuffer defines the index buffer to bind
  28235. * @param effect defines the effect associated with the vertex buffers
  28236. */
  28237. bindBuffers(vertexBuffers: {
  28238. [key: string]: Nullable<VertexBuffer>;
  28239. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28240. /**
  28241. * Unbind all instance attributes
  28242. */
  28243. unbindInstanceAttributes(): void;
  28244. /**
  28245. * Release and free the memory of a vertex array object
  28246. * @param vao defines the vertex array object to delete
  28247. */
  28248. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28249. /** @hidden */
  28250. _releaseBuffer(buffer: DataBuffer): boolean;
  28251. /**
  28252. * Creates a webGL buffer to use with instanciation
  28253. * @param capacity defines the size of the buffer
  28254. * @returns the webGL buffer
  28255. */
  28256. createInstancesBuffer(capacity: number): DataBuffer;
  28257. /**
  28258. * Delete a webGL buffer used with instanciation
  28259. * @param buffer defines the webGL buffer to delete
  28260. */
  28261. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28262. /**
  28263. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28264. * @param instancesBuffer defines the webGL buffer to update and bind
  28265. * @param data defines the data to store in the buffer
  28266. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28267. */
  28268. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28269. /**
  28270. * Apply all cached states (depth, culling, stencil and alpha)
  28271. */
  28272. applyStates(): void;
  28273. /**
  28274. * Send a draw order
  28275. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28276. * @param indexStart defines the starting index
  28277. * @param indexCount defines the number of index to draw
  28278. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28279. */
  28280. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28281. /**
  28282. * Draw a list of points
  28283. * @param verticesStart defines the index of first vertex to draw
  28284. * @param verticesCount defines the count of vertices to draw
  28285. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28286. */
  28287. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28288. /**
  28289. * Draw a list of unindexed primitives
  28290. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28291. * @param verticesStart defines the index of first vertex to draw
  28292. * @param verticesCount defines the count of vertices to draw
  28293. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28294. */
  28295. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28296. /**
  28297. * Draw a list of indexed primitives
  28298. * @param fillMode defines the primitive to use
  28299. * @param indexStart defines the starting index
  28300. * @param indexCount defines the number of index to draw
  28301. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28302. */
  28303. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28304. /**
  28305. * Draw a list of unindexed primitives
  28306. * @param fillMode defines the primitive to use
  28307. * @param verticesStart defines the index of first vertex to draw
  28308. * @param verticesCount defines the count of vertices to draw
  28309. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28310. */
  28311. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28312. private _drawMode;
  28313. /** @hidden */
  28314. _releaseEffect(effect: Effect): void;
  28315. /** @hidden */
  28316. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  28317. /**
  28318. * Create a new effect (used to store vertex/fragment shaders)
  28319. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28320. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28321. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28322. * @param samplers defines an array of string used to represent textures
  28323. * @param defines defines the string containing the defines to use to compile the shaders
  28324. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28325. * @param onCompiled defines a function to call when the effect creation is successful
  28326. * @param onError defines a function to call when the effect creation has failed
  28327. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28328. * @returns the new Effect
  28329. */
  28330. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  28331. private _compileShader;
  28332. private _compileRawShader;
  28333. /**
  28334. * Directly creates a webGL program
  28335. * @param pipelineContext defines the pipeline context to attach to
  28336. * @param vertexCode defines the vertex shader code to use
  28337. * @param fragmentCode defines the fragment shader code to use
  28338. * @param context defines the webGL context to use (if not set, the current one will be used)
  28339. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28340. * @returns the new webGL program
  28341. */
  28342. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28343. /**
  28344. * Creates a webGL program
  28345. * @param pipelineContext defines the pipeline context to attach to
  28346. * @param vertexCode defines the vertex shader code to use
  28347. * @param fragmentCode defines the fragment shader code to use
  28348. * @param defines defines the string containing the defines to use to compile the shaders
  28349. * @param context defines the webGL context to use (if not set, the current one will be used)
  28350. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28351. * @returns the new webGL program
  28352. */
  28353. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28354. /**
  28355. * Creates a new pipeline context
  28356. * @returns the new pipeline
  28357. */
  28358. createPipelineContext(): WebGLPipelineContext;
  28359. private _createShaderProgram;
  28360. private _finalizePipelineContext;
  28361. /** @hidden */
  28362. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  28363. /** @hidden */
  28364. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  28365. /** @hidden */
  28366. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  28367. /**
  28368. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28369. * @param pipelineContext defines the pipeline context to use
  28370. * @param uniformsNames defines the list of uniform names
  28371. * @returns an array of webGL uniform locations
  28372. */
  28373. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28374. /**
  28375. * Gets the lsit of active attributes for a given webGL program
  28376. * @param pipelineContext defines the pipeline context to use
  28377. * @param attributesNames defines the list of attribute names to get
  28378. * @returns an array of indices indicating the offset of each attribute
  28379. */
  28380. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  28381. /**
  28382. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28383. * @param effect defines the effect to activate
  28384. */
  28385. enableEffect(effect: Nullable<Effect>): void;
  28386. /**
  28387. * Set the value of an uniform to an array of int32
  28388. * @param uniform defines the webGL uniform location where to store the value
  28389. * @param array defines the array of int32 to store
  28390. */
  28391. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28392. /**
  28393. * Set the value of an uniform to an array of int32 (stored as vec2)
  28394. * @param uniform defines the webGL uniform location where to store the value
  28395. * @param array defines the array of int32 to store
  28396. */
  28397. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28398. /**
  28399. * Set the value of an uniform to an array of int32 (stored as vec3)
  28400. * @param uniform defines the webGL uniform location where to store the value
  28401. * @param array defines the array of int32 to store
  28402. */
  28403. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28404. /**
  28405. * Set the value of an uniform to an array of int32 (stored as vec4)
  28406. * @param uniform defines the webGL uniform location where to store the value
  28407. * @param array defines the array of int32 to store
  28408. */
  28409. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28410. /**
  28411. * Set the value of an uniform to an array of float32
  28412. * @param uniform defines the webGL uniform location where to store the value
  28413. * @param array defines the array of float32 to store
  28414. */
  28415. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28416. /**
  28417. * Set the value of an uniform to an array of float32 (stored as vec2)
  28418. * @param uniform defines the webGL uniform location where to store the value
  28419. * @param array defines the array of float32 to store
  28420. */
  28421. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28422. /**
  28423. * Set the value of an uniform to an array of float32 (stored as vec3)
  28424. * @param uniform defines the webGL uniform location where to store the value
  28425. * @param array defines the array of float32 to store
  28426. */
  28427. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28428. /**
  28429. * Set the value of an uniform to an array of float32 (stored as vec4)
  28430. * @param uniform defines the webGL uniform location where to store the value
  28431. * @param array defines the array of float32 to store
  28432. */
  28433. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28434. /**
  28435. * Set the value of an uniform to an array of number
  28436. * @param uniform defines the webGL uniform location where to store the value
  28437. * @param array defines the array of number to store
  28438. */
  28439. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28440. /**
  28441. * Set the value of an uniform to an array of number (stored as vec2)
  28442. * @param uniform defines the webGL uniform location where to store the value
  28443. * @param array defines the array of number to store
  28444. */
  28445. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28446. /**
  28447. * Set the value of an uniform to an array of number (stored as vec3)
  28448. * @param uniform defines the webGL uniform location where to store the value
  28449. * @param array defines the array of number to store
  28450. */
  28451. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28452. /**
  28453. * Set the value of an uniform to an array of number (stored as vec4)
  28454. * @param uniform defines the webGL uniform location where to store the value
  28455. * @param array defines the array of number to store
  28456. */
  28457. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28458. /**
  28459. * Set the value of an uniform to an array of float32 (stored as matrices)
  28460. * @param uniform defines the webGL uniform location where to store the value
  28461. * @param matrices defines the array of float32 to store
  28462. */
  28463. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28464. /**
  28465. * Set the value of an uniform to a matrix
  28466. * @param uniform defines the webGL uniform location where to store the value
  28467. * @param matrix defines the matrix to store
  28468. */
  28469. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28470. /**
  28471. * Set the value of an uniform to a matrix (3x3)
  28472. * @param uniform defines the webGL uniform location where to store the value
  28473. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28474. */
  28475. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28476. /**
  28477. * Set the value of an uniform to a matrix (2x2)
  28478. * @param uniform defines the webGL uniform location where to store the value
  28479. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28480. */
  28481. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28482. /**
  28483. * Set the value of an uniform to a number (int)
  28484. * @param uniform defines the webGL uniform location where to store the value
  28485. * @param value defines the int number to store
  28486. */
  28487. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28488. /**
  28489. * Set the value of an uniform to a number (float)
  28490. * @param uniform defines the webGL uniform location where to store the value
  28491. * @param value defines the float number to store
  28492. */
  28493. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28494. /**
  28495. * Set the value of an uniform to a vec2
  28496. * @param uniform defines the webGL uniform location where to store the value
  28497. * @param x defines the 1st component of the value
  28498. * @param y defines the 2nd component of the value
  28499. */
  28500. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28501. /**
  28502. * Set the value of an uniform to a vec3
  28503. * @param uniform defines the webGL uniform location where to store the value
  28504. * @param x defines the 1st component of the value
  28505. * @param y defines the 2nd component of the value
  28506. * @param z defines the 3rd component of the value
  28507. */
  28508. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28509. /**
  28510. * Set the value of an uniform to a boolean
  28511. * @param uniform defines the webGL uniform location where to store the value
  28512. * @param bool defines the boolean to store
  28513. */
  28514. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28515. /**
  28516. * Set the value of an uniform to a vec4
  28517. * @param uniform defines the webGL uniform location where to store the value
  28518. * @param x defines the 1st component of the value
  28519. * @param y defines the 2nd component of the value
  28520. * @param z defines the 3rd component of the value
  28521. * @param w defines the 4th component of the value
  28522. */
  28523. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28524. /**
  28525. * Set the value of an uniform to a Color3
  28526. * @param uniform defines the webGL uniform location where to store the value
  28527. * @param color3 defines the color to store
  28528. */
  28529. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28530. /**
  28531. * Set the value of an uniform to a Color3 and an alpha value
  28532. * @param uniform defines the webGL uniform location where to store the value
  28533. * @param color3 defines the color to store
  28534. * @param alpha defines the alpha component to store
  28535. */
  28536. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28537. /**
  28538. * Sets a Color4 on a uniform variable
  28539. * @param uniform defines the uniform location
  28540. * @param color4 defines the value to be set
  28541. */
  28542. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28543. /**
  28544. * Set various states to the webGL context
  28545. * @param culling defines backface culling state
  28546. * @param zOffset defines the value to apply to zOffset (0 by default)
  28547. * @param force defines if states must be applied even if cache is up to date
  28548. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28549. */
  28550. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28551. /**
  28552. * Set the z offset to apply to current rendering
  28553. * @param value defines the offset to apply
  28554. */
  28555. setZOffset(value: number): void;
  28556. /**
  28557. * Gets the current value of the zOffset
  28558. * @returns the current zOffset state
  28559. */
  28560. getZOffset(): number;
  28561. /**
  28562. * Enable or disable depth buffering
  28563. * @param enable defines the state to set
  28564. */
  28565. setDepthBuffer(enable: boolean): void;
  28566. /**
  28567. * Gets a boolean indicating if depth writing is enabled
  28568. * @returns the current depth writing state
  28569. */
  28570. getDepthWrite(): boolean;
  28571. /**
  28572. * Enable or disable depth writing
  28573. * @param enable defines the state to set
  28574. */
  28575. setDepthWrite(enable: boolean): void;
  28576. /**
  28577. * Enable or disable color writing
  28578. * @param enable defines the state to set
  28579. */
  28580. setColorWrite(enable: boolean): void;
  28581. /**
  28582. * Gets a boolean indicating if color writing is enabled
  28583. * @returns the current color writing state
  28584. */
  28585. getColorWrite(): boolean;
  28586. /**
  28587. * Sets alpha constants used by some alpha blending modes
  28588. * @param r defines the red component
  28589. * @param g defines the green component
  28590. * @param b defines the blue component
  28591. * @param a defines the alpha component
  28592. */
  28593. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28594. /**
  28595. * Sets the current alpha mode
  28596. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28597. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28598. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28599. */
  28600. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28601. /**
  28602. * Gets the current alpha mode
  28603. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28604. * @returns the current alpha mode
  28605. */
  28606. getAlphaMode(): number;
  28607. /**
  28608. * Clears the list of texture accessible through engine.
  28609. * This can help preventing texture load conflict due to name collision.
  28610. */
  28611. clearInternalTexturesCache(): void;
  28612. /**
  28613. * Force the entire cache to be cleared
  28614. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28615. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28616. */
  28617. wipeCaches(bruteForce?: boolean): void;
  28618. /**
  28619. * Set the compressed texture format to use, based on the formats you have, and the formats
  28620. * supported by the hardware / browser.
  28621. *
  28622. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28623. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28624. * to API arguments needed to compressed textures. This puts the burden on the container
  28625. * generator to house the arcane code for determining these for current & future formats.
  28626. *
  28627. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28628. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28629. *
  28630. * Note: The result of this call is not taken into account when a texture is base64.
  28631. *
  28632. * @param formatsAvailable defines the list of those format families you have created
  28633. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28634. *
  28635. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28636. * @returns The extension selected.
  28637. */
  28638. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28639. /** @hidden */
  28640. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28641. min: number;
  28642. mag: number;
  28643. };
  28644. /** @hidden */
  28645. _createTexture(): WebGLTexture;
  28646. /**
  28647. * Usually called from Texture.ts.
  28648. * Passed information to create a WebGLTexture
  28649. * @param urlArg defines a value which contains one of the following:
  28650. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28651. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28652. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28653. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28654. * @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)
  28655. * @param scene needed for loading to the correct scene
  28656. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28657. * @param onLoad optional callback to be called upon successful completion
  28658. * @param onError optional callback to be called upon failure
  28659. * @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
  28660. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28661. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28662. * @param forcedExtension defines the extension to use to pick the right loader
  28663. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28664. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28665. */
  28666. 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 | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  28667. private _rescaleTexture;
  28668. private _unpackFlipYCached;
  28669. /**
  28670. * In case you are sharing the context with other applications, it might
  28671. * be interested to not cache the unpack flip y state to ensure a consistent
  28672. * value would be set.
  28673. */
  28674. enableUnpackFlipYCached: boolean;
  28675. /** @hidden */
  28676. _unpackFlipY(value: boolean): void;
  28677. /** @hidden */
  28678. _getUnpackAlignement(): number;
  28679. /**
  28680. * Creates a dynamic texture
  28681. * @param width defines the width of the texture
  28682. * @param height defines the height of the texture
  28683. * @param generateMipMaps defines if the engine should generate the mip levels
  28684. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28685. * @returns the dynamic texture inside an InternalTexture
  28686. */
  28687. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28688. /**
  28689. * Update the sampling mode of a given texture
  28690. * @param samplingMode defines the required sampling mode
  28691. * @param texture defines the texture to update
  28692. */
  28693. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28694. /**
  28695. * Update the content of a dynamic texture
  28696. * @param texture defines the texture to update
  28697. * @param canvas defines the canvas containing the source
  28698. * @param invertY defines if data must be stored with Y axis inverted
  28699. * @param premulAlpha defines if alpha is stored as premultiplied
  28700. * @param format defines the format of the data
  28701. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28702. */
  28703. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28704. /**
  28705. * Update a video texture
  28706. * @param texture defines the texture to update
  28707. * @param video defines the video element to use
  28708. * @param invertY defines if data must be stored with Y axis inverted
  28709. */
  28710. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28711. /**
  28712. * Updates a depth texture Comparison Mode and Function.
  28713. * If the comparison Function is equal to 0, the mode will be set to none.
  28714. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28715. * @param texture The texture to set the comparison function for
  28716. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28717. */
  28718. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28719. /** @hidden */
  28720. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  28721. width: number;
  28722. height: number;
  28723. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  28724. /**
  28725. * Creates a depth stencil texture.
  28726. * This is only available in WebGL 2 or with the depth texture extension available.
  28727. * @param size The size of face edge in the texture.
  28728. * @param options The options defining the texture.
  28729. * @returns The texture
  28730. */
  28731. createDepthStencilTexture(size: number | {
  28732. width: number;
  28733. height: number;
  28734. }, options: DepthTextureCreationOptions): InternalTexture;
  28735. /**
  28736. * Creates a depth stencil texture.
  28737. * This is only available in WebGL 2 or with the depth texture extension available.
  28738. * @param size The size of face edge in the texture.
  28739. * @param options The options defining the texture.
  28740. * @returns The texture
  28741. */
  28742. private _createDepthStencilTexture;
  28743. /**
  28744. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28745. * @param renderTarget The render target to set the frame buffer for
  28746. */
  28747. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28748. /**
  28749. * Creates a new render target texture
  28750. * @param size defines the size of the texture
  28751. * @param options defines the options used to create the texture
  28752. * @returns a new render target texture stored in an InternalTexture
  28753. */
  28754. createRenderTargetTexture(size: number | {
  28755. width: number;
  28756. height: number;
  28757. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28758. /** @hidden */
  28759. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  28760. /**
  28761. * Updates the sample count of a render target texture
  28762. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28763. * @param texture defines the texture to update
  28764. * @param samples defines the sample count to set
  28765. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28766. */
  28767. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28768. /** @hidden */
  28769. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28770. /** @hidden */
  28771. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28772. /** @hidden */
  28773. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28774. /** @hidden */
  28775. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28776. /**
  28777. * @hidden
  28778. */
  28779. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28780. private _prepareWebGLTextureContinuation;
  28781. private _prepareWebGLTexture;
  28782. /** @hidden */
  28783. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  28784. /** @hidden */
  28785. _releaseFramebufferObjects(texture: InternalTexture): void;
  28786. /** @hidden */
  28787. _releaseTexture(texture: InternalTexture): void;
  28788. private setProgram;
  28789. private _boundUniforms;
  28790. /**
  28791. * Binds an effect to the webGL context
  28792. * @param effect defines the effect to bind
  28793. */
  28794. bindSamplers(effect: Effect): void;
  28795. private _activateCurrentTexture;
  28796. /** @hidden */
  28797. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28798. /** @hidden */
  28799. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28800. /**
  28801. * Sets a texture to the webGL context from a postprocess
  28802. * @param channel defines the channel to use
  28803. * @param postProcess defines the source postprocess
  28804. */
  28805. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28806. /**
  28807. * Binds the output of the passed in post process to the texture channel specified
  28808. * @param channel The channel the texture should be bound to
  28809. * @param postProcess The post process which's output should be bound
  28810. */
  28811. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28812. /**
  28813. * Unbind all textures from the webGL context
  28814. */
  28815. unbindAllTextures(): void;
  28816. /**
  28817. * Sets a texture to the according uniform.
  28818. * @param channel The texture channel
  28819. * @param uniform The uniform to set
  28820. * @param texture The texture to apply
  28821. */
  28822. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28823. /**
  28824. * Sets a depth stencil texture from a render target to the according uniform.
  28825. * @param channel The texture channel
  28826. * @param uniform The uniform to set
  28827. * @param texture The render target texture containing the depth stencil texture to apply
  28828. */
  28829. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28830. private _bindSamplerUniformToChannel;
  28831. private _getTextureWrapMode;
  28832. private _setTexture;
  28833. /**
  28834. * Sets an array of texture to the webGL context
  28835. * @param channel defines the channel where the texture array must be set
  28836. * @param uniform defines the associated uniform location
  28837. * @param textures defines the array of textures to bind
  28838. */
  28839. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28840. /** @hidden */
  28841. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28842. private _setTextureParameterFloat;
  28843. private _setTextureParameterInteger;
  28844. /**
  28845. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28846. * @param x defines the x coordinate of the rectangle where pixels must be read
  28847. * @param y defines the y coordinate of the rectangle where pixels must be read
  28848. * @param width defines the width of the rectangle where pixels must be read
  28849. * @param height defines the height of the rectangle where pixels must be read
  28850. * @returns a Uint8Array containing RGBA colors
  28851. */
  28852. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28853. /**
  28854. * Add an externaly attached data from its key.
  28855. * This method call will fail and return false, if such key already exists.
  28856. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28857. * @param key the unique key that identifies the data
  28858. * @param data the data object to associate to the key for this Engine instance
  28859. * @return true if no such key were already present and the data was added successfully, false otherwise
  28860. */
  28861. addExternalData<T>(key: string, data: T): boolean;
  28862. /**
  28863. * Get an externaly attached data from its key
  28864. * @param key the unique key that identifies the data
  28865. * @return the associated data, if present (can be null), or undefined if not present
  28866. */
  28867. getExternalData<T>(key: string): T;
  28868. /**
  28869. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28870. * @param key the unique key that identifies the data
  28871. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28872. * @return the associated data, can be null if the factory returned null.
  28873. */
  28874. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28875. /**
  28876. * Remove an externaly attached data from the Engine instance
  28877. * @param key the unique key that identifies the data
  28878. * @return true if the data was successfully removed, false if it doesn't exist
  28879. */
  28880. removeExternalData(key: string): boolean;
  28881. /**
  28882. * Unbind all vertex attributes from the webGL context
  28883. */
  28884. unbindAllAttributes(): void;
  28885. /**
  28886. * 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
  28887. */
  28888. releaseEffects(): void;
  28889. /**
  28890. * Dispose and release all associated resources
  28891. */
  28892. dispose(): void;
  28893. /**
  28894. * Display the loading screen
  28895. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28896. */
  28897. displayLoadingUI(): void;
  28898. /**
  28899. * Hide the loading screen
  28900. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28901. */
  28902. hideLoadingUI(): void;
  28903. /**
  28904. * Gets the current loading screen object
  28905. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28906. */
  28907. /**
  28908. * Sets the current loading screen object
  28909. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28910. */
  28911. loadingScreen: ILoadingScreen;
  28912. /**
  28913. * Sets the current loading screen text
  28914. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28915. */
  28916. loadingUIText: string;
  28917. /**
  28918. * Sets the current loading screen background color
  28919. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28920. */
  28921. loadingUIBackgroundColor: string;
  28922. /**
  28923. * Attach a new callback raised when context lost event is fired
  28924. * @param callback defines the callback to call
  28925. */
  28926. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28927. /**
  28928. * Attach a new callback raised when context restored event is fired
  28929. * @param callback defines the callback to call
  28930. */
  28931. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28932. /**
  28933. * Gets the source code of the vertex shader associated with a specific webGL program
  28934. * @param program defines the program to use
  28935. * @returns a string containing the source code of the vertex shader associated with the program
  28936. */
  28937. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28938. /**
  28939. * Gets the source code of the fragment shader associated with a specific webGL program
  28940. * @param program defines the program to use
  28941. * @returns a string containing the source code of the fragment shader associated with the program
  28942. */
  28943. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28944. /**
  28945. * Get the current error code of the webGL context
  28946. * @returns the error code
  28947. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28948. */
  28949. getError(): number;
  28950. /**
  28951. * Gets the current framerate
  28952. * @returns a number representing the framerate
  28953. */
  28954. getFps(): number;
  28955. /**
  28956. * Gets the time spent between current and previous frame
  28957. * @returns a number representing the delta time in ms
  28958. */
  28959. getDeltaTime(): number;
  28960. private _measureFps;
  28961. /** @hidden */
  28962. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28963. private _canRenderToFloatFramebuffer;
  28964. private _canRenderToHalfFloatFramebuffer;
  28965. private _canRenderToFramebuffer;
  28966. /** @hidden */
  28967. _getWebGLTextureType(type: number): number;
  28968. /** @hidden */
  28969. _getInternalFormat(format: number): number;
  28970. /** @hidden */
  28971. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28972. /** @hidden */
  28973. _getRGBAMultiSampleBufferFormat(type: number): number;
  28974. /** @hidden */
  28975. _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;
  28976. /** @hidden */
  28977. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28978. /**
  28979. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28980. * @returns true if the engine can be created
  28981. * @ignorenaming
  28982. */
  28983. static isSupported(): boolean;
  28984. }
  28985. }
  28986. declare module BABYLON {
  28987. /**
  28988. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28989. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28990. */
  28991. export class EffectFallbacks {
  28992. private _defines;
  28993. private _currentRank;
  28994. private _maxRank;
  28995. private _mesh;
  28996. /**
  28997. * Removes the fallback from the bound mesh.
  28998. */
  28999. unBindMesh(): void;
  29000. /**
  29001. * Adds a fallback on the specified property.
  29002. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29003. * @param define The name of the define in the shader
  29004. */
  29005. addFallback(rank: number, define: string): void;
  29006. /**
  29007. * Sets the mesh to use CPU skinning when needing to fallback.
  29008. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29009. * @param mesh The mesh to use the fallbacks.
  29010. */
  29011. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29012. /**
  29013. * Checks to see if more fallbacks are still availible.
  29014. */
  29015. readonly isMoreFallbacks: boolean;
  29016. /**
  29017. * Removes the defines that shoould be removed when falling back.
  29018. * @param currentDefines defines the current define statements for the shader.
  29019. * @param effect defines the current effect we try to compile
  29020. * @returns The resulting defines with defines of the current rank removed.
  29021. */
  29022. reduce(currentDefines: string, effect: Effect): string;
  29023. }
  29024. /**
  29025. * Options to be used when creating an effect.
  29026. */
  29027. export class EffectCreationOptions {
  29028. /**
  29029. * Atrributes that will be used in the shader.
  29030. */
  29031. attributes: string[];
  29032. /**
  29033. * Uniform varible names that will be set in the shader.
  29034. */
  29035. uniformsNames: string[];
  29036. /**
  29037. * Uniform buffer varible names that will be set in the shader.
  29038. */
  29039. uniformBuffersNames: string[];
  29040. /**
  29041. * Sampler texture variable names that will be set in the shader.
  29042. */
  29043. samplers: string[];
  29044. /**
  29045. * Define statements that will be set in the shader.
  29046. */
  29047. defines: any;
  29048. /**
  29049. * Possible fallbacks for this effect to improve performance when needed.
  29050. */
  29051. fallbacks: Nullable<EffectFallbacks>;
  29052. /**
  29053. * Callback that will be called when the shader is compiled.
  29054. */
  29055. onCompiled: Nullable<(effect: Effect) => void>;
  29056. /**
  29057. * Callback that will be called if an error occurs during shader compilation.
  29058. */
  29059. onError: Nullable<(effect: Effect, errors: string) => void>;
  29060. /**
  29061. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29062. */
  29063. indexParameters: any;
  29064. /**
  29065. * Max number of lights that can be used in the shader.
  29066. */
  29067. maxSimultaneousLights: number;
  29068. /**
  29069. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29070. */
  29071. transformFeedbackVaryings: Nullable<string[]>;
  29072. }
  29073. /**
  29074. * Effect containing vertex and fragment shader that can be executed on an object.
  29075. */
  29076. export class Effect implements IDisposable {
  29077. /**
  29078. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29079. */
  29080. static ShadersRepository: string;
  29081. /**
  29082. * Name of the effect.
  29083. */
  29084. name: any;
  29085. /**
  29086. * String container all the define statements that should be set on the shader.
  29087. */
  29088. defines: string;
  29089. /**
  29090. * Callback that will be called when the shader is compiled.
  29091. */
  29092. onCompiled: Nullable<(effect: Effect) => void>;
  29093. /**
  29094. * Callback that will be called if an error occurs during shader compilation.
  29095. */
  29096. onError: Nullable<(effect: Effect, errors: string) => void>;
  29097. /**
  29098. * Callback that will be called when effect is bound.
  29099. */
  29100. onBind: Nullable<(effect: Effect) => void>;
  29101. /**
  29102. * Unique ID of the effect.
  29103. */
  29104. uniqueId: number;
  29105. /**
  29106. * Observable that will be called when the shader is compiled.
  29107. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29108. */
  29109. onCompileObservable: Observable<Effect>;
  29110. /**
  29111. * Observable that will be called if an error occurs during shader compilation.
  29112. */
  29113. onErrorObservable: Observable<Effect>;
  29114. /** @hidden */
  29115. _onBindObservable: Nullable<Observable<Effect>>;
  29116. /**
  29117. * Observable that will be called when effect is bound.
  29118. */
  29119. readonly onBindObservable: Observable<Effect>;
  29120. /** @hidden */
  29121. _bonesComputationForcedToCPU: boolean;
  29122. private static _uniqueIdSeed;
  29123. private _engine;
  29124. private _uniformBuffersNames;
  29125. private _uniformsNames;
  29126. private _samplerList;
  29127. private _samplers;
  29128. private _isReady;
  29129. private _compilationError;
  29130. private _attributesNames;
  29131. private _attributes;
  29132. private _uniforms;
  29133. /**
  29134. * Key for the effect.
  29135. * @hidden
  29136. */
  29137. _key: string;
  29138. private _indexParameters;
  29139. private _fallbacks;
  29140. private _vertexSourceCode;
  29141. private _fragmentSourceCode;
  29142. private _vertexSourceCodeOverride;
  29143. private _fragmentSourceCodeOverride;
  29144. private _transformFeedbackVaryings;
  29145. /**
  29146. * Compiled shader to webGL program.
  29147. * @hidden
  29148. */
  29149. _pipelineContext: IPipelineContext;
  29150. private _valueCache;
  29151. private static _baseCache;
  29152. /**
  29153. * Instantiates an effect.
  29154. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29155. * @param baseName Name of the effect.
  29156. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29157. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29158. * @param samplers List of sampler variables that will be passed to the shader.
  29159. * @param engine Engine to be used to render the effect
  29160. * @param defines Define statements to be added to the shader.
  29161. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29162. * @param onCompiled Callback that will be called when the shader is compiled.
  29163. * @param onError Callback that will be called if an error occurs during shader compilation.
  29164. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29165. */
  29166. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29167. /**
  29168. * Unique key for this effect
  29169. */
  29170. readonly key: string;
  29171. /**
  29172. * If the effect has been compiled and prepared.
  29173. * @returns if the effect is compiled and prepared.
  29174. */
  29175. isReady(): boolean;
  29176. /**
  29177. * The engine the effect was initialized with.
  29178. * @returns the engine.
  29179. */
  29180. getEngine(): Engine;
  29181. /**
  29182. * The pipeline context for this effect
  29183. * @returns the associated pipeline context
  29184. */
  29185. getPipelineContext(): IPipelineContext;
  29186. /**
  29187. * The set of names of attribute variables for the shader.
  29188. * @returns An array of attribute names.
  29189. */
  29190. getAttributesNames(): string[];
  29191. /**
  29192. * Returns the attribute at the given index.
  29193. * @param index The index of the attribute.
  29194. * @returns The location of the attribute.
  29195. */
  29196. getAttributeLocation(index: number): number;
  29197. /**
  29198. * Returns the attribute based on the name of the variable.
  29199. * @param name of the attribute to look up.
  29200. * @returns the attribute location.
  29201. */
  29202. getAttributeLocationByName(name: string): number;
  29203. /**
  29204. * The number of attributes.
  29205. * @returns the numnber of attributes.
  29206. */
  29207. getAttributesCount(): number;
  29208. /**
  29209. * Gets the index of a uniform variable.
  29210. * @param uniformName of the uniform to look up.
  29211. * @returns the index.
  29212. */
  29213. getUniformIndex(uniformName: string): number;
  29214. /**
  29215. * Returns the attribute based on the name of the variable.
  29216. * @param uniformName of the uniform to look up.
  29217. * @returns the location of the uniform.
  29218. */
  29219. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29220. /**
  29221. * Returns an array of sampler variable names
  29222. * @returns The array of sampler variable neames.
  29223. */
  29224. getSamplers(): string[];
  29225. /**
  29226. * The error from the last compilation.
  29227. * @returns the error string.
  29228. */
  29229. getCompilationError(): string;
  29230. /**
  29231. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29232. * @param func The callback to be used.
  29233. */
  29234. executeWhenCompiled(func: (effect: Effect) => void): void;
  29235. private _checkIsReady;
  29236. /** @hidden */
  29237. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29238. /** @hidden */
  29239. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29240. /** @hidden */
  29241. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29242. private _processShaderConversion;
  29243. private _processIncludes;
  29244. private _processPrecision;
  29245. /**
  29246. * Recompiles the webGL program
  29247. * @param vertexSourceCode The source code for the vertex shader.
  29248. * @param fragmentSourceCode The source code for the fragment shader.
  29249. * @param onCompiled Callback called when completed.
  29250. * @param onError Callback called on error.
  29251. * @hidden
  29252. */
  29253. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29254. /**
  29255. * Prepares the effect
  29256. * @hidden
  29257. */
  29258. _prepareEffect(): void;
  29259. /**
  29260. * Checks if the effect is supported. (Must be called after compilation)
  29261. */
  29262. readonly isSupported: boolean;
  29263. /**
  29264. * Binds a texture to the engine to be used as output of the shader.
  29265. * @param channel Name of the output variable.
  29266. * @param texture Texture to bind.
  29267. * @hidden
  29268. */
  29269. _bindTexture(channel: string, texture: InternalTexture): void;
  29270. /**
  29271. * Sets a texture on the engine to be used in the shader.
  29272. * @param channel Name of the sampler variable.
  29273. * @param texture Texture to set.
  29274. */
  29275. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29276. /**
  29277. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29278. * @param channel Name of the sampler variable.
  29279. * @param texture Texture to set.
  29280. */
  29281. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29282. /**
  29283. * Sets an array of textures on the engine to be used in the shader.
  29284. * @param channel Name of the variable.
  29285. * @param textures Textures to set.
  29286. */
  29287. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29288. /**
  29289. * 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)
  29290. * @param channel Name of the sampler variable.
  29291. * @param postProcess Post process to get the input texture from.
  29292. */
  29293. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29294. /**
  29295. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29296. * 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)
  29297. * @param channel Name of the sampler variable.
  29298. * @param postProcess Post process to get the output texture from.
  29299. */
  29300. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29301. /** @hidden */
  29302. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29303. /** @hidden */
  29304. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29305. /** @hidden */
  29306. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29307. /** @hidden */
  29308. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29309. /**
  29310. * Binds a buffer to a uniform.
  29311. * @param buffer Buffer to bind.
  29312. * @param name Name of the uniform variable to bind to.
  29313. */
  29314. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29315. /**
  29316. * Binds block to a uniform.
  29317. * @param blockName Name of the block to bind.
  29318. * @param index Index to bind.
  29319. */
  29320. bindUniformBlock(blockName: string, index: number): void;
  29321. /**
  29322. * Sets an interger value on a uniform variable.
  29323. * @param uniformName Name of the variable.
  29324. * @param value Value to be set.
  29325. * @returns this effect.
  29326. */
  29327. setInt(uniformName: string, value: number): Effect;
  29328. /**
  29329. * Sets an int array on a uniform variable.
  29330. * @param uniformName Name of the variable.
  29331. * @param array array to be set.
  29332. * @returns this effect.
  29333. */
  29334. setIntArray(uniformName: string, array: Int32Array): Effect;
  29335. /**
  29336. * 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)
  29337. * @param uniformName Name of the variable.
  29338. * @param array array to be set.
  29339. * @returns this effect.
  29340. */
  29341. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29342. /**
  29343. * 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)
  29344. * @param uniformName Name of the variable.
  29345. * @param array array to be set.
  29346. * @returns this effect.
  29347. */
  29348. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29349. /**
  29350. * 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)
  29351. * @param uniformName Name of the variable.
  29352. * @param array array to be set.
  29353. * @returns this effect.
  29354. */
  29355. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29356. /**
  29357. * Sets an float array on a uniform variable.
  29358. * @param uniformName Name of the variable.
  29359. * @param array array to be set.
  29360. * @returns this effect.
  29361. */
  29362. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29363. /**
  29364. * 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)
  29365. * @param uniformName Name of the variable.
  29366. * @param array array to be set.
  29367. * @returns this effect.
  29368. */
  29369. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29370. /**
  29371. * 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)
  29372. * @param uniformName Name of the variable.
  29373. * @param array array to be set.
  29374. * @returns this effect.
  29375. */
  29376. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29377. /**
  29378. * 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)
  29379. * @param uniformName Name of the variable.
  29380. * @param array array to be set.
  29381. * @returns this effect.
  29382. */
  29383. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29384. /**
  29385. * Sets an array on a uniform variable.
  29386. * @param uniformName Name of the variable.
  29387. * @param array array to be set.
  29388. * @returns this effect.
  29389. */
  29390. setArray(uniformName: string, array: number[]): Effect;
  29391. /**
  29392. * 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)
  29393. * @param uniformName Name of the variable.
  29394. * @param array array to be set.
  29395. * @returns this effect.
  29396. */
  29397. setArray2(uniformName: string, array: number[]): Effect;
  29398. /**
  29399. * 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)
  29400. * @param uniformName Name of the variable.
  29401. * @param array array to be set.
  29402. * @returns this effect.
  29403. */
  29404. setArray3(uniformName: string, array: number[]): Effect;
  29405. /**
  29406. * 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)
  29407. * @param uniformName Name of the variable.
  29408. * @param array array to be set.
  29409. * @returns this effect.
  29410. */
  29411. setArray4(uniformName: string, array: number[]): Effect;
  29412. /**
  29413. * Sets matrices on a uniform variable.
  29414. * @param uniformName Name of the variable.
  29415. * @param matrices matrices to be set.
  29416. * @returns this effect.
  29417. */
  29418. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29419. /**
  29420. * Sets matrix on a uniform variable.
  29421. * @param uniformName Name of the variable.
  29422. * @param matrix matrix to be set.
  29423. * @returns this effect.
  29424. */
  29425. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29426. /**
  29427. * 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)
  29428. * @param uniformName Name of the variable.
  29429. * @param matrix matrix to be set.
  29430. * @returns this effect.
  29431. */
  29432. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29433. /**
  29434. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29435. * @param uniformName Name of the variable.
  29436. * @param matrix matrix to be set.
  29437. * @returns this effect.
  29438. */
  29439. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29440. /**
  29441. * Sets a float on a uniform variable.
  29442. * @param uniformName Name of the variable.
  29443. * @param value value to be set.
  29444. * @returns this effect.
  29445. */
  29446. setFloat(uniformName: string, value: number): Effect;
  29447. /**
  29448. * Sets a boolean on a uniform variable.
  29449. * @param uniformName Name of the variable.
  29450. * @param bool value to be set.
  29451. * @returns this effect.
  29452. */
  29453. setBool(uniformName: string, bool: boolean): Effect;
  29454. /**
  29455. * Sets a Vector2 on a uniform variable.
  29456. * @param uniformName Name of the variable.
  29457. * @param vector2 vector2 to be set.
  29458. * @returns this effect.
  29459. */
  29460. setVector2(uniformName: string, vector2: Vector2): Effect;
  29461. /**
  29462. * Sets a float2 on a uniform variable.
  29463. * @param uniformName Name of the variable.
  29464. * @param x First float in float2.
  29465. * @param y Second float in float2.
  29466. * @returns this effect.
  29467. */
  29468. setFloat2(uniformName: string, x: number, y: number): Effect;
  29469. /**
  29470. * Sets a Vector3 on a uniform variable.
  29471. * @param uniformName Name of the variable.
  29472. * @param vector3 Value to be set.
  29473. * @returns this effect.
  29474. */
  29475. setVector3(uniformName: string, vector3: Vector3): Effect;
  29476. /**
  29477. * Sets a float3 on a uniform variable.
  29478. * @param uniformName Name of the variable.
  29479. * @param x First float in float3.
  29480. * @param y Second float in float3.
  29481. * @param z Third float in float3.
  29482. * @returns this effect.
  29483. */
  29484. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29485. /**
  29486. * Sets a Vector4 on a uniform variable.
  29487. * @param uniformName Name of the variable.
  29488. * @param vector4 Value to be set.
  29489. * @returns this effect.
  29490. */
  29491. setVector4(uniformName: string, vector4: Vector4): Effect;
  29492. /**
  29493. * Sets a float4 on a uniform variable.
  29494. * @param uniformName Name of the variable.
  29495. * @param x First float in float4.
  29496. * @param y Second float in float4.
  29497. * @param z Third float in float4.
  29498. * @param w Fourth float in float4.
  29499. * @returns this effect.
  29500. */
  29501. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29502. /**
  29503. * Sets a Color3 on a uniform variable.
  29504. * @param uniformName Name of the variable.
  29505. * @param color3 Value to be set.
  29506. * @returns this effect.
  29507. */
  29508. setColor3(uniformName: string, color3: Color3): Effect;
  29509. /**
  29510. * Sets a Color4 on a uniform variable.
  29511. * @param uniformName Name of the variable.
  29512. * @param color3 Value to be set.
  29513. * @param alpha Alpha value to be set.
  29514. * @returns this effect.
  29515. */
  29516. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29517. /**
  29518. * Sets a Color4 on a uniform variable
  29519. * @param uniformName defines the name of the variable
  29520. * @param color4 defines the value to be set
  29521. * @returns this effect.
  29522. */
  29523. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29524. /** Release all associated resources */
  29525. dispose(): void;
  29526. /**
  29527. * This function will add a new shader to the shader store
  29528. * @param name the name of the shader
  29529. * @param pixelShader optional pixel shader content
  29530. * @param vertexShader optional vertex shader content
  29531. */
  29532. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29533. /**
  29534. * Store of each shader (The can be looked up using effect.key)
  29535. */
  29536. static ShadersStore: {
  29537. [key: string]: string;
  29538. };
  29539. /**
  29540. * Store of each included file for a shader (The can be looked up using effect.key)
  29541. */
  29542. static IncludesShadersStore: {
  29543. [key: string]: string;
  29544. };
  29545. /**
  29546. * Resets the cache of effects.
  29547. */
  29548. static ResetCache(): void;
  29549. }
  29550. }
  29551. declare module BABYLON {
  29552. /**
  29553. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29554. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29555. * 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;
  29556. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29557. */
  29558. export class ColorCurves {
  29559. private _dirty;
  29560. private _tempColor;
  29561. private _globalCurve;
  29562. private _highlightsCurve;
  29563. private _midtonesCurve;
  29564. private _shadowsCurve;
  29565. private _positiveCurve;
  29566. private _negativeCurve;
  29567. private _globalHue;
  29568. private _globalDensity;
  29569. private _globalSaturation;
  29570. private _globalExposure;
  29571. /**
  29572. * Gets the global Hue value.
  29573. * 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).
  29574. */
  29575. /**
  29576. * Sets the global Hue value.
  29577. * 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).
  29578. */
  29579. globalHue: number;
  29580. /**
  29581. * Gets the global Density value.
  29582. * 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.
  29583. * Values less than zero provide a filter of opposite hue.
  29584. */
  29585. /**
  29586. * Sets the global Density value.
  29587. * 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.
  29588. * Values less than zero provide a filter of opposite hue.
  29589. */
  29590. globalDensity: number;
  29591. /**
  29592. * Gets the global Saturation value.
  29593. * 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.
  29594. */
  29595. /**
  29596. * Sets the global Saturation value.
  29597. * 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.
  29598. */
  29599. globalSaturation: number;
  29600. /**
  29601. * Gets the global Exposure value.
  29602. * 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.
  29603. */
  29604. /**
  29605. * Sets the global Exposure value.
  29606. * 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.
  29607. */
  29608. globalExposure: number;
  29609. private _highlightsHue;
  29610. private _highlightsDensity;
  29611. private _highlightsSaturation;
  29612. private _highlightsExposure;
  29613. /**
  29614. * Gets the highlights Hue value.
  29615. * 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).
  29616. */
  29617. /**
  29618. * Sets the highlights Hue value.
  29619. * 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).
  29620. */
  29621. highlightsHue: number;
  29622. /**
  29623. * Gets the highlights Density value.
  29624. * 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.
  29625. * Values less than zero provide a filter of opposite hue.
  29626. */
  29627. /**
  29628. * Sets the highlights Density value.
  29629. * 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.
  29630. * Values less than zero provide a filter of opposite hue.
  29631. */
  29632. highlightsDensity: number;
  29633. /**
  29634. * Gets the highlights Saturation value.
  29635. * 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.
  29636. */
  29637. /**
  29638. * Sets the highlights Saturation value.
  29639. * 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.
  29640. */
  29641. highlightsSaturation: number;
  29642. /**
  29643. * Gets the highlights Exposure value.
  29644. * 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.
  29645. */
  29646. /**
  29647. * Sets the highlights Exposure value.
  29648. * 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.
  29649. */
  29650. highlightsExposure: number;
  29651. private _midtonesHue;
  29652. private _midtonesDensity;
  29653. private _midtonesSaturation;
  29654. private _midtonesExposure;
  29655. /**
  29656. * Gets the midtones Hue value.
  29657. * 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).
  29658. */
  29659. /**
  29660. * Sets the midtones Hue value.
  29661. * 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).
  29662. */
  29663. midtonesHue: number;
  29664. /**
  29665. * Gets the midtones Density value.
  29666. * 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.
  29667. * Values less than zero provide a filter of opposite hue.
  29668. */
  29669. /**
  29670. * Sets the midtones Density value.
  29671. * 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.
  29672. * Values less than zero provide a filter of opposite hue.
  29673. */
  29674. midtonesDensity: number;
  29675. /**
  29676. * Gets the midtones Saturation value.
  29677. * 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.
  29678. */
  29679. /**
  29680. * Sets the midtones Saturation value.
  29681. * 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.
  29682. */
  29683. midtonesSaturation: number;
  29684. /**
  29685. * Gets the midtones Exposure value.
  29686. * 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.
  29687. */
  29688. /**
  29689. * Sets the midtones Exposure value.
  29690. * 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.
  29691. */
  29692. midtonesExposure: number;
  29693. private _shadowsHue;
  29694. private _shadowsDensity;
  29695. private _shadowsSaturation;
  29696. private _shadowsExposure;
  29697. /**
  29698. * Gets the shadows Hue value.
  29699. * 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).
  29700. */
  29701. /**
  29702. * Sets the shadows Hue value.
  29703. * 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).
  29704. */
  29705. shadowsHue: number;
  29706. /**
  29707. * Gets the shadows Density value.
  29708. * 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.
  29709. * Values less than zero provide a filter of opposite hue.
  29710. */
  29711. /**
  29712. * Sets the shadows Density value.
  29713. * 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.
  29714. * Values less than zero provide a filter of opposite hue.
  29715. */
  29716. shadowsDensity: number;
  29717. /**
  29718. * Gets the shadows Saturation value.
  29719. * 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.
  29720. */
  29721. /**
  29722. * Sets the shadows Saturation value.
  29723. * 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.
  29724. */
  29725. shadowsSaturation: number;
  29726. /**
  29727. * Gets the shadows Exposure value.
  29728. * 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.
  29729. */
  29730. /**
  29731. * Sets the shadows Exposure value.
  29732. * 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.
  29733. */
  29734. shadowsExposure: number;
  29735. /**
  29736. * Returns the class name
  29737. * @returns The class name
  29738. */
  29739. getClassName(): string;
  29740. /**
  29741. * Binds the color curves to the shader.
  29742. * @param colorCurves The color curve to bind
  29743. * @param effect The effect to bind to
  29744. * @param positiveUniform The positive uniform shader parameter
  29745. * @param neutralUniform The neutral uniform shader parameter
  29746. * @param negativeUniform The negative uniform shader parameter
  29747. */
  29748. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29749. /**
  29750. * Prepare the list of uniforms associated with the ColorCurves effects.
  29751. * @param uniformsList The list of uniforms used in the effect
  29752. */
  29753. static PrepareUniforms(uniformsList: string[]): void;
  29754. /**
  29755. * Returns color grading data based on a hue, density, saturation and exposure value.
  29756. * @param filterHue The hue of the color filter.
  29757. * @param filterDensity The density of the color filter.
  29758. * @param saturation The saturation.
  29759. * @param exposure The exposure.
  29760. * @param result The result data container.
  29761. */
  29762. private getColorGradingDataToRef;
  29763. /**
  29764. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29765. * @param value The input slider value in range [-100,100].
  29766. * @returns Adjusted value.
  29767. */
  29768. private static applyColorGradingSliderNonlinear;
  29769. /**
  29770. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29771. * @param hue The hue (H) input.
  29772. * @param saturation The saturation (S) input.
  29773. * @param brightness The brightness (B) input.
  29774. * @result An RGBA color represented as Vector4.
  29775. */
  29776. private static fromHSBToRef;
  29777. /**
  29778. * Returns a value clamped between min and max
  29779. * @param value The value to clamp
  29780. * @param min The minimum of value
  29781. * @param max The maximum of value
  29782. * @returns The clamped value.
  29783. */
  29784. private static clamp;
  29785. /**
  29786. * Clones the current color curve instance.
  29787. * @return The cloned curves
  29788. */
  29789. clone(): ColorCurves;
  29790. /**
  29791. * Serializes the current color curve instance to a json representation.
  29792. * @return a JSON representation
  29793. */
  29794. serialize(): any;
  29795. /**
  29796. * Parses the color curve from a json representation.
  29797. * @param source the JSON source to parse
  29798. * @return The parsed curves
  29799. */
  29800. static Parse(source: any): ColorCurves;
  29801. }
  29802. }
  29803. declare module BABYLON {
  29804. /**
  29805. * Interface to follow in your material defines to integrate easily the
  29806. * Image proccessing functions.
  29807. * @hidden
  29808. */
  29809. export interface IImageProcessingConfigurationDefines {
  29810. IMAGEPROCESSING: boolean;
  29811. VIGNETTE: boolean;
  29812. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29813. VIGNETTEBLENDMODEOPAQUE: boolean;
  29814. TONEMAPPING: boolean;
  29815. TONEMAPPING_ACES: boolean;
  29816. CONTRAST: boolean;
  29817. EXPOSURE: boolean;
  29818. COLORCURVES: boolean;
  29819. COLORGRADING: boolean;
  29820. COLORGRADING3D: boolean;
  29821. SAMPLER3DGREENDEPTH: boolean;
  29822. SAMPLER3DBGRMAP: boolean;
  29823. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29824. }
  29825. /**
  29826. * @hidden
  29827. */
  29828. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29829. IMAGEPROCESSING: boolean;
  29830. VIGNETTE: boolean;
  29831. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29832. VIGNETTEBLENDMODEOPAQUE: boolean;
  29833. TONEMAPPING: boolean;
  29834. TONEMAPPING_ACES: boolean;
  29835. CONTRAST: boolean;
  29836. COLORCURVES: boolean;
  29837. COLORGRADING: boolean;
  29838. COLORGRADING3D: boolean;
  29839. SAMPLER3DGREENDEPTH: boolean;
  29840. SAMPLER3DBGRMAP: boolean;
  29841. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29842. EXPOSURE: boolean;
  29843. constructor();
  29844. }
  29845. /**
  29846. * This groups together the common properties used for image processing either in direct forward pass
  29847. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29848. * or not.
  29849. */
  29850. export class ImageProcessingConfiguration {
  29851. /**
  29852. * Default tone mapping applied in BabylonJS.
  29853. */
  29854. static readonly TONEMAPPING_STANDARD: number;
  29855. /**
  29856. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29857. * to other engines rendering to increase portability.
  29858. */
  29859. static readonly TONEMAPPING_ACES: number;
  29860. /**
  29861. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29862. */
  29863. colorCurves: Nullable<ColorCurves>;
  29864. private _colorCurvesEnabled;
  29865. /**
  29866. * Gets wether the color curves effect is enabled.
  29867. */
  29868. /**
  29869. * Sets wether the color curves effect is enabled.
  29870. */
  29871. colorCurvesEnabled: boolean;
  29872. private _colorGradingTexture;
  29873. /**
  29874. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29875. */
  29876. /**
  29877. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29878. */
  29879. colorGradingTexture: Nullable<BaseTexture>;
  29880. private _colorGradingEnabled;
  29881. /**
  29882. * Gets wether the color grading effect is enabled.
  29883. */
  29884. /**
  29885. * Sets wether the color grading effect is enabled.
  29886. */
  29887. colorGradingEnabled: boolean;
  29888. private _colorGradingWithGreenDepth;
  29889. /**
  29890. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29891. */
  29892. /**
  29893. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29894. */
  29895. colorGradingWithGreenDepth: boolean;
  29896. private _colorGradingBGR;
  29897. /**
  29898. * Gets wether the color grading texture contains BGR values.
  29899. */
  29900. /**
  29901. * Sets wether the color grading texture contains BGR values.
  29902. */
  29903. colorGradingBGR: boolean;
  29904. /** @hidden */
  29905. _exposure: number;
  29906. /**
  29907. * Gets the Exposure used in the effect.
  29908. */
  29909. /**
  29910. * Sets the Exposure used in the effect.
  29911. */
  29912. exposure: number;
  29913. private _toneMappingEnabled;
  29914. /**
  29915. * Gets wether the tone mapping effect is enabled.
  29916. */
  29917. /**
  29918. * Sets wether the tone mapping effect is enabled.
  29919. */
  29920. toneMappingEnabled: boolean;
  29921. private _toneMappingType;
  29922. /**
  29923. * Gets the type of tone mapping effect.
  29924. */
  29925. /**
  29926. * Sets the type of tone mapping effect used in BabylonJS.
  29927. */
  29928. toneMappingType: number;
  29929. protected _contrast: number;
  29930. /**
  29931. * Gets the contrast used in the effect.
  29932. */
  29933. /**
  29934. * Sets the contrast used in the effect.
  29935. */
  29936. contrast: number;
  29937. /**
  29938. * Vignette stretch size.
  29939. */
  29940. vignetteStretch: number;
  29941. /**
  29942. * Vignette centre X Offset.
  29943. */
  29944. vignetteCentreX: number;
  29945. /**
  29946. * Vignette centre Y Offset.
  29947. */
  29948. vignetteCentreY: number;
  29949. /**
  29950. * Vignette weight or intensity of the vignette effect.
  29951. */
  29952. vignetteWeight: number;
  29953. /**
  29954. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29955. * if vignetteEnabled is set to true.
  29956. */
  29957. vignetteColor: Color4;
  29958. /**
  29959. * Camera field of view used by the Vignette effect.
  29960. */
  29961. vignetteCameraFov: number;
  29962. private _vignetteBlendMode;
  29963. /**
  29964. * Gets the vignette blend mode allowing different kind of effect.
  29965. */
  29966. /**
  29967. * Sets the vignette blend mode allowing different kind of effect.
  29968. */
  29969. vignetteBlendMode: number;
  29970. private _vignetteEnabled;
  29971. /**
  29972. * Gets wether the vignette effect is enabled.
  29973. */
  29974. /**
  29975. * Sets wether the vignette effect is enabled.
  29976. */
  29977. vignetteEnabled: boolean;
  29978. private _applyByPostProcess;
  29979. /**
  29980. * Gets wether the image processing is applied through a post process or not.
  29981. */
  29982. /**
  29983. * Sets wether the image processing is applied through a post process or not.
  29984. */
  29985. applyByPostProcess: boolean;
  29986. private _isEnabled;
  29987. /**
  29988. * Gets wether the image processing is enabled or not.
  29989. */
  29990. /**
  29991. * Sets wether the image processing is enabled or not.
  29992. */
  29993. isEnabled: boolean;
  29994. /**
  29995. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29996. */
  29997. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29998. /**
  29999. * Method called each time the image processing information changes requires to recompile the effect.
  30000. */
  30001. protected _updateParameters(): void;
  30002. /**
  30003. * Gets the current class name.
  30004. * @return "ImageProcessingConfiguration"
  30005. */
  30006. getClassName(): string;
  30007. /**
  30008. * Prepare the list of uniforms associated with the Image Processing effects.
  30009. * @param uniforms The list of uniforms used in the effect
  30010. * @param defines the list of defines currently in use
  30011. */
  30012. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30013. /**
  30014. * Prepare the list of samplers associated with the Image Processing effects.
  30015. * @param samplersList The list of uniforms used in the effect
  30016. * @param defines the list of defines currently in use
  30017. */
  30018. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30019. /**
  30020. * Prepare the list of defines associated to the shader.
  30021. * @param defines the list of defines to complete
  30022. * @param forPostProcess Define if we are currently in post process mode or not
  30023. */
  30024. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30025. /**
  30026. * Returns true if all the image processing information are ready.
  30027. * @returns True if ready, otherwise, false
  30028. */
  30029. isReady(): boolean;
  30030. /**
  30031. * Binds the image processing to the shader.
  30032. * @param effect The effect to bind to
  30033. * @param aspectRatio Define the current aspect ratio of the effect
  30034. */
  30035. bind(effect: Effect, aspectRatio?: number): void;
  30036. /**
  30037. * Clones the current image processing instance.
  30038. * @return The cloned image processing
  30039. */
  30040. clone(): ImageProcessingConfiguration;
  30041. /**
  30042. * Serializes the current image processing instance to a json representation.
  30043. * @return a JSON representation
  30044. */
  30045. serialize(): any;
  30046. /**
  30047. * Parses the image processing from a json representation.
  30048. * @param source the JSON source to parse
  30049. * @return The parsed image processing
  30050. */
  30051. static Parse(source: any): ImageProcessingConfiguration;
  30052. private static _VIGNETTEMODE_MULTIPLY;
  30053. private static _VIGNETTEMODE_OPAQUE;
  30054. /**
  30055. * Used to apply the vignette as a mix with the pixel color.
  30056. */
  30057. static readonly VIGNETTEMODE_MULTIPLY: number;
  30058. /**
  30059. * Used to apply the vignette as a replacement of the pixel color.
  30060. */
  30061. static readonly VIGNETTEMODE_OPAQUE: number;
  30062. }
  30063. }
  30064. declare module BABYLON {
  30065. /**
  30066. * This represents all the required information to add a fresnel effect on a material:
  30067. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30068. */
  30069. export class FresnelParameters {
  30070. private _isEnabled;
  30071. /**
  30072. * Define if the fresnel effect is enable or not.
  30073. */
  30074. isEnabled: boolean;
  30075. /**
  30076. * Define the color used on edges (grazing angle)
  30077. */
  30078. leftColor: Color3;
  30079. /**
  30080. * Define the color used on center
  30081. */
  30082. rightColor: Color3;
  30083. /**
  30084. * Define bias applied to computed fresnel term
  30085. */
  30086. bias: number;
  30087. /**
  30088. * Defined the power exponent applied to fresnel term
  30089. */
  30090. power: number;
  30091. /**
  30092. * Clones the current fresnel and its valuues
  30093. * @returns a clone fresnel configuration
  30094. */
  30095. clone(): FresnelParameters;
  30096. /**
  30097. * Serializes the current fresnel parameters to a JSON representation.
  30098. * @return the JSON serialization
  30099. */
  30100. serialize(): any;
  30101. /**
  30102. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30103. * @param parsedFresnelParameters Define the JSON representation
  30104. * @returns the parsed parameters
  30105. */
  30106. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30107. }
  30108. }
  30109. declare module BABYLON {
  30110. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30111. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30112. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30113. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30114. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30115. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30116. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30117. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30118. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30119. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30120. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30121. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30122. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30123. /**
  30124. * Decorator used to define property that can be serialized as reference to a camera
  30125. * @param sourceName defines the name of the property to decorate
  30126. */
  30127. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30128. /**
  30129. * Class used to help serialization objects
  30130. */
  30131. export class SerializationHelper {
  30132. /** hidden */
  30133. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30134. /** hidden */
  30135. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30136. /** hidden */
  30137. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30138. /** hidden */
  30139. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30140. /**
  30141. * Appends the serialized animations from the source animations
  30142. * @param source Source containing the animations
  30143. * @param destination Target to store the animations
  30144. */
  30145. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30146. /**
  30147. * Static function used to serialized a specific entity
  30148. * @param entity defines the entity to serialize
  30149. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30150. * @returns a JSON compatible object representing the serialization of the entity
  30151. */
  30152. static Serialize<T>(entity: T, serializationObject?: any): any;
  30153. /**
  30154. * Creates a new entity from a serialization data object
  30155. * @param creationFunction defines a function used to instanciated the new entity
  30156. * @param source defines the source serialization data
  30157. * @param scene defines the hosting scene
  30158. * @param rootUrl defines the root url for resources
  30159. * @returns a new entity
  30160. */
  30161. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30162. /**
  30163. * Clones an object
  30164. * @param creationFunction defines the function used to instanciate the new object
  30165. * @param source defines the source object
  30166. * @returns the cloned object
  30167. */
  30168. static Clone<T>(creationFunction: () => T, source: T): T;
  30169. /**
  30170. * Instanciates a new object based on a source one (some data will be shared between both object)
  30171. * @param creationFunction defines the function used to instanciate the new object
  30172. * @param source defines the source object
  30173. * @returns the new object
  30174. */
  30175. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30176. }
  30177. }
  30178. declare module BABYLON {
  30179. /**
  30180. * This is the base class of all the camera used in the application.
  30181. * @see http://doc.babylonjs.com/features/cameras
  30182. */
  30183. export class Camera extends Node {
  30184. /** @hidden */
  30185. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30186. /**
  30187. * This is the default projection mode used by the cameras.
  30188. * It helps recreating a feeling of perspective and better appreciate depth.
  30189. * This is the best way to simulate real life cameras.
  30190. */
  30191. static readonly PERSPECTIVE_CAMERA: number;
  30192. /**
  30193. * This helps creating camera with an orthographic mode.
  30194. * 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.
  30195. */
  30196. static readonly ORTHOGRAPHIC_CAMERA: number;
  30197. /**
  30198. * This is the default FOV mode for perspective cameras.
  30199. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30200. */
  30201. static readonly FOVMODE_VERTICAL_FIXED: number;
  30202. /**
  30203. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30204. */
  30205. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30206. /**
  30207. * This specifies ther is no need for a camera rig.
  30208. * Basically only one eye is rendered corresponding to the camera.
  30209. */
  30210. static readonly RIG_MODE_NONE: number;
  30211. /**
  30212. * Simulates a camera Rig with one blue eye and one red eye.
  30213. * This can be use with 3d blue and red glasses.
  30214. */
  30215. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30216. /**
  30217. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30218. */
  30219. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30220. /**
  30221. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30222. */
  30223. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30224. /**
  30225. * Defines that both eyes of the camera will be rendered over under each other.
  30226. */
  30227. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30228. /**
  30229. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30230. */
  30231. static readonly RIG_MODE_VR: number;
  30232. /**
  30233. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30234. */
  30235. static readonly RIG_MODE_WEBVR: number;
  30236. /**
  30237. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30238. */
  30239. static readonly RIG_MODE_CUSTOM: number;
  30240. /**
  30241. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30242. */
  30243. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30244. /**
  30245. * Define the input manager associated with the camera.
  30246. */
  30247. inputs: CameraInputsManager<Camera>;
  30248. /** @hidden */
  30249. _position: Vector3;
  30250. /**
  30251. * Define the current local position of the camera in the scene
  30252. */
  30253. position: Vector3;
  30254. /**
  30255. * The vector the camera should consider as up.
  30256. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30257. */
  30258. upVector: Vector3;
  30259. /**
  30260. * Define the current limit on the left side for an orthographic camera
  30261. * In scene unit
  30262. */
  30263. orthoLeft: Nullable<number>;
  30264. /**
  30265. * Define the current limit on the right side for an orthographic camera
  30266. * In scene unit
  30267. */
  30268. orthoRight: Nullable<number>;
  30269. /**
  30270. * Define the current limit on the bottom side for an orthographic camera
  30271. * In scene unit
  30272. */
  30273. orthoBottom: Nullable<number>;
  30274. /**
  30275. * Define the current limit on the top side for an orthographic camera
  30276. * In scene unit
  30277. */
  30278. orthoTop: Nullable<number>;
  30279. /**
  30280. * Field Of View is set in Radians. (default is 0.8)
  30281. */
  30282. fov: number;
  30283. /**
  30284. * Define the minimum distance the camera can see from.
  30285. * This is important to note that the depth buffer are not infinite and the closer it starts
  30286. * the more your scene might encounter depth fighting issue.
  30287. */
  30288. minZ: number;
  30289. /**
  30290. * Define the maximum distance the camera can see to.
  30291. * This is important to note that the depth buffer are not infinite and the further it end
  30292. * the more your scene might encounter depth fighting issue.
  30293. */
  30294. maxZ: number;
  30295. /**
  30296. * Define the default inertia of the camera.
  30297. * This helps giving a smooth feeling to the camera movement.
  30298. */
  30299. inertia: number;
  30300. /**
  30301. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30302. */
  30303. mode: number;
  30304. /**
  30305. * Define wether the camera is intermediate.
  30306. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30307. */
  30308. isIntermediate: boolean;
  30309. /**
  30310. * Define the viewport of the camera.
  30311. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30312. */
  30313. viewport: Viewport;
  30314. /**
  30315. * Restricts the camera to viewing objects with the same layerMask.
  30316. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30317. */
  30318. layerMask: number;
  30319. /**
  30320. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30321. */
  30322. fovMode: number;
  30323. /**
  30324. * Rig mode of the camera.
  30325. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30326. * This is normally controlled byt the camera themselves as internal use.
  30327. */
  30328. cameraRigMode: number;
  30329. /**
  30330. * Defines the distance between both "eyes" in case of a RIG
  30331. */
  30332. interaxialDistance: number;
  30333. /**
  30334. * Defines if stereoscopic rendering is done side by side or over under.
  30335. */
  30336. isStereoscopicSideBySide: boolean;
  30337. /**
  30338. * 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
  30339. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30340. * else in the scene.
  30341. */
  30342. customRenderTargets: RenderTargetTexture[];
  30343. /**
  30344. * When set, the camera will render to this render target instead of the default canvas
  30345. */
  30346. outputRenderTarget: Nullable<RenderTargetTexture>;
  30347. /**
  30348. * Observable triggered when the camera view matrix has changed.
  30349. */
  30350. onViewMatrixChangedObservable: Observable<Camera>;
  30351. /**
  30352. * Observable triggered when the camera Projection matrix has changed.
  30353. */
  30354. onProjectionMatrixChangedObservable: Observable<Camera>;
  30355. /**
  30356. * Observable triggered when the inputs have been processed.
  30357. */
  30358. onAfterCheckInputsObservable: Observable<Camera>;
  30359. /**
  30360. * Observable triggered when reset has been called and applied to the camera.
  30361. */
  30362. onRestoreStateObservable: Observable<Camera>;
  30363. /** @hidden */
  30364. _cameraRigParams: any;
  30365. /** @hidden */
  30366. _rigCameras: Camera[];
  30367. /** @hidden */
  30368. _rigPostProcess: Nullable<PostProcess>;
  30369. protected _webvrViewMatrix: Matrix;
  30370. /** @hidden */
  30371. _skipRendering: boolean;
  30372. /** @hidden */
  30373. _projectionMatrix: Matrix;
  30374. /** @hidden */
  30375. _postProcesses: Nullable<PostProcess>[];
  30376. /** @hidden */
  30377. _activeMeshes: SmartArray<AbstractMesh>;
  30378. protected _globalPosition: Vector3;
  30379. /** hidden */
  30380. _computedViewMatrix: Matrix;
  30381. private _doNotComputeProjectionMatrix;
  30382. private _transformMatrix;
  30383. private _frustumPlanes;
  30384. private _refreshFrustumPlanes;
  30385. private _storedFov;
  30386. private _stateStored;
  30387. /**
  30388. * Instantiates a new camera object.
  30389. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30390. * @see http://doc.babylonjs.com/features/cameras
  30391. * @param name Defines the name of the camera in the scene
  30392. * @param position Defines the position of the camera
  30393. * @param scene Defines the scene the camera belongs too
  30394. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30395. */
  30396. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30397. /**
  30398. * Store current camera state (fov, position, etc..)
  30399. * @returns the camera
  30400. */
  30401. storeState(): Camera;
  30402. /**
  30403. * Restores the camera state values if it has been stored. You must call storeState() first
  30404. */
  30405. protected _restoreStateValues(): boolean;
  30406. /**
  30407. * Restored camera state. You must call storeState() first.
  30408. * @returns true if restored and false otherwise
  30409. */
  30410. restoreState(): boolean;
  30411. /**
  30412. * Gets the class name of the camera.
  30413. * @returns the class name
  30414. */
  30415. getClassName(): string;
  30416. /** @hidden */
  30417. readonly _isCamera: boolean;
  30418. /**
  30419. * Gets a string representation of the camera useful for debug purpose.
  30420. * @param fullDetails Defines that a more verboe level of logging is required
  30421. * @returns the string representation
  30422. */
  30423. toString(fullDetails?: boolean): string;
  30424. /**
  30425. * Gets the current world space position of the camera.
  30426. */
  30427. readonly globalPosition: Vector3;
  30428. /**
  30429. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30430. * @returns the active meshe list
  30431. */
  30432. getActiveMeshes(): SmartArray<AbstractMesh>;
  30433. /**
  30434. * Check wether a mesh is part of the current active mesh list of the camera
  30435. * @param mesh Defines the mesh to check
  30436. * @returns true if active, false otherwise
  30437. */
  30438. isActiveMesh(mesh: Mesh): boolean;
  30439. /**
  30440. * Is this camera ready to be used/rendered
  30441. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30442. * @return true if the camera is ready
  30443. */
  30444. isReady(completeCheck?: boolean): boolean;
  30445. /** @hidden */
  30446. _initCache(): void;
  30447. /** @hidden */
  30448. _updateCache(ignoreParentClass?: boolean): void;
  30449. /** @hidden */
  30450. _isSynchronized(): boolean;
  30451. /** @hidden */
  30452. _isSynchronizedViewMatrix(): boolean;
  30453. /** @hidden */
  30454. _isSynchronizedProjectionMatrix(): boolean;
  30455. /**
  30456. * Attach the input controls to a specific dom element to get the input from.
  30457. * @param element Defines the element the controls should be listened from
  30458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30459. */
  30460. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30461. /**
  30462. * Detach the current controls from the specified dom element.
  30463. * @param element Defines the element to stop listening the inputs from
  30464. */
  30465. detachControl(element: HTMLElement): void;
  30466. /**
  30467. * Update the camera state according to the different inputs gathered during the frame.
  30468. */
  30469. update(): void;
  30470. /** @hidden */
  30471. _checkInputs(): void;
  30472. /** @hidden */
  30473. readonly rigCameras: Camera[];
  30474. /**
  30475. * Gets the post process used by the rig cameras
  30476. */
  30477. readonly rigPostProcess: Nullable<PostProcess>;
  30478. /**
  30479. * Internal, gets the first post proces.
  30480. * @returns the first post process to be run on this camera.
  30481. */
  30482. _getFirstPostProcess(): Nullable<PostProcess>;
  30483. private _cascadePostProcessesToRigCams;
  30484. /**
  30485. * Attach a post process to the camera.
  30486. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30487. * @param postProcess The post process to attach to the camera
  30488. * @param insertAt The position of the post process in case several of them are in use in the scene
  30489. * @returns the position the post process has been inserted at
  30490. */
  30491. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30492. /**
  30493. * Detach a post process to the camera.
  30494. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30495. * @param postProcess The post process to detach from the camera
  30496. */
  30497. detachPostProcess(postProcess: PostProcess): void;
  30498. /**
  30499. * Gets the current world matrix of the camera
  30500. */
  30501. getWorldMatrix(): Matrix;
  30502. /** @hidden */
  30503. _getViewMatrix(): Matrix;
  30504. /**
  30505. * Gets the current view matrix of the camera.
  30506. * @param force forces the camera to recompute the matrix without looking at the cached state
  30507. * @returns the view matrix
  30508. */
  30509. getViewMatrix(force?: boolean): Matrix;
  30510. /**
  30511. * Freeze the projection matrix.
  30512. * It will prevent the cache check of the camera projection compute and can speed up perf
  30513. * if no parameter of the camera are meant to change
  30514. * @param projection Defines manually a projection if necessary
  30515. */
  30516. freezeProjectionMatrix(projection?: Matrix): void;
  30517. /**
  30518. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30519. */
  30520. unfreezeProjectionMatrix(): void;
  30521. /**
  30522. * Gets the current projection matrix of the camera.
  30523. * @param force forces the camera to recompute the matrix without looking at the cached state
  30524. * @returns the projection matrix
  30525. */
  30526. getProjectionMatrix(force?: boolean): Matrix;
  30527. /**
  30528. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30529. * @returns a Matrix
  30530. */
  30531. getTransformationMatrix(): Matrix;
  30532. private _updateFrustumPlanes;
  30533. /**
  30534. * Checks if a cullable object (mesh...) is in the camera frustum
  30535. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30536. * @param target The object to check
  30537. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30538. * @returns true if the object is in frustum otherwise false
  30539. */
  30540. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30541. /**
  30542. * Checks if a cullable object (mesh...) is in the camera frustum
  30543. * Unlike isInFrustum this cheks the full bounding box
  30544. * @param target The object to check
  30545. * @returns true if the object is in frustum otherwise false
  30546. */
  30547. isCompletelyInFrustum(target: ICullable): boolean;
  30548. /**
  30549. * Gets a ray in the forward direction from the camera.
  30550. * @param length Defines the length of the ray to create
  30551. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30552. * @param origin Defines the start point of the ray which defaults to the camera position
  30553. * @returns the forward ray
  30554. */
  30555. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30556. /**
  30557. * Releases resources associated with this node.
  30558. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30559. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30560. */
  30561. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30562. /** @hidden */
  30563. _isLeftCamera: boolean;
  30564. /**
  30565. * Gets the left camera of a rig setup in case of Rigged Camera
  30566. */
  30567. readonly isLeftCamera: boolean;
  30568. /** @hidden */
  30569. _isRightCamera: boolean;
  30570. /**
  30571. * Gets the right camera of a rig setup in case of Rigged Camera
  30572. */
  30573. readonly isRightCamera: boolean;
  30574. /**
  30575. * Gets the left camera of a rig setup in case of Rigged Camera
  30576. */
  30577. readonly leftCamera: Nullable<FreeCamera>;
  30578. /**
  30579. * Gets the right camera of a rig setup in case of Rigged Camera
  30580. */
  30581. readonly rightCamera: Nullable<FreeCamera>;
  30582. /**
  30583. * Gets the left camera target of a rig setup in case of Rigged Camera
  30584. * @returns the target position
  30585. */
  30586. getLeftTarget(): Nullable<Vector3>;
  30587. /**
  30588. * Gets the right camera target of a rig setup in case of Rigged Camera
  30589. * @returns the target position
  30590. */
  30591. getRightTarget(): Nullable<Vector3>;
  30592. /**
  30593. * @hidden
  30594. */
  30595. setCameraRigMode(mode: number, rigParams: any): void;
  30596. /** @hidden */
  30597. static _setStereoscopicRigMode(camera: Camera): void;
  30598. /** @hidden */
  30599. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30600. /** @hidden */
  30601. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30602. /** @hidden */
  30603. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30604. /** @hidden */
  30605. _getVRProjectionMatrix(): Matrix;
  30606. protected _updateCameraRotationMatrix(): void;
  30607. protected _updateWebVRCameraRotationMatrix(): void;
  30608. /**
  30609. * This function MUST be overwritten by the different WebVR cameras available.
  30610. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30611. * @hidden
  30612. */
  30613. _getWebVRProjectionMatrix(): Matrix;
  30614. /**
  30615. * This function MUST be overwritten by the different WebVR cameras available.
  30616. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30617. * @hidden
  30618. */
  30619. _getWebVRViewMatrix(): Matrix;
  30620. /** @hidden */
  30621. setCameraRigParameter(name: string, value: any): void;
  30622. /**
  30623. * needs to be overridden by children so sub has required properties to be copied
  30624. * @hidden
  30625. */
  30626. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30627. /**
  30628. * May need to be overridden by children
  30629. * @hidden
  30630. */
  30631. _updateRigCameras(): void;
  30632. /** @hidden */
  30633. _setupInputs(): void;
  30634. /**
  30635. * Serialiaze the camera setup to a json represention
  30636. * @returns the JSON representation
  30637. */
  30638. serialize(): any;
  30639. /**
  30640. * Clones the current camera.
  30641. * @param name The cloned camera name
  30642. * @returns the cloned camera
  30643. */
  30644. clone(name: string): Camera;
  30645. /**
  30646. * Gets the direction of the camera relative to a given local axis.
  30647. * @param localAxis Defines the reference axis to provide a relative direction.
  30648. * @return the direction
  30649. */
  30650. getDirection(localAxis: Vector3): Vector3;
  30651. /**
  30652. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30653. * @param localAxis Defines the reference axis to provide a relative direction.
  30654. * @param result Defines the vector to store the result in
  30655. */
  30656. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30657. /**
  30658. * Gets a camera constructor for a given camera type
  30659. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30660. * @param name The name of the camera the result will be able to instantiate
  30661. * @param scene The scene the result will construct the camera in
  30662. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30663. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30664. * @returns a factory method to construc the camera
  30665. */
  30666. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30667. /**
  30668. * Compute the world matrix of the camera.
  30669. * @returns the camera workd matrix
  30670. */
  30671. computeWorldMatrix(): Matrix;
  30672. /**
  30673. * Parse a JSON and creates the camera from the parsed information
  30674. * @param parsedCamera The JSON to parse
  30675. * @param scene The scene to instantiate the camera in
  30676. * @returns the newly constructed camera
  30677. */
  30678. static Parse(parsedCamera: any, scene: Scene): Camera;
  30679. }
  30680. }
  30681. declare module BABYLON {
  30682. /**
  30683. * Interface for any object that can request an animation frame
  30684. */
  30685. export interface ICustomAnimationFrameRequester {
  30686. /**
  30687. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30688. */
  30689. renderFunction?: Function;
  30690. /**
  30691. * Called to request the next frame to render to
  30692. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30693. */
  30694. requestAnimationFrame: Function;
  30695. /**
  30696. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30697. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30698. */
  30699. requestID?: number;
  30700. }
  30701. /**
  30702. * Interface containing an array of animations
  30703. */
  30704. export interface IAnimatable {
  30705. /**
  30706. * Array of animations
  30707. */
  30708. animations: Nullable<Array<Animation>>;
  30709. }
  30710. /** Interface used by value gradients (color, factor, ...) */
  30711. export interface IValueGradient {
  30712. /**
  30713. * Gets or sets the gradient value (between 0 and 1)
  30714. */
  30715. gradient: number;
  30716. }
  30717. /** Class used to store color4 gradient */
  30718. export class ColorGradient implements IValueGradient {
  30719. /**
  30720. * Gets or sets the gradient value (between 0 and 1)
  30721. */
  30722. gradient: number;
  30723. /**
  30724. * Gets or sets first associated color
  30725. */
  30726. color1: Color4;
  30727. /**
  30728. * Gets or sets second associated color
  30729. */
  30730. color2?: Color4;
  30731. /**
  30732. * Will get a color picked randomly between color1 and color2.
  30733. * If color2 is undefined then color1 will be used
  30734. * @param result defines the target Color4 to store the result in
  30735. */
  30736. getColorToRef(result: Color4): void;
  30737. }
  30738. /** Class used to store color 3 gradient */
  30739. export class Color3Gradient implements IValueGradient {
  30740. /**
  30741. * Gets or sets the gradient value (between 0 and 1)
  30742. */
  30743. gradient: number;
  30744. /**
  30745. * Gets or sets the associated color
  30746. */
  30747. color: Color3;
  30748. }
  30749. /** Class used to store factor gradient */
  30750. export class FactorGradient implements IValueGradient {
  30751. /**
  30752. * Gets or sets the gradient value (between 0 and 1)
  30753. */
  30754. gradient: number;
  30755. /**
  30756. * Gets or sets first associated factor
  30757. */
  30758. factor1: number;
  30759. /**
  30760. * Gets or sets second associated factor
  30761. */
  30762. factor2?: number;
  30763. /**
  30764. * Will get a number picked randomly between factor1 and factor2.
  30765. * If factor2 is undefined then factor1 will be used
  30766. * @returns the picked number
  30767. */
  30768. getFactor(): number;
  30769. }
  30770. /**
  30771. * @ignore
  30772. * Application error to support additional information when loading a file
  30773. */
  30774. export class LoadFileError extends Error {
  30775. /** defines the optional web request */
  30776. request?: WebRequest | undefined;
  30777. private static _setPrototypeOf;
  30778. /**
  30779. * Creates a new LoadFileError
  30780. * @param message defines the message of the error
  30781. * @param request defines the optional web request
  30782. */
  30783. constructor(message: string,
  30784. /** defines the optional web request */
  30785. request?: WebRequest | undefined);
  30786. }
  30787. /**
  30788. * Class used to define a retry strategy when error happens while loading assets
  30789. */
  30790. export class RetryStrategy {
  30791. /**
  30792. * Function used to defines an exponential back off strategy
  30793. * @param maxRetries defines the maximum number of retries (3 by default)
  30794. * @param baseInterval defines the interval between retries
  30795. * @returns the strategy function to use
  30796. */
  30797. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30798. }
  30799. /**
  30800. * File request interface
  30801. */
  30802. export interface IFileRequest {
  30803. /**
  30804. * Raised when the request is complete (success or error).
  30805. */
  30806. onCompleteObservable: Observable<IFileRequest>;
  30807. /**
  30808. * Aborts the request for a file.
  30809. */
  30810. abort: () => void;
  30811. }
  30812. /**
  30813. * Class containing a set of static utilities functions
  30814. */
  30815. export class Tools {
  30816. /**
  30817. * Gets or sets the base URL to use to load assets
  30818. */
  30819. static BaseUrl: string;
  30820. /**
  30821. * Enable/Disable Custom HTTP Request Headers globally.
  30822. * default = false
  30823. * @see CustomRequestHeaders
  30824. */
  30825. static UseCustomRequestHeaders: boolean;
  30826. /**
  30827. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30828. * i.e. when loading files, where the server/service expects an Authorization header
  30829. */
  30830. static CustomRequestHeaders: {
  30831. [key: string]: string;
  30832. };
  30833. /**
  30834. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30835. */
  30836. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30837. /**
  30838. * Default behaviour for cors in the application.
  30839. * It can be a string if the expected behavior is identical in the entire app.
  30840. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30841. */
  30842. static CorsBehavior: string | ((url: string | string[]) => string);
  30843. /**
  30844. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30845. * @ignorenaming
  30846. */
  30847. static UseFallbackTexture: boolean;
  30848. /**
  30849. * Use this object to register external classes like custom textures or material
  30850. * to allow the laoders to instantiate them
  30851. */
  30852. static RegisteredExternalClasses: {
  30853. [key: string]: Object;
  30854. };
  30855. /**
  30856. * Texture content used if a texture cannot loaded
  30857. * @ignorenaming
  30858. */
  30859. static fallbackTexture: string;
  30860. /**
  30861. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30862. * @param u defines the coordinate on X axis
  30863. * @param v defines the coordinate on Y axis
  30864. * @param width defines the width of the source data
  30865. * @param height defines the height of the source data
  30866. * @param pixels defines the source byte array
  30867. * @param color defines the output color
  30868. */
  30869. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30870. /**
  30871. * Interpolates between a and b via alpha
  30872. * @param a The lower value (returned when alpha = 0)
  30873. * @param b The upper value (returned when alpha = 1)
  30874. * @param alpha The interpolation-factor
  30875. * @return The mixed value
  30876. */
  30877. static Mix(a: number, b: number, alpha: number): number;
  30878. /**
  30879. * Tries to instantiate a new object from a given class name
  30880. * @param className defines the class name to instantiate
  30881. * @returns the new object or null if the system was not able to do the instantiation
  30882. */
  30883. static Instantiate(className: string): any;
  30884. /**
  30885. * Provides a slice function that will work even on IE
  30886. * @param data defines the array to slice
  30887. * @param start defines the start of the data (optional)
  30888. * @param end defines the end of the data (optional)
  30889. * @returns the new sliced array
  30890. */
  30891. static Slice<T>(data: T, start?: number, end?: number): T;
  30892. /**
  30893. * Polyfill for setImmediate
  30894. * @param action defines the action to execute after the current execution block
  30895. */
  30896. static SetImmediate(action: () => void): void;
  30897. /**
  30898. * Function indicating if a number is an exponent of 2
  30899. * @param value defines the value to test
  30900. * @returns true if the value is an exponent of 2
  30901. */
  30902. static IsExponentOfTwo(value: number): boolean;
  30903. private static _tmpFloatArray;
  30904. /**
  30905. * Returns the nearest 32-bit single precision float representation of a Number
  30906. * @param value A Number. If the parameter is of a different type, it will get converted
  30907. * to a number or to NaN if it cannot be converted
  30908. * @returns number
  30909. */
  30910. static FloatRound(value: number): number;
  30911. /**
  30912. * Find the next highest power of two.
  30913. * @param x Number to start search from.
  30914. * @return Next highest power of two.
  30915. */
  30916. static CeilingPOT(x: number): number;
  30917. /**
  30918. * Find the next lowest power of two.
  30919. * @param x Number to start search from.
  30920. * @return Next lowest power of two.
  30921. */
  30922. static FloorPOT(x: number): number;
  30923. /**
  30924. * Find the nearest power of two.
  30925. * @param x Number to start search from.
  30926. * @return Next nearest power of two.
  30927. */
  30928. static NearestPOT(x: number): number;
  30929. /**
  30930. * Get the closest exponent of two
  30931. * @param value defines the value to approximate
  30932. * @param max defines the maximum value to return
  30933. * @param mode defines how to define the closest value
  30934. * @returns closest exponent of two of the given value
  30935. */
  30936. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30937. /**
  30938. * Extracts the filename from a path
  30939. * @param path defines the path to use
  30940. * @returns the filename
  30941. */
  30942. static GetFilename(path: string): string;
  30943. /**
  30944. * Extracts the "folder" part of a path (everything before the filename).
  30945. * @param uri The URI to extract the info from
  30946. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30947. * @returns The "folder" part of the path
  30948. */
  30949. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30950. /**
  30951. * Extracts text content from a DOM element hierarchy
  30952. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30953. */
  30954. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30955. /**
  30956. * Convert an angle in radians to degrees
  30957. * @param angle defines the angle to convert
  30958. * @returns the angle in degrees
  30959. */
  30960. static ToDegrees(angle: number): number;
  30961. /**
  30962. * Convert an angle in degrees to radians
  30963. * @param angle defines the angle to convert
  30964. * @returns the angle in radians
  30965. */
  30966. static ToRadians(angle: number): number;
  30967. /**
  30968. * Encode a buffer to a base64 string
  30969. * @param buffer defines the buffer to encode
  30970. * @returns the encoded string
  30971. */
  30972. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30973. /**
  30974. * Extracts minimum and maximum values from a list of indexed positions
  30975. * @param positions defines the positions to use
  30976. * @param indices defines the indices to the positions
  30977. * @param indexStart defines the start index
  30978. * @param indexCount defines the end index
  30979. * @param bias defines bias value to add to the result
  30980. * @return minimum and maximum values
  30981. */
  30982. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30983. minimum: Vector3;
  30984. maximum: Vector3;
  30985. };
  30986. /**
  30987. * Extracts minimum and maximum values from a list of positions
  30988. * @param positions defines the positions to use
  30989. * @param start defines the start index in the positions array
  30990. * @param count defines the number of positions to handle
  30991. * @param bias defines bias value to add to the result
  30992. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30993. * @return minimum and maximum values
  30994. */
  30995. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30996. minimum: Vector3;
  30997. maximum: Vector3;
  30998. };
  30999. /**
  31000. * Returns an array if obj is not an array
  31001. * @param obj defines the object to evaluate as an array
  31002. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31003. * @returns either obj directly if obj is an array or a new array containing obj
  31004. */
  31005. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31006. /**
  31007. * Gets the pointer prefix to use
  31008. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31009. */
  31010. static GetPointerPrefix(): string;
  31011. /**
  31012. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31013. * @param func - the function to be called
  31014. * @param requester - the object that will request the next frame. Falls back to window.
  31015. * @returns frame number
  31016. */
  31017. static QueueNewFrame(func: () => void, requester?: any): number;
  31018. /**
  31019. * Ask the browser to promote the current element to fullscreen rendering mode
  31020. * @param element defines the DOM element to promote
  31021. */
  31022. static RequestFullscreen(element: HTMLElement): void;
  31023. /**
  31024. * Asks the browser to exit fullscreen mode
  31025. */
  31026. static ExitFullscreen(): void;
  31027. /**
  31028. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31029. * @param url define the url we are trying
  31030. * @param element define the dom element where to configure the cors policy
  31031. */
  31032. static SetCorsBehavior(url: string | string[], element: {
  31033. crossOrigin: string | null;
  31034. }): void;
  31035. /**
  31036. * Removes unwanted characters from an url
  31037. * @param url defines the url to clean
  31038. * @returns the cleaned url
  31039. */
  31040. static CleanUrl(url: string): string;
  31041. /**
  31042. * Gets or sets a function used to pre-process url before using them to load assets
  31043. */
  31044. static PreprocessUrl: (url: string) => string;
  31045. /**
  31046. * Loads an image as an HTMLImageElement.
  31047. * @param input url string, ArrayBuffer, or Blob to load
  31048. * @param onLoad callback called when the image successfully loads
  31049. * @param onError callback called when the image fails to load
  31050. * @param offlineProvider offline provider for caching
  31051. * @returns the HTMLImageElement of the loaded image
  31052. */
  31053. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31054. /**
  31055. * Loads a file
  31056. * @param url url string, ArrayBuffer, or Blob to load
  31057. * @param onSuccess callback called when the file successfully loads
  31058. * @param onProgress callback called while file is loading (if the server supports this mode)
  31059. * @param offlineProvider defines the offline provider for caching
  31060. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31061. * @param onError callback called when the file fails to load
  31062. * @returns a file request object
  31063. */
  31064. 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;
  31065. /**
  31066. * Load a script (identified by an url). When the url returns, the
  31067. * content of this file is added into a new script element, attached to the DOM (body element)
  31068. * @param scriptUrl defines the url of the script to laod
  31069. * @param onSuccess defines the callback called when the script is loaded
  31070. * @param onError defines the callback to call if an error occurs
  31071. * @param scriptId defines the id of the script element
  31072. */
  31073. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31074. /**
  31075. * Load an asynchronous script (identified by an url). When the url returns, the
  31076. * content of this file is added into a new script element, attached to the DOM (body element)
  31077. * @param scriptUrl defines the url of the script to laod
  31078. * @param scriptId defines the id of the script element
  31079. * @returns a promise request object
  31080. */
  31081. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31082. /**
  31083. * Loads a file from a blob
  31084. * @param fileToLoad defines the blob to use
  31085. * @param callback defines the callback to call when data is loaded
  31086. * @param progressCallback defines the callback to call during loading process
  31087. * @returns a file request object
  31088. */
  31089. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31090. /**
  31091. * Loads a file
  31092. * @param fileToLoad defines the file to load
  31093. * @param callback defines the callback to call when data is loaded
  31094. * @param progressCallBack defines the callback to call during loading process
  31095. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31096. * @returns a file request object
  31097. */
  31098. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31099. /**
  31100. * Creates a data url from a given string content
  31101. * @param content defines the content to convert
  31102. * @returns the new data url link
  31103. */
  31104. static FileAsURL(content: string): string;
  31105. /**
  31106. * Format the given number to a specific decimal format
  31107. * @param value defines the number to format
  31108. * @param decimals defines the number of decimals to use
  31109. * @returns the formatted string
  31110. */
  31111. static Format(value: number, decimals?: number): string;
  31112. /**
  31113. * Checks if a given vector is inside a specific range
  31114. * @param v defines the vector to test
  31115. * @param min defines the minimum range
  31116. * @param max defines the maximum range
  31117. */
  31118. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31119. /**
  31120. * Tries to copy an object by duplicating every property
  31121. * @param source defines the source object
  31122. * @param destination defines the target object
  31123. * @param doNotCopyList defines a list of properties to avoid
  31124. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31125. */
  31126. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31127. /**
  31128. * Gets a boolean indicating if the given object has no own property
  31129. * @param obj defines the object to test
  31130. * @returns true if object has no own property
  31131. */
  31132. static IsEmpty(obj: any): boolean;
  31133. /**
  31134. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31135. * @param str Source string
  31136. * @param suffix Suffix to search for in the source string
  31137. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31138. */
  31139. static EndsWith(str: string, suffix: string): boolean;
  31140. /**
  31141. * Function used to register events at window level
  31142. * @param events defines the events to register
  31143. */
  31144. static RegisterTopRootEvents(events: {
  31145. name: string;
  31146. handler: Nullable<(e: FocusEvent) => any>;
  31147. }[]): void;
  31148. /**
  31149. * Function used to unregister events from window level
  31150. * @param events defines the events to unregister
  31151. */
  31152. static UnregisterTopRootEvents(events: {
  31153. name: string;
  31154. handler: Nullable<(e: FocusEvent) => any>;
  31155. }[]): void;
  31156. /**
  31157. * @ignore
  31158. */
  31159. static _ScreenshotCanvas: HTMLCanvasElement;
  31160. /**
  31161. * Dumps the current bound framebuffer
  31162. * @param width defines the rendering width
  31163. * @param height defines the rendering height
  31164. * @param engine defines the hosting engine
  31165. * @param successCallback defines the callback triggered once the data are available
  31166. * @param mimeType defines the mime type of the result
  31167. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31168. */
  31169. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31170. /**
  31171. * Converts the canvas data to blob.
  31172. * This acts as a polyfill for browsers not supporting the to blob function.
  31173. * @param canvas Defines the canvas to extract the data from
  31174. * @param successCallback Defines the callback triggered once the data are available
  31175. * @param mimeType Defines the mime type of the result
  31176. */
  31177. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31178. /**
  31179. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31180. * @param successCallback defines the callback triggered once the data are available
  31181. * @param mimeType defines the mime type of the result
  31182. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31183. */
  31184. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31185. /**
  31186. * Downloads a blob in the browser
  31187. * @param blob defines the blob to download
  31188. * @param fileName defines the name of the downloaded file
  31189. */
  31190. static Download(blob: Blob, fileName: string): void;
  31191. /**
  31192. * Captures a screenshot of the current rendering
  31193. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31194. * @param engine defines the rendering engine
  31195. * @param camera defines the source camera
  31196. * @param size This parameter can be set to a single number or to an object with the
  31197. * following (optional) properties: precision, width, height. If a single number is passed,
  31198. * it will be used for both width and height. If an object is passed, the screenshot size
  31199. * will be derived from the parameters. The precision property is a multiplier allowing
  31200. * rendering at a higher or lower resolution
  31201. * @param successCallback defines the callback receives a single parameter which contains the
  31202. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31203. * src parameter of an <img> to display it
  31204. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31205. * Check your browser for supported MIME types
  31206. */
  31207. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31208. /**
  31209. * Generates an image screenshot from the specified camera.
  31210. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31211. * @param engine The engine to use for rendering
  31212. * @param camera The camera to use for rendering
  31213. * @param size This parameter can be set to a single number or to an object with the
  31214. * following (optional) properties: precision, width, height. If a single number is passed,
  31215. * it will be used for both width and height. If an object is passed, the screenshot size
  31216. * will be derived from the parameters. The precision property is a multiplier allowing
  31217. * rendering at a higher or lower resolution
  31218. * @param successCallback The callback receives a single parameter which contains the
  31219. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31220. * src parameter of an <img> to display it
  31221. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31222. * Check your browser for supported MIME types
  31223. * @param samples Texture samples (default: 1)
  31224. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31225. * @param fileName A name for for the downloaded file.
  31226. */
  31227. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31228. /**
  31229. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31230. * Be aware Math.random() could cause collisions, but:
  31231. * "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"
  31232. * @returns a pseudo random id
  31233. */
  31234. static RandomId(): string;
  31235. /**
  31236. * Test if the given uri is a base64 string
  31237. * @param uri The uri to test
  31238. * @return True if the uri is a base64 string or false otherwise
  31239. */
  31240. static IsBase64(uri: string): boolean;
  31241. /**
  31242. * Decode the given base64 uri.
  31243. * @param uri The uri to decode
  31244. * @return The decoded base64 data.
  31245. */
  31246. static DecodeBase64(uri: string): ArrayBuffer;
  31247. /**
  31248. * Gets the absolute url.
  31249. * @param url the input url
  31250. * @return the absolute url
  31251. */
  31252. static GetAbsoluteUrl(url: string): string;
  31253. /**
  31254. * No log
  31255. */
  31256. static readonly NoneLogLevel: number;
  31257. /**
  31258. * Only message logs
  31259. */
  31260. static readonly MessageLogLevel: number;
  31261. /**
  31262. * Only warning logs
  31263. */
  31264. static readonly WarningLogLevel: number;
  31265. /**
  31266. * Only error logs
  31267. */
  31268. static readonly ErrorLogLevel: number;
  31269. /**
  31270. * All logs
  31271. */
  31272. static readonly AllLogLevel: number;
  31273. /**
  31274. * Gets a value indicating the number of loading errors
  31275. * @ignorenaming
  31276. */
  31277. static readonly errorsCount: number;
  31278. /**
  31279. * Callback called when a new log is added
  31280. */
  31281. static OnNewCacheEntry: (entry: string) => void;
  31282. /**
  31283. * Log a message to the console
  31284. * @param message defines the message to log
  31285. */
  31286. static Log(message: string): void;
  31287. /**
  31288. * Write a warning message to the console
  31289. * @param message defines the message to log
  31290. */
  31291. static Warn(message: string): void;
  31292. /**
  31293. * Write an error message to the console
  31294. * @param message defines the message to log
  31295. */
  31296. static Error(message: string): void;
  31297. /**
  31298. * Gets current log cache (list of logs)
  31299. */
  31300. static readonly LogCache: string;
  31301. /**
  31302. * Clears the log cache
  31303. */
  31304. static ClearLogCache(): void;
  31305. /**
  31306. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31307. */
  31308. static LogLevels: number;
  31309. /**
  31310. * Checks if the loaded document was accessed via `file:`-Protocol.
  31311. * @returns boolean
  31312. */
  31313. static IsFileURL(): boolean;
  31314. /**
  31315. * Checks if the window object exists
  31316. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31317. */
  31318. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31319. /**
  31320. * No performance log
  31321. */
  31322. static readonly PerformanceNoneLogLevel: number;
  31323. /**
  31324. * Use user marks to log performance
  31325. */
  31326. static readonly PerformanceUserMarkLogLevel: number;
  31327. /**
  31328. * Log performance to the console
  31329. */
  31330. static readonly PerformanceConsoleLogLevel: number;
  31331. private static _performance;
  31332. /**
  31333. * Sets the current performance log level
  31334. */
  31335. static PerformanceLogLevel: number;
  31336. private static _StartPerformanceCounterDisabled;
  31337. private static _EndPerformanceCounterDisabled;
  31338. private static _StartUserMark;
  31339. private static _EndUserMark;
  31340. private static _StartPerformanceConsole;
  31341. private static _EndPerformanceConsole;
  31342. /**
  31343. * Starts a performance counter
  31344. */
  31345. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31346. /**
  31347. * Ends a specific performance coutner
  31348. */
  31349. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31350. /**
  31351. * Gets either window.performance.now() if supported or Date.now() else
  31352. */
  31353. static readonly Now: number;
  31354. /**
  31355. * This method will return the name of the class used to create the instance of the given object.
  31356. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31357. * @param object the object to get the class name from
  31358. * @param isType defines if the object is actually a type
  31359. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31360. */
  31361. static GetClassName(object: any, isType?: boolean): string;
  31362. /**
  31363. * Gets the first element of an array satisfying a given predicate
  31364. * @param array defines the array to browse
  31365. * @param predicate defines the predicate to use
  31366. * @returns null if not found or the element
  31367. */
  31368. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31369. /**
  31370. * This method will return the name of the full name of the class, including its owning module (if any).
  31371. * 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).
  31372. * @param object the object to get the class name from
  31373. * @param isType defines if the object is actually a type
  31374. * @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.
  31375. * @ignorenaming
  31376. */
  31377. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31378. /**
  31379. * Returns a promise that resolves after the given amount of time.
  31380. * @param delay Number of milliseconds to delay
  31381. * @returns Promise that resolves after the given amount of time
  31382. */
  31383. static DelayAsync(delay: number): Promise<void>;
  31384. /**
  31385. * Gets the current gradient from an array of IValueGradient
  31386. * @param ratio defines the current ratio to get
  31387. * @param gradients defines the array of IValueGradient
  31388. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31389. */
  31390. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31391. }
  31392. /**
  31393. * This class is used to track a performance counter which is number based.
  31394. * The user has access to many properties which give statistics of different nature.
  31395. *
  31396. * The implementer can track two kinds of Performance Counter: time and count.
  31397. * 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.
  31398. * 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.
  31399. */
  31400. export class PerfCounter {
  31401. /**
  31402. * Gets or sets a global boolean to turn on and off all the counters
  31403. */
  31404. static Enabled: boolean;
  31405. /**
  31406. * Returns the smallest value ever
  31407. */
  31408. readonly min: number;
  31409. /**
  31410. * Returns the biggest value ever
  31411. */
  31412. readonly max: number;
  31413. /**
  31414. * Returns the average value since the performance counter is running
  31415. */
  31416. readonly average: number;
  31417. /**
  31418. * Returns the average value of the last second the counter was monitored
  31419. */
  31420. readonly lastSecAverage: number;
  31421. /**
  31422. * Returns the current value
  31423. */
  31424. readonly current: number;
  31425. /**
  31426. * Gets the accumulated total
  31427. */
  31428. readonly total: number;
  31429. /**
  31430. * Gets the total value count
  31431. */
  31432. readonly count: number;
  31433. /**
  31434. * Creates a new counter
  31435. */
  31436. constructor();
  31437. /**
  31438. * Call this method to start monitoring a new frame.
  31439. * 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.
  31440. */
  31441. fetchNewFrame(): void;
  31442. /**
  31443. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31444. * @param newCount the count value to add to the monitored count
  31445. * @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.
  31446. */
  31447. addCount(newCount: number, fetchResult: boolean): void;
  31448. /**
  31449. * Start monitoring this performance counter
  31450. */
  31451. beginMonitoring(): void;
  31452. /**
  31453. * Compute the time lapsed since the previous beginMonitoring() call.
  31454. * @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
  31455. */
  31456. endMonitoring(newFrame?: boolean): void;
  31457. private _fetchResult;
  31458. private _startMonitoringTime;
  31459. private _min;
  31460. private _max;
  31461. private _average;
  31462. private _current;
  31463. private _totalValueCount;
  31464. private _totalAccumulated;
  31465. private _lastSecAverage;
  31466. private _lastSecAccumulated;
  31467. private _lastSecTime;
  31468. private _lastSecValueCount;
  31469. }
  31470. /**
  31471. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31472. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31473. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31474. * @param name The name of the class, case should be preserved
  31475. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31476. */
  31477. export function className(name: string, module?: string): (target: Object) => void;
  31478. /**
  31479. * An implementation of a loop for asynchronous functions.
  31480. */
  31481. export class AsyncLoop {
  31482. /**
  31483. * Defines the number of iterations for the loop
  31484. */
  31485. iterations: number;
  31486. /**
  31487. * Defines the current index of the loop.
  31488. */
  31489. index: number;
  31490. private _done;
  31491. private _fn;
  31492. private _successCallback;
  31493. /**
  31494. * Constructor.
  31495. * @param iterations the number of iterations.
  31496. * @param func the function to run each iteration
  31497. * @param successCallback the callback that will be called upon succesful execution
  31498. * @param offset starting offset.
  31499. */
  31500. constructor(
  31501. /**
  31502. * Defines the number of iterations for the loop
  31503. */
  31504. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31505. /**
  31506. * Execute the next iteration. Must be called after the last iteration was finished.
  31507. */
  31508. executeNext(): void;
  31509. /**
  31510. * Break the loop and run the success callback.
  31511. */
  31512. breakLoop(): void;
  31513. /**
  31514. * Create and run an async loop.
  31515. * @param iterations the number of iterations.
  31516. * @param fn the function to run each iteration
  31517. * @param successCallback the callback that will be called upon succesful execution
  31518. * @param offset starting offset.
  31519. * @returns the created async loop object
  31520. */
  31521. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31522. /**
  31523. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31524. * @param iterations total number of iterations
  31525. * @param syncedIterations number of synchronous iterations in each async iteration.
  31526. * @param fn the function to call each iteration.
  31527. * @param callback a success call back that will be called when iterating stops.
  31528. * @param breakFunction a break condition (optional)
  31529. * @param timeout timeout settings for the setTimeout function. default - 0.
  31530. * @returns the created async loop object
  31531. */
  31532. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31533. }
  31534. }
  31535. declare module BABYLON {
  31536. /** @hidden */
  31537. export interface ICollisionCoordinator {
  31538. createCollider(): Collider;
  31539. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31540. init(scene: Scene): void;
  31541. }
  31542. /** @hidden */
  31543. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31544. private _scene;
  31545. private _scaledPosition;
  31546. private _scaledVelocity;
  31547. private _finalPosition;
  31548. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31549. createCollider(): Collider;
  31550. init(scene: Scene): void;
  31551. private _collideWithWorld;
  31552. }
  31553. }
  31554. declare module BABYLON {
  31555. /**
  31556. * Class used to manage all inputs for the scene.
  31557. */
  31558. export class InputManager {
  31559. /** The distance in pixel that you have to move to prevent some events */
  31560. static DragMovementThreshold: number;
  31561. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31562. static LongPressDelay: number;
  31563. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31564. static DoubleClickDelay: number;
  31565. /** If you need to check double click without raising a single click at first click, enable this flag */
  31566. static ExclusiveDoubleClickMode: boolean;
  31567. private _wheelEventName;
  31568. private _onPointerMove;
  31569. private _onPointerDown;
  31570. private _onPointerUp;
  31571. private _initClickEvent;
  31572. private _initActionManager;
  31573. private _delayedSimpleClick;
  31574. private _delayedSimpleClickTimeout;
  31575. private _previousDelayedSimpleClickTimeout;
  31576. private _meshPickProceed;
  31577. private _previousButtonPressed;
  31578. private _currentPickResult;
  31579. private _previousPickResult;
  31580. private _totalPointersPressed;
  31581. private _doubleClickOccured;
  31582. private _pointerOverMesh;
  31583. private _pickedDownMesh;
  31584. private _pickedUpMesh;
  31585. private _pointerX;
  31586. private _pointerY;
  31587. private _unTranslatedPointerX;
  31588. private _unTranslatedPointerY;
  31589. private _startingPointerPosition;
  31590. private _previousStartingPointerPosition;
  31591. private _startingPointerTime;
  31592. private _previousStartingPointerTime;
  31593. private _pointerCaptures;
  31594. private _onKeyDown;
  31595. private _onKeyUp;
  31596. private _onCanvasFocusObserver;
  31597. private _onCanvasBlurObserver;
  31598. private _scene;
  31599. /**
  31600. * Creates a new InputManager
  31601. * @param scene defines the hosting scene
  31602. */
  31603. constructor(scene: Scene);
  31604. /**
  31605. * Gets the mesh that is currently under the pointer
  31606. */
  31607. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31608. /**
  31609. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31610. */
  31611. readonly unTranslatedPointer: Vector2;
  31612. /**
  31613. * Gets or sets the current on-screen X position of the pointer
  31614. */
  31615. pointerX: number;
  31616. /**
  31617. * Gets or sets the current on-screen Y position of the pointer
  31618. */
  31619. pointerY: number;
  31620. private _updatePointerPosition;
  31621. private _processPointerMove;
  31622. private _setRayOnPointerInfo;
  31623. private _checkPrePointerObservable;
  31624. /**
  31625. * Use this method to simulate a pointer move on a mesh
  31626. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31627. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31628. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31629. */
  31630. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31631. /**
  31632. * Use this method to simulate a pointer down on a mesh
  31633. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31634. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31635. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31636. */
  31637. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31638. private _processPointerDown;
  31639. /** @hidden */
  31640. _isPointerSwiping(): boolean;
  31641. /**
  31642. * Use this method to simulate a pointer up on a mesh
  31643. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31644. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31645. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31646. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31647. */
  31648. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31649. private _processPointerUp;
  31650. /**
  31651. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31652. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31653. * @returns true if the pointer was captured
  31654. */
  31655. isPointerCaptured(pointerId?: number): boolean;
  31656. /**
  31657. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31658. * @param attachUp defines if you want to attach events to pointerup
  31659. * @param attachDown defines if you want to attach events to pointerdown
  31660. * @param attachMove defines if you want to attach events to pointermove
  31661. */
  31662. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31663. /**
  31664. * Detaches all event handlers
  31665. */
  31666. detachControl(): void;
  31667. /**
  31668. * Force the value of meshUnderPointer
  31669. * @param mesh defines the mesh to use
  31670. */
  31671. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31672. /**
  31673. * Gets the mesh under the pointer
  31674. * @returns a Mesh or null if no mesh is under the pointer
  31675. */
  31676. getPointerOverMesh(): Nullable<AbstractMesh>;
  31677. }
  31678. }
  31679. declare module BABYLON {
  31680. /**
  31681. * This class defines the direct association between an animation and a target
  31682. */
  31683. export class TargetedAnimation {
  31684. /**
  31685. * Animation to perform
  31686. */
  31687. animation: Animation;
  31688. /**
  31689. * Target to animate
  31690. */
  31691. target: any;
  31692. }
  31693. /**
  31694. * Use this class to create coordinated animations on multiple targets
  31695. */
  31696. export class AnimationGroup implements IDisposable {
  31697. /** The name of the animation group */
  31698. name: string;
  31699. private _scene;
  31700. private _targetedAnimations;
  31701. private _animatables;
  31702. private _from;
  31703. private _to;
  31704. private _isStarted;
  31705. private _isPaused;
  31706. private _speedRatio;
  31707. /**
  31708. * Gets or sets the unique id of the node
  31709. */
  31710. uniqueId: number;
  31711. /**
  31712. * This observable will notify when one animation have ended
  31713. */
  31714. onAnimationEndObservable: Observable<TargetedAnimation>;
  31715. /**
  31716. * Observer raised when one animation loops
  31717. */
  31718. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31719. /**
  31720. * This observable will notify when all animations have ended.
  31721. */
  31722. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31723. /**
  31724. * This observable will notify when all animations have paused.
  31725. */
  31726. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31727. /**
  31728. * This observable will notify when all animations are playing.
  31729. */
  31730. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31731. /**
  31732. * Gets the first frame
  31733. */
  31734. readonly from: number;
  31735. /**
  31736. * Gets the last frame
  31737. */
  31738. readonly to: number;
  31739. /**
  31740. * Define if the animations are started
  31741. */
  31742. readonly isStarted: boolean;
  31743. /**
  31744. * Gets a value indicating that the current group is playing
  31745. */
  31746. readonly isPlaying: boolean;
  31747. /**
  31748. * Gets or sets the speed ratio to use for all animations
  31749. */
  31750. /**
  31751. * Gets or sets the speed ratio to use for all animations
  31752. */
  31753. speedRatio: number;
  31754. /**
  31755. * Gets the targeted animations for this animation group
  31756. */
  31757. readonly targetedAnimations: Array<TargetedAnimation>;
  31758. /**
  31759. * returning the list of animatables controlled by this animation group.
  31760. */
  31761. readonly animatables: Array<Animatable>;
  31762. /**
  31763. * Instantiates a new Animation Group.
  31764. * This helps managing several animations at once.
  31765. * @see http://doc.babylonjs.com/how_to/group
  31766. * @param name Defines the name of the group
  31767. * @param scene Defines the scene the group belongs to
  31768. */
  31769. constructor(
  31770. /** The name of the animation group */
  31771. name: string, scene?: Nullable<Scene>);
  31772. /**
  31773. * Add an animation (with its target) in the group
  31774. * @param animation defines the animation we want to add
  31775. * @param target defines the target of the animation
  31776. * @returns the TargetedAnimation object
  31777. */
  31778. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31779. /**
  31780. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31781. * It can add constant keys at begin or end
  31782. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31783. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31784. * @returns the animation group
  31785. */
  31786. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31787. /**
  31788. * Start all animations on given targets
  31789. * @param loop defines if animations must loop
  31790. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31791. * @param from defines the from key (optional)
  31792. * @param to defines the to key (optional)
  31793. * @returns the current animation group
  31794. */
  31795. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31796. /**
  31797. * Pause all animations
  31798. * @returns the animation group
  31799. */
  31800. pause(): AnimationGroup;
  31801. /**
  31802. * Play all animations to initial state
  31803. * This function will start() the animations if they were not started or will restart() them if they were paused
  31804. * @param loop defines if animations must loop
  31805. * @returns the animation group
  31806. */
  31807. play(loop?: boolean): AnimationGroup;
  31808. /**
  31809. * Reset all animations to initial state
  31810. * @returns the animation group
  31811. */
  31812. reset(): AnimationGroup;
  31813. /**
  31814. * Restart animations from key 0
  31815. * @returns the animation group
  31816. */
  31817. restart(): AnimationGroup;
  31818. /**
  31819. * Stop all animations
  31820. * @returns the animation group
  31821. */
  31822. stop(): AnimationGroup;
  31823. /**
  31824. * Set animation weight for all animatables
  31825. * @param weight defines the weight to use
  31826. * @return the animationGroup
  31827. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31828. */
  31829. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31830. /**
  31831. * Synchronize and normalize all animatables with a source animatable
  31832. * @param root defines the root animatable to synchronize with
  31833. * @return the animationGroup
  31834. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31835. */
  31836. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31837. /**
  31838. * Goes to a specific frame in this animation group
  31839. * @param frame the frame number to go to
  31840. * @return the animationGroup
  31841. */
  31842. goToFrame(frame: number): AnimationGroup;
  31843. /**
  31844. * Dispose all associated resources
  31845. */
  31846. dispose(): void;
  31847. private _checkAnimationGroupEnded;
  31848. /**
  31849. * Clone the current animation group and returns a copy
  31850. * @param newName defines the name of the new group
  31851. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31852. * @returns the new aniamtion group
  31853. */
  31854. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31855. /**
  31856. * Returns a new AnimationGroup object parsed from the source provided.
  31857. * @param parsedAnimationGroup defines the source
  31858. * @param scene defines the scene that will receive the animationGroup
  31859. * @returns a new AnimationGroup
  31860. */
  31861. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31862. /**
  31863. * Returns the string "AnimationGroup"
  31864. * @returns "AnimationGroup"
  31865. */
  31866. getClassName(): string;
  31867. /**
  31868. * Creates a detailled string about the object
  31869. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31870. * @returns a string representing the object
  31871. */
  31872. toString(fullDetails?: boolean): string;
  31873. }
  31874. }
  31875. declare module BABYLON {
  31876. /**
  31877. * Define an interface for all classes that will hold resources
  31878. */
  31879. export interface IDisposable {
  31880. /**
  31881. * Releases all held resources
  31882. */
  31883. dispose(): void;
  31884. }
  31885. /** Interface defining initialization parameters for Scene class */
  31886. export interface SceneOptions {
  31887. /**
  31888. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31889. * It will improve performance when the number of geometries becomes important.
  31890. */
  31891. useGeometryUniqueIdsMap?: boolean;
  31892. /**
  31893. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31894. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31895. */
  31896. useMaterialMeshMap?: boolean;
  31897. /**
  31898. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31899. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31900. */
  31901. useClonedMeshhMap?: boolean;
  31902. }
  31903. /**
  31904. * Represents a scene to be rendered by the engine.
  31905. * @see http://doc.babylonjs.com/features/scene
  31906. */
  31907. export class Scene extends AbstractScene implements IAnimatable {
  31908. private static _uniqueIdCounter;
  31909. /** The fog is deactivated */
  31910. static readonly FOGMODE_NONE: number;
  31911. /** The fog density is following an exponential function */
  31912. static readonly FOGMODE_EXP: number;
  31913. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31914. static readonly FOGMODE_EXP2: number;
  31915. /** The fog density is following a linear function. */
  31916. static readonly FOGMODE_LINEAR: number;
  31917. /**
  31918. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31919. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31920. */
  31921. static MinDeltaTime: number;
  31922. /**
  31923. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31924. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31925. */
  31926. static MaxDeltaTime: number;
  31927. /**
  31928. * Factory used to create the default material.
  31929. * @param name The name of the material to create
  31930. * @param scene The scene to create the material for
  31931. * @returns The default material
  31932. */
  31933. static DefaultMaterialFactory(scene: Scene): Material;
  31934. /**
  31935. * Factory used to create the a collision coordinator.
  31936. * @returns The collision coordinator
  31937. */
  31938. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31939. /** @hidden */
  31940. _inputManager: InputManager;
  31941. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31942. cameraToUseForPointers: Nullable<Camera>;
  31943. /** @hidden */
  31944. readonly _isScene: boolean;
  31945. /**
  31946. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31947. */
  31948. autoClear: boolean;
  31949. /**
  31950. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31951. */
  31952. autoClearDepthAndStencil: boolean;
  31953. /**
  31954. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31955. */
  31956. clearColor: Color4;
  31957. /**
  31958. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31959. */
  31960. ambientColor: Color3;
  31961. /**
  31962. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31963. * It should only be one of the following (if not the default embedded one):
  31964. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31965. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31966. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31967. * The material properties need to be setup according to the type of texture in use.
  31968. */
  31969. environmentBRDFTexture: BaseTexture;
  31970. /** @hidden */
  31971. protected _environmentTexture: Nullable<BaseTexture>;
  31972. /**
  31973. * Texture used in all pbr material as the reflection texture.
  31974. * As in the majority of the scene they are the same (exception for multi room and so on),
  31975. * this is easier to reference from here than from all the materials.
  31976. */
  31977. /**
  31978. * Texture used in all pbr material as the reflection texture.
  31979. * As in the majority of the scene they are the same (exception for multi room and so on),
  31980. * this is easier to set here than in all the materials.
  31981. */
  31982. environmentTexture: Nullable<BaseTexture>;
  31983. /** @hidden */
  31984. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31985. /**
  31986. * Default image processing configuration used either in the rendering
  31987. * Forward main pass or through the imageProcessingPostProcess if present.
  31988. * As in the majority of the scene they are the same (exception for multi camera),
  31989. * this is easier to reference from here than from all the materials and post process.
  31990. *
  31991. * No setter as we it is a shared configuration, you can set the values instead.
  31992. */
  31993. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31994. private _forceWireframe;
  31995. /**
  31996. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31997. */
  31998. forceWireframe: boolean;
  31999. private _forcePointsCloud;
  32000. /**
  32001. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32002. */
  32003. forcePointsCloud: boolean;
  32004. /**
  32005. * Gets or sets the active clipplane 1
  32006. */
  32007. clipPlane: Nullable<Plane>;
  32008. /**
  32009. * Gets or sets the active clipplane 2
  32010. */
  32011. clipPlane2: Nullable<Plane>;
  32012. /**
  32013. * Gets or sets the active clipplane 3
  32014. */
  32015. clipPlane3: Nullable<Plane>;
  32016. /**
  32017. * Gets or sets the active clipplane 4
  32018. */
  32019. clipPlane4: Nullable<Plane>;
  32020. /**
  32021. * Gets or sets a boolean indicating if animations are enabled
  32022. */
  32023. animationsEnabled: boolean;
  32024. private _animationPropertiesOverride;
  32025. /**
  32026. * Gets or sets the animation properties override
  32027. */
  32028. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32029. /**
  32030. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32031. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32032. */
  32033. useConstantAnimationDeltaTime: boolean;
  32034. /**
  32035. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32036. * Please note that it requires to run a ray cast through the scene on every frame
  32037. */
  32038. constantlyUpdateMeshUnderPointer: boolean;
  32039. /**
  32040. * Defines the HTML cursor to use when hovering over interactive elements
  32041. */
  32042. hoverCursor: string;
  32043. /**
  32044. * Defines the HTML default cursor to use (empty by default)
  32045. */
  32046. defaultCursor: string;
  32047. /**
  32048. * This is used to call preventDefault() on pointer down
  32049. * in order to block unwanted artifacts like system double clicks
  32050. */
  32051. preventDefaultOnPointerDown: boolean;
  32052. /**
  32053. * This is used to call preventDefault() on pointer up
  32054. * in order to block unwanted artifacts like system double clicks
  32055. */
  32056. preventDefaultOnPointerUp: boolean;
  32057. /**
  32058. * Gets or sets user defined metadata
  32059. */
  32060. metadata: any;
  32061. /**
  32062. * For internal use only. Please do not use.
  32063. */
  32064. reservedDataStore: any;
  32065. /**
  32066. * Gets the name of the plugin used to load this scene (null by default)
  32067. */
  32068. loadingPluginName: string;
  32069. /**
  32070. * Use this array to add regular expressions used to disable offline support for specific urls
  32071. */
  32072. disableOfflineSupportExceptionRules: RegExp[];
  32073. /**
  32074. * An event triggered when the scene is disposed.
  32075. */
  32076. onDisposeObservable: Observable<Scene>;
  32077. private _onDisposeObserver;
  32078. /** Sets a function to be executed when this scene is disposed. */
  32079. onDispose: () => void;
  32080. /**
  32081. * An event triggered before rendering the scene (right after animations and physics)
  32082. */
  32083. onBeforeRenderObservable: Observable<Scene>;
  32084. private _onBeforeRenderObserver;
  32085. /** Sets a function to be executed before rendering this scene */
  32086. beforeRender: Nullable<() => void>;
  32087. /**
  32088. * An event triggered after rendering the scene
  32089. */
  32090. onAfterRenderObservable: Observable<Scene>;
  32091. private _onAfterRenderObserver;
  32092. /** Sets a function to be executed after rendering this scene */
  32093. afterRender: Nullable<() => void>;
  32094. /**
  32095. * An event triggered before animating the scene
  32096. */
  32097. onBeforeAnimationsObservable: Observable<Scene>;
  32098. /**
  32099. * An event triggered after animations processing
  32100. */
  32101. onAfterAnimationsObservable: Observable<Scene>;
  32102. /**
  32103. * An event triggered before draw calls are ready to be sent
  32104. */
  32105. onBeforeDrawPhaseObservable: Observable<Scene>;
  32106. /**
  32107. * An event triggered after draw calls have been sent
  32108. */
  32109. onAfterDrawPhaseObservable: Observable<Scene>;
  32110. /**
  32111. * An event triggered when the scene is ready
  32112. */
  32113. onReadyObservable: Observable<Scene>;
  32114. /**
  32115. * An event triggered before rendering a camera
  32116. */
  32117. onBeforeCameraRenderObservable: Observable<Camera>;
  32118. private _onBeforeCameraRenderObserver;
  32119. /** Sets a function to be executed before rendering a camera*/
  32120. beforeCameraRender: () => void;
  32121. /**
  32122. * An event triggered after rendering a camera
  32123. */
  32124. onAfterCameraRenderObservable: Observable<Camera>;
  32125. private _onAfterCameraRenderObserver;
  32126. /** Sets a function to be executed after rendering a camera*/
  32127. afterCameraRender: () => void;
  32128. /**
  32129. * An event triggered when active meshes evaluation is about to start
  32130. */
  32131. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32132. /**
  32133. * An event triggered when active meshes evaluation is done
  32134. */
  32135. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32136. /**
  32137. * An event triggered when particles rendering is about to start
  32138. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32139. */
  32140. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32141. /**
  32142. * An event triggered when particles rendering is done
  32143. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32144. */
  32145. onAfterParticlesRenderingObservable: Observable<Scene>;
  32146. /**
  32147. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32148. */
  32149. onDataLoadedObservable: Observable<Scene>;
  32150. /**
  32151. * An event triggered when a camera is created
  32152. */
  32153. onNewCameraAddedObservable: Observable<Camera>;
  32154. /**
  32155. * An event triggered when a camera is removed
  32156. */
  32157. onCameraRemovedObservable: Observable<Camera>;
  32158. /**
  32159. * An event triggered when a light is created
  32160. */
  32161. onNewLightAddedObservable: Observable<Light>;
  32162. /**
  32163. * An event triggered when a light is removed
  32164. */
  32165. onLightRemovedObservable: Observable<Light>;
  32166. /**
  32167. * An event triggered when a geometry is created
  32168. */
  32169. onNewGeometryAddedObservable: Observable<Geometry>;
  32170. /**
  32171. * An event triggered when a geometry is removed
  32172. */
  32173. onGeometryRemovedObservable: Observable<Geometry>;
  32174. /**
  32175. * An event triggered when a transform node is created
  32176. */
  32177. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32178. /**
  32179. * An event triggered when a transform node is removed
  32180. */
  32181. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32182. /**
  32183. * An event triggered when a mesh is created
  32184. */
  32185. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32186. /**
  32187. * An event triggered when a mesh is removed
  32188. */
  32189. onMeshRemovedObservable: Observable<AbstractMesh>;
  32190. /**
  32191. * An event triggered when a skeleton is created
  32192. */
  32193. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32194. /**
  32195. * An event triggered when a skeleton is removed
  32196. */
  32197. onSkeletonRemovedObservable: Observable<Skeleton>;
  32198. /**
  32199. * An event triggered when a material is created
  32200. */
  32201. onNewMaterialAddedObservable: Observable<Material>;
  32202. /**
  32203. * An event triggered when a material is removed
  32204. */
  32205. onMaterialRemovedObservable: Observable<Material>;
  32206. /**
  32207. * An event triggered when a texture is created
  32208. */
  32209. onNewTextureAddedObservable: Observable<BaseTexture>;
  32210. /**
  32211. * An event triggered when a texture is removed
  32212. */
  32213. onTextureRemovedObservable: Observable<BaseTexture>;
  32214. /**
  32215. * An event triggered when render targets are about to be rendered
  32216. * Can happen multiple times per frame.
  32217. */
  32218. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32219. /**
  32220. * An event triggered when render targets were rendered.
  32221. * Can happen multiple times per frame.
  32222. */
  32223. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32224. /**
  32225. * An event triggered before calculating deterministic simulation step
  32226. */
  32227. onBeforeStepObservable: Observable<Scene>;
  32228. /**
  32229. * An event triggered after calculating deterministic simulation step
  32230. */
  32231. onAfterStepObservable: Observable<Scene>;
  32232. /**
  32233. * An event triggered when the activeCamera property is updated
  32234. */
  32235. onActiveCameraChanged: Observable<Scene>;
  32236. /**
  32237. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32238. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32239. * 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)
  32240. */
  32241. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32242. /**
  32243. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32244. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32245. * 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)
  32246. */
  32247. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32248. /**
  32249. * This Observable will when a mesh has been imported into the scene.
  32250. */
  32251. onMeshImportedObservable: Observable<AbstractMesh>;
  32252. /**
  32253. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32254. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32255. */
  32256. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32257. /** @hidden */
  32258. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32259. /**
  32260. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32261. */
  32262. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32263. /**
  32264. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32265. */
  32266. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32267. /**
  32268. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32269. */
  32270. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32271. /** Callback called when a pointer move is detected */
  32272. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32273. /** Callback called when a pointer down is detected */
  32274. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32275. /** Callback called when a pointer up is detected */
  32276. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32277. /** Callback called when a pointer pick is detected */
  32278. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32279. /**
  32280. * 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).
  32281. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32282. */
  32283. onPrePointerObservable: Observable<PointerInfoPre>;
  32284. /**
  32285. * Observable event triggered each time an input event is received from the rendering canvas
  32286. */
  32287. onPointerObservable: Observable<PointerInfo>;
  32288. /**
  32289. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32290. */
  32291. readonly unTranslatedPointer: Vector2;
  32292. /**
  32293. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32294. */
  32295. static DragMovementThreshold: number;
  32296. /**
  32297. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32298. */
  32299. static LongPressDelay: number;
  32300. /**
  32301. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32302. */
  32303. static DoubleClickDelay: number;
  32304. /** If you need to check double click without raising a single click at first click, enable this flag */
  32305. static ExclusiveDoubleClickMode: boolean;
  32306. /** @hidden */
  32307. _mirroredCameraPosition: Nullable<Vector3>;
  32308. /**
  32309. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32310. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32311. */
  32312. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32313. /**
  32314. * Observable event triggered each time an keyboard event is received from the hosting window
  32315. */
  32316. onKeyboardObservable: Observable<KeyboardInfo>;
  32317. private _useRightHandedSystem;
  32318. /**
  32319. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32320. */
  32321. useRightHandedSystem: boolean;
  32322. private _timeAccumulator;
  32323. private _currentStepId;
  32324. private _currentInternalStep;
  32325. /**
  32326. * Sets the step Id used by deterministic lock step
  32327. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32328. * @param newStepId defines the step Id
  32329. */
  32330. setStepId(newStepId: number): void;
  32331. /**
  32332. * Gets the step Id used by deterministic lock step
  32333. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32334. * @returns the step Id
  32335. */
  32336. getStepId(): number;
  32337. /**
  32338. * Gets the internal step used by deterministic lock step
  32339. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32340. * @returns the internal step
  32341. */
  32342. getInternalStep(): number;
  32343. private _fogEnabled;
  32344. /**
  32345. * Gets or sets a boolean indicating if fog is enabled on this scene
  32346. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32347. * (Default is true)
  32348. */
  32349. fogEnabled: boolean;
  32350. private _fogMode;
  32351. /**
  32352. * Gets or sets the fog mode to use
  32353. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32354. * | mode | value |
  32355. * | --- | --- |
  32356. * | FOGMODE_NONE | 0 |
  32357. * | FOGMODE_EXP | 1 |
  32358. * | FOGMODE_EXP2 | 2 |
  32359. * | FOGMODE_LINEAR | 3 |
  32360. */
  32361. fogMode: number;
  32362. /**
  32363. * Gets or sets the fog color to use
  32364. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32365. * (Default is Color3(0.2, 0.2, 0.3))
  32366. */
  32367. fogColor: Color3;
  32368. /**
  32369. * Gets or sets the fog density to use
  32370. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32371. * (Default is 0.1)
  32372. */
  32373. fogDensity: number;
  32374. /**
  32375. * Gets or sets the fog start distance to use
  32376. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32377. * (Default is 0)
  32378. */
  32379. fogStart: number;
  32380. /**
  32381. * Gets or sets the fog end distance to use
  32382. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32383. * (Default is 1000)
  32384. */
  32385. fogEnd: number;
  32386. private _shadowsEnabled;
  32387. /**
  32388. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32389. */
  32390. shadowsEnabled: boolean;
  32391. private _lightsEnabled;
  32392. /**
  32393. * Gets or sets a boolean indicating if lights are enabled on this scene
  32394. */
  32395. lightsEnabled: boolean;
  32396. /** All of the active cameras added to this scene. */
  32397. activeCameras: Camera[];
  32398. /** @hidden */
  32399. _activeCamera: Nullable<Camera>;
  32400. /** Gets or sets the current active camera */
  32401. activeCamera: Nullable<Camera>;
  32402. private _defaultMaterial;
  32403. /** The default material used on meshes when no material is affected */
  32404. /** The default material used on meshes when no material is affected */
  32405. defaultMaterial: Material;
  32406. private _texturesEnabled;
  32407. /**
  32408. * Gets or sets a boolean indicating if textures are enabled on this scene
  32409. */
  32410. texturesEnabled: boolean;
  32411. /**
  32412. * Gets or sets a boolean indicating if particles are enabled on this scene
  32413. */
  32414. particlesEnabled: boolean;
  32415. /**
  32416. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32417. */
  32418. spritesEnabled: boolean;
  32419. private _skeletonsEnabled;
  32420. /**
  32421. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32422. */
  32423. skeletonsEnabled: boolean;
  32424. /**
  32425. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32426. */
  32427. lensFlaresEnabled: boolean;
  32428. /**
  32429. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32430. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32431. */
  32432. collisionsEnabled: boolean;
  32433. private _collisionCoordinator;
  32434. /** @hidden */
  32435. readonly collisionCoordinator: ICollisionCoordinator;
  32436. /**
  32437. * Defines the gravity applied to this scene (used only for collisions)
  32438. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32439. */
  32440. gravity: Vector3;
  32441. /**
  32442. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32443. */
  32444. postProcessesEnabled: boolean;
  32445. /**
  32446. * The list of postprocesses added to the scene
  32447. */
  32448. postProcesses: PostProcess[];
  32449. /**
  32450. * Gets the current postprocess manager
  32451. */
  32452. postProcessManager: PostProcessManager;
  32453. /**
  32454. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32455. */
  32456. renderTargetsEnabled: boolean;
  32457. /**
  32458. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32459. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32460. */
  32461. dumpNextRenderTargets: boolean;
  32462. /**
  32463. * The list of user defined render targets added to the scene
  32464. */
  32465. customRenderTargets: RenderTargetTexture[];
  32466. /**
  32467. * Defines if texture loading must be delayed
  32468. * If true, textures will only be loaded when they need to be rendered
  32469. */
  32470. useDelayedTextureLoading: boolean;
  32471. /**
  32472. * Gets the list of meshes imported to the scene through SceneLoader
  32473. */
  32474. importedMeshesFiles: String[];
  32475. /**
  32476. * Gets or sets a boolean indicating if probes are enabled on this scene
  32477. */
  32478. probesEnabled: boolean;
  32479. /**
  32480. * Gets or sets the current offline provider to use to store scene data
  32481. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32482. */
  32483. offlineProvider: IOfflineProvider;
  32484. /**
  32485. * Gets or sets the action manager associated with the scene
  32486. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32487. */
  32488. actionManager: AbstractActionManager;
  32489. private _meshesForIntersections;
  32490. /**
  32491. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32492. */
  32493. proceduralTexturesEnabled: boolean;
  32494. private _engine;
  32495. private _totalVertices;
  32496. /** @hidden */
  32497. _activeIndices: PerfCounter;
  32498. /** @hidden */
  32499. _activeParticles: PerfCounter;
  32500. /** @hidden */
  32501. _activeBones: PerfCounter;
  32502. private _animationRatio;
  32503. /** @hidden */
  32504. _animationTimeLast: number;
  32505. /** @hidden */
  32506. _animationTime: number;
  32507. /**
  32508. * Gets or sets a general scale for animation speed
  32509. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32510. */
  32511. animationTimeScale: number;
  32512. /** @hidden */
  32513. _cachedMaterial: Nullable<Material>;
  32514. /** @hidden */
  32515. _cachedEffect: Nullable<Effect>;
  32516. /** @hidden */
  32517. _cachedVisibility: Nullable<number>;
  32518. private _renderId;
  32519. private _frameId;
  32520. private _executeWhenReadyTimeoutId;
  32521. private _intermediateRendering;
  32522. private _viewUpdateFlag;
  32523. private _projectionUpdateFlag;
  32524. /** @hidden */
  32525. _toBeDisposed: Nullable<IDisposable>[];
  32526. private _activeRequests;
  32527. /** @hidden */
  32528. _pendingData: any[];
  32529. private _isDisposed;
  32530. /**
  32531. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32532. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32533. */
  32534. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32535. private _activeMeshes;
  32536. private _processedMaterials;
  32537. private _renderTargets;
  32538. /** @hidden */
  32539. _activeParticleSystems: SmartArray<IParticleSystem>;
  32540. private _activeSkeletons;
  32541. private _softwareSkinnedMeshes;
  32542. private _renderingManager;
  32543. /** @hidden */
  32544. _activeAnimatables: Animatable[];
  32545. private _transformMatrix;
  32546. private _sceneUbo;
  32547. /** @hidden */
  32548. _viewMatrix: Matrix;
  32549. private _projectionMatrix;
  32550. /** @hidden */
  32551. _forcedViewPosition: Nullable<Vector3>;
  32552. /** @hidden */
  32553. _frustumPlanes: Plane[];
  32554. /**
  32555. * Gets the list of frustum planes (built from the active camera)
  32556. */
  32557. readonly frustumPlanes: Plane[];
  32558. /**
  32559. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32560. * This is useful if there are more lights that the maximum simulteanous authorized
  32561. */
  32562. requireLightSorting: boolean;
  32563. /** @hidden */
  32564. readonly useMaterialMeshMap: boolean;
  32565. /** @hidden */
  32566. readonly useClonedMeshhMap: boolean;
  32567. private _externalData;
  32568. private _uid;
  32569. /**
  32570. * @hidden
  32571. * Backing store of defined scene components.
  32572. */
  32573. _components: ISceneComponent[];
  32574. /**
  32575. * @hidden
  32576. * Backing store of defined scene components.
  32577. */
  32578. _serializableComponents: ISceneSerializableComponent[];
  32579. /**
  32580. * List of components to register on the next registration step.
  32581. */
  32582. private _transientComponents;
  32583. /**
  32584. * Registers the transient components if needed.
  32585. */
  32586. private _registerTransientComponents;
  32587. /**
  32588. * @hidden
  32589. * Add a component to the scene.
  32590. * Note that the ccomponent could be registered on th next frame if this is called after
  32591. * the register component stage.
  32592. * @param component Defines the component to add to the scene
  32593. */
  32594. _addComponent(component: ISceneComponent): void;
  32595. /**
  32596. * @hidden
  32597. * Gets a component from the scene.
  32598. * @param name defines the name of the component to retrieve
  32599. * @returns the component or null if not present
  32600. */
  32601. _getComponent(name: string): Nullable<ISceneComponent>;
  32602. /**
  32603. * @hidden
  32604. * Defines the actions happening before camera updates.
  32605. */
  32606. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32607. /**
  32608. * @hidden
  32609. * Defines the actions happening before clear the canvas.
  32610. */
  32611. _beforeClearStage: Stage<SimpleStageAction>;
  32612. /**
  32613. * @hidden
  32614. * Defines the actions when collecting render targets for the frame.
  32615. */
  32616. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32617. /**
  32618. * @hidden
  32619. * Defines the actions happening for one camera in the frame.
  32620. */
  32621. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32622. /**
  32623. * @hidden
  32624. * Defines the actions happening during the per mesh ready checks.
  32625. */
  32626. _isReadyForMeshStage: Stage<MeshStageAction>;
  32627. /**
  32628. * @hidden
  32629. * Defines the actions happening before evaluate active mesh checks.
  32630. */
  32631. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32632. /**
  32633. * @hidden
  32634. * Defines the actions happening during the evaluate sub mesh checks.
  32635. */
  32636. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32637. /**
  32638. * @hidden
  32639. * Defines the actions happening during the active mesh stage.
  32640. */
  32641. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32642. /**
  32643. * @hidden
  32644. * Defines the actions happening during the per camera render target step.
  32645. */
  32646. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32647. /**
  32648. * @hidden
  32649. * Defines the actions happening just before the active camera is drawing.
  32650. */
  32651. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32652. /**
  32653. * @hidden
  32654. * Defines the actions happening just before a render target is drawing.
  32655. */
  32656. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32657. /**
  32658. * @hidden
  32659. * Defines the actions happening just before a rendering group is drawing.
  32660. */
  32661. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32662. /**
  32663. * @hidden
  32664. * Defines the actions happening just before a mesh is drawing.
  32665. */
  32666. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32667. /**
  32668. * @hidden
  32669. * Defines the actions happening just after a mesh has been drawn.
  32670. */
  32671. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32672. /**
  32673. * @hidden
  32674. * Defines the actions happening just after a rendering group has been drawn.
  32675. */
  32676. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32677. /**
  32678. * @hidden
  32679. * Defines the actions happening just after the active camera has been drawn.
  32680. */
  32681. _afterCameraDrawStage: Stage<CameraStageAction>;
  32682. /**
  32683. * @hidden
  32684. * Defines the actions happening just after a render target has been drawn.
  32685. */
  32686. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32687. /**
  32688. * @hidden
  32689. * Defines the actions happening just after rendering all cameras and computing intersections.
  32690. */
  32691. _afterRenderStage: Stage<SimpleStageAction>;
  32692. /**
  32693. * @hidden
  32694. * Defines the actions happening when a pointer move event happens.
  32695. */
  32696. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32697. /**
  32698. * @hidden
  32699. * Defines the actions happening when a pointer down event happens.
  32700. */
  32701. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32702. /**
  32703. * @hidden
  32704. * Defines the actions happening when a pointer up event happens.
  32705. */
  32706. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32707. /**
  32708. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32709. */
  32710. private geometriesByUniqueId;
  32711. /**
  32712. * Creates a new Scene
  32713. * @param engine defines the engine to use to render this scene
  32714. * @param options defines the scene options
  32715. */
  32716. constructor(engine: Engine, options?: SceneOptions);
  32717. /**
  32718. * Gets a string idenfifying the name of the class
  32719. * @returns "Scene" string
  32720. */
  32721. getClassName(): string;
  32722. private _defaultMeshCandidates;
  32723. /**
  32724. * @hidden
  32725. */
  32726. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32727. private _defaultSubMeshCandidates;
  32728. /**
  32729. * @hidden
  32730. */
  32731. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32732. /**
  32733. * Sets the default candidate providers for the scene.
  32734. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32735. * and getCollidingSubMeshCandidates to their default function
  32736. */
  32737. setDefaultCandidateProviders(): void;
  32738. /**
  32739. * Gets the mesh that is currently under the pointer
  32740. */
  32741. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32742. /**
  32743. * Gets or sets the current on-screen X position of the pointer
  32744. */
  32745. pointerX: number;
  32746. /**
  32747. * Gets or sets the current on-screen Y position of the pointer
  32748. */
  32749. pointerY: number;
  32750. /**
  32751. * Gets the cached material (ie. the latest rendered one)
  32752. * @returns the cached material
  32753. */
  32754. getCachedMaterial(): Nullable<Material>;
  32755. /**
  32756. * Gets the cached effect (ie. the latest rendered one)
  32757. * @returns the cached effect
  32758. */
  32759. getCachedEffect(): Nullable<Effect>;
  32760. /**
  32761. * Gets the cached visibility state (ie. the latest rendered one)
  32762. * @returns the cached visibility state
  32763. */
  32764. getCachedVisibility(): Nullable<number>;
  32765. /**
  32766. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32767. * @param material defines the current material
  32768. * @param effect defines the current effect
  32769. * @param visibility defines the current visibility state
  32770. * @returns true if one parameter is not cached
  32771. */
  32772. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32773. /**
  32774. * Gets the engine associated with the scene
  32775. * @returns an Engine
  32776. */
  32777. getEngine(): Engine;
  32778. /**
  32779. * Gets the total number of vertices rendered per frame
  32780. * @returns the total number of vertices rendered per frame
  32781. */
  32782. getTotalVertices(): number;
  32783. /**
  32784. * Gets the performance counter for total vertices
  32785. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32786. */
  32787. readonly totalVerticesPerfCounter: PerfCounter;
  32788. /**
  32789. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32790. * @returns the total number of active indices rendered per frame
  32791. */
  32792. getActiveIndices(): number;
  32793. /**
  32794. * Gets the performance counter for active indices
  32795. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32796. */
  32797. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32798. /**
  32799. * Gets the total number of active particles rendered per frame
  32800. * @returns the total number of active particles rendered per frame
  32801. */
  32802. getActiveParticles(): number;
  32803. /**
  32804. * Gets the performance counter for active particles
  32805. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32806. */
  32807. readonly activeParticlesPerfCounter: PerfCounter;
  32808. /**
  32809. * Gets the total number of active bones rendered per frame
  32810. * @returns the total number of active bones rendered per frame
  32811. */
  32812. getActiveBones(): number;
  32813. /**
  32814. * Gets the performance counter for active bones
  32815. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32816. */
  32817. readonly activeBonesPerfCounter: PerfCounter;
  32818. /**
  32819. * Gets the array of active meshes
  32820. * @returns an array of AbstractMesh
  32821. */
  32822. getActiveMeshes(): SmartArray<AbstractMesh>;
  32823. /**
  32824. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32825. * @returns a number
  32826. */
  32827. getAnimationRatio(): number;
  32828. /**
  32829. * Gets an unique Id for the current render phase
  32830. * @returns a number
  32831. */
  32832. getRenderId(): number;
  32833. /**
  32834. * Gets an unique Id for the current frame
  32835. * @returns a number
  32836. */
  32837. getFrameId(): number;
  32838. /** Call this function if you want to manually increment the render Id*/
  32839. incrementRenderId(): void;
  32840. private _createUbo;
  32841. /**
  32842. * Use this method to simulate a pointer move on a mesh
  32843. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32844. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32845. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32846. * @returns the current scene
  32847. */
  32848. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32849. /**
  32850. * Use this method to simulate a pointer down on a mesh
  32851. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32852. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32853. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32854. * @returns the current scene
  32855. */
  32856. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32857. /**
  32858. * Use this method to simulate a pointer up on a mesh
  32859. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32860. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32861. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32862. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32863. * @returns the current scene
  32864. */
  32865. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32866. /**
  32867. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32868. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32869. * @returns true if the pointer was captured
  32870. */
  32871. isPointerCaptured(pointerId?: number): boolean;
  32872. /**
  32873. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32874. * @param attachUp defines if you want to attach events to pointerup
  32875. * @param attachDown defines if you want to attach events to pointerdown
  32876. * @param attachMove defines if you want to attach events to pointermove
  32877. */
  32878. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32879. /** Detaches all event handlers*/
  32880. detachControl(): void;
  32881. /**
  32882. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32883. * Delay loaded resources are not taking in account
  32884. * @return true if all required resources are ready
  32885. */
  32886. isReady(): boolean;
  32887. /** Resets all cached information relative to material (including effect and visibility) */
  32888. resetCachedMaterial(): void;
  32889. /**
  32890. * Registers a function to be called before every frame render
  32891. * @param func defines the function to register
  32892. */
  32893. registerBeforeRender(func: () => void): void;
  32894. /**
  32895. * Unregisters a function called before every frame render
  32896. * @param func defines the function to unregister
  32897. */
  32898. unregisterBeforeRender(func: () => void): void;
  32899. /**
  32900. * Registers a function to be called after every frame render
  32901. * @param func defines the function to register
  32902. */
  32903. registerAfterRender(func: () => void): void;
  32904. /**
  32905. * Unregisters a function called after every frame render
  32906. * @param func defines the function to unregister
  32907. */
  32908. unregisterAfterRender(func: () => void): void;
  32909. private _executeOnceBeforeRender;
  32910. /**
  32911. * The provided function will run before render once and will be disposed afterwards.
  32912. * A timeout delay can be provided so that the function will be executed in N ms.
  32913. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32914. * @param func The function to be executed.
  32915. * @param timeout optional delay in ms
  32916. */
  32917. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32918. /** @hidden */
  32919. _addPendingData(data: any): void;
  32920. /** @hidden */
  32921. _removePendingData(data: any): void;
  32922. /**
  32923. * Returns the number of items waiting to be loaded
  32924. * @returns the number of items waiting to be loaded
  32925. */
  32926. getWaitingItemsCount(): number;
  32927. /**
  32928. * Returns a boolean indicating if the scene is still loading data
  32929. */
  32930. readonly isLoading: boolean;
  32931. /**
  32932. * Registers a function to be executed when the scene is ready
  32933. * @param {Function} func - the function to be executed
  32934. */
  32935. executeWhenReady(func: () => void): void;
  32936. /**
  32937. * Returns a promise that resolves when the scene is ready
  32938. * @returns A promise that resolves when the scene is ready
  32939. */
  32940. whenReadyAsync(): Promise<void>;
  32941. /** @hidden */
  32942. _checkIsReady(): void;
  32943. /**
  32944. * Gets all animatable attached to the scene
  32945. */
  32946. readonly animatables: Animatable[];
  32947. /**
  32948. * Resets the last animation time frame.
  32949. * Useful to override when animations start running when loading a scene for the first time.
  32950. */
  32951. resetLastAnimationTimeFrame(): void;
  32952. /**
  32953. * Gets the current view matrix
  32954. * @returns a Matrix
  32955. */
  32956. getViewMatrix(): Matrix;
  32957. /**
  32958. * Gets the current projection matrix
  32959. * @returns a Matrix
  32960. */
  32961. getProjectionMatrix(): Matrix;
  32962. /**
  32963. * Gets the current transform matrix
  32964. * @returns a Matrix made of View * Projection
  32965. */
  32966. getTransformMatrix(): Matrix;
  32967. /**
  32968. * Sets the current transform matrix
  32969. * @param viewL defines the View matrix to use
  32970. * @param projectionL defines the Projection matrix to use
  32971. * @param viewR defines the right View matrix to use (if provided)
  32972. * @param projectionR defines the right Projection matrix to use (if provided)
  32973. */
  32974. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32975. /**
  32976. * Gets the uniform buffer used to store scene data
  32977. * @returns a UniformBuffer
  32978. */
  32979. getSceneUniformBuffer(): UniformBuffer;
  32980. /**
  32981. * Gets an unique (relatively to the current scene) Id
  32982. * @returns an unique number for the scene
  32983. */
  32984. getUniqueId(): number;
  32985. /**
  32986. * Add a mesh to the list of scene's meshes
  32987. * @param newMesh defines the mesh to add
  32988. * @param recursive if all child meshes should also be added to the scene
  32989. */
  32990. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32991. /**
  32992. * Remove a mesh for the list of scene's meshes
  32993. * @param toRemove defines the mesh to remove
  32994. * @param recursive if all child meshes should also be removed from the scene
  32995. * @returns the index where the mesh was in the mesh list
  32996. */
  32997. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32998. /**
  32999. * Add a transform node to the list of scene's transform nodes
  33000. * @param newTransformNode defines the transform node to add
  33001. */
  33002. addTransformNode(newTransformNode: TransformNode): void;
  33003. /**
  33004. * Remove a transform node for the list of scene's transform nodes
  33005. * @param toRemove defines the transform node to remove
  33006. * @returns the index where the transform node was in the transform node list
  33007. */
  33008. removeTransformNode(toRemove: TransformNode): number;
  33009. /**
  33010. * Remove a skeleton for the list of scene's skeletons
  33011. * @param toRemove defines the skeleton to remove
  33012. * @returns the index where the skeleton was in the skeleton list
  33013. */
  33014. removeSkeleton(toRemove: Skeleton): number;
  33015. /**
  33016. * Remove a morph target for the list of scene's morph targets
  33017. * @param toRemove defines the morph target to remove
  33018. * @returns the index where the morph target was in the morph target list
  33019. */
  33020. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33021. /**
  33022. * Remove a light for the list of scene's lights
  33023. * @param toRemove defines the light to remove
  33024. * @returns the index where the light was in the light list
  33025. */
  33026. removeLight(toRemove: Light): number;
  33027. /**
  33028. * Remove a camera for the list of scene's cameras
  33029. * @param toRemove defines the camera to remove
  33030. * @returns the index where the camera was in the camera list
  33031. */
  33032. removeCamera(toRemove: Camera): number;
  33033. /**
  33034. * Remove a particle system for the list of scene's particle systems
  33035. * @param toRemove defines the particle system to remove
  33036. * @returns the index where the particle system was in the particle system list
  33037. */
  33038. removeParticleSystem(toRemove: IParticleSystem): number;
  33039. /**
  33040. * Remove a animation for the list of scene's animations
  33041. * @param toRemove defines the animation to remove
  33042. * @returns the index where the animation was in the animation list
  33043. */
  33044. removeAnimation(toRemove: Animation): number;
  33045. /**
  33046. * Will stop the animation of the given target
  33047. * @param target - the target
  33048. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33049. * @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)
  33050. */
  33051. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33052. /**
  33053. * Removes the given animation group from this scene.
  33054. * @param toRemove The animation group to remove
  33055. * @returns The index of the removed animation group
  33056. */
  33057. removeAnimationGroup(toRemove: AnimationGroup): number;
  33058. /**
  33059. * Removes the given multi-material from this scene.
  33060. * @param toRemove The multi-material to remove
  33061. * @returns The index of the removed multi-material
  33062. */
  33063. removeMultiMaterial(toRemove: MultiMaterial): number;
  33064. /**
  33065. * Removes the given material from this scene.
  33066. * @param toRemove The material to remove
  33067. * @returns The index of the removed material
  33068. */
  33069. removeMaterial(toRemove: Material): number;
  33070. /**
  33071. * Removes the given action manager from this scene.
  33072. * @param toRemove The action manager to remove
  33073. * @returns The index of the removed action manager
  33074. */
  33075. removeActionManager(toRemove: AbstractActionManager): number;
  33076. /**
  33077. * Removes the given texture from this scene.
  33078. * @param toRemove The texture to remove
  33079. * @returns The index of the removed texture
  33080. */
  33081. removeTexture(toRemove: BaseTexture): number;
  33082. /**
  33083. * Adds the given light to this scene
  33084. * @param newLight The light to add
  33085. */
  33086. addLight(newLight: Light): void;
  33087. /**
  33088. * Sorts the list list based on light priorities
  33089. */
  33090. sortLightsByPriority(): void;
  33091. /**
  33092. * Adds the given camera to this scene
  33093. * @param newCamera The camera to add
  33094. */
  33095. addCamera(newCamera: Camera): void;
  33096. /**
  33097. * Adds the given skeleton to this scene
  33098. * @param newSkeleton The skeleton to add
  33099. */
  33100. addSkeleton(newSkeleton: Skeleton): void;
  33101. /**
  33102. * Adds the given particle system to this scene
  33103. * @param newParticleSystem The particle system to add
  33104. */
  33105. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33106. /**
  33107. * Adds the given animation to this scene
  33108. * @param newAnimation The animation to add
  33109. */
  33110. addAnimation(newAnimation: Animation): void;
  33111. /**
  33112. * Adds the given animation group to this scene.
  33113. * @param newAnimationGroup The animation group to add
  33114. */
  33115. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33116. /**
  33117. * Adds the given multi-material to this scene
  33118. * @param newMultiMaterial The multi-material to add
  33119. */
  33120. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33121. /**
  33122. * Adds the given material to this scene
  33123. * @param newMaterial The material to add
  33124. */
  33125. addMaterial(newMaterial: Material): void;
  33126. /**
  33127. * Adds the given morph target to this scene
  33128. * @param newMorphTargetManager The morph target to add
  33129. */
  33130. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33131. /**
  33132. * Adds the given geometry to this scene
  33133. * @param newGeometry The geometry to add
  33134. */
  33135. addGeometry(newGeometry: Geometry): void;
  33136. /**
  33137. * Adds the given action manager to this scene
  33138. * @param newActionManager The action manager to add
  33139. */
  33140. addActionManager(newActionManager: AbstractActionManager): void;
  33141. /**
  33142. * Adds the given texture to this scene.
  33143. * @param newTexture The texture to add
  33144. */
  33145. addTexture(newTexture: BaseTexture): void;
  33146. /**
  33147. * Switch active camera
  33148. * @param newCamera defines the new active camera
  33149. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33150. */
  33151. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33152. /**
  33153. * sets the active camera of the scene using its ID
  33154. * @param id defines the camera's ID
  33155. * @return the new active camera or null if none found.
  33156. */
  33157. setActiveCameraByID(id: string): Nullable<Camera>;
  33158. /**
  33159. * sets the active camera of the scene using its name
  33160. * @param name defines the camera's name
  33161. * @returns the new active camera or null if none found.
  33162. */
  33163. setActiveCameraByName(name: string): Nullable<Camera>;
  33164. /**
  33165. * get an animation group using its name
  33166. * @param name defines the material's name
  33167. * @return the animation group or null if none found.
  33168. */
  33169. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33170. /**
  33171. * Get a material using its unique id
  33172. * @param uniqueId defines the material's unique id
  33173. * @return the material or null if none found.
  33174. */
  33175. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33176. /**
  33177. * get a material using its id
  33178. * @param id defines the material's ID
  33179. * @return the material or null if none found.
  33180. */
  33181. getMaterialByID(id: string): Nullable<Material>;
  33182. /**
  33183. * Gets a material using its name
  33184. * @param name defines the material's name
  33185. * @return the material or null if none found.
  33186. */
  33187. getMaterialByName(name: string): Nullable<Material>;
  33188. /**
  33189. * Gets a camera using its id
  33190. * @param id defines the id to look for
  33191. * @returns the camera or null if not found
  33192. */
  33193. getCameraByID(id: string): Nullable<Camera>;
  33194. /**
  33195. * Gets a camera using its unique id
  33196. * @param uniqueId defines the unique id to look for
  33197. * @returns the camera or null if not found
  33198. */
  33199. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33200. /**
  33201. * Gets a camera using its name
  33202. * @param name defines the camera's name
  33203. * @return the camera or null if none found.
  33204. */
  33205. getCameraByName(name: string): Nullable<Camera>;
  33206. /**
  33207. * Gets a bone using its id
  33208. * @param id defines the bone's id
  33209. * @return the bone or null if not found
  33210. */
  33211. getBoneByID(id: string): Nullable<Bone>;
  33212. /**
  33213. * Gets a bone using its id
  33214. * @param name defines the bone's name
  33215. * @return the bone or null if not found
  33216. */
  33217. getBoneByName(name: string): Nullable<Bone>;
  33218. /**
  33219. * Gets a light node using its name
  33220. * @param name defines the the light's name
  33221. * @return the light or null if none found.
  33222. */
  33223. getLightByName(name: string): Nullable<Light>;
  33224. /**
  33225. * Gets a light node using its id
  33226. * @param id defines the light's id
  33227. * @return the light or null if none found.
  33228. */
  33229. getLightByID(id: string): Nullable<Light>;
  33230. /**
  33231. * Gets a light node using its scene-generated unique ID
  33232. * @param uniqueId defines the light's unique id
  33233. * @return the light or null if none found.
  33234. */
  33235. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33236. /**
  33237. * Gets a particle system by id
  33238. * @param id defines the particle system id
  33239. * @return the corresponding system or null if none found
  33240. */
  33241. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33242. /**
  33243. * Gets a geometry using its ID
  33244. * @param id defines the geometry's id
  33245. * @return the geometry or null if none found.
  33246. */
  33247. getGeometryByID(id: string): Nullable<Geometry>;
  33248. private _getGeometryByUniqueID;
  33249. /**
  33250. * Add a new geometry to this scene
  33251. * @param geometry defines the geometry to be added to the scene.
  33252. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33253. * @return a boolean defining if the geometry was added or not
  33254. */
  33255. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33256. /**
  33257. * Removes an existing geometry
  33258. * @param geometry defines the geometry to be removed from the scene
  33259. * @return a boolean defining if the geometry was removed or not
  33260. */
  33261. removeGeometry(geometry: Geometry): boolean;
  33262. /**
  33263. * Gets the list of geometries attached to the scene
  33264. * @returns an array of Geometry
  33265. */
  33266. getGeometries(): Geometry[];
  33267. /**
  33268. * Gets the first added mesh found of a given ID
  33269. * @param id defines the id to search for
  33270. * @return the mesh found or null if not found at all
  33271. */
  33272. getMeshByID(id: string): Nullable<AbstractMesh>;
  33273. /**
  33274. * Gets a list of meshes using their id
  33275. * @param id defines the id to search for
  33276. * @returns a list of meshes
  33277. */
  33278. getMeshesByID(id: string): Array<AbstractMesh>;
  33279. /**
  33280. * Gets the first added transform node found of a given ID
  33281. * @param id defines the id to search for
  33282. * @return the found transform node or null if not found at all.
  33283. */
  33284. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33285. /**
  33286. * Gets a transform node with its auto-generated unique id
  33287. * @param uniqueId efines the unique id to search for
  33288. * @return the found transform node or null if not found at all.
  33289. */
  33290. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33291. /**
  33292. * Gets a list of transform nodes using their id
  33293. * @param id defines the id to search for
  33294. * @returns a list of transform nodes
  33295. */
  33296. getTransformNodesByID(id: string): Array<TransformNode>;
  33297. /**
  33298. * Gets a mesh with its auto-generated unique id
  33299. * @param uniqueId defines the unique id to search for
  33300. * @return the found mesh or null if not found at all.
  33301. */
  33302. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33303. /**
  33304. * Gets a the last added mesh using a given id
  33305. * @param id defines the id to search for
  33306. * @return the found mesh or null if not found at all.
  33307. */
  33308. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33309. /**
  33310. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33311. * @param id defines the id to search for
  33312. * @return the found node or null if not found at all
  33313. */
  33314. getLastEntryByID(id: string): Nullable<Node>;
  33315. /**
  33316. * Gets a node (Mesh, Camera, Light) using a given id
  33317. * @param id defines the id to search for
  33318. * @return the found node or null if not found at all
  33319. */
  33320. getNodeByID(id: string): Nullable<Node>;
  33321. /**
  33322. * Gets a node (Mesh, Camera, Light) using a given name
  33323. * @param name defines the name to search for
  33324. * @return the found node or null if not found at all.
  33325. */
  33326. getNodeByName(name: string): Nullable<Node>;
  33327. /**
  33328. * Gets a mesh using a given name
  33329. * @param name defines the name to search for
  33330. * @return the found mesh or null if not found at all.
  33331. */
  33332. getMeshByName(name: string): Nullable<AbstractMesh>;
  33333. /**
  33334. * Gets a transform node using a given name
  33335. * @param name defines the name to search for
  33336. * @return the found transform node or null if not found at all.
  33337. */
  33338. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33339. /**
  33340. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33341. * @param id defines the id to search for
  33342. * @return the found skeleton or null if not found at all.
  33343. */
  33344. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33345. /**
  33346. * Gets a skeleton using a given auto generated unique id
  33347. * @param uniqueId defines the unique id to search for
  33348. * @return the found skeleton or null if not found at all.
  33349. */
  33350. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33351. /**
  33352. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33353. * @param id defines the id to search for
  33354. * @return the found skeleton or null if not found at all.
  33355. */
  33356. getSkeletonById(id: string): Nullable<Skeleton>;
  33357. /**
  33358. * Gets a skeleton using a given name
  33359. * @param name defines the name to search for
  33360. * @return the found skeleton or null if not found at all.
  33361. */
  33362. getSkeletonByName(name: string): Nullable<Skeleton>;
  33363. /**
  33364. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33365. * @param id defines the id to search for
  33366. * @return the found morph target manager or null if not found at all.
  33367. */
  33368. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33369. /**
  33370. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33371. * @param id defines the id to search for
  33372. * @return the found morph target or null if not found at all.
  33373. */
  33374. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33375. /**
  33376. * Gets a boolean indicating if the given mesh is active
  33377. * @param mesh defines the mesh to look for
  33378. * @returns true if the mesh is in the active list
  33379. */
  33380. isActiveMesh(mesh: AbstractMesh): boolean;
  33381. /**
  33382. * Return a unique id as a string which can serve as an identifier for the scene
  33383. */
  33384. readonly uid: string;
  33385. /**
  33386. * Add an externaly attached data from its key.
  33387. * This method call will fail and return false, if such key already exists.
  33388. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33389. * @param key the unique key that identifies the data
  33390. * @param data the data object to associate to the key for this Engine instance
  33391. * @return true if no such key were already present and the data was added successfully, false otherwise
  33392. */
  33393. addExternalData<T>(key: string, data: T): boolean;
  33394. /**
  33395. * Get an externaly attached data from its key
  33396. * @param key the unique key that identifies the data
  33397. * @return the associated data, if present (can be null), or undefined if not present
  33398. */
  33399. getExternalData<T>(key: string): Nullable<T>;
  33400. /**
  33401. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33402. * @param key the unique key that identifies the data
  33403. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33404. * @return the associated data, can be null if the factory returned null.
  33405. */
  33406. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33407. /**
  33408. * Remove an externaly attached data from the Engine instance
  33409. * @param key the unique key that identifies the data
  33410. * @return true if the data was successfully removed, false if it doesn't exist
  33411. */
  33412. removeExternalData(key: string): boolean;
  33413. private _evaluateSubMesh;
  33414. /**
  33415. * Clear the processed materials smart array preventing retention point in material dispose.
  33416. */
  33417. freeProcessedMaterials(): void;
  33418. private _preventFreeActiveMeshesAndRenderingGroups;
  33419. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33420. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33421. * when disposing several meshes in a row or a hierarchy of meshes.
  33422. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33423. */
  33424. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33425. /**
  33426. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33427. */
  33428. freeActiveMeshes(): void;
  33429. /**
  33430. * Clear the info related to rendering groups preventing retention points during dispose.
  33431. */
  33432. freeRenderingGroups(): void;
  33433. /** @hidden */
  33434. _isInIntermediateRendering(): boolean;
  33435. /**
  33436. * Lambda returning the list of potentially active meshes.
  33437. */
  33438. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33439. /**
  33440. * Lambda returning the list of potentially active sub meshes.
  33441. */
  33442. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33443. /**
  33444. * Lambda returning the list of potentially intersecting sub meshes.
  33445. */
  33446. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33447. /**
  33448. * Lambda returning the list of potentially colliding sub meshes.
  33449. */
  33450. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33451. private _activeMeshesFrozen;
  33452. /**
  33453. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33454. * @returns the current scene
  33455. */
  33456. freezeActiveMeshes(): Scene;
  33457. /**
  33458. * Use this function to restart evaluating active meshes on every frame
  33459. * @returns the current scene
  33460. */
  33461. unfreezeActiveMeshes(): Scene;
  33462. private _evaluateActiveMeshes;
  33463. private _activeMesh;
  33464. /**
  33465. * Update the transform matrix to update from the current active camera
  33466. * @param force defines a boolean used to force the update even if cache is up to date
  33467. */
  33468. updateTransformMatrix(force?: boolean): void;
  33469. private _bindFrameBuffer;
  33470. /** @hidden */
  33471. _allowPostProcessClearColor: boolean;
  33472. /** @hidden */
  33473. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33474. private _processSubCameras;
  33475. private _checkIntersections;
  33476. /** @hidden */
  33477. _advancePhysicsEngineStep(step: number): void;
  33478. /**
  33479. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33480. */
  33481. getDeterministicFrameTime: () => number;
  33482. /** @hidden */
  33483. _animate(): void;
  33484. /** Execute all animations (for a frame) */
  33485. animate(): void;
  33486. /**
  33487. * Render the scene
  33488. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33489. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33490. */
  33491. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33492. /**
  33493. * Freeze all materials
  33494. * A frozen material will not be updatable but should be faster to render
  33495. */
  33496. freezeMaterials(): void;
  33497. /**
  33498. * Unfreeze all materials
  33499. * A frozen material will not be updatable but should be faster to render
  33500. */
  33501. unfreezeMaterials(): void;
  33502. /**
  33503. * Releases all held ressources
  33504. */
  33505. dispose(): void;
  33506. /**
  33507. * Gets if the scene is already disposed
  33508. */
  33509. readonly isDisposed: boolean;
  33510. /**
  33511. * Call this function to reduce memory footprint of the scene.
  33512. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33513. */
  33514. clearCachedVertexData(): void;
  33515. /**
  33516. * This function will remove the local cached buffer data from texture.
  33517. * It will save memory but will prevent the texture from being rebuilt
  33518. */
  33519. cleanCachedTextureBuffer(): void;
  33520. /**
  33521. * Get the world extend vectors with an optional filter
  33522. *
  33523. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33524. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33525. */
  33526. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33527. min: Vector3;
  33528. max: Vector3;
  33529. };
  33530. /**
  33531. * Creates a ray that can be used to pick in the scene
  33532. * @param x defines the x coordinate of the origin (on-screen)
  33533. * @param y defines the y coordinate of the origin (on-screen)
  33534. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33535. * @param camera defines the camera to use for the picking
  33536. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33537. * @returns a Ray
  33538. */
  33539. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33540. /**
  33541. * Creates a ray that can be used to pick in the scene
  33542. * @param x defines the x coordinate of the origin (on-screen)
  33543. * @param y defines the y coordinate of the origin (on-screen)
  33544. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33545. * @param result defines the ray where to store the picking ray
  33546. * @param camera defines the camera to use for the picking
  33547. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33548. * @returns the current scene
  33549. */
  33550. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33551. /**
  33552. * Creates a ray that can be used to pick in the scene
  33553. * @param x defines the x coordinate of the origin (on-screen)
  33554. * @param y defines the y coordinate of the origin (on-screen)
  33555. * @param camera defines the camera to use for the picking
  33556. * @returns a Ray
  33557. */
  33558. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33559. /**
  33560. * Creates a ray that can be used to pick in the scene
  33561. * @param x defines the x coordinate of the origin (on-screen)
  33562. * @param y defines the y coordinate of the origin (on-screen)
  33563. * @param result defines the ray where to store the picking ray
  33564. * @param camera defines the camera to use for the picking
  33565. * @returns the current scene
  33566. */
  33567. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33568. /** Launch a ray to try to pick a mesh in the scene
  33569. * @param x position on screen
  33570. * @param y position on screen
  33571. * @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
  33572. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33573. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33574. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33575. * @returns a PickingInfo
  33576. */
  33577. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33578. /** Use the given ray to pick a mesh in the scene
  33579. * @param ray The ray to use to pick meshes
  33580. * @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
  33581. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33582. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33583. * @returns a PickingInfo
  33584. */
  33585. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33586. /**
  33587. * Launch a ray to try to pick a mesh in the scene
  33588. * @param x X position on screen
  33589. * @param y Y position on screen
  33590. * @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
  33591. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33592. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33593. * @returns an array of PickingInfo
  33594. */
  33595. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33596. /**
  33597. * Launch a ray to try to pick a mesh in the scene
  33598. * @param ray Ray to use
  33599. * @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
  33600. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33601. * @returns an array of PickingInfo
  33602. */
  33603. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33604. /**
  33605. * Force the value of meshUnderPointer
  33606. * @param mesh defines the mesh to use
  33607. */
  33608. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33609. /**
  33610. * Gets the mesh under the pointer
  33611. * @returns a Mesh or null if no mesh is under the pointer
  33612. */
  33613. getPointerOverMesh(): Nullable<AbstractMesh>;
  33614. /** @hidden */
  33615. _rebuildGeometries(): void;
  33616. /** @hidden */
  33617. _rebuildTextures(): void;
  33618. private _getByTags;
  33619. /**
  33620. * Get a list of meshes by tags
  33621. * @param tagsQuery defines the tags query to use
  33622. * @param forEach defines a predicate used to filter results
  33623. * @returns an array of Mesh
  33624. */
  33625. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33626. /**
  33627. * Get a list of cameras by tags
  33628. * @param tagsQuery defines the tags query to use
  33629. * @param forEach defines a predicate used to filter results
  33630. * @returns an array of Camera
  33631. */
  33632. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33633. /**
  33634. * Get a list of lights by tags
  33635. * @param tagsQuery defines the tags query to use
  33636. * @param forEach defines a predicate used to filter results
  33637. * @returns an array of Light
  33638. */
  33639. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33640. /**
  33641. * Get a list of materials by tags
  33642. * @param tagsQuery defines the tags query to use
  33643. * @param forEach defines a predicate used to filter results
  33644. * @returns an array of Material
  33645. */
  33646. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33647. /**
  33648. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33649. * This allowed control for front to back rendering or reversly depending of the special needs.
  33650. *
  33651. * @param renderingGroupId The rendering group id corresponding to its index
  33652. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33653. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33654. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33655. */
  33656. 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;
  33657. /**
  33658. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33659. *
  33660. * @param renderingGroupId The rendering group id corresponding to its index
  33661. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33662. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33663. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33664. */
  33665. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33666. /**
  33667. * Gets the current auto clear configuration for one rendering group of the rendering
  33668. * manager.
  33669. * @param index the rendering group index to get the information for
  33670. * @returns The auto clear setup for the requested rendering group
  33671. */
  33672. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33673. private _blockMaterialDirtyMechanism;
  33674. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33675. blockMaterialDirtyMechanism: boolean;
  33676. /**
  33677. * Will flag all materials as dirty to trigger new shader compilation
  33678. * @param flag defines the flag used to specify which material part must be marked as dirty
  33679. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33680. */
  33681. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33682. /** @hidden */
  33683. _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;
  33684. /** @hidden */
  33685. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33686. }
  33687. }
  33688. declare module BABYLON {
  33689. /**
  33690. * Set of assets to keep when moving a scene into an asset container.
  33691. */
  33692. export class KeepAssets extends AbstractScene {
  33693. }
  33694. /**
  33695. * Container with a set of assets that can be added or removed from a scene.
  33696. */
  33697. export class AssetContainer extends AbstractScene {
  33698. /**
  33699. * The scene the AssetContainer belongs to.
  33700. */
  33701. scene: Scene;
  33702. /**
  33703. * Instantiates an AssetContainer.
  33704. * @param scene The scene the AssetContainer belongs to.
  33705. */
  33706. constructor(scene: Scene);
  33707. /**
  33708. * Adds all the assets from the container to the scene.
  33709. */
  33710. addAllToScene(): void;
  33711. /**
  33712. * Removes all the assets in the container from the scene
  33713. */
  33714. removeAllFromScene(): void;
  33715. /**
  33716. * Disposes all the assets in the container
  33717. */
  33718. dispose(): void;
  33719. private _moveAssets;
  33720. /**
  33721. * Removes all the assets contained in the scene and adds them to the container.
  33722. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33723. */
  33724. moveAllFromScene(keepAssets?: KeepAssets): void;
  33725. /**
  33726. * 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.
  33727. * @returns the root mesh
  33728. */
  33729. createRootMesh(): Mesh;
  33730. }
  33731. }
  33732. declare module BABYLON {
  33733. /**
  33734. * Defines how the parser contract is defined.
  33735. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33736. */
  33737. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33738. /**
  33739. * Defines how the individual parser contract is defined.
  33740. * These parser can parse an individual asset
  33741. */
  33742. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33743. /**
  33744. * Base class of the scene acting as a container for the different elements composing a scene.
  33745. * This class is dynamically extended by the different components of the scene increasing
  33746. * flexibility and reducing coupling
  33747. */
  33748. export abstract class AbstractScene {
  33749. /**
  33750. * Stores the list of available parsers in the application.
  33751. */
  33752. private static _BabylonFileParsers;
  33753. /**
  33754. * Stores the list of available individual parsers in the application.
  33755. */
  33756. private static _IndividualBabylonFileParsers;
  33757. /**
  33758. * Adds a parser in the list of available ones
  33759. * @param name Defines the name of the parser
  33760. * @param parser Defines the parser to add
  33761. */
  33762. static AddParser(name: string, parser: BabylonFileParser): void;
  33763. /**
  33764. * Gets a general parser from the list of avaialble ones
  33765. * @param name Defines the name of the parser
  33766. * @returns the requested parser or null
  33767. */
  33768. static GetParser(name: string): Nullable<BabylonFileParser>;
  33769. /**
  33770. * Adds n individual parser in the list of available ones
  33771. * @param name Defines the name of the parser
  33772. * @param parser Defines the parser to add
  33773. */
  33774. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33775. /**
  33776. * Gets an individual parser from the list of avaialble ones
  33777. * @param name Defines the name of the parser
  33778. * @returns the requested parser or null
  33779. */
  33780. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33781. /**
  33782. * Parser json data and populate both a scene and its associated container object
  33783. * @param jsonData Defines the data to parse
  33784. * @param scene Defines the scene to parse the data for
  33785. * @param container Defines the container attached to the parsing sequence
  33786. * @param rootUrl Defines the root url of the data
  33787. */
  33788. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33789. /**
  33790. * Gets the list of root nodes (ie. nodes with no parent)
  33791. */
  33792. rootNodes: Node[];
  33793. /** All of the cameras added to this scene
  33794. * @see http://doc.babylonjs.com/babylon101/cameras
  33795. */
  33796. cameras: Camera[];
  33797. /**
  33798. * All of the lights added to this scene
  33799. * @see http://doc.babylonjs.com/babylon101/lights
  33800. */
  33801. lights: Light[];
  33802. /**
  33803. * All of the (abstract) meshes added to this scene
  33804. */
  33805. meshes: AbstractMesh[];
  33806. /**
  33807. * The list of skeletons added to the scene
  33808. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33809. */
  33810. skeletons: Skeleton[];
  33811. /**
  33812. * All of the particle systems added to this scene
  33813. * @see http://doc.babylonjs.com/babylon101/particles
  33814. */
  33815. particleSystems: IParticleSystem[];
  33816. /**
  33817. * Gets a list of Animations associated with the scene
  33818. */
  33819. animations: Animation[];
  33820. /**
  33821. * All of the animation groups added to this scene
  33822. * @see http://doc.babylonjs.com/how_to/group
  33823. */
  33824. animationGroups: AnimationGroup[];
  33825. /**
  33826. * All of the multi-materials added to this scene
  33827. * @see http://doc.babylonjs.com/how_to/multi_materials
  33828. */
  33829. multiMaterials: MultiMaterial[];
  33830. /**
  33831. * All of the materials added to this scene
  33832. * In the context of a Scene, it is not supposed to be modified manually.
  33833. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33834. * Note also that the order of the Material wihin the array is not significant and might change.
  33835. * @see http://doc.babylonjs.com/babylon101/materials
  33836. */
  33837. materials: Material[];
  33838. /**
  33839. * The list of morph target managers added to the scene
  33840. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33841. */
  33842. morphTargetManagers: MorphTargetManager[];
  33843. /**
  33844. * The list of geometries used in the scene.
  33845. */
  33846. geometries: Geometry[];
  33847. /**
  33848. * All of the tranform nodes added to this scene
  33849. * In the context of a Scene, it is not supposed to be modified manually.
  33850. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33851. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33852. * @see http://doc.babylonjs.com/how_to/transformnode
  33853. */
  33854. transformNodes: TransformNode[];
  33855. /**
  33856. * ActionManagers available on the scene.
  33857. */
  33858. actionManagers: AbstractActionManager[];
  33859. /**
  33860. * Textures to keep.
  33861. */
  33862. textures: BaseTexture[];
  33863. /**
  33864. * Environment texture for the scene
  33865. */
  33866. environmentTexture: Nullable<BaseTexture>;
  33867. }
  33868. }
  33869. declare module BABYLON {
  33870. /**
  33871. * Defines a sound that can be played in the application.
  33872. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33873. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33874. */
  33875. export class Sound {
  33876. /**
  33877. * The name of the sound in the scene.
  33878. */
  33879. name: string;
  33880. /**
  33881. * Does the sound autoplay once loaded.
  33882. */
  33883. autoplay: boolean;
  33884. /**
  33885. * Does the sound loop after it finishes playing once.
  33886. */
  33887. loop: boolean;
  33888. /**
  33889. * Does the sound use a custom attenuation curve to simulate the falloff
  33890. * happening when the source gets further away from the camera.
  33891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33892. */
  33893. useCustomAttenuation: boolean;
  33894. /**
  33895. * The sound track id this sound belongs to.
  33896. */
  33897. soundTrackId: number;
  33898. /**
  33899. * Is this sound currently played.
  33900. */
  33901. isPlaying: boolean;
  33902. /**
  33903. * Is this sound currently paused.
  33904. */
  33905. isPaused: boolean;
  33906. /**
  33907. * Does this sound enables spatial sound.
  33908. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33909. */
  33910. spatialSound: boolean;
  33911. /**
  33912. * Define the reference distance the sound should be heard perfectly.
  33913. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33914. */
  33915. refDistance: number;
  33916. /**
  33917. * Define the roll off factor of spatial sounds.
  33918. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33919. */
  33920. rolloffFactor: number;
  33921. /**
  33922. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33923. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33924. */
  33925. maxDistance: number;
  33926. /**
  33927. * Define the distance attenuation model the sound will follow.
  33928. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33929. */
  33930. distanceModel: string;
  33931. /**
  33932. * @hidden
  33933. * Back Compat
  33934. **/
  33935. onended: () => any;
  33936. /**
  33937. * Observable event when the current playing sound finishes.
  33938. */
  33939. onEndedObservable: Observable<Sound>;
  33940. private _panningModel;
  33941. private _playbackRate;
  33942. private _streaming;
  33943. private _startTime;
  33944. private _startOffset;
  33945. private _position;
  33946. /** @hidden */
  33947. _positionInEmitterSpace: boolean;
  33948. private _localDirection;
  33949. private _volume;
  33950. private _isReadyToPlay;
  33951. private _isDirectional;
  33952. private _readyToPlayCallback;
  33953. private _audioBuffer;
  33954. private _soundSource;
  33955. private _streamingSource;
  33956. private _soundPanner;
  33957. private _soundGain;
  33958. private _inputAudioNode;
  33959. private _outputAudioNode;
  33960. private _coneInnerAngle;
  33961. private _coneOuterAngle;
  33962. private _coneOuterGain;
  33963. private _scene;
  33964. private _connectedTransformNode;
  33965. private _customAttenuationFunction;
  33966. private _registerFunc;
  33967. private _isOutputConnected;
  33968. private _htmlAudioElement;
  33969. private _urlType;
  33970. /** @hidden */
  33971. static _SceneComponentInitialization: (scene: Scene) => void;
  33972. /**
  33973. * Create a sound and attach it to a scene
  33974. * @param name Name of your sound
  33975. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33976. * @param scene defines the scene the sound belongs to
  33977. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33978. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33979. */
  33980. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33981. /**
  33982. * Release the sound and its associated resources
  33983. */
  33984. dispose(): void;
  33985. /**
  33986. * Gets if the sounds is ready to be played or not.
  33987. * @returns true if ready, otherwise false
  33988. */
  33989. isReady(): boolean;
  33990. private _soundLoaded;
  33991. /**
  33992. * Sets the data of the sound from an audiobuffer
  33993. * @param audioBuffer The audioBuffer containing the data
  33994. */
  33995. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33996. /**
  33997. * Updates the current sounds options such as maxdistance, loop...
  33998. * @param options A JSON object containing values named as the object properties
  33999. */
  34000. updateOptions(options: any): void;
  34001. private _createSpatialParameters;
  34002. private _updateSpatialParameters;
  34003. /**
  34004. * Switch the panning model to HRTF:
  34005. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34006. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34007. */
  34008. switchPanningModelToHRTF(): void;
  34009. /**
  34010. * Switch the panning model to Equal Power:
  34011. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34012. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34013. */
  34014. switchPanningModelToEqualPower(): void;
  34015. private _switchPanningModel;
  34016. /**
  34017. * Connect this sound to a sound track audio node like gain...
  34018. * @param soundTrackAudioNode the sound track audio node to connect to
  34019. */
  34020. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34021. /**
  34022. * Transform this sound into a directional source
  34023. * @param coneInnerAngle Size of the inner cone in degree
  34024. * @param coneOuterAngle Size of the outer cone in degree
  34025. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34026. */
  34027. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34028. /**
  34029. * Gets or sets the inner angle for the directional cone.
  34030. */
  34031. /**
  34032. * Gets or sets the inner angle for the directional cone.
  34033. */
  34034. directionalConeInnerAngle: number;
  34035. /**
  34036. * Gets or sets the outer angle for the directional cone.
  34037. */
  34038. /**
  34039. * Gets or sets the outer angle for the directional cone.
  34040. */
  34041. directionalConeOuterAngle: number;
  34042. /**
  34043. * Sets the position of the emitter if spatial sound is enabled
  34044. * @param newPosition Defines the new posisiton
  34045. */
  34046. setPosition(newPosition: Vector3): void;
  34047. /**
  34048. * Sets the local direction of the emitter if spatial sound is enabled
  34049. * @param newLocalDirection Defines the new local direction
  34050. */
  34051. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34052. private _updateDirection;
  34053. /** @hidden */
  34054. updateDistanceFromListener(): void;
  34055. /**
  34056. * Sets a new custom attenuation function for the sound.
  34057. * @param callback Defines the function used for the attenuation
  34058. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34059. */
  34060. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34061. /**
  34062. * Play the sound
  34063. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34064. * @param offset (optional) Start the sound setting it at a specific time
  34065. */
  34066. play(time?: number, offset?: number): void;
  34067. private _onended;
  34068. /**
  34069. * Stop the sound
  34070. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34071. */
  34072. stop(time?: number): void;
  34073. /**
  34074. * Put the sound in pause
  34075. */
  34076. pause(): void;
  34077. /**
  34078. * Sets a dedicated volume for this sounds
  34079. * @param newVolume Define the new volume of the sound
  34080. * @param time Define in how long the sound should be at this value
  34081. */
  34082. setVolume(newVolume: number, time?: number): void;
  34083. /**
  34084. * Set the sound play back rate
  34085. * @param newPlaybackRate Define the playback rate the sound should be played at
  34086. */
  34087. setPlaybackRate(newPlaybackRate: number): void;
  34088. /**
  34089. * Gets the volume of the sound.
  34090. * @returns the volume of the sound
  34091. */
  34092. getVolume(): number;
  34093. /**
  34094. * Attach the sound to a dedicated mesh
  34095. * @param transformNode The transform node to connect the sound with
  34096. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34097. */
  34098. attachToMesh(transformNode: TransformNode): void;
  34099. /**
  34100. * Detach the sound from the previously attached mesh
  34101. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34102. */
  34103. detachFromMesh(): void;
  34104. private _onRegisterAfterWorldMatrixUpdate;
  34105. /**
  34106. * Clone the current sound in the scene.
  34107. * @returns the new sound clone
  34108. */
  34109. clone(): Nullable<Sound>;
  34110. /**
  34111. * Gets the current underlying audio buffer containing the data
  34112. * @returns the audio buffer
  34113. */
  34114. getAudioBuffer(): Nullable<AudioBuffer>;
  34115. /**
  34116. * Serializes the Sound in a JSON representation
  34117. * @returns the JSON representation of the sound
  34118. */
  34119. serialize(): any;
  34120. /**
  34121. * Parse a JSON representation of a sound to innstantiate in a given scene
  34122. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34123. * @param scene Define the scene the new parsed sound should be created in
  34124. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34125. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34126. * @returns the newly parsed sound
  34127. */
  34128. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34129. }
  34130. }
  34131. declare module BABYLON {
  34132. /**
  34133. * This defines an action helpful to play a defined sound on a triggered action.
  34134. */
  34135. export class PlaySoundAction extends Action {
  34136. private _sound;
  34137. /**
  34138. * Instantiate the action
  34139. * @param triggerOptions defines the trigger options
  34140. * @param sound defines the sound to play
  34141. * @param condition defines the trigger related conditions
  34142. */
  34143. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34144. /** @hidden */
  34145. _prepare(): void;
  34146. /**
  34147. * Execute the action and play the sound.
  34148. */
  34149. execute(): void;
  34150. /**
  34151. * Serializes the actions and its related information.
  34152. * @param parent defines the object to serialize in
  34153. * @returns the serialized object
  34154. */
  34155. serialize(parent: any): any;
  34156. }
  34157. /**
  34158. * This defines an action helpful to stop a defined sound on a triggered action.
  34159. */
  34160. export class StopSoundAction extends Action {
  34161. private _sound;
  34162. /**
  34163. * Instantiate the action
  34164. * @param triggerOptions defines the trigger options
  34165. * @param sound defines the sound to stop
  34166. * @param condition defines the trigger related conditions
  34167. */
  34168. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34169. /** @hidden */
  34170. _prepare(): void;
  34171. /**
  34172. * Execute the action and stop the sound.
  34173. */
  34174. execute(): void;
  34175. /**
  34176. * Serializes the actions and its related information.
  34177. * @param parent defines the object to serialize in
  34178. * @returns the serialized object
  34179. */
  34180. serialize(parent: any): any;
  34181. }
  34182. }
  34183. declare module BABYLON {
  34184. /**
  34185. * This defines an action responsible to change the value of a property
  34186. * by interpolating between its current value and the newly set one once triggered.
  34187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34188. */
  34189. export class InterpolateValueAction extends Action {
  34190. /**
  34191. * Defines the path of the property where the value should be interpolated
  34192. */
  34193. propertyPath: string;
  34194. /**
  34195. * Defines the target value at the end of the interpolation.
  34196. */
  34197. value: any;
  34198. /**
  34199. * Defines the time it will take for the property to interpolate to the value.
  34200. */
  34201. duration: number;
  34202. /**
  34203. * Defines if the other scene animations should be stopped when the action has been triggered
  34204. */
  34205. stopOtherAnimations?: boolean;
  34206. /**
  34207. * Defines a callback raised once the interpolation animation has been done.
  34208. */
  34209. onInterpolationDone?: () => void;
  34210. /**
  34211. * Observable triggered once the interpolation animation has been done.
  34212. */
  34213. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34214. private _target;
  34215. private _effectiveTarget;
  34216. private _property;
  34217. /**
  34218. * Instantiate the action
  34219. * @param triggerOptions defines the trigger options
  34220. * @param target defines the object containing the value to interpolate
  34221. * @param propertyPath defines the path to the property in the target object
  34222. * @param value defines the target value at the end of the interpolation
  34223. * @param duration deines the time it will take for the property to interpolate to the value.
  34224. * @param condition defines the trigger related conditions
  34225. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34226. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34227. */
  34228. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34229. /** @hidden */
  34230. _prepare(): void;
  34231. /**
  34232. * Execute the action starts the value interpolation.
  34233. */
  34234. execute(): void;
  34235. /**
  34236. * Serializes the actions and its related information.
  34237. * @param parent defines the object to serialize in
  34238. * @returns the serialized object
  34239. */
  34240. serialize(parent: any): any;
  34241. }
  34242. }
  34243. declare module BABYLON {
  34244. /**
  34245. * Options allowed during the creation of a sound track.
  34246. */
  34247. export interface ISoundTrackOptions {
  34248. /**
  34249. * The volume the sound track should take during creation
  34250. */
  34251. volume?: number;
  34252. /**
  34253. * Define if the sound track is the main sound track of the scene
  34254. */
  34255. mainTrack?: boolean;
  34256. }
  34257. /**
  34258. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34259. * It will be also used in a future release to apply effects on a specific track.
  34260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34261. */
  34262. export class SoundTrack {
  34263. /**
  34264. * The unique identifier of the sound track in the scene.
  34265. */
  34266. id: number;
  34267. /**
  34268. * The list of sounds included in the sound track.
  34269. */
  34270. soundCollection: Array<Sound>;
  34271. private _outputAudioNode;
  34272. private _scene;
  34273. private _isMainTrack;
  34274. private _connectedAnalyser;
  34275. private _options;
  34276. private _isInitialized;
  34277. /**
  34278. * Creates a new sound track.
  34279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34280. * @param scene Define the scene the sound track belongs to
  34281. * @param options
  34282. */
  34283. constructor(scene: Scene, options?: ISoundTrackOptions);
  34284. private _initializeSoundTrackAudioGraph;
  34285. /**
  34286. * Release the sound track and its associated resources
  34287. */
  34288. dispose(): void;
  34289. /**
  34290. * Adds a sound to this sound track
  34291. * @param sound define the cound to add
  34292. * @ignoreNaming
  34293. */
  34294. AddSound(sound: Sound): void;
  34295. /**
  34296. * Removes a sound to this sound track
  34297. * @param sound define the cound to remove
  34298. * @ignoreNaming
  34299. */
  34300. RemoveSound(sound: Sound): void;
  34301. /**
  34302. * Set a global volume for the full sound track.
  34303. * @param newVolume Define the new volume of the sound track
  34304. */
  34305. setVolume(newVolume: number): void;
  34306. /**
  34307. * Switch the panning model to HRTF:
  34308. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34309. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34310. */
  34311. switchPanningModelToHRTF(): void;
  34312. /**
  34313. * Switch the panning model to Equal Power:
  34314. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34316. */
  34317. switchPanningModelToEqualPower(): void;
  34318. /**
  34319. * Connect the sound track to an audio analyser allowing some amazing
  34320. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34322. * @param analyser The analyser to connect to the engine
  34323. */
  34324. connectToAnalyser(analyser: Analyser): void;
  34325. }
  34326. }
  34327. declare module BABYLON {
  34328. interface AbstractScene {
  34329. /**
  34330. * The list of sounds used in the scene.
  34331. */
  34332. sounds: Nullable<Array<Sound>>;
  34333. }
  34334. interface Scene {
  34335. /**
  34336. * @hidden
  34337. * Backing field
  34338. */
  34339. _mainSoundTrack: SoundTrack;
  34340. /**
  34341. * The main sound track played by the scene.
  34342. * It cotains your primary collection of sounds.
  34343. */
  34344. mainSoundTrack: SoundTrack;
  34345. /**
  34346. * The list of sound tracks added to the scene
  34347. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34348. */
  34349. soundTracks: Nullable<Array<SoundTrack>>;
  34350. /**
  34351. * Gets a sound using a given name
  34352. * @param name defines the name to search for
  34353. * @return the found sound or null if not found at all.
  34354. */
  34355. getSoundByName(name: string): Nullable<Sound>;
  34356. /**
  34357. * Gets or sets if audio support is enabled
  34358. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34359. */
  34360. audioEnabled: boolean;
  34361. /**
  34362. * Gets or sets if audio will be output to headphones
  34363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34364. */
  34365. headphone: boolean;
  34366. }
  34367. /**
  34368. * Defines the sound scene component responsible to manage any sounds
  34369. * in a given scene.
  34370. */
  34371. export class AudioSceneComponent implements ISceneSerializableComponent {
  34372. /**
  34373. * The component name helpfull to identify the component in the list of scene components.
  34374. */
  34375. readonly name: string;
  34376. /**
  34377. * The scene the component belongs to.
  34378. */
  34379. scene: Scene;
  34380. private _audioEnabled;
  34381. /**
  34382. * Gets whether audio is enabled or not.
  34383. * Please use related enable/disable method to switch state.
  34384. */
  34385. readonly audioEnabled: boolean;
  34386. private _headphone;
  34387. /**
  34388. * Gets whether audio is outputing to headphone or not.
  34389. * Please use the according Switch methods to change output.
  34390. */
  34391. readonly headphone: boolean;
  34392. /**
  34393. * Creates a new instance of the component for the given scene
  34394. * @param scene Defines the scene to register the component in
  34395. */
  34396. constructor(scene: Scene);
  34397. /**
  34398. * Registers the component in a given scene
  34399. */
  34400. register(): void;
  34401. /**
  34402. * Rebuilds the elements related to this component in case of
  34403. * context lost for instance.
  34404. */
  34405. rebuild(): void;
  34406. /**
  34407. * Serializes the component data to the specified json object
  34408. * @param serializationObject The object to serialize to
  34409. */
  34410. serialize(serializationObject: any): void;
  34411. /**
  34412. * Adds all the element from the container to the scene
  34413. * @param container the container holding the elements
  34414. */
  34415. addFromContainer(container: AbstractScene): void;
  34416. /**
  34417. * Removes all the elements in the container from the scene
  34418. * @param container contains the elements to remove
  34419. * @param dispose if the removed element should be disposed (default: false)
  34420. */
  34421. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34422. /**
  34423. * Disposes the component and the associated ressources.
  34424. */
  34425. dispose(): void;
  34426. /**
  34427. * Disables audio in the associated scene.
  34428. */
  34429. disableAudio(): void;
  34430. /**
  34431. * Enables audio in the associated scene.
  34432. */
  34433. enableAudio(): void;
  34434. /**
  34435. * Switch audio to headphone output.
  34436. */
  34437. switchAudioModeForHeadphones(): void;
  34438. /**
  34439. * Switch audio to normal speakers.
  34440. */
  34441. switchAudioModeForNormalSpeakers(): void;
  34442. private _afterRender;
  34443. }
  34444. }
  34445. declare module BABYLON {
  34446. /**
  34447. * Wraps one or more Sound objects and selects one with random weight for playback.
  34448. */
  34449. export class WeightedSound {
  34450. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34451. loop: boolean;
  34452. private _coneInnerAngle;
  34453. private _coneOuterAngle;
  34454. private _volume;
  34455. /** A Sound is currently playing. */
  34456. isPlaying: boolean;
  34457. /** A Sound is currently paused. */
  34458. isPaused: boolean;
  34459. private _sounds;
  34460. private _weights;
  34461. private _currentIndex?;
  34462. /**
  34463. * Creates a new WeightedSound from the list of sounds given.
  34464. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34465. * @param sounds Array of Sounds that will be selected from.
  34466. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34467. */
  34468. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34469. /**
  34470. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34471. */
  34472. /**
  34473. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34474. */
  34475. directionalConeInnerAngle: number;
  34476. /**
  34477. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34478. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34479. */
  34480. /**
  34481. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34482. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34483. */
  34484. directionalConeOuterAngle: number;
  34485. /**
  34486. * Playback volume.
  34487. */
  34488. /**
  34489. * Playback volume.
  34490. */
  34491. volume: number;
  34492. private _onended;
  34493. /**
  34494. * Suspend playback
  34495. */
  34496. pause(): void;
  34497. /**
  34498. * Stop playback
  34499. */
  34500. stop(): void;
  34501. /**
  34502. * Start playback.
  34503. * @param startOffset Position the clip head at a specific time in seconds.
  34504. */
  34505. play(startOffset?: number): void;
  34506. }
  34507. }
  34508. declare module BABYLON {
  34509. /**
  34510. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34511. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34512. */
  34513. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34514. /**
  34515. * Gets the name of the behavior.
  34516. */
  34517. readonly name: string;
  34518. /**
  34519. * The easing function used by animations
  34520. */
  34521. static EasingFunction: BackEase;
  34522. /**
  34523. * The easing mode used by animations
  34524. */
  34525. static EasingMode: number;
  34526. /**
  34527. * The duration of the animation, in milliseconds
  34528. */
  34529. transitionDuration: number;
  34530. /**
  34531. * Length of the distance animated by the transition when lower radius is reached
  34532. */
  34533. lowerRadiusTransitionRange: number;
  34534. /**
  34535. * Length of the distance animated by the transition when upper radius is reached
  34536. */
  34537. upperRadiusTransitionRange: number;
  34538. private _autoTransitionRange;
  34539. /**
  34540. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34541. */
  34542. /**
  34543. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34544. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34545. */
  34546. autoTransitionRange: boolean;
  34547. private _attachedCamera;
  34548. private _onAfterCheckInputsObserver;
  34549. private _onMeshTargetChangedObserver;
  34550. /**
  34551. * Initializes the behavior.
  34552. */
  34553. init(): void;
  34554. /**
  34555. * Attaches the behavior to its arc rotate camera.
  34556. * @param camera Defines the camera to attach the behavior to
  34557. */
  34558. attach(camera: ArcRotateCamera): void;
  34559. /**
  34560. * Detaches the behavior from its current arc rotate camera.
  34561. */
  34562. detach(): void;
  34563. private _radiusIsAnimating;
  34564. private _radiusBounceTransition;
  34565. private _animatables;
  34566. private _cachedWheelPrecision;
  34567. /**
  34568. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34569. * @param radiusLimit The limit to check against.
  34570. * @return Bool to indicate if at limit.
  34571. */
  34572. private _isRadiusAtLimit;
  34573. /**
  34574. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34575. * @param radiusDelta The delta by which to animate to. Can be negative.
  34576. */
  34577. private _applyBoundRadiusAnimation;
  34578. /**
  34579. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34580. */
  34581. protected _clearAnimationLocks(): void;
  34582. /**
  34583. * Stops and removes all animations that have been applied to the camera
  34584. */
  34585. stopAllAnimations(): void;
  34586. }
  34587. }
  34588. declare module BABYLON {
  34589. /**
  34590. * 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.
  34591. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34592. */
  34593. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34594. /**
  34595. * Gets the name of the behavior.
  34596. */
  34597. readonly name: string;
  34598. private _mode;
  34599. private _radiusScale;
  34600. private _positionScale;
  34601. private _defaultElevation;
  34602. private _elevationReturnTime;
  34603. private _elevationReturnWaitTime;
  34604. private _zoomStopsAnimation;
  34605. private _framingTime;
  34606. /**
  34607. * The easing function used by animations
  34608. */
  34609. static EasingFunction: ExponentialEase;
  34610. /**
  34611. * The easing mode used by animations
  34612. */
  34613. static EasingMode: number;
  34614. /**
  34615. * Sets the current mode used by the behavior
  34616. */
  34617. /**
  34618. * Gets current mode used by the behavior.
  34619. */
  34620. mode: number;
  34621. /**
  34622. * Sets the scale applied to the radius (1 by default)
  34623. */
  34624. /**
  34625. * Gets the scale applied to the radius
  34626. */
  34627. radiusScale: number;
  34628. /**
  34629. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34630. */
  34631. /**
  34632. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34633. */
  34634. positionScale: number;
  34635. /**
  34636. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34637. * behaviour is triggered, in radians.
  34638. */
  34639. /**
  34640. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34641. * behaviour is triggered, in radians.
  34642. */
  34643. defaultElevation: number;
  34644. /**
  34645. * Sets the time (in milliseconds) taken to return to the default beta position.
  34646. * Negative value indicates camera should not return to default.
  34647. */
  34648. /**
  34649. * Gets the time (in milliseconds) taken to return to the default beta position.
  34650. * Negative value indicates camera should not return to default.
  34651. */
  34652. elevationReturnTime: number;
  34653. /**
  34654. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34655. */
  34656. /**
  34657. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34658. */
  34659. elevationReturnWaitTime: number;
  34660. /**
  34661. * Sets the flag that indicates if user zooming should stop animation.
  34662. */
  34663. /**
  34664. * Gets the flag that indicates if user zooming should stop animation.
  34665. */
  34666. zoomStopsAnimation: boolean;
  34667. /**
  34668. * Sets the transition time when framing the mesh, in milliseconds
  34669. */
  34670. /**
  34671. * Gets the transition time when framing the mesh, in milliseconds
  34672. */
  34673. framingTime: number;
  34674. /**
  34675. * Define if the behavior should automatically change the configured
  34676. * camera limits and sensibilities.
  34677. */
  34678. autoCorrectCameraLimitsAndSensibility: boolean;
  34679. private _onPrePointerObservableObserver;
  34680. private _onAfterCheckInputsObserver;
  34681. private _onMeshTargetChangedObserver;
  34682. private _attachedCamera;
  34683. private _isPointerDown;
  34684. private _lastInteractionTime;
  34685. /**
  34686. * Initializes the behavior.
  34687. */
  34688. init(): void;
  34689. /**
  34690. * Attaches the behavior to its arc rotate camera.
  34691. * @param camera Defines the camera to attach the behavior to
  34692. */
  34693. attach(camera: ArcRotateCamera): void;
  34694. /**
  34695. * Detaches the behavior from its current arc rotate camera.
  34696. */
  34697. detach(): void;
  34698. private _animatables;
  34699. private _betaIsAnimating;
  34700. private _betaTransition;
  34701. private _radiusTransition;
  34702. private _vectorTransition;
  34703. /**
  34704. * Targets the given mesh and updates zoom level accordingly.
  34705. * @param mesh The mesh to target.
  34706. * @param radius Optional. If a cached radius position already exists, overrides default.
  34707. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34708. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34709. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34710. */
  34711. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34712. /**
  34713. * Targets the given mesh with its children and updates zoom level accordingly.
  34714. * @param mesh The mesh to target.
  34715. * @param radius Optional. If a cached radius position already exists, overrides default.
  34716. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34717. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34718. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34719. */
  34720. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34721. /**
  34722. * Targets the given meshes with their children and updates zoom level accordingly.
  34723. * @param meshes The mesh to target.
  34724. * @param radius Optional. If a cached radius position already exists, overrides default.
  34725. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34726. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34727. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34728. */
  34729. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34730. /**
  34731. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34732. * @param minimumWorld Determines the smaller position of the bounding box extend
  34733. * @param maximumWorld Determines the bigger position of the bounding box extend
  34734. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34735. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34736. */
  34737. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34738. /**
  34739. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34740. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34741. * frustum width.
  34742. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34743. * to fully enclose the mesh in the viewing frustum.
  34744. */
  34745. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34746. /**
  34747. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34748. * is automatically returned to its default position (expected to be above ground plane).
  34749. */
  34750. private _maintainCameraAboveGround;
  34751. /**
  34752. * Returns the frustum slope based on the canvas ratio and camera FOV
  34753. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34754. */
  34755. private _getFrustumSlope;
  34756. /**
  34757. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34758. */
  34759. private _clearAnimationLocks;
  34760. /**
  34761. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34762. */
  34763. private _applyUserInteraction;
  34764. /**
  34765. * Stops and removes all animations that have been applied to the camera
  34766. */
  34767. stopAllAnimations(): void;
  34768. /**
  34769. * Gets a value indicating if the user is moving the camera
  34770. */
  34771. readonly isUserIsMoving: boolean;
  34772. /**
  34773. * The camera can move all the way towards the mesh.
  34774. */
  34775. static IgnoreBoundsSizeMode: number;
  34776. /**
  34777. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34778. */
  34779. static FitFrustumSidesMode: number;
  34780. }
  34781. }
  34782. declare module BABYLON {
  34783. /**
  34784. * Base class for Camera Pointer Inputs.
  34785. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34786. * for example usage.
  34787. */
  34788. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34789. /**
  34790. * Defines the camera the input is attached to.
  34791. */
  34792. abstract camera: Camera;
  34793. /**
  34794. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34795. */
  34796. protected _altKey: boolean;
  34797. protected _ctrlKey: boolean;
  34798. protected _metaKey: boolean;
  34799. protected _shiftKey: boolean;
  34800. /**
  34801. * Which mouse buttons were pressed at time of last mouse event.
  34802. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34803. */
  34804. protected _buttonsPressed: number;
  34805. /**
  34806. * Defines the buttons associated with the input to handle camera move.
  34807. */
  34808. buttons: number[];
  34809. /**
  34810. * Attach the input controls to a specific dom element to get the input from.
  34811. * @param element Defines the element the controls should be listened from
  34812. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34813. */
  34814. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34815. /**
  34816. * Detach the current controls from the specified dom element.
  34817. * @param element Defines the element to stop listening the inputs from
  34818. */
  34819. detachControl(element: Nullable<HTMLElement>): void;
  34820. /**
  34821. * Gets the class name of the current input.
  34822. * @returns the class name
  34823. */
  34824. getClassName(): string;
  34825. /**
  34826. * Get the friendly name associated with the input class.
  34827. * @returns the input friendly name
  34828. */
  34829. getSimpleName(): string;
  34830. /**
  34831. * Called on pointer POINTERDOUBLETAP event.
  34832. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34833. */
  34834. protected onDoubleTap(type: string): void;
  34835. /**
  34836. * Called on pointer POINTERMOVE event if only a single touch is active.
  34837. * Override this method to provide functionality.
  34838. */
  34839. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34840. /**
  34841. * Called on pointer POINTERMOVE event if multiple touches are active.
  34842. * Override this method to provide functionality.
  34843. */
  34844. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34845. /**
  34846. * Called on JS contextmenu event.
  34847. * Override this method to provide functionality.
  34848. */
  34849. protected onContextMenu(evt: PointerEvent): void;
  34850. /**
  34851. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34852. * press.
  34853. * Override this method to provide functionality.
  34854. */
  34855. protected onButtonDown(evt: PointerEvent): void;
  34856. /**
  34857. * Called each time a new POINTERUP event occurs. Ie, for each button
  34858. * release.
  34859. * Override this method to provide functionality.
  34860. */
  34861. protected onButtonUp(evt: PointerEvent): void;
  34862. /**
  34863. * Called when window becomes inactive.
  34864. * Override this method to provide functionality.
  34865. */
  34866. protected onLostFocus(): void;
  34867. private _pointerInput;
  34868. private _observer;
  34869. private _onLostFocus;
  34870. private pointA;
  34871. private pointB;
  34872. }
  34873. }
  34874. declare module BABYLON {
  34875. /**
  34876. * Manage the pointers inputs to control an arc rotate camera.
  34877. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34878. */
  34879. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34880. /**
  34881. * Defines the camera the input is attached to.
  34882. */
  34883. camera: ArcRotateCamera;
  34884. /**
  34885. * Gets the class name of the current input.
  34886. * @returns the class name
  34887. */
  34888. getClassName(): string;
  34889. /**
  34890. * Defines the buttons associated with the input to handle camera move.
  34891. */
  34892. buttons: number[];
  34893. /**
  34894. * Defines the pointer angular sensibility along the X axis or how fast is
  34895. * the camera rotating.
  34896. */
  34897. angularSensibilityX: number;
  34898. /**
  34899. * Defines the pointer angular sensibility along the Y axis or how fast is
  34900. * the camera rotating.
  34901. */
  34902. angularSensibilityY: number;
  34903. /**
  34904. * Defines the pointer pinch precision or how fast is the camera zooming.
  34905. */
  34906. pinchPrecision: number;
  34907. /**
  34908. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34909. * from 0.
  34910. * It defines the percentage of current camera.radius to use as delta when
  34911. * pinch zoom is used.
  34912. */
  34913. pinchDeltaPercentage: number;
  34914. /**
  34915. * Defines the pointer panning sensibility or how fast is the camera moving.
  34916. */
  34917. panningSensibility: number;
  34918. /**
  34919. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34920. */
  34921. multiTouchPanning: boolean;
  34922. /**
  34923. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34924. * zoom (pinch) through multitouch.
  34925. */
  34926. multiTouchPanAndZoom: boolean;
  34927. /**
  34928. * Revers pinch action direction.
  34929. */
  34930. pinchInwards: boolean;
  34931. private _isPanClick;
  34932. private _twoFingerActivityCount;
  34933. private _isPinching;
  34934. /**
  34935. * Called on pointer POINTERMOVE event if only a single touch is active.
  34936. */
  34937. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34938. /**
  34939. * Called on pointer POINTERDOUBLETAP event.
  34940. */
  34941. protected onDoubleTap(type: string): void;
  34942. /**
  34943. * Called on pointer POINTERMOVE event if multiple touches are active.
  34944. */
  34945. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34946. /**
  34947. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34948. * press.
  34949. */
  34950. protected onButtonDown(evt: PointerEvent): void;
  34951. /**
  34952. * Called each time a new POINTERUP event occurs. Ie, for each button
  34953. * release.
  34954. */
  34955. protected onButtonUp(evt: PointerEvent): void;
  34956. /**
  34957. * Called when window becomes inactive.
  34958. */
  34959. protected onLostFocus(): void;
  34960. }
  34961. }
  34962. declare module BABYLON {
  34963. /**
  34964. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34965. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34966. */
  34967. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34968. /**
  34969. * Defines the camera the input is attached to.
  34970. */
  34971. camera: ArcRotateCamera;
  34972. /**
  34973. * Defines the list of key codes associated with the up action (increase alpha)
  34974. */
  34975. keysUp: number[];
  34976. /**
  34977. * Defines the list of key codes associated with the down action (decrease alpha)
  34978. */
  34979. keysDown: number[];
  34980. /**
  34981. * Defines the list of key codes associated with the left action (increase beta)
  34982. */
  34983. keysLeft: number[];
  34984. /**
  34985. * Defines the list of key codes associated with the right action (decrease beta)
  34986. */
  34987. keysRight: number[];
  34988. /**
  34989. * Defines the list of key codes associated with the reset action.
  34990. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34991. */
  34992. keysReset: number[];
  34993. /**
  34994. * Defines the panning sensibility of the inputs.
  34995. * (How fast is the camera paning)
  34996. */
  34997. panningSensibility: number;
  34998. /**
  34999. * Defines the zooming sensibility of the inputs.
  35000. * (How fast is the camera zooming)
  35001. */
  35002. zoomingSensibility: number;
  35003. /**
  35004. * Defines wether maintaining the alt key down switch the movement mode from
  35005. * orientation to zoom.
  35006. */
  35007. useAltToZoom: boolean;
  35008. /**
  35009. * Rotation speed of the camera
  35010. */
  35011. angularSpeed: number;
  35012. private _keys;
  35013. private _ctrlPressed;
  35014. private _altPressed;
  35015. private _onCanvasBlurObserver;
  35016. private _onKeyboardObserver;
  35017. private _engine;
  35018. private _scene;
  35019. /**
  35020. * Attach the input controls to a specific dom element to get the input from.
  35021. * @param element Defines the element the controls should be listened from
  35022. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35023. */
  35024. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35025. /**
  35026. * Detach the current controls from the specified dom element.
  35027. * @param element Defines the element to stop listening the inputs from
  35028. */
  35029. detachControl(element: Nullable<HTMLElement>): void;
  35030. /**
  35031. * Update the current camera state depending on the inputs that have been used this frame.
  35032. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35033. */
  35034. checkInputs(): void;
  35035. /**
  35036. * Gets the class name of the current intput.
  35037. * @returns the class name
  35038. */
  35039. getClassName(): string;
  35040. /**
  35041. * Get the friendly name associated with the input class.
  35042. * @returns the input friendly name
  35043. */
  35044. getSimpleName(): string;
  35045. }
  35046. }
  35047. declare module BABYLON {
  35048. /**
  35049. * Manage the mouse wheel inputs to control an arc rotate camera.
  35050. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35051. */
  35052. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35053. /**
  35054. * Defines the camera the input is attached to.
  35055. */
  35056. camera: ArcRotateCamera;
  35057. /**
  35058. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35059. */
  35060. wheelPrecision: number;
  35061. /**
  35062. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35063. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35064. */
  35065. wheelDeltaPercentage: number;
  35066. private _wheel;
  35067. private _observer;
  35068. private computeDeltaFromMouseWheelLegacyEvent;
  35069. /**
  35070. * Attach the input controls to a specific dom element to get the input from.
  35071. * @param element Defines the element the controls should be listened from
  35072. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35073. */
  35074. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35075. /**
  35076. * Detach the current controls from the specified dom element.
  35077. * @param element Defines the element to stop listening the inputs from
  35078. */
  35079. detachControl(element: Nullable<HTMLElement>): void;
  35080. /**
  35081. * Gets the class name of the current intput.
  35082. * @returns the class name
  35083. */
  35084. getClassName(): string;
  35085. /**
  35086. * Get the friendly name associated with the input class.
  35087. * @returns the input friendly name
  35088. */
  35089. getSimpleName(): string;
  35090. }
  35091. }
  35092. declare module BABYLON {
  35093. /**
  35094. * Default Inputs manager for the ArcRotateCamera.
  35095. * It groups all the default supported inputs for ease of use.
  35096. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35097. */
  35098. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35099. /**
  35100. * Instantiates a new ArcRotateCameraInputsManager.
  35101. * @param camera Defines the camera the inputs belong to
  35102. */
  35103. constructor(camera: ArcRotateCamera);
  35104. /**
  35105. * Add mouse wheel input support to the input manager.
  35106. * @returns the current input manager
  35107. */
  35108. addMouseWheel(): ArcRotateCameraInputsManager;
  35109. /**
  35110. * Add pointers input support to the input manager.
  35111. * @returns the current input manager
  35112. */
  35113. addPointers(): ArcRotateCameraInputsManager;
  35114. /**
  35115. * Add keyboard input support to the input manager.
  35116. * @returns the current input manager
  35117. */
  35118. addKeyboard(): ArcRotateCameraInputsManager;
  35119. }
  35120. }
  35121. declare module BABYLON {
  35122. /**
  35123. * This represents an orbital type of camera.
  35124. *
  35125. * 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.
  35126. * 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.
  35127. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35128. */
  35129. export class ArcRotateCamera extends TargetCamera {
  35130. /**
  35131. * Defines the rotation angle of the camera along the longitudinal axis.
  35132. */
  35133. alpha: number;
  35134. /**
  35135. * Defines the rotation angle of the camera along the latitudinal axis.
  35136. */
  35137. beta: number;
  35138. /**
  35139. * Defines the radius of the camera from it s target point.
  35140. */
  35141. radius: number;
  35142. protected _target: Vector3;
  35143. protected _targetHost: Nullable<AbstractMesh>;
  35144. /**
  35145. * Defines the target point of the camera.
  35146. * The camera looks towards it form the radius distance.
  35147. */
  35148. target: Vector3;
  35149. /**
  35150. * Define the current local position of the camera in the scene
  35151. */
  35152. position: Vector3;
  35153. protected _upVector: Vector3;
  35154. protected _upToYMatrix: Matrix;
  35155. protected _YToUpMatrix: Matrix;
  35156. /**
  35157. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35158. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35159. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35160. */
  35161. upVector: Vector3;
  35162. /**
  35163. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35164. */
  35165. setMatUp(): void;
  35166. /**
  35167. * Current inertia value on the longitudinal axis.
  35168. * The bigger this number the longer it will take for the camera to stop.
  35169. */
  35170. inertialAlphaOffset: number;
  35171. /**
  35172. * Current inertia value on the latitudinal axis.
  35173. * The bigger this number the longer it will take for the camera to stop.
  35174. */
  35175. inertialBetaOffset: number;
  35176. /**
  35177. * Current inertia value on the radius axis.
  35178. * The bigger this number the longer it will take for the camera to stop.
  35179. */
  35180. inertialRadiusOffset: number;
  35181. /**
  35182. * Minimum allowed angle on the longitudinal axis.
  35183. * This can help limiting how the Camera is able to move in the scene.
  35184. */
  35185. lowerAlphaLimit: Nullable<number>;
  35186. /**
  35187. * Maximum allowed angle on the longitudinal axis.
  35188. * This can help limiting how the Camera is able to move in the scene.
  35189. */
  35190. upperAlphaLimit: Nullable<number>;
  35191. /**
  35192. * Minimum allowed angle on the latitudinal axis.
  35193. * This can help limiting how the Camera is able to move in the scene.
  35194. */
  35195. lowerBetaLimit: number;
  35196. /**
  35197. * Maximum allowed angle on the latitudinal axis.
  35198. * This can help limiting how the Camera is able to move in the scene.
  35199. */
  35200. upperBetaLimit: number;
  35201. /**
  35202. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35203. * This can help limiting how the Camera is able to move in the scene.
  35204. */
  35205. lowerRadiusLimit: Nullable<number>;
  35206. /**
  35207. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35208. * This can help limiting how the Camera is able to move in the scene.
  35209. */
  35210. upperRadiusLimit: Nullable<number>;
  35211. /**
  35212. * Defines the current inertia value used during panning of the camera along the X axis.
  35213. */
  35214. inertialPanningX: number;
  35215. /**
  35216. * Defines the current inertia value used during panning of the camera along the Y axis.
  35217. */
  35218. inertialPanningY: number;
  35219. /**
  35220. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35221. * Basically if your fingers moves away from more than this distance you will be considered
  35222. * in pinch mode.
  35223. */
  35224. pinchToPanMaxDistance: number;
  35225. /**
  35226. * Defines the maximum distance the camera can pan.
  35227. * This could help keeping the cammera always in your scene.
  35228. */
  35229. panningDistanceLimit: Nullable<number>;
  35230. /**
  35231. * Defines the target of the camera before paning.
  35232. */
  35233. panningOriginTarget: Vector3;
  35234. /**
  35235. * Defines the value of the inertia used during panning.
  35236. * 0 would mean stop inertia and one would mean no decelleration at all.
  35237. */
  35238. panningInertia: number;
  35239. /**
  35240. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35241. */
  35242. angularSensibilityX: number;
  35243. /**
  35244. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35245. */
  35246. angularSensibilityY: number;
  35247. /**
  35248. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35249. */
  35250. pinchPrecision: number;
  35251. /**
  35252. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35253. * It will be used instead of pinchDeltaPrecision if different from 0.
  35254. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35255. */
  35256. pinchDeltaPercentage: number;
  35257. /**
  35258. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35259. */
  35260. panningSensibility: number;
  35261. /**
  35262. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35263. */
  35264. keysUp: number[];
  35265. /**
  35266. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35267. */
  35268. keysDown: number[];
  35269. /**
  35270. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35271. */
  35272. keysLeft: number[];
  35273. /**
  35274. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35275. */
  35276. keysRight: number[];
  35277. /**
  35278. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35279. */
  35280. wheelPrecision: number;
  35281. /**
  35282. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35283. * It will be used instead of pinchDeltaPrecision if different from 0.
  35284. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35285. */
  35286. wheelDeltaPercentage: number;
  35287. /**
  35288. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35289. */
  35290. zoomOnFactor: number;
  35291. /**
  35292. * Defines a screen offset for the camera position.
  35293. */
  35294. targetScreenOffset: Vector2;
  35295. /**
  35296. * Allows the camera to be completely reversed.
  35297. * If false the camera can not arrive upside down.
  35298. */
  35299. allowUpsideDown: boolean;
  35300. /**
  35301. * Define if double tap/click is used to restore the previously saved state of the camera.
  35302. */
  35303. useInputToRestoreState: boolean;
  35304. /** @hidden */
  35305. _viewMatrix: Matrix;
  35306. /** @hidden */
  35307. _useCtrlForPanning: boolean;
  35308. /** @hidden */
  35309. _panningMouseButton: number;
  35310. /**
  35311. * Defines the input associated to the camera.
  35312. */
  35313. inputs: ArcRotateCameraInputsManager;
  35314. /** @hidden */
  35315. _reset: () => void;
  35316. /**
  35317. * Defines the allowed panning axis.
  35318. */
  35319. panningAxis: Vector3;
  35320. protected _localDirection: Vector3;
  35321. protected _transformedDirection: Vector3;
  35322. private _bouncingBehavior;
  35323. /**
  35324. * Gets the bouncing behavior of the camera if it has been enabled.
  35325. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35326. */
  35327. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35328. /**
  35329. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35330. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35331. */
  35332. useBouncingBehavior: boolean;
  35333. private _framingBehavior;
  35334. /**
  35335. * Gets the framing behavior of the camera if it has been enabled.
  35336. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35337. */
  35338. readonly framingBehavior: Nullable<FramingBehavior>;
  35339. /**
  35340. * Defines if the framing behavior of the camera is enabled on the camera.
  35341. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35342. */
  35343. useFramingBehavior: boolean;
  35344. private _autoRotationBehavior;
  35345. /**
  35346. * Gets the auto rotation behavior of the camera if it has been enabled.
  35347. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35348. */
  35349. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35350. /**
  35351. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35352. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35353. */
  35354. useAutoRotationBehavior: boolean;
  35355. /**
  35356. * Observable triggered when the mesh target has been changed on the camera.
  35357. */
  35358. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35359. /**
  35360. * Event raised when the camera is colliding with a mesh.
  35361. */
  35362. onCollide: (collidedMesh: AbstractMesh) => void;
  35363. /**
  35364. * Defines whether the camera should check collision with the objects oh the scene.
  35365. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35366. */
  35367. checkCollisions: boolean;
  35368. /**
  35369. * Defines the collision radius of the camera.
  35370. * This simulates a sphere around the camera.
  35371. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35372. */
  35373. collisionRadius: Vector3;
  35374. protected _collider: Collider;
  35375. protected _previousPosition: Vector3;
  35376. protected _collisionVelocity: Vector3;
  35377. protected _newPosition: Vector3;
  35378. protected _previousAlpha: number;
  35379. protected _previousBeta: number;
  35380. protected _previousRadius: number;
  35381. protected _collisionTriggered: boolean;
  35382. protected _targetBoundingCenter: Nullable<Vector3>;
  35383. private _computationVector;
  35384. /**
  35385. * Instantiates a new ArcRotateCamera in a given scene
  35386. * @param name Defines the name of the camera
  35387. * @param alpha Defines the camera rotation along the logitudinal axis
  35388. * @param beta Defines the camera rotation along the latitudinal axis
  35389. * @param radius Defines the camera distance from its target
  35390. * @param target Defines the camera target
  35391. * @param scene Defines the scene the camera belongs to
  35392. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35393. */
  35394. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35395. /** @hidden */
  35396. _initCache(): void;
  35397. /** @hidden */
  35398. _updateCache(ignoreParentClass?: boolean): void;
  35399. protected _getTargetPosition(): Vector3;
  35400. private _storedAlpha;
  35401. private _storedBeta;
  35402. private _storedRadius;
  35403. private _storedTarget;
  35404. /**
  35405. * Stores the current state of the camera (alpha, beta, radius and target)
  35406. * @returns the camera itself
  35407. */
  35408. storeState(): Camera;
  35409. /**
  35410. * @hidden
  35411. * Restored camera state. You must call storeState() first
  35412. */
  35413. _restoreStateValues(): boolean;
  35414. /** @hidden */
  35415. _isSynchronizedViewMatrix(): boolean;
  35416. /**
  35417. * Attached controls to the current camera.
  35418. * @param element Defines the element the controls should be listened from
  35419. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35420. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35421. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35422. */
  35423. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35424. /**
  35425. * Detach the current controls from the camera.
  35426. * The camera will stop reacting to inputs.
  35427. * @param element Defines the element to stop listening the inputs from
  35428. */
  35429. detachControl(element: HTMLElement): void;
  35430. /** @hidden */
  35431. _checkInputs(): void;
  35432. protected _checkLimits(): void;
  35433. /**
  35434. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35435. */
  35436. rebuildAnglesAndRadius(): void;
  35437. /**
  35438. * Use a position to define the current camera related information like aplha, beta and radius
  35439. * @param position Defines the position to set the camera at
  35440. */
  35441. setPosition(position: Vector3): void;
  35442. /**
  35443. * Defines the target the camera should look at.
  35444. * This will automatically adapt alpha beta and radius to fit within the new target.
  35445. * @param target Defines the new target as a Vector or a mesh
  35446. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35447. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35448. */
  35449. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35450. /** @hidden */
  35451. _getViewMatrix(): Matrix;
  35452. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35453. /**
  35454. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35455. * @param meshes Defines the mesh to zoom on
  35456. * @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)
  35457. */
  35458. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35459. /**
  35460. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35461. * The target will be changed but the radius
  35462. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35463. * @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)
  35464. */
  35465. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35466. min: Vector3;
  35467. max: Vector3;
  35468. distance: number;
  35469. }, doNotUpdateMaxZ?: boolean): void;
  35470. /**
  35471. * @override
  35472. * Override Camera.createRigCamera
  35473. */
  35474. createRigCamera(name: string, cameraIndex: number): Camera;
  35475. /**
  35476. * @hidden
  35477. * @override
  35478. * Override Camera._updateRigCameras
  35479. */
  35480. _updateRigCameras(): void;
  35481. /**
  35482. * Destroy the camera and release the current resources hold by it.
  35483. */
  35484. dispose(): void;
  35485. /**
  35486. * Gets the current object class name.
  35487. * @return the class name
  35488. */
  35489. getClassName(): string;
  35490. }
  35491. }
  35492. declare module BABYLON {
  35493. /**
  35494. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35495. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35496. */
  35497. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35498. /**
  35499. * Gets the name of the behavior.
  35500. */
  35501. readonly name: string;
  35502. private _zoomStopsAnimation;
  35503. private _idleRotationSpeed;
  35504. private _idleRotationWaitTime;
  35505. private _idleRotationSpinupTime;
  35506. /**
  35507. * Sets the flag that indicates if user zooming should stop animation.
  35508. */
  35509. /**
  35510. * Gets the flag that indicates if user zooming should stop animation.
  35511. */
  35512. zoomStopsAnimation: boolean;
  35513. /**
  35514. * Sets the default speed at which the camera rotates around the model.
  35515. */
  35516. /**
  35517. * Gets the default speed at which the camera rotates around the model.
  35518. */
  35519. idleRotationSpeed: number;
  35520. /**
  35521. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35522. */
  35523. /**
  35524. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35525. */
  35526. idleRotationWaitTime: number;
  35527. /**
  35528. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35529. */
  35530. /**
  35531. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35532. */
  35533. idleRotationSpinupTime: number;
  35534. /**
  35535. * Gets a value indicating if the camera is currently rotating because of this behavior
  35536. */
  35537. readonly rotationInProgress: boolean;
  35538. private _onPrePointerObservableObserver;
  35539. private _onAfterCheckInputsObserver;
  35540. private _attachedCamera;
  35541. private _isPointerDown;
  35542. private _lastFrameTime;
  35543. private _lastInteractionTime;
  35544. private _cameraRotationSpeed;
  35545. /**
  35546. * Initializes the behavior.
  35547. */
  35548. init(): void;
  35549. /**
  35550. * Attaches the behavior to its arc rotate camera.
  35551. * @param camera Defines the camera to attach the behavior to
  35552. */
  35553. attach(camera: ArcRotateCamera): void;
  35554. /**
  35555. * Detaches the behavior from its current arc rotate camera.
  35556. */
  35557. detach(): void;
  35558. /**
  35559. * Returns true if user is scrolling.
  35560. * @return true if user is scrolling.
  35561. */
  35562. private _userIsZooming;
  35563. private _lastFrameRadius;
  35564. private _shouldAnimationStopForInteraction;
  35565. /**
  35566. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35567. */
  35568. private _applyUserInteraction;
  35569. private _userIsMoving;
  35570. }
  35571. }
  35572. declare module BABYLON {
  35573. /**
  35574. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35575. */
  35576. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35577. private ui;
  35578. /**
  35579. * The name of the behavior
  35580. */
  35581. name: string;
  35582. /**
  35583. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35584. */
  35585. distanceAwayFromFace: number;
  35586. /**
  35587. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35588. */
  35589. distanceAwayFromBottomOfFace: number;
  35590. private _faceVectors;
  35591. private _target;
  35592. private _scene;
  35593. private _onRenderObserver;
  35594. private _tmpMatrix;
  35595. private _tmpVector;
  35596. /**
  35597. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35598. * @param ui The transform node that should be attched to the mesh
  35599. */
  35600. constructor(ui: TransformNode);
  35601. /**
  35602. * Initializes the behavior
  35603. */
  35604. init(): void;
  35605. private _closestFace;
  35606. private _zeroVector;
  35607. private _lookAtTmpMatrix;
  35608. private _lookAtToRef;
  35609. /**
  35610. * Attaches the AttachToBoxBehavior to the passed in mesh
  35611. * @param target The mesh that the specified node will be attached to
  35612. */
  35613. attach(target: Mesh): void;
  35614. /**
  35615. * Detaches the behavior from the mesh
  35616. */
  35617. detach(): void;
  35618. }
  35619. }
  35620. declare module BABYLON {
  35621. /**
  35622. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35623. */
  35624. export class FadeInOutBehavior implements Behavior<Mesh> {
  35625. /**
  35626. * Time in milliseconds to delay before fading in (Default: 0)
  35627. */
  35628. delay: number;
  35629. /**
  35630. * Time in milliseconds for the mesh to fade in (Default: 300)
  35631. */
  35632. fadeInTime: number;
  35633. private _millisecondsPerFrame;
  35634. private _hovered;
  35635. private _hoverValue;
  35636. private _ownerNode;
  35637. /**
  35638. * Instatiates the FadeInOutBehavior
  35639. */
  35640. constructor();
  35641. /**
  35642. * The name of the behavior
  35643. */
  35644. readonly name: string;
  35645. /**
  35646. * Initializes the behavior
  35647. */
  35648. init(): void;
  35649. /**
  35650. * Attaches the fade behavior on the passed in mesh
  35651. * @param ownerNode The mesh that will be faded in/out once attached
  35652. */
  35653. attach(ownerNode: Mesh): void;
  35654. /**
  35655. * Detaches the behavior from the mesh
  35656. */
  35657. detach(): void;
  35658. /**
  35659. * Triggers the mesh to begin fading in or out
  35660. * @param value if the object should fade in or out (true to fade in)
  35661. */
  35662. fadeIn(value: boolean): void;
  35663. private _update;
  35664. private _setAllVisibility;
  35665. }
  35666. }
  35667. declare module BABYLON {
  35668. /**
  35669. * Class containing a set of static utilities functions for managing Pivots
  35670. * @hidden
  35671. */
  35672. export class PivotTools {
  35673. private static _PivotCached;
  35674. private static _OldPivotPoint;
  35675. private static _PivotTranslation;
  35676. private static _PivotTmpVector;
  35677. /** @hidden */
  35678. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35679. /** @hidden */
  35680. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35681. }
  35682. }
  35683. declare module BABYLON {
  35684. /**
  35685. * Class containing static functions to help procedurally build meshes
  35686. */
  35687. export class PlaneBuilder {
  35688. /**
  35689. * Creates a plane mesh
  35690. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35691. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35692. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35693. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35694. * * 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
  35695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35696. * @param name defines the name of the mesh
  35697. * @param options defines the options used to create the mesh
  35698. * @param scene defines the hosting scene
  35699. * @returns the plane mesh
  35700. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35701. */
  35702. static CreatePlane(name: string, options: {
  35703. size?: number;
  35704. width?: number;
  35705. height?: number;
  35706. sideOrientation?: number;
  35707. frontUVs?: Vector4;
  35708. backUVs?: Vector4;
  35709. updatable?: boolean;
  35710. sourcePlane?: Plane;
  35711. }, scene?: Nullable<Scene>): Mesh;
  35712. }
  35713. }
  35714. declare module BABYLON {
  35715. /**
  35716. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35717. */
  35718. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35719. private static _AnyMouseID;
  35720. private _attachedNode;
  35721. private _dragPlane;
  35722. private _scene;
  35723. private _pointerObserver;
  35724. private _beforeRenderObserver;
  35725. private static _planeScene;
  35726. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35727. /**
  35728. * 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)
  35729. */
  35730. maxDragAngle: number;
  35731. /**
  35732. * @hidden
  35733. */
  35734. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35735. /**
  35736. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35737. */
  35738. currentDraggingPointerID: number;
  35739. /**
  35740. * The last position where the pointer hit the drag plane in world space
  35741. */
  35742. lastDragPosition: Vector3;
  35743. /**
  35744. * If the behavior is currently in a dragging state
  35745. */
  35746. dragging: boolean;
  35747. /**
  35748. * 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)
  35749. */
  35750. dragDeltaRatio: number;
  35751. /**
  35752. * If the drag plane orientation should be updated during the dragging (Default: true)
  35753. */
  35754. updateDragPlane: boolean;
  35755. private _debugMode;
  35756. private _moving;
  35757. /**
  35758. * Fires each time the attached mesh is dragged with the pointer
  35759. * * delta between last drag position and current drag position in world space
  35760. * * dragDistance along the drag axis
  35761. * * dragPlaneNormal normal of the current drag plane used during the drag
  35762. * * dragPlanePoint in world space where the drag intersects the drag plane
  35763. */
  35764. onDragObservable: Observable<{
  35765. delta: Vector3;
  35766. dragPlanePoint: Vector3;
  35767. dragPlaneNormal: Vector3;
  35768. dragDistance: number;
  35769. pointerId: number;
  35770. }>;
  35771. /**
  35772. * Fires each time a drag begins (eg. mouse down on mesh)
  35773. */
  35774. onDragStartObservable: Observable<{
  35775. dragPlanePoint: Vector3;
  35776. pointerId: number;
  35777. }>;
  35778. /**
  35779. * Fires each time a drag ends (eg. mouse release after drag)
  35780. */
  35781. onDragEndObservable: Observable<{
  35782. dragPlanePoint: Vector3;
  35783. pointerId: number;
  35784. }>;
  35785. /**
  35786. * If the attached mesh should be moved when dragged
  35787. */
  35788. moveAttached: boolean;
  35789. /**
  35790. * If the drag behavior will react to drag events (Default: true)
  35791. */
  35792. enabled: boolean;
  35793. /**
  35794. * If camera controls should be detached during the drag
  35795. */
  35796. detachCameraControls: boolean;
  35797. /**
  35798. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35799. */
  35800. useObjectOrienationForDragging: boolean;
  35801. private _options;
  35802. /**
  35803. * Creates a pointer drag behavior that can be attached to a mesh
  35804. * @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)
  35805. */
  35806. constructor(options?: {
  35807. dragAxis?: Vector3;
  35808. dragPlaneNormal?: Vector3;
  35809. });
  35810. /**
  35811. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35812. */
  35813. validateDrag: (targetPosition: Vector3) => boolean;
  35814. /**
  35815. * The name of the behavior
  35816. */
  35817. readonly name: string;
  35818. /**
  35819. * Initializes the behavior
  35820. */
  35821. init(): void;
  35822. private _tmpVector;
  35823. private _alternatePickedPoint;
  35824. private _worldDragAxis;
  35825. private _targetPosition;
  35826. private _attachedElement;
  35827. /**
  35828. * Attaches the drag behavior the passed in mesh
  35829. * @param ownerNode The mesh that will be dragged around once attached
  35830. */
  35831. attach(ownerNode: AbstractMesh): void;
  35832. /**
  35833. * Force relase the drag action by code.
  35834. */
  35835. releaseDrag(): void;
  35836. private _startDragRay;
  35837. private _lastPointerRay;
  35838. /**
  35839. * Simulates the start of a pointer drag event on the behavior
  35840. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35841. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35842. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35843. */
  35844. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35845. private _startDrag;
  35846. private _dragDelta;
  35847. private _moveDrag;
  35848. private _pickWithRayOnDragPlane;
  35849. private _pointA;
  35850. private _pointB;
  35851. private _pointC;
  35852. private _lineA;
  35853. private _lineB;
  35854. private _localAxis;
  35855. private _lookAt;
  35856. private _updateDragPlanePosition;
  35857. /**
  35858. * Detaches the behavior from the mesh
  35859. */
  35860. detach(): void;
  35861. }
  35862. }
  35863. declare module BABYLON {
  35864. /**
  35865. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35866. */
  35867. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35868. private _dragBehaviorA;
  35869. private _dragBehaviorB;
  35870. private _startDistance;
  35871. private _initialScale;
  35872. private _targetScale;
  35873. private _ownerNode;
  35874. private _sceneRenderObserver;
  35875. /**
  35876. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35877. */
  35878. constructor();
  35879. /**
  35880. * The name of the behavior
  35881. */
  35882. readonly name: string;
  35883. /**
  35884. * Initializes the behavior
  35885. */
  35886. init(): void;
  35887. private _getCurrentDistance;
  35888. /**
  35889. * Attaches the scale behavior the passed in mesh
  35890. * @param ownerNode The mesh that will be scaled around once attached
  35891. */
  35892. attach(ownerNode: Mesh): void;
  35893. /**
  35894. * Detaches the behavior from the mesh
  35895. */
  35896. detach(): void;
  35897. }
  35898. }
  35899. declare module BABYLON {
  35900. /**
  35901. * 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
  35902. */
  35903. export class SixDofDragBehavior implements Behavior<Mesh> {
  35904. private static _virtualScene;
  35905. private _ownerNode;
  35906. private _sceneRenderObserver;
  35907. private _scene;
  35908. private _targetPosition;
  35909. private _virtualOriginMesh;
  35910. private _virtualDragMesh;
  35911. private _pointerObserver;
  35912. private _moving;
  35913. private _startingOrientation;
  35914. /**
  35915. * 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)
  35916. */
  35917. private zDragFactor;
  35918. /**
  35919. * If the object should rotate to face the drag origin
  35920. */
  35921. rotateDraggedObject: boolean;
  35922. /**
  35923. * If the behavior is currently in a dragging state
  35924. */
  35925. dragging: boolean;
  35926. /**
  35927. * 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)
  35928. */
  35929. dragDeltaRatio: number;
  35930. /**
  35931. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35932. */
  35933. currentDraggingPointerID: number;
  35934. /**
  35935. * If camera controls should be detached during the drag
  35936. */
  35937. detachCameraControls: boolean;
  35938. /**
  35939. * Fires each time a drag starts
  35940. */
  35941. onDragStartObservable: Observable<{}>;
  35942. /**
  35943. * Fires each time a drag ends (eg. mouse release after drag)
  35944. */
  35945. onDragEndObservable: Observable<{}>;
  35946. /**
  35947. * 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
  35948. */
  35949. constructor();
  35950. /**
  35951. * The name of the behavior
  35952. */
  35953. readonly name: string;
  35954. /**
  35955. * Initializes the behavior
  35956. */
  35957. init(): void;
  35958. /**
  35959. * Attaches the scale behavior the passed in mesh
  35960. * @param ownerNode The mesh that will be scaled around once attached
  35961. */
  35962. attach(ownerNode: Mesh): void;
  35963. /**
  35964. * Detaches the behavior from the mesh
  35965. */
  35966. detach(): void;
  35967. }
  35968. }
  35969. declare module BABYLON {
  35970. /**
  35971. * Class used to apply inverse kinematics to bones
  35972. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35973. */
  35974. export class BoneIKController {
  35975. private static _tmpVecs;
  35976. private static _tmpQuat;
  35977. private static _tmpMats;
  35978. /**
  35979. * Gets or sets the target mesh
  35980. */
  35981. targetMesh: AbstractMesh;
  35982. /** Gets or sets the mesh used as pole */
  35983. poleTargetMesh: AbstractMesh;
  35984. /**
  35985. * Gets or sets the bone used as pole
  35986. */
  35987. poleTargetBone: Nullable<Bone>;
  35988. /**
  35989. * Gets or sets the target position
  35990. */
  35991. targetPosition: Vector3;
  35992. /**
  35993. * Gets or sets the pole target position
  35994. */
  35995. poleTargetPosition: Vector3;
  35996. /**
  35997. * Gets or sets the pole target local offset
  35998. */
  35999. poleTargetLocalOffset: Vector3;
  36000. /**
  36001. * Gets or sets the pole angle
  36002. */
  36003. poleAngle: number;
  36004. /**
  36005. * Gets or sets the mesh associated with the controller
  36006. */
  36007. mesh: AbstractMesh;
  36008. /**
  36009. * 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)
  36010. */
  36011. slerpAmount: number;
  36012. private _bone1Quat;
  36013. private _bone1Mat;
  36014. private _bone2Ang;
  36015. private _bone1;
  36016. private _bone2;
  36017. private _bone1Length;
  36018. private _bone2Length;
  36019. private _maxAngle;
  36020. private _maxReach;
  36021. private _rightHandedSystem;
  36022. private _bendAxis;
  36023. private _slerping;
  36024. private _adjustRoll;
  36025. /**
  36026. * Gets or sets maximum allowed angle
  36027. */
  36028. maxAngle: number;
  36029. /**
  36030. * Creates a new BoneIKController
  36031. * @param mesh defines the mesh to control
  36032. * @param bone defines the bone to control
  36033. * @param options defines options to set up the controller
  36034. */
  36035. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36036. targetMesh?: AbstractMesh;
  36037. poleTargetMesh?: AbstractMesh;
  36038. poleTargetBone?: Bone;
  36039. poleTargetLocalOffset?: Vector3;
  36040. poleAngle?: number;
  36041. bendAxis?: Vector3;
  36042. maxAngle?: number;
  36043. slerpAmount?: number;
  36044. });
  36045. private _setMaxAngle;
  36046. /**
  36047. * Force the controller to update the bones
  36048. */
  36049. update(): void;
  36050. }
  36051. }
  36052. declare module BABYLON {
  36053. /**
  36054. * Class used to make a bone look toward a point in space
  36055. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36056. */
  36057. export class BoneLookController {
  36058. private static _tmpVecs;
  36059. private static _tmpQuat;
  36060. private static _tmpMats;
  36061. /**
  36062. * The target Vector3 that the bone will look at
  36063. */
  36064. target: Vector3;
  36065. /**
  36066. * The mesh that the bone is attached to
  36067. */
  36068. mesh: AbstractMesh;
  36069. /**
  36070. * The bone that will be looking to the target
  36071. */
  36072. bone: Bone;
  36073. /**
  36074. * The up axis of the coordinate system that is used when the bone is rotated
  36075. */
  36076. upAxis: Vector3;
  36077. /**
  36078. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36079. */
  36080. upAxisSpace: Space;
  36081. /**
  36082. * Used to make an adjustment to the yaw of the bone
  36083. */
  36084. adjustYaw: number;
  36085. /**
  36086. * Used to make an adjustment to the pitch of the bone
  36087. */
  36088. adjustPitch: number;
  36089. /**
  36090. * Used to make an adjustment to the roll of the bone
  36091. */
  36092. adjustRoll: number;
  36093. /**
  36094. * 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)
  36095. */
  36096. slerpAmount: number;
  36097. private _minYaw;
  36098. private _maxYaw;
  36099. private _minPitch;
  36100. private _maxPitch;
  36101. private _minYawSin;
  36102. private _minYawCos;
  36103. private _maxYawSin;
  36104. private _maxYawCos;
  36105. private _midYawConstraint;
  36106. private _minPitchTan;
  36107. private _maxPitchTan;
  36108. private _boneQuat;
  36109. private _slerping;
  36110. private _transformYawPitch;
  36111. private _transformYawPitchInv;
  36112. private _firstFrameSkipped;
  36113. private _yawRange;
  36114. private _fowardAxis;
  36115. /**
  36116. * Gets or sets the minimum yaw angle that the bone can look to
  36117. */
  36118. minYaw: number;
  36119. /**
  36120. * Gets or sets the maximum yaw angle that the bone can look to
  36121. */
  36122. maxYaw: number;
  36123. /**
  36124. * Gets or sets the minimum pitch angle that the bone can look to
  36125. */
  36126. minPitch: number;
  36127. /**
  36128. * Gets or sets the maximum pitch angle that the bone can look to
  36129. */
  36130. maxPitch: number;
  36131. /**
  36132. * Create a BoneLookController
  36133. * @param mesh the mesh that the bone belongs to
  36134. * @param bone the bone that will be looking to the target
  36135. * @param target the target Vector3 to look at
  36136. * @param options optional settings:
  36137. * * maxYaw: the maximum angle the bone will yaw to
  36138. * * minYaw: the minimum angle the bone will yaw to
  36139. * * maxPitch: the maximum angle the bone will pitch to
  36140. * * minPitch: the minimum angle the bone will yaw to
  36141. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36142. * * upAxis: the up axis of the coordinate system
  36143. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36144. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36145. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36146. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36147. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36148. * * adjustRoll: used to make an adjustment to the roll of the bone
  36149. **/
  36150. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36151. maxYaw?: number;
  36152. minYaw?: number;
  36153. maxPitch?: number;
  36154. minPitch?: number;
  36155. slerpAmount?: number;
  36156. upAxis?: Vector3;
  36157. upAxisSpace?: Space;
  36158. yawAxis?: Vector3;
  36159. pitchAxis?: Vector3;
  36160. adjustYaw?: number;
  36161. adjustPitch?: number;
  36162. adjustRoll?: number;
  36163. });
  36164. /**
  36165. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36166. */
  36167. update(): void;
  36168. private _getAngleDiff;
  36169. private _getAngleBetween;
  36170. private _isAngleBetween;
  36171. }
  36172. }
  36173. declare module BABYLON {
  36174. /**
  36175. * Manage the gamepad inputs to control an arc rotate camera.
  36176. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36177. */
  36178. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36179. /**
  36180. * Defines the camera the input is attached to.
  36181. */
  36182. camera: ArcRotateCamera;
  36183. /**
  36184. * Defines the gamepad the input is gathering event from.
  36185. */
  36186. gamepad: Nullable<Gamepad>;
  36187. /**
  36188. * Defines the gamepad rotation sensiblity.
  36189. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36190. */
  36191. gamepadRotationSensibility: number;
  36192. /**
  36193. * Defines the gamepad move sensiblity.
  36194. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36195. */
  36196. gamepadMoveSensibility: number;
  36197. private _onGamepadConnectedObserver;
  36198. private _onGamepadDisconnectedObserver;
  36199. /**
  36200. * Attach the input controls to a specific dom element to get the input from.
  36201. * @param element Defines the element the controls should be listened from
  36202. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36203. */
  36204. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36205. /**
  36206. * Detach the current controls from the specified dom element.
  36207. * @param element Defines the element to stop listening the inputs from
  36208. */
  36209. detachControl(element: Nullable<HTMLElement>): void;
  36210. /**
  36211. * Update the current camera state depending on the inputs that have been used this frame.
  36212. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36213. */
  36214. checkInputs(): void;
  36215. /**
  36216. * Gets the class name of the current intput.
  36217. * @returns the class name
  36218. */
  36219. getClassName(): string;
  36220. /**
  36221. * Get the friendly name associated with the input class.
  36222. * @returns the input friendly name
  36223. */
  36224. getSimpleName(): string;
  36225. }
  36226. }
  36227. declare module BABYLON {
  36228. interface ArcRotateCameraInputsManager {
  36229. /**
  36230. * Add orientation input support to the input manager.
  36231. * @returns the current input manager
  36232. */
  36233. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36234. }
  36235. /**
  36236. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36237. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36238. */
  36239. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36240. /**
  36241. * Defines the camera the input is attached to.
  36242. */
  36243. camera: ArcRotateCamera;
  36244. /**
  36245. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36246. */
  36247. alphaCorrection: number;
  36248. /**
  36249. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36250. */
  36251. gammaCorrection: number;
  36252. private _alpha;
  36253. private _gamma;
  36254. private _dirty;
  36255. private _deviceOrientationHandler;
  36256. /**
  36257. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36258. */
  36259. constructor();
  36260. /**
  36261. * Attach the input controls to a specific dom element to get the input from.
  36262. * @param element Defines the element the controls should be listened from
  36263. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36264. */
  36265. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36266. /** @hidden */
  36267. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36268. /**
  36269. * Update the current camera state depending on the inputs that have been used this frame.
  36270. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36271. */
  36272. checkInputs(): void;
  36273. /**
  36274. * Detach the current controls from the specified dom element.
  36275. * @param element Defines the element to stop listening the inputs from
  36276. */
  36277. detachControl(element: Nullable<HTMLElement>): void;
  36278. /**
  36279. * Gets the class name of the current intput.
  36280. * @returns the class name
  36281. */
  36282. getClassName(): string;
  36283. /**
  36284. * Get the friendly name associated with the input class.
  36285. * @returns the input friendly name
  36286. */
  36287. getSimpleName(): string;
  36288. }
  36289. }
  36290. declare module BABYLON {
  36291. /**
  36292. * Listen to mouse events to control the camera.
  36293. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36294. */
  36295. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36296. /**
  36297. * Defines the camera the input is attached to.
  36298. */
  36299. camera: FlyCamera;
  36300. /**
  36301. * Defines if touch is enabled. (Default is true.)
  36302. */
  36303. touchEnabled: boolean;
  36304. /**
  36305. * Defines the buttons associated with the input to handle camera rotation.
  36306. */
  36307. buttons: number[];
  36308. /**
  36309. * Assign buttons for Yaw control.
  36310. */
  36311. buttonsYaw: number[];
  36312. /**
  36313. * Assign buttons for Pitch control.
  36314. */
  36315. buttonsPitch: number[];
  36316. /**
  36317. * Assign buttons for Roll control.
  36318. */
  36319. buttonsRoll: number[];
  36320. /**
  36321. * Detect if any button is being pressed while mouse is moved.
  36322. * -1 = Mouse locked.
  36323. * 0 = Left button.
  36324. * 1 = Middle Button.
  36325. * 2 = Right Button.
  36326. */
  36327. activeButton: number;
  36328. /**
  36329. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36330. * Higher values reduce its sensitivity.
  36331. */
  36332. angularSensibility: number;
  36333. private _mousemoveCallback;
  36334. private _observer;
  36335. private _rollObserver;
  36336. private previousPosition;
  36337. private noPreventDefault;
  36338. private element;
  36339. /**
  36340. * Listen to mouse events to control the camera.
  36341. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36342. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36343. */
  36344. constructor(touchEnabled?: boolean);
  36345. /**
  36346. * Attach the mouse control to the HTML DOM element.
  36347. * @param element Defines the element that listens to the input events.
  36348. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36349. */
  36350. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36351. /**
  36352. * Detach the current controls from the specified dom element.
  36353. * @param element Defines the element to stop listening the inputs from
  36354. */
  36355. detachControl(element: Nullable<HTMLElement>): void;
  36356. /**
  36357. * Gets the class name of the current input.
  36358. * @returns the class name.
  36359. */
  36360. getClassName(): string;
  36361. /**
  36362. * Get the friendly name associated with the input class.
  36363. * @returns the input's friendly name.
  36364. */
  36365. getSimpleName(): string;
  36366. private _pointerInput;
  36367. private _onMouseMove;
  36368. /**
  36369. * Rotate camera by mouse offset.
  36370. */
  36371. private rotateCamera;
  36372. }
  36373. }
  36374. declare module BABYLON {
  36375. /**
  36376. * Default Inputs manager for the FlyCamera.
  36377. * It groups all the default supported inputs for ease of use.
  36378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36379. */
  36380. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36381. /**
  36382. * Instantiates a new FlyCameraInputsManager.
  36383. * @param camera Defines the camera the inputs belong to.
  36384. */
  36385. constructor(camera: FlyCamera);
  36386. /**
  36387. * Add keyboard input support to the input manager.
  36388. * @returns the new FlyCameraKeyboardMoveInput().
  36389. */
  36390. addKeyboard(): FlyCameraInputsManager;
  36391. /**
  36392. * Add mouse input support to the input manager.
  36393. * @param touchEnabled Enable touch screen support.
  36394. * @returns the new FlyCameraMouseInput().
  36395. */
  36396. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36397. }
  36398. }
  36399. declare module BABYLON {
  36400. /**
  36401. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36402. * such as in a 3D Space Shooter or a Flight Simulator.
  36403. */
  36404. export class FlyCamera extends TargetCamera {
  36405. /**
  36406. * Define the collision ellipsoid of the camera.
  36407. * This is helpful for simulating a camera body, like a player's body.
  36408. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36409. */
  36410. ellipsoid: Vector3;
  36411. /**
  36412. * Define an offset for the position of the ellipsoid around the camera.
  36413. * This can be helpful if the camera is attached away from the player's body center,
  36414. * such as at its head.
  36415. */
  36416. ellipsoidOffset: Vector3;
  36417. /**
  36418. * Enable or disable collisions of the camera with the rest of the scene objects.
  36419. */
  36420. checkCollisions: boolean;
  36421. /**
  36422. * Enable or disable gravity on the camera.
  36423. */
  36424. applyGravity: boolean;
  36425. /**
  36426. * Define the current direction the camera is moving to.
  36427. */
  36428. cameraDirection: Vector3;
  36429. /**
  36430. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36431. * This overrides and empties cameraRotation.
  36432. */
  36433. rotationQuaternion: Quaternion;
  36434. /**
  36435. * Track Roll to maintain the wanted Rolling when looking around.
  36436. */
  36437. _trackRoll: number;
  36438. /**
  36439. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36440. */
  36441. rollCorrect: number;
  36442. /**
  36443. * Mimic a banked turn, Rolling the camera when Yawing.
  36444. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36445. */
  36446. bankedTurn: boolean;
  36447. /**
  36448. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36449. */
  36450. bankedTurnLimit: number;
  36451. /**
  36452. * Value of 0 disables the banked Roll.
  36453. * Value of 1 is equal to the Yaw angle in radians.
  36454. */
  36455. bankedTurnMultiplier: number;
  36456. /**
  36457. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36458. */
  36459. inputs: FlyCameraInputsManager;
  36460. /**
  36461. * Gets the input sensibility for mouse input.
  36462. * Higher values reduce sensitivity.
  36463. */
  36464. /**
  36465. * Sets the input sensibility for a mouse input.
  36466. * Higher values reduce sensitivity.
  36467. */
  36468. angularSensibility: number;
  36469. /**
  36470. * Get the keys for camera movement forward.
  36471. */
  36472. /**
  36473. * Set the keys for camera movement forward.
  36474. */
  36475. keysForward: number[];
  36476. /**
  36477. * Get the keys for camera movement backward.
  36478. */
  36479. keysBackward: number[];
  36480. /**
  36481. * Get the keys for camera movement up.
  36482. */
  36483. /**
  36484. * Set the keys for camera movement up.
  36485. */
  36486. keysUp: number[];
  36487. /**
  36488. * Get the keys for camera movement down.
  36489. */
  36490. /**
  36491. * Set the keys for camera movement down.
  36492. */
  36493. keysDown: number[];
  36494. /**
  36495. * Get the keys for camera movement left.
  36496. */
  36497. /**
  36498. * Set the keys for camera movement left.
  36499. */
  36500. keysLeft: number[];
  36501. /**
  36502. * Set the keys for camera movement right.
  36503. */
  36504. /**
  36505. * Set the keys for camera movement right.
  36506. */
  36507. keysRight: number[];
  36508. /**
  36509. * Event raised when the camera collides with a mesh in the scene.
  36510. */
  36511. onCollide: (collidedMesh: AbstractMesh) => void;
  36512. private _collider;
  36513. private _needMoveForGravity;
  36514. private _oldPosition;
  36515. private _diffPosition;
  36516. private _newPosition;
  36517. /** @hidden */
  36518. _localDirection: Vector3;
  36519. /** @hidden */
  36520. _transformedDirection: Vector3;
  36521. /**
  36522. * Instantiates a FlyCamera.
  36523. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36524. * such as in a 3D Space Shooter or a Flight Simulator.
  36525. * @param name Define the name of the camera in the scene.
  36526. * @param position Define the starting position of the camera in the scene.
  36527. * @param scene Define the scene the camera belongs to.
  36528. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36529. */
  36530. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36531. /**
  36532. * Attach a control to the HTML DOM element.
  36533. * @param element Defines the element that listens to the input events.
  36534. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36535. */
  36536. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36537. /**
  36538. * Detach a control from the HTML DOM element.
  36539. * The camera will stop reacting to that input.
  36540. * @param element Defines the element that listens to the input events.
  36541. */
  36542. detachControl(element: HTMLElement): void;
  36543. private _collisionMask;
  36544. /**
  36545. * Get the mask that the camera ignores in collision events.
  36546. */
  36547. /**
  36548. * Set the mask that the camera ignores in collision events.
  36549. */
  36550. collisionMask: number;
  36551. /** @hidden */
  36552. _collideWithWorld(displacement: Vector3): void;
  36553. /** @hidden */
  36554. private _onCollisionPositionChange;
  36555. /** @hidden */
  36556. _checkInputs(): void;
  36557. /** @hidden */
  36558. _decideIfNeedsToMove(): boolean;
  36559. /** @hidden */
  36560. _updatePosition(): void;
  36561. /**
  36562. * Restore the Roll to its target value at the rate specified.
  36563. * @param rate - Higher means slower restoring.
  36564. * @hidden
  36565. */
  36566. restoreRoll(rate: number): void;
  36567. /**
  36568. * Destroy the camera and release the current resources held by it.
  36569. */
  36570. dispose(): void;
  36571. /**
  36572. * Get the current object class name.
  36573. * @returns the class name.
  36574. */
  36575. getClassName(): string;
  36576. }
  36577. }
  36578. declare module BABYLON {
  36579. /**
  36580. * Listen to keyboard events to control the camera.
  36581. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36582. */
  36583. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36584. /**
  36585. * Defines the camera the input is attached to.
  36586. */
  36587. camera: FlyCamera;
  36588. /**
  36589. * The list of keyboard keys used to control the forward move of the camera.
  36590. */
  36591. keysForward: number[];
  36592. /**
  36593. * The list of keyboard keys used to control the backward move of the camera.
  36594. */
  36595. keysBackward: number[];
  36596. /**
  36597. * The list of keyboard keys used to control the forward move of the camera.
  36598. */
  36599. keysUp: number[];
  36600. /**
  36601. * The list of keyboard keys used to control the backward move of the camera.
  36602. */
  36603. keysDown: number[];
  36604. /**
  36605. * The list of keyboard keys used to control the right strafe move of the camera.
  36606. */
  36607. keysRight: number[];
  36608. /**
  36609. * The list of keyboard keys used to control the left strafe move of the camera.
  36610. */
  36611. keysLeft: number[];
  36612. private _keys;
  36613. private _onCanvasBlurObserver;
  36614. private _onKeyboardObserver;
  36615. private _engine;
  36616. private _scene;
  36617. /**
  36618. * Attach the input controls to a specific dom element to get the input from.
  36619. * @param element Defines the element the controls should be listened from
  36620. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36621. */
  36622. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36623. /**
  36624. * Detach the current controls from the specified dom element.
  36625. * @param element Defines the element to stop listening the inputs from
  36626. */
  36627. detachControl(element: Nullable<HTMLElement>): void;
  36628. /**
  36629. * Gets the class name of the current intput.
  36630. * @returns the class name
  36631. */
  36632. getClassName(): string;
  36633. /** @hidden */
  36634. _onLostFocus(e: FocusEvent): void;
  36635. /**
  36636. * Get the friendly name associated with the input class.
  36637. * @returns the input friendly name
  36638. */
  36639. getSimpleName(): string;
  36640. /**
  36641. * Update the current camera state depending on the inputs that have been used this frame.
  36642. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36643. */
  36644. checkInputs(): void;
  36645. }
  36646. }
  36647. declare module BABYLON {
  36648. /**
  36649. * Manage the mouse wheel inputs to control a follow camera.
  36650. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36651. */
  36652. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36653. /**
  36654. * Defines the camera the input is attached to.
  36655. */
  36656. camera: FollowCamera;
  36657. /**
  36658. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36659. */
  36660. axisControlRadius: boolean;
  36661. /**
  36662. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36663. */
  36664. axisControlHeight: boolean;
  36665. /**
  36666. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36667. */
  36668. axisControlRotation: boolean;
  36669. /**
  36670. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36671. * relation to mouseWheel events.
  36672. */
  36673. wheelPrecision: number;
  36674. /**
  36675. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36676. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36677. */
  36678. wheelDeltaPercentage: number;
  36679. private _wheel;
  36680. private _observer;
  36681. /**
  36682. * Attach the input controls to a specific dom element to get the input from.
  36683. * @param element Defines the element the controls should be listened from
  36684. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36685. */
  36686. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36687. /**
  36688. * Detach the current controls from the specified dom element.
  36689. * @param element Defines the element to stop listening the inputs from
  36690. */
  36691. detachControl(element: Nullable<HTMLElement>): void;
  36692. /**
  36693. * Gets the class name of the current intput.
  36694. * @returns the class name
  36695. */
  36696. getClassName(): string;
  36697. /**
  36698. * Get the friendly name associated with the input class.
  36699. * @returns the input friendly name
  36700. */
  36701. getSimpleName(): string;
  36702. }
  36703. }
  36704. declare module BABYLON {
  36705. /**
  36706. * Manage the pointers inputs to control an follow camera.
  36707. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36708. */
  36709. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36710. /**
  36711. * Defines the camera the input is attached to.
  36712. */
  36713. camera: FollowCamera;
  36714. /**
  36715. * Gets the class name of the current input.
  36716. * @returns the class name
  36717. */
  36718. getClassName(): string;
  36719. /**
  36720. * Defines the pointer angular sensibility along the X axis or how fast is
  36721. * the camera rotating.
  36722. * A negative number will reverse the axis direction.
  36723. */
  36724. angularSensibilityX: number;
  36725. /**
  36726. * Defines the pointer angular sensibility along the Y axis or how fast is
  36727. * the camera rotating.
  36728. * A negative number will reverse the axis direction.
  36729. */
  36730. angularSensibilityY: number;
  36731. /**
  36732. * Defines the pointer pinch precision or how fast is the camera zooming.
  36733. * A negative number will reverse the axis direction.
  36734. */
  36735. pinchPrecision: number;
  36736. /**
  36737. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36738. * from 0.
  36739. * It defines the percentage of current camera.radius to use as delta when
  36740. * pinch zoom is used.
  36741. */
  36742. pinchDeltaPercentage: number;
  36743. /**
  36744. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36745. */
  36746. axisXControlRadius: boolean;
  36747. /**
  36748. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36749. */
  36750. axisXControlHeight: boolean;
  36751. /**
  36752. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36753. */
  36754. axisXControlRotation: boolean;
  36755. /**
  36756. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36757. */
  36758. axisYControlRadius: boolean;
  36759. /**
  36760. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36761. */
  36762. axisYControlHeight: boolean;
  36763. /**
  36764. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36765. */
  36766. axisYControlRotation: boolean;
  36767. /**
  36768. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36769. */
  36770. axisPinchControlRadius: boolean;
  36771. /**
  36772. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36773. */
  36774. axisPinchControlHeight: boolean;
  36775. /**
  36776. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36777. */
  36778. axisPinchControlRotation: boolean;
  36779. /**
  36780. * Log error messages if basic misconfiguration has occurred.
  36781. */
  36782. warningEnable: boolean;
  36783. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36784. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36785. private _warningCounter;
  36786. private _warning;
  36787. }
  36788. }
  36789. declare module BABYLON {
  36790. /**
  36791. * Default Inputs manager for the FollowCamera.
  36792. * It groups all the default supported inputs for ease of use.
  36793. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36794. */
  36795. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36796. /**
  36797. * Instantiates a new FollowCameraInputsManager.
  36798. * @param camera Defines the camera the inputs belong to
  36799. */
  36800. constructor(camera: FollowCamera);
  36801. /**
  36802. * Add keyboard input support to the input manager.
  36803. * @returns the current input manager
  36804. */
  36805. addKeyboard(): FollowCameraInputsManager;
  36806. /**
  36807. * Add mouse wheel input support to the input manager.
  36808. * @returns the current input manager
  36809. */
  36810. addMouseWheel(): FollowCameraInputsManager;
  36811. /**
  36812. * Add pointers input support to the input manager.
  36813. * @returns the current input manager
  36814. */
  36815. addPointers(): FollowCameraInputsManager;
  36816. /**
  36817. * Add orientation input support to the input manager.
  36818. * @returns the current input manager
  36819. */
  36820. addVRDeviceOrientation(): FollowCameraInputsManager;
  36821. }
  36822. }
  36823. declare module BABYLON {
  36824. /**
  36825. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36826. * an arc rotate version arcFollowCamera are available.
  36827. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36828. */
  36829. export class FollowCamera extends TargetCamera {
  36830. /**
  36831. * Distance the follow camera should follow an object at
  36832. */
  36833. radius: number;
  36834. /**
  36835. * Minimum allowed distance of the camera to the axis of rotation
  36836. * (The camera can not get closer).
  36837. * This can help limiting how the Camera is able to move in the scene.
  36838. */
  36839. lowerRadiusLimit: Nullable<number>;
  36840. /**
  36841. * Maximum allowed distance of the camera to the axis of rotation
  36842. * (The camera can not get further).
  36843. * This can help limiting how the Camera is able to move in the scene.
  36844. */
  36845. upperRadiusLimit: Nullable<number>;
  36846. /**
  36847. * Define a rotation offset between the camera and the object it follows
  36848. */
  36849. rotationOffset: number;
  36850. /**
  36851. * Minimum allowed angle to camera position relative to target object.
  36852. * This can help limiting how the Camera is able to move in the scene.
  36853. */
  36854. lowerRotationOffsetLimit: Nullable<number>;
  36855. /**
  36856. * Maximum allowed angle to camera position relative to target object.
  36857. * This can help limiting how the Camera is able to move in the scene.
  36858. */
  36859. upperRotationOffsetLimit: Nullable<number>;
  36860. /**
  36861. * Define a height offset between the camera and the object it follows.
  36862. * It can help following an object from the top (like a car chaing a plane)
  36863. */
  36864. heightOffset: number;
  36865. /**
  36866. * Minimum allowed height of camera position relative to target object.
  36867. * This can help limiting how the Camera is able to move in the scene.
  36868. */
  36869. lowerHeightOffsetLimit: Nullable<number>;
  36870. /**
  36871. * Maximum allowed height of camera position relative to target object.
  36872. * This can help limiting how the Camera is able to move in the scene.
  36873. */
  36874. upperHeightOffsetLimit: Nullable<number>;
  36875. /**
  36876. * Define how fast the camera can accelerate to follow it s target.
  36877. */
  36878. cameraAcceleration: number;
  36879. /**
  36880. * Define the speed limit of the camera following an object.
  36881. */
  36882. maxCameraSpeed: number;
  36883. /**
  36884. * Define the target of the camera.
  36885. */
  36886. lockedTarget: Nullable<AbstractMesh>;
  36887. /**
  36888. * Defines the input associated with the camera.
  36889. */
  36890. inputs: FollowCameraInputsManager;
  36891. /**
  36892. * Instantiates the follow camera.
  36893. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36894. * @param name Define the name of the camera in the scene
  36895. * @param position Define the position of the camera
  36896. * @param scene Define the scene the camera belong to
  36897. * @param lockedTarget Define the target of the camera
  36898. */
  36899. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36900. private _follow;
  36901. /**
  36902. * Attached controls to the current camera.
  36903. * @param element Defines the element the controls should be listened from
  36904. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36905. */
  36906. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36907. /**
  36908. * Detach the current controls from the camera.
  36909. * The camera will stop reacting to inputs.
  36910. * @param element Defines the element to stop listening the inputs from
  36911. */
  36912. detachControl(element: HTMLElement): void;
  36913. /** @hidden */
  36914. _checkInputs(): void;
  36915. private _checkLimits;
  36916. /**
  36917. * Gets the camera class name.
  36918. * @returns the class name
  36919. */
  36920. getClassName(): string;
  36921. }
  36922. /**
  36923. * Arc Rotate version of the follow camera.
  36924. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36925. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36926. */
  36927. export class ArcFollowCamera extends TargetCamera {
  36928. /** The longitudinal angle of the camera */
  36929. alpha: number;
  36930. /** The latitudinal angle of the camera */
  36931. beta: number;
  36932. /** The radius of the camera from its target */
  36933. radius: number;
  36934. /** Define the camera target (the messh it should follow) */
  36935. target: Nullable<AbstractMesh>;
  36936. private _cartesianCoordinates;
  36937. /**
  36938. * Instantiates a new ArcFollowCamera
  36939. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36940. * @param name Define the name of the camera
  36941. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36942. * @param beta Define the rotation angle of the camera around the elevation axis
  36943. * @param radius Define the radius of the camera from its target point
  36944. * @param target Define the target of the camera
  36945. * @param scene Define the scene the camera belongs to
  36946. */
  36947. constructor(name: string,
  36948. /** The longitudinal angle of the camera */
  36949. alpha: number,
  36950. /** The latitudinal angle of the camera */
  36951. beta: number,
  36952. /** The radius of the camera from its target */
  36953. radius: number,
  36954. /** Define the camera target (the messh it should follow) */
  36955. target: Nullable<AbstractMesh>, scene: Scene);
  36956. private _follow;
  36957. /** @hidden */
  36958. _checkInputs(): void;
  36959. /**
  36960. * Returns the class name of the object.
  36961. * It is mostly used internally for serialization purposes.
  36962. */
  36963. getClassName(): string;
  36964. }
  36965. }
  36966. declare module BABYLON {
  36967. /**
  36968. * Manage the keyboard inputs to control the movement of a follow camera.
  36969. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36970. */
  36971. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36972. /**
  36973. * Defines the camera the input is attached to.
  36974. */
  36975. camera: FollowCamera;
  36976. /**
  36977. * Defines the list of key codes associated with the up action (increase heightOffset)
  36978. */
  36979. keysHeightOffsetIncr: number[];
  36980. /**
  36981. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36982. */
  36983. keysHeightOffsetDecr: number[];
  36984. /**
  36985. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36986. */
  36987. keysHeightOffsetModifierAlt: boolean;
  36988. /**
  36989. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36990. */
  36991. keysHeightOffsetModifierCtrl: boolean;
  36992. /**
  36993. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36994. */
  36995. keysHeightOffsetModifierShift: boolean;
  36996. /**
  36997. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36998. */
  36999. keysRotationOffsetIncr: number[];
  37000. /**
  37001. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37002. */
  37003. keysRotationOffsetDecr: number[];
  37004. /**
  37005. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37006. */
  37007. keysRotationOffsetModifierAlt: boolean;
  37008. /**
  37009. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37010. */
  37011. keysRotationOffsetModifierCtrl: boolean;
  37012. /**
  37013. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37014. */
  37015. keysRotationOffsetModifierShift: boolean;
  37016. /**
  37017. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37018. */
  37019. keysRadiusIncr: number[];
  37020. /**
  37021. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37022. */
  37023. keysRadiusDecr: number[];
  37024. /**
  37025. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37026. */
  37027. keysRadiusModifierAlt: boolean;
  37028. /**
  37029. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37030. */
  37031. keysRadiusModifierCtrl: boolean;
  37032. /**
  37033. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37034. */
  37035. keysRadiusModifierShift: boolean;
  37036. /**
  37037. * Defines the rate of change of heightOffset.
  37038. */
  37039. heightSensibility: number;
  37040. /**
  37041. * Defines the rate of change of rotationOffset.
  37042. */
  37043. rotationSensibility: number;
  37044. /**
  37045. * Defines the rate of change of radius.
  37046. */
  37047. radiusSensibility: number;
  37048. private _keys;
  37049. private _ctrlPressed;
  37050. private _altPressed;
  37051. private _shiftPressed;
  37052. private _onCanvasBlurObserver;
  37053. private _onKeyboardObserver;
  37054. private _engine;
  37055. private _scene;
  37056. /**
  37057. * Attach the input controls to a specific dom element to get the input from.
  37058. * @param element Defines the element the controls should be listened from
  37059. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37060. */
  37061. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37062. /**
  37063. * Detach the current controls from the specified dom element.
  37064. * @param element Defines the element to stop listening the inputs from
  37065. */
  37066. detachControl(element: Nullable<HTMLElement>): void;
  37067. /**
  37068. * Update the current camera state depending on the inputs that have been used this frame.
  37069. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37070. */
  37071. checkInputs(): void;
  37072. /**
  37073. * Gets the class name of the current input.
  37074. * @returns the class name
  37075. */
  37076. getClassName(): string;
  37077. /**
  37078. * Get the friendly name associated with the input class.
  37079. * @returns the input friendly name
  37080. */
  37081. getSimpleName(): string;
  37082. /**
  37083. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37084. * allow modification of the heightOffset value.
  37085. */
  37086. private _modifierHeightOffset;
  37087. /**
  37088. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37089. * allow modification of the rotationOffset value.
  37090. */
  37091. private _modifierRotationOffset;
  37092. /**
  37093. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37094. * allow modification of the radius value.
  37095. */
  37096. private _modifierRadius;
  37097. }
  37098. }
  37099. declare module BABYLON {
  37100. interface FreeCameraInputsManager {
  37101. /**
  37102. * @hidden
  37103. */
  37104. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37105. /**
  37106. * Add orientation input support to the input manager.
  37107. * @returns the current input manager
  37108. */
  37109. addDeviceOrientation(): FreeCameraInputsManager;
  37110. }
  37111. /**
  37112. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37113. * Screen rotation is taken into account.
  37114. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37115. */
  37116. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37117. private _camera;
  37118. private _screenOrientationAngle;
  37119. private _constantTranform;
  37120. private _screenQuaternion;
  37121. private _alpha;
  37122. private _beta;
  37123. private _gamma;
  37124. /**
  37125. * @hidden
  37126. */
  37127. _onDeviceOrientationChangedObservable: Observable<void>;
  37128. /**
  37129. * Instantiates a new input
  37130. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37131. */
  37132. constructor();
  37133. /**
  37134. * Define the camera controlled by the input.
  37135. */
  37136. camera: FreeCamera;
  37137. /**
  37138. * Attach the input controls to a specific dom element to get the input from.
  37139. * @param element Defines the element the controls should be listened from
  37140. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37141. */
  37142. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37143. private _orientationChanged;
  37144. private _deviceOrientation;
  37145. /**
  37146. * Detach the current controls from the specified dom element.
  37147. * @param element Defines the element to stop listening the inputs from
  37148. */
  37149. detachControl(element: Nullable<HTMLElement>): void;
  37150. /**
  37151. * Update the current camera state depending on the inputs that have been used this frame.
  37152. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37153. */
  37154. checkInputs(): void;
  37155. /**
  37156. * Gets the class name of the current intput.
  37157. * @returns the class name
  37158. */
  37159. getClassName(): string;
  37160. /**
  37161. * Get the friendly name associated with the input class.
  37162. * @returns the input friendly name
  37163. */
  37164. getSimpleName(): string;
  37165. }
  37166. }
  37167. declare module BABYLON {
  37168. /**
  37169. * Manage the gamepad inputs to control a free camera.
  37170. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37171. */
  37172. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37173. /**
  37174. * Define the camera the input is attached to.
  37175. */
  37176. camera: FreeCamera;
  37177. /**
  37178. * Define the Gamepad controlling the input
  37179. */
  37180. gamepad: Nullable<Gamepad>;
  37181. /**
  37182. * Defines the gamepad rotation sensiblity.
  37183. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37184. */
  37185. gamepadAngularSensibility: number;
  37186. /**
  37187. * Defines the gamepad move sensiblity.
  37188. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37189. */
  37190. gamepadMoveSensibility: number;
  37191. private _onGamepadConnectedObserver;
  37192. private _onGamepadDisconnectedObserver;
  37193. private _cameraTransform;
  37194. private _deltaTransform;
  37195. private _vector3;
  37196. private _vector2;
  37197. /**
  37198. * Attach the input controls to a specific dom element to get the input from.
  37199. * @param element Defines the element the controls should be listened from
  37200. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37201. */
  37202. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37203. /**
  37204. * Detach the current controls from the specified dom element.
  37205. * @param element Defines the element to stop listening the inputs from
  37206. */
  37207. detachControl(element: Nullable<HTMLElement>): void;
  37208. /**
  37209. * Update the current camera state depending on the inputs that have been used this frame.
  37210. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37211. */
  37212. checkInputs(): void;
  37213. /**
  37214. * Gets the class name of the current intput.
  37215. * @returns the class name
  37216. */
  37217. getClassName(): string;
  37218. /**
  37219. * Get the friendly name associated with the input class.
  37220. * @returns the input friendly name
  37221. */
  37222. getSimpleName(): string;
  37223. }
  37224. }
  37225. declare module BABYLON {
  37226. /**
  37227. * Defines the potential axis of a Joystick
  37228. */
  37229. export enum JoystickAxis {
  37230. /** X axis */
  37231. X = 0,
  37232. /** Y axis */
  37233. Y = 1,
  37234. /** Z axis */
  37235. Z = 2
  37236. }
  37237. /**
  37238. * Class used to define virtual joystick (used in touch mode)
  37239. */
  37240. export class VirtualJoystick {
  37241. /**
  37242. * Gets or sets a boolean indicating that left and right values must be inverted
  37243. */
  37244. reverseLeftRight: boolean;
  37245. /**
  37246. * Gets or sets a boolean indicating that up and down values must be inverted
  37247. */
  37248. reverseUpDown: boolean;
  37249. /**
  37250. * Gets the offset value for the position (ie. the change of the position value)
  37251. */
  37252. deltaPosition: Vector3;
  37253. /**
  37254. * Gets a boolean indicating if the virtual joystick was pressed
  37255. */
  37256. pressed: boolean;
  37257. /**
  37258. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37259. */
  37260. static Canvas: Nullable<HTMLCanvasElement>;
  37261. private static _globalJoystickIndex;
  37262. private static vjCanvasContext;
  37263. private static vjCanvasWidth;
  37264. private static vjCanvasHeight;
  37265. private static halfWidth;
  37266. private _action;
  37267. private _axisTargetedByLeftAndRight;
  37268. private _axisTargetedByUpAndDown;
  37269. private _joystickSensibility;
  37270. private _inversedSensibility;
  37271. private _joystickPointerID;
  37272. private _joystickColor;
  37273. private _joystickPointerPos;
  37274. private _joystickPreviousPointerPos;
  37275. private _joystickPointerStartPos;
  37276. private _deltaJoystickVector;
  37277. private _leftJoystick;
  37278. private _touches;
  37279. private _onPointerDownHandlerRef;
  37280. private _onPointerMoveHandlerRef;
  37281. private _onPointerUpHandlerRef;
  37282. private _onResize;
  37283. /**
  37284. * Creates a new virtual joystick
  37285. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37286. */
  37287. constructor(leftJoystick?: boolean);
  37288. /**
  37289. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37290. * @param newJoystickSensibility defines the new sensibility
  37291. */
  37292. setJoystickSensibility(newJoystickSensibility: number): void;
  37293. private _onPointerDown;
  37294. private _onPointerMove;
  37295. private _onPointerUp;
  37296. /**
  37297. * Change the color of the virtual joystick
  37298. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37299. */
  37300. setJoystickColor(newColor: string): void;
  37301. /**
  37302. * Defines a callback to call when the joystick is touched
  37303. * @param action defines the callback
  37304. */
  37305. setActionOnTouch(action: () => any): void;
  37306. /**
  37307. * Defines which axis you'd like to control for left & right
  37308. * @param axis defines the axis to use
  37309. */
  37310. setAxisForLeftRight(axis: JoystickAxis): void;
  37311. /**
  37312. * Defines which axis you'd like to control for up & down
  37313. * @param axis defines the axis to use
  37314. */
  37315. setAxisForUpDown(axis: JoystickAxis): void;
  37316. private _drawVirtualJoystick;
  37317. /**
  37318. * Release internal HTML canvas
  37319. */
  37320. releaseCanvas(): void;
  37321. }
  37322. }
  37323. declare module BABYLON {
  37324. interface FreeCameraInputsManager {
  37325. /**
  37326. * Add virtual joystick input support to the input manager.
  37327. * @returns the current input manager
  37328. */
  37329. addVirtualJoystick(): FreeCameraInputsManager;
  37330. }
  37331. /**
  37332. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37333. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37334. */
  37335. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37336. /**
  37337. * Defines the camera the input is attached to.
  37338. */
  37339. camera: FreeCamera;
  37340. private _leftjoystick;
  37341. private _rightjoystick;
  37342. /**
  37343. * Gets the left stick of the virtual joystick.
  37344. * @returns The virtual Joystick
  37345. */
  37346. getLeftJoystick(): VirtualJoystick;
  37347. /**
  37348. * Gets the right stick of the virtual joystick.
  37349. * @returns The virtual Joystick
  37350. */
  37351. getRightJoystick(): VirtualJoystick;
  37352. /**
  37353. * Update the current camera state depending on the inputs that have been used this frame.
  37354. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37355. */
  37356. checkInputs(): void;
  37357. /**
  37358. * Attach the input controls to a specific dom element to get the input from.
  37359. * @param element Defines the element the controls should be listened from
  37360. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37361. */
  37362. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37363. /**
  37364. * Detach the current controls from the specified dom element.
  37365. * @param element Defines the element to stop listening the inputs from
  37366. */
  37367. detachControl(element: Nullable<HTMLElement>): void;
  37368. /**
  37369. * Gets the class name of the current intput.
  37370. * @returns the class name
  37371. */
  37372. getClassName(): string;
  37373. /**
  37374. * Get the friendly name associated with the input class.
  37375. * @returns the input friendly name
  37376. */
  37377. getSimpleName(): string;
  37378. }
  37379. }
  37380. declare module BABYLON {
  37381. /**
  37382. * This represents a FPS type of camera controlled by touch.
  37383. * This is like a universal camera minus the Gamepad controls.
  37384. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37385. */
  37386. export class TouchCamera extends FreeCamera {
  37387. /**
  37388. * Defines the touch sensibility for rotation.
  37389. * The higher the faster.
  37390. */
  37391. touchAngularSensibility: number;
  37392. /**
  37393. * Defines the touch sensibility for move.
  37394. * The higher the faster.
  37395. */
  37396. touchMoveSensibility: number;
  37397. /**
  37398. * Instantiates a new touch camera.
  37399. * This represents a FPS type of camera controlled by touch.
  37400. * This is like a universal camera minus the Gamepad controls.
  37401. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37402. * @param name Define the name of the camera in the scene
  37403. * @param position Define the start position of the camera in the scene
  37404. * @param scene Define the scene the camera belongs to
  37405. */
  37406. constructor(name: string, position: Vector3, scene: Scene);
  37407. /**
  37408. * Gets the current object class name.
  37409. * @return the class name
  37410. */
  37411. getClassName(): string;
  37412. /** @hidden */
  37413. _setupInputs(): void;
  37414. }
  37415. }
  37416. declare module BABYLON {
  37417. /**
  37418. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37419. * being tilted forward or back and left or right.
  37420. */
  37421. export class DeviceOrientationCamera extends FreeCamera {
  37422. private _initialQuaternion;
  37423. private _quaternionCache;
  37424. private _tmpDragQuaternion;
  37425. /**
  37426. * Creates a new device orientation camera
  37427. * @param name The name of the camera
  37428. * @param position The start position camera
  37429. * @param scene The scene the camera belongs to
  37430. */
  37431. constructor(name: string, position: Vector3, scene: Scene);
  37432. /**
  37433. * @hidden
  37434. * Disabled pointer input on first orientation sensor update (Default: true)
  37435. */
  37436. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37437. private _dragFactor;
  37438. /**
  37439. * Enabled turning on the y axis when the orientation sensor is active
  37440. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37441. */
  37442. enableHorizontalDragging(dragFactor?: number): void;
  37443. /**
  37444. * Gets the current instance class name ("DeviceOrientationCamera").
  37445. * This helps avoiding instanceof at run time.
  37446. * @returns the class name
  37447. */
  37448. getClassName(): string;
  37449. /**
  37450. * @hidden
  37451. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37452. */
  37453. _checkInputs(): void;
  37454. /**
  37455. * Reset the camera to its default orientation on the specified axis only.
  37456. * @param axis The axis to reset
  37457. */
  37458. resetToCurrentRotation(axis?: Axis): void;
  37459. }
  37460. }
  37461. declare module BABYLON {
  37462. /**
  37463. * 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,
  37464. * which still works and will still be found in many Playgrounds.
  37465. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37466. */
  37467. export class UniversalCamera extends TouchCamera {
  37468. /**
  37469. * Defines the gamepad rotation sensiblity.
  37470. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37471. */
  37472. gamepadAngularSensibility: number;
  37473. /**
  37474. * Defines the gamepad move sensiblity.
  37475. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37476. */
  37477. gamepadMoveSensibility: number;
  37478. /**
  37479. * 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,
  37480. * which still works and will still be found in many Playgrounds.
  37481. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37482. * @param name Define the name of the camera in the scene
  37483. * @param position Define the start position of the camera in the scene
  37484. * @param scene Define the scene the camera belongs to
  37485. */
  37486. constructor(name: string, position: Vector3, scene: Scene);
  37487. /**
  37488. * Gets the current object class name.
  37489. * @return the class name
  37490. */
  37491. getClassName(): string;
  37492. }
  37493. }
  37494. declare module BABYLON {
  37495. /**
  37496. * This represents a FPS type of camera. This is only here for back compat purpose.
  37497. * Please use the UniversalCamera instead as both are identical.
  37498. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37499. */
  37500. export class GamepadCamera extends UniversalCamera {
  37501. /**
  37502. * Instantiates a new Gamepad Camera
  37503. * This represents a FPS type of camera. This is only here for back compat purpose.
  37504. * Please use the UniversalCamera instead as both are identical.
  37505. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37506. * @param name Define the name of the camera in the scene
  37507. * @param position Define the start position of the camera in the scene
  37508. * @param scene Define the scene the camera belongs to
  37509. */
  37510. constructor(name: string, position: Vector3, scene: Scene);
  37511. /**
  37512. * Gets the current object class name.
  37513. * @return the class name
  37514. */
  37515. getClassName(): string;
  37516. }
  37517. }
  37518. declare module BABYLON {
  37519. /** @hidden */
  37520. export var passPixelShader: {
  37521. name: string;
  37522. shader: string;
  37523. };
  37524. }
  37525. declare module BABYLON {
  37526. /** @hidden */
  37527. export var passCubePixelShader: {
  37528. name: string;
  37529. shader: string;
  37530. };
  37531. }
  37532. declare module BABYLON {
  37533. /**
  37534. * PassPostProcess which produces an output the same as it's input
  37535. */
  37536. export class PassPostProcess extends PostProcess {
  37537. /**
  37538. * Creates the PassPostProcess
  37539. * @param name The name of the effect.
  37540. * @param options The required width/height ratio to downsize to before computing the render pass.
  37541. * @param camera The camera to apply the render pass to.
  37542. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37543. * @param engine The engine which the post process will be applied. (default: current engine)
  37544. * @param reusable If the post process can be reused on the same frame. (default: false)
  37545. * @param textureType The type of texture to be used when performing the post processing.
  37546. * @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)
  37547. */
  37548. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37549. }
  37550. /**
  37551. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37552. */
  37553. export class PassCubePostProcess extends PostProcess {
  37554. private _face;
  37555. /**
  37556. * Gets or sets the cube face to display.
  37557. * * 0 is +X
  37558. * * 1 is -X
  37559. * * 2 is +Y
  37560. * * 3 is -Y
  37561. * * 4 is +Z
  37562. * * 5 is -Z
  37563. */
  37564. face: number;
  37565. /**
  37566. * Creates the PassCubePostProcess
  37567. * @param name The name of the effect.
  37568. * @param options The required width/height ratio to downsize to before computing the render pass.
  37569. * @param camera The camera to apply the render pass to.
  37570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37571. * @param engine The engine which the post process will be applied. (default: current engine)
  37572. * @param reusable If the post process can be reused on the same frame. (default: false)
  37573. * @param textureType The type of texture to be used when performing the post processing.
  37574. * @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)
  37575. */
  37576. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37577. }
  37578. }
  37579. declare module BABYLON {
  37580. /** @hidden */
  37581. export var anaglyphPixelShader: {
  37582. name: string;
  37583. shader: string;
  37584. };
  37585. }
  37586. declare module BABYLON {
  37587. /**
  37588. * Postprocess used to generate anaglyphic rendering
  37589. */
  37590. export class AnaglyphPostProcess extends PostProcess {
  37591. private _passedProcess;
  37592. /**
  37593. * Creates a new AnaglyphPostProcess
  37594. * @param name defines postprocess name
  37595. * @param options defines creation options or target ratio scale
  37596. * @param rigCameras defines cameras using this postprocess
  37597. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37598. * @param engine defines hosting engine
  37599. * @param reusable defines if the postprocess will be reused multiple times per frame
  37600. */
  37601. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37602. }
  37603. }
  37604. declare module BABYLON {
  37605. /**
  37606. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37607. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37608. */
  37609. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37610. /**
  37611. * Creates a new AnaglyphArcRotateCamera
  37612. * @param name defines camera name
  37613. * @param alpha defines alpha angle (in radians)
  37614. * @param beta defines beta angle (in radians)
  37615. * @param radius defines radius
  37616. * @param target defines camera target
  37617. * @param interaxialDistance defines distance between each color axis
  37618. * @param scene defines the hosting scene
  37619. */
  37620. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37621. /**
  37622. * Gets camera class name
  37623. * @returns AnaglyphArcRotateCamera
  37624. */
  37625. getClassName(): string;
  37626. }
  37627. }
  37628. declare module BABYLON {
  37629. /**
  37630. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37631. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37632. */
  37633. export class AnaglyphFreeCamera extends FreeCamera {
  37634. /**
  37635. * Creates a new AnaglyphFreeCamera
  37636. * @param name defines camera name
  37637. * @param position defines initial position
  37638. * @param interaxialDistance defines distance between each color axis
  37639. * @param scene defines the hosting scene
  37640. */
  37641. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37642. /**
  37643. * Gets camera class name
  37644. * @returns AnaglyphFreeCamera
  37645. */
  37646. getClassName(): string;
  37647. }
  37648. }
  37649. declare module BABYLON {
  37650. /**
  37651. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37652. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37653. */
  37654. export class AnaglyphGamepadCamera extends GamepadCamera {
  37655. /**
  37656. * Creates a new AnaglyphGamepadCamera
  37657. * @param name defines camera name
  37658. * @param position defines initial position
  37659. * @param interaxialDistance defines distance between each color axis
  37660. * @param scene defines the hosting scene
  37661. */
  37662. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37663. /**
  37664. * Gets camera class name
  37665. * @returns AnaglyphGamepadCamera
  37666. */
  37667. getClassName(): string;
  37668. }
  37669. }
  37670. declare module BABYLON {
  37671. /**
  37672. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37673. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37674. */
  37675. export class AnaglyphUniversalCamera extends UniversalCamera {
  37676. /**
  37677. * Creates a new AnaglyphUniversalCamera
  37678. * @param name defines camera name
  37679. * @param position defines initial position
  37680. * @param interaxialDistance defines distance between each color axis
  37681. * @param scene defines the hosting scene
  37682. */
  37683. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37684. /**
  37685. * Gets camera class name
  37686. * @returns AnaglyphUniversalCamera
  37687. */
  37688. getClassName(): string;
  37689. }
  37690. }
  37691. declare module BABYLON {
  37692. /** @hidden */
  37693. export var stereoscopicInterlacePixelShader: {
  37694. name: string;
  37695. shader: string;
  37696. };
  37697. }
  37698. declare module BABYLON {
  37699. /**
  37700. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37701. */
  37702. export class StereoscopicInterlacePostProcess extends PostProcess {
  37703. private _stepSize;
  37704. private _passedProcess;
  37705. /**
  37706. * Initializes a StereoscopicInterlacePostProcess
  37707. * @param name The name of the effect.
  37708. * @param rigCameras The rig cameras to be appled to the post process
  37709. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37710. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37711. * @param engine The engine which the post process will be applied. (default: current engine)
  37712. * @param reusable If the post process can be reused on the same frame. (default: false)
  37713. */
  37714. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37715. }
  37716. }
  37717. declare module BABYLON {
  37718. /**
  37719. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37720. * @see http://doc.babylonjs.com/features/cameras
  37721. */
  37722. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37723. /**
  37724. * Creates a new StereoscopicArcRotateCamera
  37725. * @param name defines camera name
  37726. * @param alpha defines alpha angle (in radians)
  37727. * @param beta defines beta angle (in radians)
  37728. * @param radius defines radius
  37729. * @param target defines camera target
  37730. * @param interaxialDistance defines distance between each color axis
  37731. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37732. * @param scene defines the hosting scene
  37733. */
  37734. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37735. /**
  37736. * Gets camera class name
  37737. * @returns StereoscopicArcRotateCamera
  37738. */
  37739. getClassName(): string;
  37740. }
  37741. }
  37742. declare module BABYLON {
  37743. /**
  37744. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37745. * @see http://doc.babylonjs.com/features/cameras
  37746. */
  37747. export class StereoscopicFreeCamera extends FreeCamera {
  37748. /**
  37749. * Creates a new StereoscopicFreeCamera
  37750. * @param name defines camera name
  37751. * @param position defines initial position
  37752. * @param interaxialDistance defines distance between each color axis
  37753. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37754. * @param scene defines the hosting scene
  37755. */
  37756. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37757. /**
  37758. * Gets camera class name
  37759. * @returns StereoscopicFreeCamera
  37760. */
  37761. getClassName(): string;
  37762. }
  37763. }
  37764. declare module BABYLON {
  37765. /**
  37766. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37767. * @see http://doc.babylonjs.com/features/cameras
  37768. */
  37769. export class StereoscopicGamepadCamera extends GamepadCamera {
  37770. /**
  37771. * Creates a new StereoscopicGamepadCamera
  37772. * @param name defines camera name
  37773. * @param position defines initial position
  37774. * @param interaxialDistance defines distance between each color axis
  37775. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37776. * @param scene defines the hosting scene
  37777. */
  37778. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37779. /**
  37780. * Gets camera class name
  37781. * @returns StereoscopicGamepadCamera
  37782. */
  37783. getClassName(): string;
  37784. }
  37785. }
  37786. declare module BABYLON {
  37787. /**
  37788. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37789. * @see http://doc.babylonjs.com/features/cameras
  37790. */
  37791. export class StereoscopicUniversalCamera extends UniversalCamera {
  37792. /**
  37793. * Creates a new StereoscopicUniversalCamera
  37794. * @param name defines camera name
  37795. * @param position defines initial position
  37796. * @param interaxialDistance defines distance between each color axis
  37797. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37798. * @param scene defines the hosting scene
  37799. */
  37800. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37801. /**
  37802. * Gets camera class name
  37803. * @returns StereoscopicUniversalCamera
  37804. */
  37805. getClassName(): string;
  37806. }
  37807. }
  37808. declare module BABYLON {
  37809. /**
  37810. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37811. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37812. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37813. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37814. */
  37815. export class VirtualJoysticksCamera extends FreeCamera {
  37816. /**
  37817. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37818. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37819. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37820. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37821. * @param name Define the name of the camera in the scene
  37822. * @param position Define the start position of the camera in the scene
  37823. * @param scene Define the scene the camera belongs to
  37824. */
  37825. constructor(name: string, position: Vector3, scene: Scene);
  37826. /**
  37827. * Gets the current object class name.
  37828. * @return the class name
  37829. */
  37830. getClassName(): string;
  37831. }
  37832. }
  37833. declare module BABYLON {
  37834. /**
  37835. * This represents all the required metrics to create a VR camera.
  37836. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37837. */
  37838. export class VRCameraMetrics {
  37839. /**
  37840. * Define the horizontal resolution off the screen.
  37841. */
  37842. hResolution: number;
  37843. /**
  37844. * Define the vertical resolution off the screen.
  37845. */
  37846. vResolution: number;
  37847. /**
  37848. * Define the horizontal screen size.
  37849. */
  37850. hScreenSize: number;
  37851. /**
  37852. * Define the vertical screen size.
  37853. */
  37854. vScreenSize: number;
  37855. /**
  37856. * Define the vertical screen center position.
  37857. */
  37858. vScreenCenter: number;
  37859. /**
  37860. * Define the distance of the eyes to the screen.
  37861. */
  37862. eyeToScreenDistance: number;
  37863. /**
  37864. * Define the distance between both lenses
  37865. */
  37866. lensSeparationDistance: number;
  37867. /**
  37868. * Define the distance between both viewer's eyes.
  37869. */
  37870. interpupillaryDistance: number;
  37871. /**
  37872. * Define the distortion factor of the VR postprocess.
  37873. * Please, touch with care.
  37874. */
  37875. distortionK: number[];
  37876. /**
  37877. * Define the chromatic aberration correction factors for the VR post process.
  37878. */
  37879. chromaAbCorrection: number[];
  37880. /**
  37881. * Define the scale factor of the post process.
  37882. * The smaller the better but the slower.
  37883. */
  37884. postProcessScaleFactor: number;
  37885. /**
  37886. * Define an offset for the lens center.
  37887. */
  37888. lensCenterOffset: number;
  37889. /**
  37890. * Define if the current vr camera should compensate the distortion of the lense or not.
  37891. */
  37892. compensateDistortion: boolean;
  37893. /**
  37894. * Defines if multiview should be enabled when rendering (Default: false)
  37895. */
  37896. multiviewEnabled: boolean;
  37897. /**
  37898. * Gets the rendering aspect ratio based on the provided resolutions.
  37899. */
  37900. readonly aspectRatio: number;
  37901. /**
  37902. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37903. */
  37904. readonly aspectRatioFov: number;
  37905. /**
  37906. * @hidden
  37907. */
  37908. readonly leftHMatrix: Matrix;
  37909. /**
  37910. * @hidden
  37911. */
  37912. readonly rightHMatrix: Matrix;
  37913. /**
  37914. * @hidden
  37915. */
  37916. readonly leftPreViewMatrix: Matrix;
  37917. /**
  37918. * @hidden
  37919. */
  37920. readonly rightPreViewMatrix: Matrix;
  37921. /**
  37922. * Get the default VRMetrics based on the most generic setup.
  37923. * @returns the default vr metrics
  37924. */
  37925. static GetDefault(): VRCameraMetrics;
  37926. }
  37927. }
  37928. declare module BABYLON {
  37929. /** @hidden */
  37930. export var vrDistortionCorrectionPixelShader: {
  37931. name: string;
  37932. shader: string;
  37933. };
  37934. }
  37935. declare module BABYLON {
  37936. /**
  37937. * VRDistortionCorrectionPostProcess used for mobile VR
  37938. */
  37939. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37940. private _isRightEye;
  37941. private _distortionFactors;
  37942. private _postProcessScaleFactor;
  37943. private _lensCenterOffset;
  37944. private _scaleIn;
  37945. private _scaleFactor;
  37946. private _lensCenter;
  37947. /**
  37948. * Initializes the VRDistortionCorrectionPostProcess
  37949. * @param name The name of the effect.
  37950. * @param camera The camera to apply the render pass to.
  37951. * @param isRightEye If this is for the right eye distortion
  37952. * @param vrMetrics All the required metrics for the VR camera
  37953. */
  37954. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37955. }
  37956. }
  37957. declare module BABYLON {
  37958. /**
  37959. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37960. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37961. */
  37962. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37963. /**
  37964. * Creates a new VRDeviceOrientationArcRotateCamera
  37965. * @param name defines camera name
  37966. * @param alpha defines the camera rotation along the logitudinal axis
  37967. * @param beta defines the camera rotation along the latitudinal axis
  37968. * @param radius defines the camera distance from its target
  37969. * @param target defines the camera target
  37970. * @param scene defines the scene the camera belongs to
  37971. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37972. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37973. */
  37974. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37975. /**
  37976. * Gets camera class name
  37977. * @returns VRDeviceOrientationArcRotateCamera
  37978. */
  37979. getClassName(): string;
  37980. }
  37981. }
  37982. declare module BABYLON {
  37983. /**
  37984. * Camera used to simulate VR rendering (based on FreeCamera)
  37985. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37986. */
  37987. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37988. /**
  37989. * Creates a new VRDeviceOrientationFreeCamera
  37990. * @param name defines camera name
  37991. * @param position defines the start position of the camera
  37992. * @param scene defines the scene the camera belongs to
  37993. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37994. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37995. */
  37996. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37997. /**
  37998. * Gets camera class name
  37999. * @returns VRDeviceOrientationFreeCamera
  38000. */
  38001. getClassName(): string;
  38002. }
  38003. }
  38004. declare module BABYLON {
  38005. /**
  38006. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38007. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38008. */
  38009. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38010. /**
  38011. * Creates a new VRDeviceOrientationGamepadCamera
  38012. * @param name defines camera name
  38013. * @param position defines the start position of the camera
  38014. * @param scene defines the scene the camera belongs to
  38015. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38016. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38017. */
  38018. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38019. /**
  38020. * Gets camera class name
  38021. * @returns VRDeviceOrientationGamepadCamera
  38022. */
  38023. getClassName(): string;
  38024. }
  38025. }
  38026. declare module BABYLON {
  38027. /**
  38028. * Defines supported buttons for XBox360 compatible gamepads
  38029. */
  38030. export enum Xbox360Button {
  38031. /** A */
  38032. A = 0,
  38033. /** B */
  38034. B = 1,
  38035. /** X */
  38036. X = 2,
  38037. /** Y */
  38038. Y = 3,
  38039. /** Start */
  38040. Start = 4,
  38041. /** Back */
  38042. Back = 5,
  38043. /** Left button */
  38044. LB = 6,
  38045. /** Right button */
  38046. RB = 7,
  38047. /** Left stick */
  38048. LeftStick = 8,
  38049. /** Right stick */
  38050. RightStick = 9
  38051. }
  38052. /** Defines values for XBox360 DPad */
  38053. export enum Xbox360Dpad {
  38054. /** Up */
  38055. Up = 0,
  38056. /** Down */
  38057. Down = 1,
  38058. /** Left */
  38059. Left = 2,
  38060. /** Right */
  38061. Right = 3
  38062. }
  38063. /**
  38064. * Defines a XBox360 gamepad
  38065. */
  38066. export class Xbox360Pad extends Gamepad {
  38067. private _leftTrigger;
  38068. private _rightTrigger;
  38069. private _onlefttriggerchanged;
  38070. private _onrighttriggerchanged;
  38071. private _onbuttondown;
  38072. private _onbuttonup;
  38073. private _ondpaddown;
  38074. private _ondpadup;
  38075. /** Observable raised when a button is pressed */
  38076. onButtonDownObservable: Observable<Xbox360Button>;
  38077. /** Observable raised when a button is released */
  38078. onButtonUpObservable: Observable<Xbox360Button>;
  38079. /** Observable raised when a pad is pressed */
  38080. onPadDownObservable: Observable<Xbox360Dpad>;
  38081. /** Observable raised when a pad is released */
  38082. onPadUpObservable: Observable<Xbox360Dpad>;
  38083. private _buttonA;
  38084. private _buttonB;
  38085. private _buttonX;
  38086. private _buttonY;
  38087. private _buttonBack;
  38088. private _buttonStart;
  38089. private _buttonLB;
  38090. private _buttonRB;
  38091. private _buttonLeftStick;
  38092. private _buttonRightStick;
  38093. private _dPadUp;
  38094. private _dPadDown;
  38095. private _dPadLeft;
  38096. private _dPadRight;
  38097. private _isXboxOnePad;
  38098. /**
  38099. * Creates a new XBox360 gamepad object
  38100. * @param id defines the id of this gamepad
  38101. * @param index defines its index
  38102. * @param gamepad defines the internal HTML gamepad object
  38103. * @param xboxOne defines if it is a XBox One gamepad
  38104. */
  38105. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38106. /**
  38107. * Defines the callback to call when left trigger is pressed
  38108. * @param callback defines the callback to use
  38109. */
  38110. onlefttriggerchanged(callback: (value: number) => void): void;
  38111. /**
  38112. * Defines the callback to call when right trigger is pressed
  38113. * @param callback defines the callback to use
  38114. */
  38115. onrighttriggerchanged(callback: (value: number) => void): void;
  38116. /**
  38117. * Gets the left trigger value
  38118. */
  38119. /**
  38120. * Sets the left trigger value
  38121. */
  38122. leftTrigger: number;
  38123. /**
  38124. * Gets the right trigger value
  38125. */
  38126. /**
  38127. * Sets the right trigger value
  38128. */
  38129. rightTrigger: number;
  38130. /**
  38131. * Defines the callback to call when a button is pressed
  38132. * @param callback defines the callback to use
  38133. */
  38134. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38135. /**
  38136. * Defines the callback to call when a button is released
  38137. * @param callback defines the callback to use
  38138. */
  38139. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38140. /**
  38141. * Defines the callback to call when a pad is pressed
  38142. * @param callback defines the callback to use
  38143. */
  38144. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38145. /**
  38146. * Defines the callback to call when a pad is released
  38147. * @param callback defines the callback to use
  38148. */
  38149. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38150. private _setButtonValue;
  38151. private _setDPadValue;
  38152. /**
  38153. * Gets the value of the `A` button
  38154. */
  38155. /**
  38156. * Sets the value of the `A` button
  38157. */
  38158. buttonA: number;
  38159. /**
  38160. * Gets the value of the `B` button
  38161. */
  38162. /**
  38163. * Sets the value of the `B` button
  38164. */
  38165. buttonB: number;
  38166. /**
  38167. * Gets the value of the `X` button
  38168. */
  38169. /**
  38170. * Sets the value of the `X` button
  38171. */
  38172. buttonX: number;
  38173. /**
  38174. * Gets the value of the `Y` button
  38175. */
  38176. /**
  38177. * Sets the value of the `Y` button
  38178. */
  38179. buttonY: number;
  38180. /**
  38181. * Gets the value of the `Start` button
  38182. */
  38183. /**
  38184. * Sets the value of the `Start` button
  38185. */
  38186. buttonStart: number;
  38187. /**
  38188. * Gets the value of the `Back` button
  38189. */
  38190. /**
  38191. * Sets the value of the `Back` button
  38192. */
  38193. buttonBack: number;
  38194. /**
  38195. * Gets the value of the `Left` button
  38196. */
  38197. /**
  38198. * Sets the value of the `Left` button
  38199. */
  38200. buttonLB: number;
  38201. /**
  38202. * Gets the value of the `Right` button
  38203. */
  38204. /**
  38205. * Sets the value of the `Right` button
  38206. */
  38207. buttonRB: number;
  38208. /**
  38209. * Gets the value of the Left joystick
  38210. */
  38211. /**
  38212. * Sets the value of the Left joystick
  38213. */
  38214. buttonLeftStick: number;
  38215. /**
  38216. * Gets the value of the Right joystick
  38217. */
  38218. /**
  38219. * Sets the value of the Right joystick
  38220. */
  38221. buttonRightStick: number;
  38222. /**
  38223. * Gets the value of D-pad up
  38224. */
  38225. /**
  38226. * Sets the value of D-pad up
  38227. */
  38228. dPadUp: number;
  38229. /**
  38230. * Gets the value of D-pad down
  38231. */
  38232. /**
  38233. * Sets the value of D-pad down
  38234. */
  38235. dPadDown: number;
  38236. /**
  38237. * Gets the value of D-pad left
  38238. */
  38239. /**
  38240. * Sets the value of D-pad left
  38241. */
  38242. dPadLeft: number;
  38243. /**
  38244. * Gets the value of D-pad right
  38245. */
  38246. /**
  38247. * Sets the value of D-pad right
  38248. */
  38249. dPadRight: number;
  38250. /**
  38251. * Force the gamepad to synchronize with device values
  38252. */
  38253. update(): void;
  38254. /**
  38255. * Disposes the gamepad
  38256. */
  38257. dispose(): void;
  38258. }
  38259. }
  38260. declare module BABYLON {
  38261. /**
  38262. * Base class of materials working in push mode in babylon JS
  38263. * @hidden
  38264. */
  38265. export class PushMaterial extends Material {
  38266. protected _activeEffect: Effect;
  38267. protected _normalMatrix: Matrix;
  38268. /**
  38269. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38270. * This means that the material can keep using a previous shader while a new one is being compiled.
  38271. * This is mostly used when shader parallel compilation is supported (true by default)
  38272. */
  38273. allowShaderHotSwapping: boolean;
  38274. constructor(name: string, scene: Scene);
  38275. getEffect(): Effect;
  38276. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38277. /**
  38278. * Binds the given world matrix to the active effect
  38279. *
  38280. * @param world the matrix to bind
  38281. */
  38282. bindOnlyWorldMatrix(world: Matrix): void;
  38283. /**
  38284. * Binds the given normal matrix to the active effect
  38285. *
  38286. * @param normalMatrix the matrix to bind
  38287. */
  38288. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38289. bind(world: Matrix, mesh?: Mesh): void;
  38290. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38291. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38292. }
  38293. }
  38294. declare module BABYLON {
  38295. /**
  38296. * This groups all the flags used to control the materials channel.
  38297. */
  38298. export class MaterialFlags {
  38299. private static _DiffuseTextureEnabled;
  38300. /**
  38301. * Are diffuse textures enabled in the application.
  38302. */
  38303. static DiffuseTextureEnabled: boolean;
  38304. private static _AmbientTextureEnabled;
  38305. /**
  38306. * Are ambient textures enabled in the application.
  38307. */
  38308. static AmbientTextureEnabled: boolean;
  38309. private static _OpacityTextureEnabled;
  38310. /**
  38311. * Are opacity textures enabled in the application.
  38312. */
  38313. static OpacityTextureEnabled: boolean;
  38314. private static _ReflectionTextureEnabled;
  38315. /**
  38316. * Are reflection textures enabled in the application.
  38317. */
  38318. static ReflectionTextureEnabled: boolean;
  38319. private static _EmissiveTextureEnabled;
  38320. /**
  38321. * Are emissive textures enabled in the application.
  38322. */
  38323. static EmissiveTextureEnabled: boolean;
  38324. private static _SpecularTextureEnabled;
  38325. /**
  38326. * Are specular textures enabled in the application.
  38327. */
  38328. static SpecularTextureEnabled: boolean;
  38329. private static _BumpTextureEnabled;
  38330. /**
  38331. * Are bump textures enabled in the application.
  38332. */
  38333. static BumpTextureEnabled: boolean;
  38334. private static _LightmapTextureEnabled;
  38335. /**
  38336. * Are lightmap textures enabled in the application.
  38337. */
  38338. static LightmapTextureEnabled: boolean;
  38339. private static _RefractionTextureEnabled;
  38340. /**
  38341. * Are refraction textures enabled in the application.
  38342. */
  38343. static RefractionTextureEnabled: boolean;
  38344. private static _ColorGradingTextureEnabled;
  38345. /**
  38346. * Are color grading textures enabled in the application.
  38347. */
  38348. static ColorGradingTextureEnabled: boolean;
  38349. private static _FresnelEnabled;
  38350. /**
  38351. * Are fresnels enabled in the application.
  38352. */
  38353. static FresnelEnabled: boolean;
  38354. private static _ClearCoatTextureEnabled;
  38355. /**
  38356. * Are clear coat textures enabled in the application.
  38357. */
  38358. static ClearCoatTextureEnabled: boolean;
  38359. private static _ClearCoatBumpTextureEnabled;
  38360. /**
  38361. * Are clear coat bump textures enabled in the application.
  38362. */
  38363. static ClearCoatBumpTextureEnabled: boolean;
  38364. private static _ClearCoatTintTextureEnabled;
  38365. /**
  38366. * Are clear coat tint textures enabled in the application.
  38367. */
  38368. static ClearCoatTintTextureEnabled: boolean;
  38369. private static _SheenTextureEnabled;
  38370. /**
  38371. * Are sheen textures enabled in the application.
  38372. */
  38373. static SheenTextureEnabled: boolean;
  38374. private static _AnisotropicTextureEnabled;
  38375. /**
  38376. * Are anisotropic textures enabled in the application.
  38377. */
  38378. static AnisotropicTextureEnabled: boolean;
  38379. private static _ThicknessTextureEnabled;
  38380. /**
  38381. * Are thickness textures enabled in the application.
  38382. */
  38383. static ThicknessTextureEnabled: boolean;
  38384. }
  38385. }
  38386. declare module BABYLON {
  38387. /** @hidden */
  38388. export var defaultFragmentDeclaration: {
  38389. name: string;
  38390. shader: string;
  38391. };
  38392. }
  38393. declare module BABYLON {
  38394. /** @hidden */
  38395. export var defaultUboDeclaration: {
  38396. name: string;
  38397. shader: string;
  38398. };
  38399. }
  38400. declare module BABYLON {
  38401. /** @hidden */
  38402. export var lightFragmentDeclaration: {
  38403. name: string;
  38404. shader: string;
  38405. };
  38406. }
  38407. declare module BABYLON {
  38408. /** @hidden */
  38409. export var lightUboDeclaration: {
  38410. name: string;
  38411. shader: string;
  38412. };
  38413. }
  38414. declare module BABYLON {
  38415. /** @hidden */
  38416. export var lightsFragmentFunctions: {
  38417. name: string;
  38418. shader: string;
  38419. };
  38420. }
  38421. declare module BABYLON {
  38422. /** @hidden */
  38423. export var shadowsFragmentFunctions: {
  38424. name: string;
  38425. shader: string;
  38426. };
  38427. }
  38428. declare module BABYLON {
  38429. /** @hidden */
  38430. export var fresnelFunction: {
  38431. name: string;
  38432. shader: string;
  38433. };
  38434. }
  38435. declare module BABYLON {
  38436. /** @hidden */
  38437. export var reflectionFunction: {
  38438. name: string;
  38439. shader: string;
  38440. };
  38441. }
  38442. declare module BABYLON {
  38443. /** @hidden */
  38444. export var bumpFragmentFunctions: {
  38445. name: string;
  38446. shader: string;
  38447. };
  38448. }
  38449. declare module BABYLON {
  38450. /** @hidden */
  38451. export var logDepthDeclaration: {
  38452. name: string;
  38453. shader: string;
  38454. };
  38455. }
  38456. declare module BABYLON {
  38457. /** @hidden */
  38458. export var bumpFragment: {
  38459. name: string;
  38460. shader: string;
  38461. };
  38462. }
  38463. declare module BABYLON {
  38464. /** @hidden */
  38465. export var depthPrePass: {
  38466. name: string;
  38467. shader: string;
  38468. };
  38469. }
  38470. declare module BABYLON {
  38471. /** @hidden */
  38472. export var lightFragment: {
  38473. name: string;
  38474. shader: string;
  38475. };
  38476. }
  38477. declare module BABYLON {
  38478. /** @hidden */
  38479. export var logDepthFragment: {
  38480. name: string;
  38481. shader: string;
  38482. };
  38483. }
  38484. declare module BABYLON {
  38485. /** @hidden */
  38486. export var defaultPixelShader: {
  38487. name: string;
  38488. shader: string;
  38489. };
  38490. }
  38491. declare module BABYLON {
  38492. /** @hidden */
  38493. export var defaultVertexDeclaration: {
  38494. name: string;
  38495. shader: string;
  38496. };
  38497. }
  38498. declare module BABYLON {
  38499. /** @hidden */
  38500. export var bumpVertexDeclaration: {
  38501. name: string;
  38502. shader: string;
  38503. };
  38504. }
  38505. declare module BABYLON {
  38506. /** @hidden */
  38507. export var bumpVertex: {
  38508. name: string;
  38509. shader: string;
  38510. };
  38511. }
  38512. declare module BABYLON {
  38513. /** @hidden */
  38514. export var fogVertex: {
  38515. name: string;
  38516. shader: string;
  38517. };
  38518. }
  38519. declare module BABYLON {
  38520. /** @hidden */
  38521. export var shadowsVertex: {
  38522. name: string;
  38523. shader: string;
  38524. };
  38525. }
  38526. declare module BABYLON {
  38527. /** @hidden */
  38528. export var pointCloudVertex: {
  38529. name: string;
  38530. shader: string;
  38531. };
  38532. }
  38533. declare module BABYLON {
  38534. /** @hidden */
  38535. export var logDepthVertex: {
  38536. name: string;
  38537. shader: string;
  38538. };
  38539. }
  38540. declare module BABYLON {
  38541. /** @hidden */
  38542. export var defaultVertexShader: {
  38543. name: string;
  38544. shader: string;
  38545. };
  38546. }
  38547. declare module BABYLON {
  38548. /** @hidden */
  38549. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38550. MAINUV1: boolean;
  38551. MAINUV2: boolean;
  38552. DIFFUSE: boolean;
  38553. DIFFUSEDIRECTUV: number;
  38554. AMBIENT: boolean;
  38555. AMBIENTDIRECTUV: number;
  38556. OPACITY: boolean;
  38557. OPACITYDIRECTUV: number;
  38558. OPACITYRGB: boolean;
  38559. REFLECTION: boolean;
  38560. EMISSIVE: boolean;
  38561. EMISSIVEDIRECTUV: number;
  38562. SPECULAR: boolean;
  38563. SPECULARDIRECTUV: number;
  38564. BUMP: boolean;
  38565. BUMPDIRECTUV: number;
  38566. PARALLAX: boolean;
  38567. PARALLAXOCCLUSION: boolean;
  38568. SPECULAROVERALPHA: boolean;
  38569. CLIPPLANE: boolean;
  38570. CLIPPLANE2: boolean;
  38571. CLIPPLANE3: boolean;
  38572. CLIPPLANE4: boolean;
  38573. ALPHATEST: boolean;
  38574. DEPTHPREPASS: boolean;
  38575. ALPHAFROMDIFFUSE: boolean;
  38576. POINTSIZE: boolean;
  38577. FOG: boolean;
  38578. SPECULARTERM: boolean;
  38579. DIFFUSEFRESNEL: boolean;
  38580. OPACITYFRESNEL: boolean;
  38581. REFLECTIONFRESNEL: boolean;
  38582. REFRACTIONFRESNEL: boolean;
  38583. EMISSIVEFRESNEL: boolean;
  38584. FRESNEL: boolean;
  38585. NORMAL: boolean;
  38586. UV1: boolean;
  38587. UV2: boolean;
  38588. VERTEXCOLOR: boolean;
  38589. VERTEXALPHA: boolean;
  38590. NUM_BONE_INFLUENCERS: number;
  38591. BonesPerMesh: number;
  38592. BONETEXTURE: boolean;
  38593. INSTANCES: boolean;
  38594. GLOSSINESS: boolean;
  38595. ROUGHNESS: boolean;
  38596. EMISSIVEASILLUMINATION: boolean;
  38597. LINKEMISSIVEWITHDIFFUSE: boolean;
  38598. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38599. LIGHTMAP: boolean;
  38600. LIGHTMAPDIRECTUV: number;
  38601. OBJECTSPACE_NORMALMAP: boolean;
  38602. USELIGHTMAPASSHADOWMAP: boolean;
  38603. REFLECTIONMAP_3D: boolean;
  38604. REFLECTIONMAP_SPHERICAL: boolean;
  38605. REFLECTIONMAP_PLANAR: boolean;
  38606. REFLECTIONMAP_CUBIC: boolean;
  38607. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38608. REFLECTIONMAP_PROJECTION: boolean;
  38609. REFLECTIONMAP_SKYBOX: boolean;
  38610. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38611. REFLECTIONMAP_EXPLICIT: boolean;
  38612. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38613. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38614. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38615. INVERTCUBICMAP: boolean;
  38616. LOGARITHMICDEPTH: boolean;
  38617. REFRACTION: boolean;
  38618. REFRACTIONMAP_3D: boolean;
  38619. REFLECTIONOVERALPHA: boolean;
  38620. TWOSIDEDLIGHTING: boolean;
  38621. SHADOWFLOAT: boolean;
  38622. MORPHTARGETS: boolean;
  38623. MORPHTARGETS_NORMAL: boolean;
  38624. MORPHTARGETS_TANGENT: boolean;
  38625. NUM_MORPH_INFLUENCERS: number;
  38626. NONUNIFORMSCALING: boolean;
  38627. PREMULTIPLYALPHA: boolean;
  38628. IMAGEPROCESSING: boolean;
  38629. VIGNETTE: boolean;
  38630. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38631. VIGNETTEBLENDMODEOPAQUE: boolean;
  38632. TONEMAPPING: boolean;
  38633. TONEMAPPING_ACES: boolean;
  38634. CONTRAST: boolean;
  38635. COLORCURVES: boolean;
  38636. COLORGRADING: boolean;
  38637. COLORGRADING3D: boolean;
  38638. SAMPLER3DGREENDEPTH: boolean;
  38639. SAMPLER3DBGRMAP: boolean;
  38640. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38641. MULTIVIEW: boolean;
  38642. /**
  38643. * If the reflection texture on this material is in linear color space
  38644. * @hidden
  38645. */
  38646. IS_REFLECTION_LINEAR: boolean;
  38647. /**
  38648. * If the refraction texture on this material is in linear color space
  38649. * @hidden
  38650. */
  38651. IS_REFRACTION_LINEAR: boolean;
  38652. EXPOSURE: boolean;
  38653. constructor();
  38654. setReflectionMode(modeToEnable: string): void;
  38655. }
  38656. /**
  38657. * This is the default material used in Babylon. It is the best trade off between quality
  38658. * and performances.
  38659. * @see http://doc.babylonjs.com/babylon101/materials
  38660. */
  38661. export class StandardMaterial extends PushMaterial {
  38662. private _diffuseTexture;
  38663. /**
  38664. * The basic texture of the material as viewed under a light.
  38665. */
  38666. diffuseTexture: Nullable<BaseTexture>;
  38667. private _ambientTexture;
  38668. /**
  38669. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38670. */
  38671. ambientTexture: Nullable<BaseTexture>;
  38672. private _opacityTexture;
  38673. /**
  38674. * Define the transparency of the material from a texture.
  38675. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38676. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38677. */
  38678. opacityTexture: Nullable<BaseTexture>;
  38679. private _reflectionTexture;
  38680. /**
  38681. * Define the texture used to display the reflection.
  38682. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38683. */
  38684. reflectionTexture: Nullable<BaseTexture>;
  38685. private _emissiveTexture;
  38686. /**
  38687. * Define texture of the material as if self lit.
  38688. * This will be mixed in the final result even in the absence of light.
  38689. */
  38690. emissiveTexture: Nullable<BaseTexture>;
  38691. private _specularTexture;
  38692. /**
  38693. * Define how the color and intensity of the highlight given by the light in the material.
  38694. */
  38695. specularTexture: Nullable<BaseTexture>;
  38696. private _bumpTexture;
  38697. /**
  38698. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38699. * 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.
  38700. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38701. */
  38702. bumpTexture: Nullable<BaseTexture>;
  38703. private _lightmapTexture;
  38704. /**
  38705. * Complex lighting can be computationally expensive to compute at runtime.
  38706. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38707. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38708. */
  38709. lightmapTexture: Nullable<BaseTexture>;
  38710. private _refractionTexture;
  38711. /**
  38712. * Define the texture used to display the refraction.
  38713. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38714. */
  38715. refractionTexture: Nullable<BaseTexture>;
  38716. /**
  38717. * The color of the material lit by the environmental background lighting.
  38718. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38719. */
  38720. ambientColor: Color3;
  38721. /**
  38722. * The basic color of the material as viewed under a light.
  38723. */
  38724. diffuseColor: Color3;
  38725. /**
  38726. * Define how the color and intensity of the highlight given by the light in the material.
  38727. */
  38728. specularColor: Color3;
  38729. /**
  38730. * Define the color of the material as if self lit.
  38731. * This will be mixed in the final result even in the absence of light.
  38732. */
  38733. emissiveColor: Color3;
  38734. /**
  38735. * Defines how sharp are the highlights in the material.
  38736. * The bigger the value the sharper giving a more glossy feeling to the result.
  38737. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38738. */
  38739. specularPower: number;
  38740. private _useAlphaFromDiffuseTexture;
  38741. /**
  38742. * Does the transparency come from the diffuse texture alpha channel.
  38743. */
  38744. useAlphaFromDiffuseTexture: boolean;
  38745. private _useEmissiveAsIllumination;
  38746. /**
  38747. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38748. */
  38749. useEmissiveAsIllumination: boolean;
  38750. private _linkEmissiveWithDiffuse;
  38751. /**
  38752. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38753. * the emissive level when the final color is close to one.
  38754. */
  38755. linkEmissiveWithDiffuse: boolean;
  38756. private _useSpecularOverAlpha;
  38757. /**
  38758. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38759. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38760. */
  38761. useSpecularOverAlpha: boolean;
  38762. private _useReflectionOverAlpha;
  38763. /**
  38764. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38765. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38766. */
  38767. useReflectionOverAlpha: boolean;
  38768. private _disableLighting;
  38769. /**
  38770. * Does lights from the scene impacts this material.
  38771. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38772. */
  38773. disableLighting: boolean;
  38774. private _useObjectSpaceNormalMap;
  38775. /**
  38776. * Allows using an object space normal map (instead of tangent space).
  38777. */
  38778. useObjectSpaceNormalMap: boolean;
  38779. private _useParallax;
  38780. /**
  38781. * Is parallax enabled or not.
  38782. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38783. */
  38784. useParallax: boolean;
  38785. private _useParallaxOcclusion;
  38786. /**
  38787. * Is parallax occlusion enabled or not.
  38788. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38789. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38790. */
  38791. useParallaxOcclusion: boolean;
  38792. /**
  38793. * 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.
  38794. */
  38795. parallaxScaleBias: number;
  38796. private _roughness;
  38797. /**
  38798. * Helps to define how blurry the reflections should appears in the material.
  38799. */
  38800. roughness: number;
  38801. /**
  38802. * In case of refraction, define the value of the indice of refraction.
  38803. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38804. */
  38805. indexOfRefraction: number;
  38806. /**
  38807. * Invert the refraction texture alongside the y axis.
  38808. * It can be useful with procedural textures or probe for instance.
  38809. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38810. */
  38811. invertRefractionY: boolean;
  38812. /**
  38813. * Defines the alpha limits in alpha test mode.
  38814. */
  38815. alphaCutOff: number;
  38816. private _useLightmapAsShadowmap;
  38817. /**
  38818. * In case of light mapping, define whether the map contains light or shadow informations.
  38819. */
  38820. useLightmapAsShadowmap: boolean;
  38821. private _diffuseFresnelParameters;
  38822. /**
  38823. * Define the diffuse fresnel parameters of the material.
  38824. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38825. */
  38826. diffuseFresnelParameters: FresnelParameters;
  38827. private _opacityFresnelParameters;
  38828. /**
  38829. * Define the opacity fresnel parameters of the material.
  38830. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38831. */
  38832. opacityFresnelParameters: FresnelParameters;
  38833. private _reflectionFresnelParameters;
  38834. /**
  38835. * Define the reflection fresnel parameters of the material.
  38836. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38837. */
  38838. reflectionFresnelParameters: FresnelParameters;
  38839. private _refractionFresnelParameters;
  38840. /**
  38841. * Define the refraction fresnel parameters of the material.
  38842. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38843. */
  38844. refractionFresnelParameters: FresnelParameters;
  38845. private _emissiveFresnelParameters;
  38846. /**
  38847. * Define the emissive fresnel parameters of the material.
  38848. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38849. */
  38850. emissiveFresnelParameters: FresnelParameters;
  38851. private _useReflectionFresnelFromSpecular;
  38852. /**
  38853. * If true automatically deducts the fresnels values from the material specularity.
  38854. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38855. */
  38856. useReflectionFresnelFromSpecular: boolean;
  38857. private _useGlossinessFromSpecularMapAlpha;
  38858. /**
  38859. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38860. */
  38861. useGlossinessFromSpecularMapAlpha: boolean;
  38862. private _maxSimultaneousLights;
  38863. /**
  38864. * Defines the maximum number of lights that can be used in the material
  38865. */
  38866. maxSimultaneousLights: number;
  38867. private _invertNormalMapX;
  38868. /**
  38869. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38870. */
  38871. invertNormalMapX: boolean;
  38872. private _invertNormalMapY;
  38873. /**
  38874. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38875. */
  38876. invertNormalMapY: boolean;
  38877. private _twoSidedLighting;
  38878. /**
  38879. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38880. */
  38881. twoSidedLighting: boolean;
  38882. /**
  38883. * Default configuration related to image processing available in the standard Material.
  38884. */
  38885. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38886. /**
  38887. * Gets the image processing configuration used either in this material.
  38888. */
  38889. /**
  38890. * Sets the Default image processing configuration used either in the this material.
  38891. *
  38892. * If sets to null, the scene one is in use.
  38893. */
  38894. imageProcessingConfiguration: ImageProcessingConfiguration;
  38895. /**
  38896. * Keep track of the image processing observer to allow dispose and replace.
  38897. */
  38898. private _imageProcessingObserver;
  38899. /**
  38900. * Attaches a new image processing configuration to the Standard Material.
  38901. * @param configuration
  38902. */
  38903. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38904. /**
  38905. * Gets wether the color curves effect is enabled.
  38906. */
  38907. /**
  38908. * Sets wether the color curves effect is enabled.
  38909. */
  38910. cameraColorCurvesEnabled: boolean;
  38911. /**
  38912. * Gets wether the color grading effect is enabled.
  38913. */
  38914. /**
  38915. * Gets wether the color grading effect is enabled.
  38916. */
  38917. cameraColorGradingEnabled: boolean;
  38918. /**
  38919. * Gets wether tonemapping is enabled or not.
  38920. */
  38921. /**
  38922. * Sets wether tonemapping is enabled or not
  38923. */
  38924. cameraToneMappingEnabled: boolean;
  38925. /**
  38926. * The camera exposure used on this material.
  38927. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38928. * This corresponds to a photographic exposure.
  38929. */
  38930. /**
  38931. * The camera exposure used on this material.
  38932. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38933. * This corresponds to a photographic exposure.
  38934. */
  38935. cameraExposure: number;
  38936. /**
  38937. * Gets The camera contrast used on this material.
  38938. */
  38939. /**
  38940. * Sets The camera contrast used on this material.
  38941. */
  38942. cameraContrast: number;
  38943. /**
  38944. * Gets the Color Grading 2D Lookup Texture.
  38945. */
  38946. /**
  38947. * Sets the Color Grading 2D Lookup Texture.
  38948. */
  38949. cameraColorGradingTexture: Nullable<BaseTexture>;
  38950. /**
  38951. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38952. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38953. * 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;
  38954. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38955. */
  38956. /**
  38957. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38958. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38959. * 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;
  38960. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38961. */
  38962. cameraColorCurves: Nullable<ColorCurves>;
  38963. /**
  38964. * Custom callback helping to override the default shader used in the material.
  38965. */
  38966. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38967. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38968. protected _worldViewProjectionMatrix: Matrix;
  38969. protected _globalAmbientColor: Color3;
  38970. protected _useLogarithmicDepth: boolean;
  38971. /**
  38972. * Instantiates a new standard material.
  38973. * This is the default material used in Babylon. It is the best trade off between quality
  38974. * and performances.
  38975. * @see http://doc.babylonjs.com/babylon101/materials
  38976. * @param name Define the name of the material in the scene
  38977. * @param scene Define the scene the material belong to
  38978. */
  38979. constructor(name: string, scene: Scene);
  38980. /**
  38981. * Gets a boolean indicating that current material needs to register RTT
  38982. */
  38983. readonly hasRenderTargetTextures: boolean;
  38984. /**
  38985. * Gets the current class name of the material e.g. "StandardMaterial"
  38986. * Mainly use in serialization.
  38987. * @returns the class name
  38988. */
  38989. getClassName(): string;
  38990. /**
  38991. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38992. * You can try switching to logarithmic depth.
  38993. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38994. */
  38995. useLogarithmicDepth: boolean;
  38996. /**
  38997. * Specifies if the material will require alpha blending
  38998. * @returns a boolean specifying if alpha blending is needed
  38999. */
  39000. needAlphaBlending(): boolean;
  39001. /**
  39002. * Specifies if this material should be rendered in alpha test mode
  39003. * @returns a boolean specifying if an alpha test is needed.
  39004. */
  39005. needAlphaTesting(): boolean;
  39006. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39007. /**
  39008. * Get the texture used for alpha test purpose.
  39009. * @returns the diffuse texture in case of the standard material.
  39010. */
  39011. getAlphaTestTexture(): Nullable<BaseTexture>;
  39012. /**
  39013. * Get if the submesh is ready to be used and all its information available.
  39014. * Child classes can use it to update shaders
  39015. * @param mesh defines the mesh to check
  39016. * @param subMesh defines which submesh to check
  39017. * @param useInstances specifies that instances should be used
  39018. * @returns a boolean indicating that the submesh is ready or not
  39019. */
  39020. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39021. /**
  39022. * Builds the material UBO layouts.
  39023. * Used internally during the effect preparation.
  39024. */
  39025. buildUniformLayout(): void;
  39026. /**
  39027. * Unbinds the material from the mesh
  39028. */
  39029. unbind(): void;
  39030. /**
  39031. * Binds the submesh to this material by preparing the effect and shader to draw
  39032. * @param world defines the world transformation matrix
  39033. * @param mesh defines the mesh containing the submesh
  39034. * @param subMesh defines the submesh to bind the material to
  39035. */
  39036. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39037. /**
  39038. * Get the list of animatables in the material.
  39039. * @returns the list of animatables object used in the material
  39040. */
  39041. getAnimatables(): IAnimatable[];
  39042. /**
  39043. * Gets the active textures from the material
  39044. * @returns an array of textures
  39045. */
  39046. getActiveTextures(): BaseTexture[];
  39047. /**
  39048. * Specifies if the material uses a texture
  39049. * @param texture defines the texture to check against the material
  39050. * @returns a boolean specifying if the material uses the texture
  39051. */
  39052. hasTexture(texture: BaseTexture): boolean;
  39053. /**
  39054. * Disposes the material
  39055. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39056. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39057. */
  39058. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39059. /**
  39060. * Makes a duplicate of the material, and gives it a new name
  39061. * @param name defines the new name for the duplicated material
  39062. * @returns the cloned material
  39063. */
  39064. clone(name: string): StandardMaterial;
  39065. /**
  39066. * Serializes this material in a JSON representation
  39067. * @returns the serialized material object
  39068. */
  39069. serialize(): any;
  39070. /**
  39071. * Creates a standard material from parsed material data
  39072. * @param source defines the JSON representation of the material
  39073. * @param scene defines the hosting scene
  39074. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39075. * @returns a new standard material
  39076. */
  39077. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39078. /**
  39079. * Are diffuse textures enabled in the application.
  39080. */
  39081. static DiffuseTextureEnabled: boolean;
  39082. /**
  39083. * Are ambient textures enabled in the application.
  39084. */
  39085. static AmbientTextureEnabled: boolean;
  39086. /**
  39087. * Are opacity textures enabled in the application.
  39088. */
  39089. static OpacityTextureEnabled: boolean;
  39090. /**
  39091. * Are reflection textures enabled in the application.
  39092. */
  39093. static ReflectionTextureEnabled: boolean;
  39094. /**
  39095. * Are emissive textures enabled in the application.
  39096. */
  39097. static EmissiveTextureEnabled: boolean;
  39098. /**
  39099. * Are specular textures enabled in the application.
  39100. */
  39101. static SpecularTextureEnabled: boolean;
  39102. /**
  39103. * Are bump textures enabled in the application.
  39104. */
  39105. static BumpTextureEnabled: boolean;
  39106. /**
  39107. * Are lightmap textures enabled in the application.
  39108. */
  39109. static LightmapTextureEnabled: boolean;
  39110. /**
  39111. * Are refraction textures enabled in the application.
  39112. */
  39113. static RefractionTextureEnabled: boolean;
  39114. /**
  39115. * Are color grading textures enabled in the application.
  39116. */
  39117. static ColorGradingTextureEnabled: boolean;
  39118. /**
  39119. * Are fresnels enabled in the application.
  39120. */
  39121. static FresnelEnabled: boolean;
  39122. }
  39123. }
  39124. declare module BABYLON {
  39125. /**
  39126. * A class extending Texture allowing drawing on a texture
  39127. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39128. */
  39129. export class DynamicTexture extends Texture {
  39130. private _generateMipMaps;
  39131. private _canvas;
  39132. private _context;
  39133. private _engine;
  39134. /**
  39135. * Creates a DynamicTexture
  39136. * @param name defines the name of the texture
  39137. * @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
  39138. * @param scene defines the scene where you want the texture
  39139. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39140. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39141. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39142. */
  39143. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39144. /**
  39145. * Get the current class name of the texture useful for serialization or dynamic coding.
  39146. * @returns "DynamicTexture"
  39147. */
  39148. getClassName(): string;
  39149. /**
  39150. * Gets the current state of canRescale
  39151. */
  39152. readonly canRescale: boolean;
  39153. private _recreate;
  39154. /**
  39155. * Scales the texture
  39156. * @param ratio the scale factor to apply to both width and height
  39157. */
  39158. scale(ratio: number): void;
  39159. /**
  39160. * Resizes the texture
  39161. * @param width the new width
  39162. * @param height the new height
  39163. */
  39164. scaleTo(width: number, height: number): void;
  39165. /**
  39166. * Gets the context of the canvas used by the texture
  39167. * @returns the canvas context of the dynamic texture
  39168. */
  39169. getContext(): CanvasRenderingContext2D;
  39170. /**
  39171. * Clears the texture
  39172. */
  39173. clear(): void;
  39174. /**
  39175. * Updates the texture
  39176. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39177. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39178. */
  39179. update(invertY?: boolean, premulAlpha?: boolean): void;
  39180. /**
  39181. * Draws text onto the texture
  39182. * @param text defines the text to be drawn
  39183. * @param x defines the placement of the text from the left
  39184. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39185. * @param font defines the font to be used with font-style, font-size, font-name
  39186. * @param color defines the color used for the text
  39187. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39188. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39189. * @param update defines whether texture is immediately update (default is true)
  39190. */
  39191. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39192. /**
  39193. * Clones the texture
  39194. * @returns the clone of the texture.
  39195. */
  39196. clone(): DynamicTexture;
  39197. /**
  39198. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39199. * @returns a serialized dynamic texture object
  39200. */
  39201. serialize(): any;
  39202. /** @hidden */
  39203. _rebuild(): void;
  39204. }
  39205. }
  39206. declare module BABYLON {
  39207. /** @hidden */
  39208. export var imageProcessingPixelShader: {
  39209. name: string;
  39210. shader: string;
  39211. };
  39212. }
  39213. declare module BABYLON {
  39214. /**
  39215. * ImageProcessingPostProcess
  39216. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39217. */
  39218. export class ImageProcessingPostProcess extends PostProcess {
  39219. /**
  39220. * Default configuration related to image processing available in the PBR Material.
  39221. */
  39222. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39223. /**
  39224. * Gets the image processing configuration used either in this material.
  39225. */
  39226. /**
  39227. * Sets the Default image processing configuration used either in the this material.
  39228. *
  39229. * If sets to null, the scene one is in use.
  39230. */
  39231. imageProcessingConfiguration: ImageProcessingConfiguration;
  39232. /**
  39233. * Keep track of the image processing observer to allow dispose and replace.
  39234. */
  39235. private _imageProcessingObserver;
  39236. /**
  39237. * Attaches a new image processing configuration to the PBR Material.
  39238. * @param configuration
  39239. */
  39240. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39241. /**
  39242. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39243. */
  39244. /**
  39245. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39246. */
  39247. colorCurves: Nullable<ColorCurves>;
  39248. /**
  39249. * Gets wether the color curves effect is enabled.
  39250. */
  39251. /**
  39252. * Sets wether the color curves effect is enabled.
  39253. */
  39254. colorCurvesEnabled: boolean;
  39255. /**
  39256. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39257. */
  39258. /**
  39259. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39260. */
  39261. colorGradingTexture: Nullable<BaseTexture>;
  39262. /**
  39263. * Gets wether the color grading effect is enabled.
  39264. */
  39265. /**
  39266. * Gets wether the color grading effect is enabled.
  39267. */
  39268. colorGradingEnabled: boolean;
  39269. /**
  39270. * Gets exposure used in the effect.
  39271. */
  39272. /**
  39273. * Sets exposure used in the effect.
  39274. */
  39275. exposure: number;
  39276. /**
  39277. * Gets wether tonemapping is enabled or not.
  39278. */
  39279. /**
  39280. * Sets wether tonemapping is enabled or not
  39281. */
  39282. toneMappingEnabled: boolean;
  39283. /**
  39284. * Gets the type of tone mapping effect.
  39285. */
  39286. /**
  39287. * Sets the type of tone mapping effect.
  39288. */
  39289. toneMappingType: number;
  39290. /**
  39291. * Gets contrast used in the effect.
  39292. */
  39293. /**
  39294. * Sets contrast used in the effect.
  39295. */
  39296. contrast: number;
  39297. /**
  39298. * Gets Vignette stretch size.
  39299. */
  39300. /**
  39301. * Sets Vignette stretch size.
  39302. */
  39303. vignetteStretch: number;
  39304. /**
  39305. * Gets Vignette centre X Offset.
  39306. */
  39307. /**
  39308. * Sets Vignette centre X Offset.
  39309. */
  39310. vignetteCentreX: number;
  39311. /**
  39312. * Gets Vignette centre Y Offset.
  39313. */
  39314. /**
  39315. * Sets Vignette centre Y Offset.
  39316. */
  39317. vignetteCentreY: number;
  39318. /**
  39319. * Gets Vignette weight or intensity of the vignette effect.
  39320. */
  39321. /**
  39322. * Sets Vignette weight or intensity of the vignette effect.
  39323. */
  39324. vignetteWeight: number;
  39325. /**
  39326. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39327. * if vignetteEnabled is set to true.
  39328. */
  39329. /**
  39330. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39331. * if vignetteEnabled is set to true.
  39332. */
  39333. vignetteColor: Color4;
  39334. /**
  39335. * Gets Camera field of view used by the Vignette effect.
  39336. */
  39337. /**
  39338. * Sets Camera field of view used by the Vignette effect.
  39339. */
  39340. vignetteCameraFov: number;
  39341. /**
  39342. * Gets the vignette blend mode allowing different kind of effect.
  39343. */
  39344. /**
  39345. * Sets the vignette blend mode allowing different kind of effect.
  39346. */
  39347. vignetteBlendMode: number;
  39348. /**
  39349. * Gets wether the vignette effect is enabled.
  39350. */
  39351. /**
  39352. * Sets wether the vignette effect is enabled.
  39353. */
  39354. vignetteEnabled: boolean;
  39355. private _fromLinearSpace;
  39356. /**
  39357. * Gets wether the input of the processing is in Gamma or Linear Space.
  39358. */
  39359. /**
  39360. * Sets wether the input of the processing is in Gamma or Linear Space.
  39361. */
  39362. fromLinearSpace: boolean;
  39363. /**
  39364. * Defines cache preventing GC.
  39365. */
  39366. private _defines;
  39367. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39368. /**
  39369. * "ImageProcessingPostProcess"
  39370. * @returns "ImageProcessingPostProcess"
  39371. */
  39372. getClassName(): string;
  39373. protected _updateParameters(): void;
  39374. dispose(camera?: Camera): void;
  39375. }
  39376. }
  39377. declare module BABYLON {
  39378. /**
  39379. * Class containing static functions to help procedurally build meshes
  39380. */
  39381. export class GroundBuilder {
  39382. /**
  39383. * Creates a ground mesh
  39384. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39385. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39387. * @param name defines the name of the mesh
  39388. * @param options defines the options used to create the mesh
  39389. * @param scene defines the hosting scene
  39390. * @returns the ground mesh
  39391. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39392. */
  39393. static CreateGround(name: string, options: {
  39394. width?: number;
  39395. height?: number;
  39396. subdivisions?: number;
  39397. subdivisionsX?: number;
  39398. subdivisionsY?: number;
  39399. updatable?: boolean;
  39400. }, scene: any): Mesh;
  39401. /**
  39402. * Creates a tiled ground mesh
  39403. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39404. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39405. * * 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
  39406. * * 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
  39407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39408. * @param name defines the name of the mesh
  39409. * @param options defines the options used to create the mesh
  39410. * @param scene defines the hosting scene
  39411. * @returns the tiled ground mesh
  39412. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39413. */
  39414. static CreateTiledGround(name: string, options: {
  39415. xmin: number;
  39416. zmin: number;
  39417. xmax: number;
  39418. zmax: number;
  39419. subdivisions?: {
  39420. w: number;
  39421. h: number;
  39422. };
  39423. precision?: {
  39424. w: number;
  39425. h: number;
  39426. };
  39427. updatable?: boolean;
  39428. }, scene?: Nullable<Scene>): Mesh;
  39429. /**
  39430. * Creates a ground mesh from a height map
  39431. * * The parameter `url` sets the URL of the height map image resource.
  39432. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39433. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39434. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39435. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39436. * * 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.
  39437. * * 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).
  39438. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39440. * @param name defines the name of the mesh
  39441. * @param url defines the url to the height map
  39442. * @param options defines the options used to create the mesh
  39443. * @param scene defines the hosting scene
  39444. * @returns the ground mesh
  39445. * @see https://doc.babylonjs.com/babylon101/height_map
  39446. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39447. */
  39448. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39449. width?: number;
  39450. height?: number;
  39451. subdivisions?: number;
  39452. minHeight?: number;
  39453. maxHeight?: number;
  39454. colorFilter?: Color3;
  39455. alphaFilter?: number;
  39456. updatable?: boolean;
  39457. onReady?: (mesh: GroundMesh) => void;
  39458. }, scene?: Nullable<Scene>): GroundMesh;
  39459. }
  39460. }
  39461. declare module BABYLON {
  39462. /**
  39463. * Class containing static functions to help procedurally build meshes
  39464. */
  39465. export class TorusBuilder {
  39466. /**
  39467. * Creates a torus mesh
  39468. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39469. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39470. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39472. * * 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
  39473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39474. * @param name defines the name of the mesh
  39475. * @param options defines the options used to create the mesh
  39476. * @param scene defines the hosting scene
  39477. * @returns the torus mesh
  39478. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39479. */
  39480. static CreateTorus(name: string, options: {
  39481. diameter?: number;
  39482. thickness?: number;
  39483. tessellation?: number;
  39484. updatable?: boolean;
  39485. sideOrientation?: number;
  39486. frontUVs?: Vector4;
  39487. backUVs?: Vector4;
  39488. }, scene: any): Mesh;
  39489. }
  39490. }
  39491. declare module BABYLON {
  39492. /**
  39493. * Class containing static functions to help procedurally build meshes
  39494. */
  39495. export class CylinderBuilder {
  39496. /**
  39497. * Creates a cylinder or a cone mesh
  39498. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39499. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39500. * * 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.
  39501. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39502. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39503. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39504. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39505. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39506. * * 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).
  39507. * * 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
  39508. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39509. * * 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
  39510. * * 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.
  39511. * * If `enclose` is false, a ring surface is one element.
  39512. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39513. * * 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
  39514. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39515. * * 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
  39516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39517. * @param name defines the name of the mesh
  39518. * @param options defines the options used to create the mesh
  39519. * @param scene defines the hosting scene
  39520. * @returns the cylinder mesh
  39521. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39522. */
  39523. static CreateCylinder(name: string, options: {
  39524. height?: number;
  39525. diameterTop?: number;
  39526. diameterBottom?: number;
  39527. diameter?: number;
  39528. tessellation?: number;
  39529. subdivisions?: number;
  39530. arc?: number;
  39531. faceColors?: Color4[];
  39532. faceUV?: Vector4[];
  39533. updatable?: boolean;
  39534. hasRings?: boolean;
  39535. enclose?: boolean;
  39536. sideOrientation?: number;
  39537. frontUVs?: Vector4;
  39538. backUVs?: Vector4;
  39539. }, scene: any): Mesh;
  39540. }
  39541. }
  39542. declare module BABYLON {
  39543. /**
  39544. * Manager for handling gamepads
  39545. */
  39546. export class GamepadManager {
  39547. private _scene?;
  39548. private _babylonGamepads;
  39549. private _oneGamepadConnected;
  39550. /** @hidden */
  39551. _isMonitoring: boolean;
  39552. private _gamepadEventSupported;
  39553. private _gamepadSupport;
  39554. /**
  39555. * observable to be triggered when the gamepad controller has been connected
  39556. */
  39557. onGamepadConnectedObservable: Observable<Gamepad>;
  39558. /**
  39559. * observable to be triggered when the gamepad controller has been disconnected
  39560. */
  39561. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39562. private _onGamepadConnectedEvent;
  39563. private _onGamepadDisconnectedEvent;
  39564. /**
  39565. * Initializes the gamepad manager
  39566. * @param _scene BabylonJS scene
  39567. */
  39568. constructor(_scene?: Scene | undefined);
  39569. /**
  39570. * The gamepads in the game pad manager
  39571. */
  39572. readonly gamepads: Gamepad[];
  39573. /**
  39574. * Get the gamepad controllers based on type
  39575. * @param type The type of gamepad controller
  39576. * @returns Nullable gamepad
  39577. */
  39578. getGamepadByType(type?: number): Nullable<Gamepad>;
  39579. /**
  39580. * Disposes the gamepad manager
  39581. */
  39582. dispose(): void;
  39583. private _addNewGamepad;
  39584. private _startMonitoringGamepads;
  39585. private _stopMonitoringGamepads;
  39586. /** @hidden */
  39587. _checkGamepadsStatus(): void;
  39588. private _updateGamepadObjects;
  39589. }
  39590. }
  39591. declare module BABYLON {
  39592. interface Scene {
  39593. /** @hidden */
  39594. _gamepadManager: Nullable<GamepadManager>;
  39595. /**
  39596. * Gets the gamepad manager associated with the scene
  39597. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39598. */
  39599. gamepadManager: GamepadManager;
  39600. }
  39601. /**
  39602. * Interface representing a free camera inputs manager
  39603. */
  39604. interface FreeCameraInputsManager {
  39605. /**
  39606. * Adds gamepad input support to the FreeCameraInputsManager.
  39607. * @returns the FreeCameraInputsManager
  39608. */
  39609. addGamepad(): FreeCameraInputsManager;
  39610. }
  39611. /**
  39612. * Interface representing an arc rotate camera inputs manager
  39613. */
  39614. interface ArcRotateCameraInputsManager {
  39615. /**
  39616. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39617. * @returns the camera inputs manager
  39618. */
  39619. addGamepad(): ArcRotateCameraInputsManager;
  39620. }
  39621. /**
  39622. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39623. */
  39624. export class GamepadSystemSceneComponent implements ISceneComponent {
  39625. /**
  39626. * The component name helpfull to identify the component in the list of scene components.
  39627. */
  39628. readonly name: string;
  39629. /**
  39630. * The scene the component belongs to.
  39631. */
  39632. scene: Scene;
  39633. /**
  39634. * Creates a new instance of the component for the given scene
  39635. * @param scene Defines the scene to register the component in
  39636. */
  39637. constructor(scene: Scene);
  39638. /**
  39639. * Registers the component in a given scene
  39640. */
  39641. register(): void;
  39642. /**
  39643. * Rebuilds the elements related to this component in case of
  39644. * context lost for instance.
  39645. */
  39646. rebuild(): void;
  39647. /**
  39648. * Disposes the component and the associated ressources
  39649. */
  39650. dispose(): void;
  39651. private _beforeCameraUpdate;
  39652. }
  39653. }
  39654. declare module BABYLON {
  39655. /**
  39656. * Options to modify the vr teleportation behavior.
  39657. */
  39658. export interface VRTeleportationOptions {
  39659. /**
  39660. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39661. */
  39662. floorMeshName?: string;
  39663. /**
  39664. * A list of meshes to be used as the teleportation floor. (default: empty)
  39665. */
  39666. floorMeshes?: Mesh[];
  39667. }
  39668. /**
  39669. * Options to modify the vr experience helper's behavior.
  39670. */
  39671. export interface VRExperienceHelperOptions extends WebVROptions {
  39672. /**
  39673. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39674. */
  39675. createDeviceOrientationCamera?: boolean;
  39676. /**
  39677. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39678. */
  39679. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39680. /**
  39681. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39682. */
  39683. laserToggle?: boolean;
  39684. /**
  39685. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39686. */
  39687. floorMeshes?: Mesh[];
  39688. /**
  39689. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39690. */
  39691. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39692. }
  39693. /**
  39694. * Event containing information after VR has been entered
  39695. */
  39696. export class OnAfterEnteringVRObservableEvent {
  39697. /**
  39698. * If entering vr was successful
  39699. */
  39700. success: boolean;
  39701. }
  39702. /**
  39703. * Helps to quickly add VR support to an existing scene.
  39704. * See http://doc.babylonjs.com/how_to/webvr_helper
  39705. */
  39706. export class VRExperienceHelper {
  39707. /** Options to modify the vr experience helper's behavior. */
  39708. webVROptions: VRExperienceHelperOptions;
  39709. private _scene;
  39710. private _position;
  39711. private _btnVR;
  39712. private _btnVRDisplayed;
  39713. private _webVRsupported;
  39714. private _webVRready;
  39715. private _webVRrequesting;
  39716. private _webVRpresenting;
  39717. private _hasEnteredVR;
  39718. private _fullscreenVRpresenting;
  39719. private _canvas;
  39720. private _webVRCamera;
  39721. private _vrDeviceOrientationCamera;
  39722. private _deviceOrientationCamera;
  39723. private _existingCamera;
  39724. private _onKeyDown;
  39725. private _onVrDisplayPresentChange;
  39726. private _onVRDisplayChanged;
  39727. private _onVRRequestPresentStart;
  39728. private _onVRRequestPresentComplete;
  39729. /**
  39730. * Observable raised right before entering VR.
  39731. */
  39732. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39733. /**
  39734. * Observable raised when entering VR has completed.
  39735. */
  39736. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39737. /**
  39738. * Observable raised when exiting VR.
  39739. */
  39740. onExitingVRObservable: Observable<VRExperienceHelper>;
  39741. /**
  39742. * Observable raised when controller mesh is loaded.
  39743. */
  39744. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39745. /** Return this.onEnteringVRObservable
  39746. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39747. */
  39748. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39749. /** Return this.onExitingVRObservable
  39750. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39751. */
  39752. readonly onExitingVR: Observable<VRExperienceHelper>;
  39753. /** Return this.onControllerMeshLoadedObservable
  39754. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39755. */
  39756. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39757. private _rayLength;
  39758. private _useCustomVRButton;
  39759. private _teleportationRequested;
  39760. private _teleportActive;
  39761. private _floorMeshName;
  39762. private _floorMeshesCollection;
  39763. private _rotationAllowed;
  39764. private _teleportBackwardsVector;
  39765. private _teleportationTarget;
  39766. private _isDefaultTeleportationTarget;
  39767. private _postProcessMove;
  39768. private _teleportationFillColor;
  39769. private _teleportationBorderColor;
  39770. private _rotationAngle;
  39771. private _haloCenter;
  39772. private _cameraGazer;
  39773. private _padSensibilityUp;
  39774. private _padSensibilityDown;
  39775. private _leftController;
  39776. private _rightController;
  39777. /**
  39778. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39779. */
  39780. onNewMeshSelected: Observable<AbstractMesh>;
  39781. /**
  39782. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39783. */
  39784. onNewMeshPicked: Observable<PickingInfo>;
  39785. private _circleEase;
  39786. /**
  39787. * Observable raised before camera teleportation
  39788. */
  39789. onBeforeCameraTeleport: Observable<Vector3>;
  39790. /**
  39791. * Observable raised after camera teleportation
  39792. */
  39793. onAfterCameraTeleport: Observable<Vector3>;
  39794. /**
  39795. * Observable raised when current selected mesh gets unselected
  39796. */
  39797. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39798. private _raySelectionPredicate;
  39799. /**
  39800. * To be optionaly changed by user to define custom ray selection
  39801. */
  39802. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39803. /**
  39804. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39805. */
  39806. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39807. /**
  39808. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39809. */
  39810. teleportationEnabled: boolean;
  39811. private _defaultHeight;
  39812. private _teleportationInitialized;
  39813. private _interactionsEnabled;
  39814. private _interactionsRequested;
  39815. private _displayGaze;
  39816. private _displayLaserPointer;
  39817. /**
  39818. * The mesh used to display where the user is going to teleport.
  39819. */
  39820. /**
  39821. * Sets the mesh to be used to display where the user is going to teleport.
  39822. */
  39823. teleportationTarget: Mesh;
  39824. /**
  39825. * 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
  39826. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39827. * See http://doc.babylonjs.com/resources/baking_transformations
  39828. */
  39829. gazeTrackerMesh: Mesh;
  39830. /**
  39831. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39832. */
  39833. updateGazeTrackerScale: boolean;
  39834. /**
  39835. * If the gaze trackers color should be updated when selecting meshes
  39836. */
  39837. updateGazeTrackerColor: boolean;
  39838. /**
  39839. * The gaze tracking mesh corresponding to the left controller
  39840. */
  39841. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39842. /**
  39843. * The gaze tracking mesh corresponding to the right controller
  39844. */
  39845. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39846. /**
  39847. * If the ray of the gaze should be displayed.
  39848. */
  39849. /**
  39850. * Sets if the ray of the gaze should be displayed.
  39851. */
  39852. displayGaze: boolean;
  39853. /**
  39854. * If the ray of the LaserPointer should be displayed.
  39855. */
  39856. /**
  39857. * Sets if the ray of the LaserPointer should be displayed.
  39858. */
  39859. displayLaserPointer: boolean;
  39860. /**
  39861. * The deviceOrientationCamera used as the camera when not in VR.
  39862. */
  39863. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39864. /**
  39865. * Based on the current WebVR support, returns the current VR camera used.
  39866. */
  39867. readonly currentVRCamera: Nullable<Camera>;
  39868. /**
  39869. * The webVRCamera which is used when in VR.
  39870. */
  39871. readonly webVRCamera: WebVRFreeCamera;
  39872. /**
  39873. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39874. */
  39875. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39876. private readonly _teleportationRequestInitiated;
  39877. /**
  39878. * Defines wether or not Pointer lock should be requested when switching to
  39879. * full screen.
  39880. */
  39881. requestPointerLockOnFullScreen: boolean;
  39882. /**
  39883. * Instantiates a VRExperienceHelper.
  39884. * Helps to quickly add VR support to an existing scene.
  39885. * @param scene The scene the VRExperienceHelper belongs to.
  39886. * @param webVROptions Options to modify the vr experience helper's behavior.
  39887. */
  39888. constructor(scene: Scene,
  39889. /** Options to modify the vr experience helper's behavior. */
  39890. webVROptions?: VRExperienceHelperOptions);
  39891. private _onDefaultMeshLoaded;
  39892. private _onResize;
  39893. private _onFullscreenChange;
  39894. /**
  39895. * Gets a value indicating if we are currently in VR mode.
  39896. */
  39897. readonly isInVRMode: boolean;
  39898. private onVrDisplayPresentChange;
  39899. private onVRDisplayChanged;
  39900. private moveButtonToBottomRight;
  39901. private displayVRButton;
  39902. private updateButtonVisibility;
  39903. private _cachedAngularSensibility;
  39904. /**
  39905. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39906. * Otherwise, will use the fullscreen API.
  39907. */
  39908. enterVR(): void;
  39909. /**
  39910. * Attempt to exit VR, or fullscreen.
  39911. */
  39912. exitVR(): void;
  39913. /**
  39914. * The position of the vr experience helper.
  39915. */
  39916. /**
  39917. * Sets the position of the vr experience helper.
  39918. */
  39919. position: Vector3;
  39920. /**
  39921. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39922. */
  39923. enableInteractions(): void;
  39924. private readonly _noControllerIsActive;
  39925. private beforeRender;
  39926. private _isTeleportationFloor;
  39927. /**
  39928. * Adds a floor mesh to be used for teleportation.
  39929. * @param floorMesh the mesh to be used for teleportation.
  39930. */
  39931. addFloorMesh(floorMesh: Mesh): void;
  39932. /**
  39933. * Removes a floor mesh from being used for teleportation.
  39934. * @param floorMesh the mesh to be removed.
  39935. */
  39936. removeFloorMesh(floorMesh: Mesh): void;
  39937. /**
  39938. * Enables interactions and teleportation using the VR controllers and gaze.
  39939. * @param vrTeleportationOptions options to modify teleportation behavior.
  39940. */
  39941. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39942. private _onNewGamepadConnected;
  39943. private _tryEnableInteractionOnController;
  39944. private _onNewGamepadDisconnected;
  39945. private _enableInteractionOnController;
  39946. private _checkTeleportWithRay;
  39947. private _checkRotate;
  39948. private _checkTeleportBackwards;
  39949. private _enableTeleportationOnController;
  39950. private _createTeleportationCircles;
  39951. private _displayTeleportationTarget;
  39952. private _hideTeleportationTarget;
  39953. private _rotateCamera;
  39954. private _moveTeleportationSelectorTo;
  39955. private _workingVector;
  39956. private _workingQuaternion;
  39957. private _workingMatrix;
  39958. /**
  39959. * Teleports the users feet to the desired location
  39960. * @param location The location where the user's feet should be placed
  39961. */
  39962. teleportCamera(location: Vector3): void;
  39963. private _convertNormalToDirectionOfRay;
  39964. private _castRayAndSelectObject;
  39965. private _notifySelectedMeshUnselected;
  39966. /**
  39967. * Sets the color of the laser ray from the vr controllers.
  39968. * @param color new color for the ray.
  39969. */
  39970. changeLaserColor(color: Color3): void;
  39971. /**
  39972. * Sets the color of the ray from the vr headsets gaze.
  39973. * @param color new color for the ray.
  39974. */
  39975. changeGazeColor(color: Color3): void;
  39976. /**
  39977. * Exits VR and disposes of the vr experience helper
  39978. */
  39979. dispose(): void;
  39980. /**
  39981. * Gets the name of the VRExperienceHelper class
  39982. * @returns "VRExperienceHelper"
  39983. */
  39984. getClassName(): string;
  39985. }
  39986. }
  39987. declare module BABYLON {
  39988. /**
  39989. * Manages an XRSession
  39990. * @see https://doc.babylonjs.com/how_to/webxr
  39991. */
  39992. export class WebXRSessionManager implements IDisposable {
  39993. private scene;
  39994. /**
  39995. * Fires every time a new xrFrame arrives which can be used to update the camera
  39996. */
  39997. onXRFrameObservable: Observable<any>;
  39998. /**
  39999. * Fires when the xr session is ended either by the device or manually done
  40000. */
  40001. onXRSessionEnded: Observable<any>;
  40002. /** @hidden */
  40003. _xrSession: XRSession;
  40004. /** @hidden */
  40005. _frameOfReference: XRFrameOfReference;
  40006. /** @hidden */
  40007. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40008. /** @hidden */
  40009. _currentXRFrame: Nullable<XRFrame>;
  40010. private _xrNavigator;
  40011. private _xrDevice;
  40012. private _tmpMatrix;
  40013. /**
  40014. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40015. * @param scene The scene which the session should be created for
  40016. */
  40017. constructor(scene: Scene);
  40018. /**
  40019. * Initializes the manager
  40020. * After initialization enterXR can be called to start an XR session
  40021. * @returns Promise which resolves after it is initialized
  40022. */
  40023. initializeAsync(): Promise<void>;
  40024. /**
  40025. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40026. * @param sessionCreationOptions xr options to create the session with
  40027. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40028. * @returns Promise which resolves after it enters XR
  40029. */
  40030. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40031. /**
  40032. * Stops the xrSession and restores the renderloop
  40033. * @returns Promise which resolves after it exits XR
  40034. */
  40035. exitXRAsync(): Promise<void>;
  40036. /**
  40037. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40038. * @param ray ray to cast into the environment
  40039. * @returns Promise which resolves with a collision point in the environment if it exists
  40040. */
  40041. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40042. /**
  40043. * Checks if a session would be supported for the creation options specified
  40044. * @param options creation options to check if they are supported
  40045. * @returns true if supported
  40046. */
  40047. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40048. /**
  40049. * @hidden
  40050. * Converts the render layer of xrSession to a render target
  40051. * @param session session to create render target for
  40052. * @param scene scene the new render target should be created for
  40053. */
  40054. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40055. /**
  40056. * Disposes of the session manager
  40057. */
  40058. dispose(): void;
  40059. }
  40060. }
  40061. declare module BABYLON {
  40062. /**
  40063. * WebXR Camera which holds the views for the xrSession
  40064. * @see https://doc.babylonjs.com/how_to/webxr
  40065. */
  40066. export class WebXRCamera extends FreeCamera {
  40067. private static _TmpMatrix;
  40068. /**
  40069. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40070. * @param name the name of the camera
  40071. * @param scene the scene to add the camera to
  40072. */
  40073. constructor(name: string, scene: Scene);
  40074. private _updateNumberOfRigCameras;
  40075. /** @hidden */
  40076. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40077. /**
  40078. * Updates the cameras position from the current pose information of the XR session
  40079. * @param xrSessionManager the session containing pose information
  40080. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40081. */
  40082. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40083. }
  40084. }
  40085. declare module BABYLON {
  40086. /**
  40087. * States of the webXR experience
  40088. */
  40089. export enum WebXRState {
  40090. /**
  40091. * Transitioning to being in XR mode
  40092. */
  40093. ENTERING_XR = 0,
  40094. /**
  40095. * Transitioning to non XR mode
  40096. */
  40097. EXITING_XR = 1,
  40098. /**
  40099. * In XR mode and presenting
  40100. */
  40101. IN_XR = 2,
  40102. /**
  40103. * Not entered XR mode
  40104. */
  40105. NOT_IN_XR = 3
  40106. }
  40107. /**
  40108. * Helper class used to enable XR
  40109. * @see https://doc.babylonjs.com/how_to/webxr
  40110. */
  40111. export class WebXRExperienceHelper implements IDisposable {
  40112. private scene;
  40113. /**
  40114. * 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
  40115. */
  40116. container: AbstractMesh;
  40117. /**
  40118. * Camera used to render xr content
  40119. */
  40120. camera: WebXRCamera;
  40121. /**
  40122. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40123. */
  40124. state: WebXRState;
  40125. private _setState;
  40126. private static _TmpVector;
  40127. /**
  40128. * Fires when the state of the experience helper has changed
  40129. */
  40130. onStateChangedObservable: Observable<WebXRState>;
  40131. /** @hidden */
  40132. _sessionManager: WebXRSessionManager;
  40133. private _nonVRCamera;
  40134. private _originalSceneAutoClear;
  40135. private _supported;
  40136. /**
  40137. * Creates the experience helper
  40138. * @param scene the scene to attach the experience helper to
  40139. * @returns a promise for the experience helper
  40140. */
  40141. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40142. /**
  40143. * Creates a WebXRExperienceHelper
  40144. * @param scene The scene the helper should be created in
  40145. */
  40146. private constructor();
  40147. /**
  40148. * Exits XR mode and returns the scene to its original state
  40149. * @returns promise that resolves after xr mode has exited
  40150. */
  40151. exitXRAsync(): Promise<void>;
  40152. /**
  40153. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40154. * @param sessionCreationOptions options for the XR session
  40155. * @param frameOfReference frame of reference of the XR session
  40156. * @returns promise that resolves after xr mode has entered
  40157. */
  40158. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40159. /**
  40160. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40161. * @param ray ray to cast into the environment
  40162. * @returns Promise which resolves with a collision point in the environment if it exists
  40163. */
  40164. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40165. /**
  40166. * Updates the global position of the camera by moving the camera's container
  40167. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40168. * @param position The desired global position of the camera
  40169. */
  40170. setPositionOfCameraUsingContainer(position: Vector3): void;
  40171. /**
  40172. * Rotates the xr camera by rotating the camera's container around the camera's position
  40173. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40174. * @param rotation the desired quaternion rotation to apply to the camera
  40175. */
  40176. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40177. /**
  40178. * Checks if the creation options are supported by the xr session
  40179. * @param options creation options
  40180. * @returns true if supported
  40181. */
  40182. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40183. /**
  40184. * Disposes of the experience helper
  40185. */
  40186. dispose(): void;
  40187. }
  40188. }
  40189. declare module BABYLON {
  40190. /**
  40191. * Button which can be used to enter a different mode of XR
  40192. */
  40193. export class WebXREnterExitUIButton {
  40194. /** button element */
  40195. element: HTMLElement;
  40196. /** XR initialization options for the button */
  40197. initializationOptions: XRSessionCreationOptions;
  40198. /**
  40199. * Creates a WebXREnterExitUIButton
  40200. * @param element button element
  40201. * @param initializationOptions XR initialization options for the button
  40202. */
  40203. constructor(
  40204. /** button element */
  40205. element: HTMLElement,
  40206. /** XR initialization options for the button */
  40207. initializationOptions: XRSessionCreationOptions);
  40208. /**
  40209. * Overwritable function which can be used to update the button's visuals when the state changes
  40210. * @param activeButton the current active button in the UI
  40211. */
  40212. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40213. }
  40214. /**
  40215. * Options to create the webXR UI
  40216. */
  40217. export class WebXREnterExitUIOptions {
  40218. /**
  40219. * Context to enter xr with
  40220. */
  40221. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40222. /**
  40223. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40224. */
  40225. customButtons?: Array<WebXREnterExitUIButton>;
  40226. }
  40227. /**
  40228. * UI to allow the user to enter/exit XR mode
  40229. */
  40230. export class WebXREnterExitUI implements IDisposable {
  40231. private scene;
  40232. private _overlay;
  40233. private _buttons;
  40234. private _activeButton;
  40235. /**
  40236. * Fired every time the active button is changed.
  40237. *
  40238. * When xr is entered via a button that launches xr that button will be the callback parameter
  40239. *
  40240. * When exiting xr the callback parameter will be null)
  40241. */
  40242. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40243. /**
  40244. * Creates UI to allow the user to enter/exit XR mode
  40245. * @param scene the scene to add the ui to
  40246. * @param helper the xr experience helper to enter/exit xr with
  40247. * @param options options to configure the UI
  40248. * @returns the created ui
  40249. */
  40250. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40251. private constructor();
  40252. private _updateButtons;
  40253. /**
  40254. * Disposes of the object
  40255. */
  40256. dispose(): void;
  40257. }
  40258. }
  40259. declare module BABYLON {
  40260. /**
  40261. * Represents an XR input
  40262. */
  40263. export class WebXRController {
  40264. /**
  40265. * 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
  40266. */
  40267. grip?: AbstractMesh;
  40268. /**
  40269. * Pointer which can be used to select objects or attach a visible laser to
  40270. */
  40271. pointer: AbstractMesh;
  40272. /**
  40273. * Creates the controller
  40274. * @see https://doc.babylonjs.com/how_to/webxr
  40275. * @param scene the scene which the controller should be associated to
  40276. */
  40277. constructor(scene: Scene);
  40278. /**
  40279. * Disposes of the object
  40280. */
  40281. dispose(): void;
  40282. }
  40283. /**
  40284. * XR input used to track XR inputs such as controllers/rays
  40285. */
  40286. export class WebXRInput implements IDisposable {
  40287. private helper;
  40288. /**
  40289. * XR controllers being tracked
  40290. */
  40291. controllers: Array<WebXRController>;
  40292. private _tmpMatrix;
  40293. private _frameObserver;
  40294. /**
  40295. * Initializes the WebXRInput
  40296. * @param helper experience helper which the input should be created for
  40297. */
  40298. constructor(helper: WebXRExperienceHelper);
  40299. /**
  40300. * Disposes of the object
  40301. */
  40302. dispose(): void;
  40303. }
  40304. }
  40305. declare module BABYLON {
  40306. /**
  40307. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40308. */
  40309. export class WebXRManagedOutputCanvas implements IDisposable {
  40310. private _canvas;
  40311. /**
  40312. * xrpresent context of the canvas which can be used to display/mirror xr content
  40313. */
  40314. canvasContext: Nullable<WebGLRenderingContext>;
  40315. /**
  40316. * Initializes the canvas to be added/removed upon entering/exiting xr
  40317. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40318. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40319. */
  40320. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40321. /**
  40322. * Disposes of the object
  40323. */
  40324. dispose(): void;
  40325. private _setManagedOutputCanvas;
  40326. private _addCanvas;
  40327. private _removeCanvas;
  40328. }
  40329. }
  40330. declare module BABYLON {
  40331. /**
  40332. * Contains an array of blocks representing the octree
  40333. */
  40334. export interface IOctreeContainer<T> {
  40335. /**
  40336. * Blocks within the octree
  40337. */
  40338. blocks: Array<OctreeBlock<T>>;
  40339. }
  40340. /**
  40341. * Class used to store a cell in an octree
  40342. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40343. */
  40344. export class OctreeBlock<T> {
  40345. /**
  40346. * Gets the content of the current block
  40347. */
  40348. entries: T[];
  40349. /**
  40350. * Gets the list of block children
  40351. */
  40352. blocks: Array<OctreeBlock<T>>;
  40353. private _depth;
  40354. private _maxDepth;
  40355. private _capacity;
  40356. private _minPoint;
  40357. private _maxPoint;
  40358. private _boundingVectors;
  40359. private _creationFunc;
  40360. /**
  40361. * Creates a new block
  40362. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40363. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40364. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40365. * @param depth defines the current depth of this block in the octree
  40366. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40367. * @param creationFunc defines a callback to call when an element is added to the block
  40368. */
  40369. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40370. /**
  40371. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40372. */
  40373. readonly capacity: number;
  40374. /**
  40375. * Gets the minimum vector (in world space) of the block's bounding box
  40376. */
  40377. readonly minPoint: Vector3;
  40378. /**
  40379. * Gets the maximum vector (in world space) of the block's bounding box
  40380. */
  40381. readonly maxPoint: Vector3;
  40382. /**
  40383. * Add a new element to this block
  40384. * @param entry defines the element to add
  40385. */
  40386. addEntry(entry: T): void;
  40387. /**
  40388. * Remove an element from this block
  40389. * @param entry defines the element to remove
  40390. */
  40391. removeEntry(entry: T): void;
  40392. /**
  40393. * Add an array of elements to this block
  40394. * @param entries defines the array of elements to add
  40395. */
  40396. addEntries(entries: T[]): void;
  40397. /**
  40398. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40399. * @param frustumPlanes defines the frustum planes to test
  40400. * @param selection defines the array to store current content if selection is positive
  40401. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40402. */
  40403. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40404. /**
  40405. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40406. * @param sphereCenter defines the bounding sphere center
  40407. * @param sphereRadius defines the bounding sphere radius
  40408. * @param selection defines the array to store current content if selection is positive
  40409. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40410. */
  40411. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40412. /**
  40413. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40414. * @param ray defines the ray to test with
  40415. * @param selection defines the array to store current content if selection is positive
  40416. */
  40417. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40418. /**
  40419. * Subdivide the content into child blocks (this block will then be empty)
  40420. */
  40421. createInnerBlocks(): void;
  40422. /**
  40423. * @hidden
  40424. */
  40425. 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;
  40426. }
  40427. }
  40428. declare module BABYLON {
  40429. /**
  40430. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40431. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40432. */
  40433. export class Octree<T> {
  40434. /** 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.) */
  40435. maxDepth: number;
  40436. /**
  40437. * Blocks within the octree containing objects
  40438. */
  40439. blocks: Array<OctreeBlock<T>>;
  40440. /**
  40441. * Content stored in the octree
  40442. */
  40443. dynamicContent: T[];
  40444. private _maxBlockCapacity;
  40445. private _selectionContent;
  40446. private _creationFunc;
  40447. /**
  40448. * Creates a octree
  40449. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40450. * @param creationFunc function to be used to instatiate the octree
  40451. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40452. * @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.)
  40453. */
  40454. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40455. /** 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.) */
  40456. maxDepth?: number);
  40457. /**
  40458. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40459. * @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);
  40460. * @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);
  40461. * @param entries meshes to be added to the octree blocks
  40462. */
  40463. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40464. /**
  40465. * Adds a mesh to the octree
  40466. * @param entry Mesh to add to the octree
  40467. */
  40468. addMesh(entry: T): void;
  40469. /**
  40470. * Remove an element from the octree
  40471. * @param entry defines the element to remove
  40472. */
  40473. removeMesh(entry: T): void;
  40474. /**
  40475. * Selects an array of meshes within the frustum
  40476. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40477. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40478. * @returns array of meshes within the frustum
  40479. */
  40480. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40481. /**
  40482. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40483. * @param sphereCenter defines the bounding sphere center
  40484. * @param sphereRadius defines the bounding sphere radius
  40485. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40486. * @returns an array of objects that intersect the sphere
  40487. */
  40488. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40489. /**
  40490. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40491. * @param ray defines the ray to test with
  40492. * @returns array of intersected objects
  40493. */
  40494. intersectsRay(ray: Ray): SmartArray<T>;
  40495. /**
  40496. * Adds a mesh into the octree block if it intersects the block
  40497. */
  40498. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40499. /**
  40500. * Adds a submesh into the octree block if it intersects the block
  40501. */
  40502. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40503. }
  40504. }
  40505. declare module BABYLON {
  40506. interface Scene {
  40507. /**
  40508. * @hidden
  40509. * Backing Filed
  40510. */
  40511. _selectionOctree: Octree<AbstractMesh>;
  40512. /**
  40513. * Gets the octree used to boost mesh selection (picking)
  40514. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40515. */
  40516. selectionOctree: Octree<AbstractMesh>;
  40517. /**
  40518. * Creates or updates the octree used to boost selection (picking)
  40519. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40520. * @param maxCapacity defines the maximum capacity per leaf
  40521. * @param maxDepth defines the maximum depth of the octree
  40522. * @returns an octree of AbstractMesh
  40523. */
  40524. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40525. }
  40526. interface AbstractMesh {
  40527. /**
  40528. * @hidden
  40529. * Backing Field
  40530. */
  40531. _submeshesOctree: Octree<SubMesh>;
  40532. /**
  40533. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40534. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40535. * @param maxCapacity defines the maximum size of each block (64 by default)
  40536. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40537. * @returns the new octree
  40538. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40539. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40540. */
  40541. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40542. }
  40543. /**
  40544. * Defines the octree scene component responsible to manage any octrees
  40545. * in a given scene.
  40546. */
  40547. export class OctreeSceneComponent {
  40548. /**
  40549. * The component name help to identify the component in the list of scene components.
  40550. */
  40551. readonly name: string;
  40552. /**
  40553. * The scene the component belongs to.
  40554. */
  40555. scene: Scene;
  40556. /**
  40557. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40558. */
  40559. readonly checksIsEnabled: boolean;
  40560. /**
  40561. * Creates a new instance of the component for the given scene
  40562. * @param scene Defines the scene to register the component in
  40563. */
  40564. constructor(scene: Scene);
  40565. /**
  40566. * Registers the component in a given scene
  40567. */
  40568. register(): void;
  40569. /**
  40570. * Return the list of active meshes
  40571. * @returns the list of active meshes
  40572. */
  40573. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40574. /**
  40575. * Return the list of active sub meshes
  40576. * @param mesh The mesh to get the candidates sub meshes from
  40577. * @returns the list of active sub meshes
  40578. */
  40579. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40580. private _tempRay;
  40581. /**
  40582. * Return the list of sub meshes intersecting with a given local ray
  40583. * @param mesh defines the mesh to find the submesh for
  40584. * @param localRay defines the ray in local space
  40585. * @returns the list of intersecting sub meshes
  40586. */
  40587. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40588. /**
  40589. * Return the list of sub meshes colliding with a collider
  40590. * @param mesh defines the mesh to find the submesh for
  40591. * @param collider defines the collider to evaluate the collision against
  40592. * @returns the list of colliding sub meshes
  40593. */
  40594. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40595. /**
  40596. * Rebuilds the elements related to this component in case of
  40597. * context lost for instance.
  40598. */
  40599. rebuild(): void;
  40600. /**
  40601. * Disposes the component and the associated ressources.
  40602. */
  40603. dispose(): void;
  40604. }
  40605. }
  40606. declare module BABYLON {
  40607. /**
  40608. * Renders a layer on top of an existing scene
  40609. */
  40610. export class UtilityLayerRenderer implements IDisposable {
  40611. /** the original scene that will be rendered on top of */
  40612. originalScene: Scene;
  40613. private _pointerCaptures;
  40614. private _lastPointerEvents;
  40615. private static _DefaultUtilityLayer;
  40616. private static _DefaultKeepDepthUtilityLayer;
  40617. private _sharedGizmoLight;
  40618. /**
  40619. * @hidden
  40620. * Light which used by gizmos to get light shading
  40621. */
  40622. _getSharedGizmoLight(): HemisphericLight;
  40623. /**
  40624. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40625. */
  40626. pickUtilitySceneFirst: boolean;
  40627. /**
  40628. * 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)
  40629. */
  40630. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40631. /**
  40632. * 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)
  40633. */
  40634. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40635. /**
  40636. * The scene that is rendered on top of the original scene
  40637. */
  40638. utilityLayerScene: Scene;
  40639. /**
  40640. * If the utility layer should automatically be rendered on top of existing scene
  40641. */
  40642. shouldRender: boolean;
  40643. /**
  40644. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40645. */
  40646. onlyCheckPointerDownEvents: boolean;
  40647. /**
  40648. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40649. */
  40650. processAllEvents: boolean;
  40651. /**
  40652. * Observable raised when the pointer move from the utility layer scene to the main scene
  40653. */
  40654. onPointerOutObservable: Observable<number>;
  40655. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40656. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40657. private _afterRenderObserver;
  40658. private _sceneDisposeObserver;
  40659. private _originalPointerObserver;
  40660. /**
  40661. * Instantiates a UtilityLayerRenderer
  40662. * @param originalScene the original scene that will be rendered on top of
  40663. * @param handleEvents boolean indicating if the utility layer should handle events
  40664. */
  40665. constructor(
  40666. /** the original scene that will be rendered on top of */
  40667. originalScene: Scene, handleEvents?: boolean);
  40668. private _notifyObservers;
  40669. /**
  40670. * Renders the utility layers scene on top of the original scene
  40671. */
  40672. render(): void;
  40673. /**
  40674. * Disposes of the renderer
  40675. */
  40676. dispose(): void;
  40677. private _updateCamera;
  40678. }
  40679. }
  40680. declare module BABYLON {
  40681. /**
  40682. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40683. */
  40684. export class Gizmo implements IDisposable {
  40685. /** The utility layer the gizmo will be added to */
  40686. gizmoLayer: UtilityLayerRenderer;
  40687. /**
  40688. * The root mesh of the gizmo
  40689. */
  40690. _rootMesh: Mesh;
  40691. private _attachedMesh;
  40692. /**
  40693. * Ratio for the scale of the gizmo (Default: 1)
  40694. */
  40695. scaleRatio: number;
  40696. /**
  40697. * If a custom mesh has been set (Default: false)
  40698. */
  40699. protected _customMeshSet: boolean;
  40700. /**
  40701. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40702. * * When set, interactions will be enabled
  40703. */
  40704. attachedMesh: Nullable<AbstractMesh>;
  40705. /**
  40706. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40707. * @param mesh The mesh to replace the default mesh of the gizmo
  40708. */
  40709. setCustomMesh(mesh: Mesh): void;
  40710. /**
  40711. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40712. */
  40713. updateGizmoRotationToMatchAttachedMesh: boolean;
  40714. /**
  40715. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40716. */
  40717. updateGizmoPositionToMatchAttachedMesh: boolean;
  40718. /**
  40719. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40720. */
  40721. protected _updateScale: boolean;
  40722. protected _interactionsEnabled: boolean;
  40723. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40724. private _beforeRenderObserver;
  40725. private _tempVector;
  40726. /**
  40727. * Creates a gizmo
  40728. * @param gizmoLayer The utility layer the gizmo will be added to
  40729. */
  40730. constructor(
  40731. /** The utility layer the gizmo will be added to */
  40732. gizmoLayer?: UtilityLayerRenderer);
  40733. /**
  40734. * Updates the gizmo to match the attached mesh's position/rotation
  40735. */
  40736. protected _update(): void;
  40737. /**
  40738. * Disposes of the gizmo
  40739. */
  40740. dispose(): void;
  40741. }
  40742. }
  40743. declare module BABYLON {
  40744. /**
  40745. * Single axis drag gizmo
  40746. */
  40747. export class AxisDragGizmo extends Gizmo {
  40748. /**
  40749. * Drag behavior responsible for the gizmos dragging interactions
  40750. */
  40751. dragBehavior: PointerDragBehavior;
  40752. private _pointerObserver;
  40753. /**
  40754. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40755. */
  40756. snapDistance: number;
  40757. /**
  40758. * Event that fires each time the gizmo snaps to a new location.
  40759. * * snapDistance is the the change in distance
  40760. */
  40761. onSnapObservable: Observable<{
  40762. snapDistance: number;
  40763. }>;
  40764. /** @hidden */
  40765. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40766. /** @hidden */
  40767. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40768. /**
  40769. * Creates an AxisDragGizmo
  40770. * @param gizmoLayer The utility layer the gizmo will be added to
  40771. * @param dragAxis The axis which the gizmo will be able to drag on
  40772. * @param color The color of the gizmo
  40773. */
  40774. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40775. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40776. /**
  40777. * Disposes of the gizmo
  40778. */
  40779. dispose(): void;
  40780. }
  40781. }
  40782. declare module BABYLON.Debug {
  40783. /**
  40784. * The Axes viewer will show 3 axes in a specific point in space
  40785. */
  40786. export class AxesViewer {
  40787. private _xAxis;
  40788. private _yAxis;
  40789. private _zAxis;
  40790. private _scaleLinesFactor;
  40791. private _instanced;
  40792. /**
  40793. * Gets the hosting scene
  40794. */
  40795. scene: Scene;
  40796. /**
  40797. * Gets or sets a number used to scale line length
  40798. */
  40799. scaleLines: number;
  40800. /** Gets the node hierarchy used to render x-axis */
  40801. readonly xAxis: TransformNode;
  40802. /** Gets the node hierarchy used to render y-axis */
  40803. readonly yAxis: TransformNode;
  40804. /** Gets the node hierarchy used to render z-axis */
  40805. readonly zAxis: TransformNode;
  40806. /**
  40807. * Creates a new AxesViewer
  40808. * @param scene defines the hosting scene
  40809. * @param scaleLines defines a number used to scale line length (1 by default)
  40810. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40811. * @param xAxis defines the node hierarchy used to render the x-axis
  40812. * @param yAxis defines the node hierarchy used to render the y-axis
  40813. * @param zAxis defines the node hierarchy used to render the z-axis
  40814. */
  40815. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40816. /**
  40817. * Force the viewer to update
  40818. * @param position defines the position of the viewer
  40819. * @param xaxis defines the x axis of the viewer
  40820. * @param yaxis defines the y axis of the viewer
  40821. * @param zaxis defines the z axis of the viewer
  40822. */
  40823. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40824. /**
  40825. * Creates an instance of this axes viewer.
  40826. * @returns a new axes viewer with instanced meshes
  40827. */
  40828. createInstance(): AxesViewer;
  40829. /** Releases resources */
  40830. dispose(): void;
  40831. private static _SetRenderingGroupId;
  40832. }
  40833. }
  40834. declare module BABYLON.Debug {
  40835. /**
  40836. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40837. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40838. */
  40839. export class BoneAxesViewer extends AxesViewer {
  40840. /**
  40841. * Gets or sets the target mesh where to display the axes viewer
  40842. */
  40843. mesh: Nullable<Mesh>;
  40844. /**
  40845. * Gets or sets the target bone where to display the axes viewer
  40846. */
  40847. bone: Nullable<Bone>;
  40848. /** Gets current position */
  40849. pos: Vector3;
  40850. /** Gets direction of X axis */
  40851. xaxis: Vector3;
  40852. /** Gets direction of Y axis */
  40853. yaxis: Vector3;
  40854. /** Gets direction of Z axis */
  40855. zaxis: Vector3;
  40856. /**
  40857. * Creates a new BoneAxesViewer
  40858. * @param scene defines the hosting scene
  40859. * @param bone defines the target bone
  40860. * @param mesh defines the target mesh
  40861. * @param scaleLines defines a scaling factor for line length (1 by default)
  40862. */
  40863. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40864. /**
  40865. * Force the viewer to update
  40866. */
  40867. update(): void;
  40868. /** Releases resources */
  40869. dispose(): void;
  40870. }
  40871. }
  40872. declare module BABYLON {
  40873. /**
  40874. * Interface used to define scene explorer extensibility option
  40875. */
  40876. export interface IExplorerExtensibilityOption {
  40877. /**
  40878. * Define the option label
  40879. */
  40880. label: string;
  40881. /**
  40882. * Defines the action to execute on click
  40883. */
  40884. action: (entity: any) => void;
  40885. }
  40886. /**
  40887. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40888. */
  40889. export interface IExplorerExtensibilityGroup {
  40890. /**
  40891. * Defines a predicate to test if a given type mut be extended
  40892. */
  40893. predicate: (entity: any) => boolean;
  40894. /**
  40895. * Gets the list of options added to a type
  40896. */
  40897. entries: IExplorerExtensibilityOption[];
  40898. }
  40899. /**
  40900. * Interface used to define the options to use to create the Inspector
  40901. */
  40902. export interface IInspectorOptions {
  40903. /**
  40904. * Display in overlay mode (default: false)
  40905. */
  40906. overlay?: boolean;
  40907. /**
  40908. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40909. */
  40910. globalRoot?: HTMLElement;
  40911. /**
  40912. * Display the Scene explorer
  40913. */
  40914. showExplorer?: boolean;
  40915. /**
  40916. * Display the property inspector
  40917. */
  40918. showInspector?: boolean;
  40919. /**
  40920. * Display in embed mode (both panes on the right)
  40921. */
  40922. embedMode?: boolean;
  40923. /**
  40924. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40925. */
  40926. handleResize?: boolean;
  40927. /**
  40928. * Allow the panes to popup (default: true)
  40929. */
  40930. enablePopup?: boolean;
  40931. /**
  40932. * Allow the panes to be closed by users (default: true)
  40933. */
  40934. enableClose?: boolean;
  40935. /**
  40936. * Optional list of extensibility entries
  40937. */
  40938. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40939. /**
  40940. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40941. */
  40942. inspectorURL?: string;
  40943. }
  40944. interface Scene {
  40945. /**
  40946. * @hidden
  40947. * Backing field
  40948. */
  40949. _debugLayer: DebugLayer;
  40950. /**
  40951. * Gets the debug layer (aka Inspector) associated with the scene
  40952. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40953. */
  40954. debugLayer: DebugLayer;
  40955. }
  40956. /**
  40957. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40958. * what is happening in your scene
  40959. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40960. */
  40961. export class DebugLayer {
  40962. /**
  40963. * Define the url to get the inspector script from.
  40964. * By default it uses the babylonjs CDN.
  40965. * @ignoreNaming
  40966. */
  40967. static InspectorURL: string;
  40968. private _scene;
  40969. private BJSINSPECTOR;
  40970. /**
  40971. * Observable triggered when a property is changed through the inspector.
  40972. */
  40973. onPropertyChangedObservable: Observable<{
  40974. object: any;
  40975. property: string;
  40976. value: any;
  40977. initialValue: any;
  40978. }>;
  40979. /**
  40980. * Instantiates a new debug layer.
  40981. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40982. * what is happening in your scene
  40983. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40984. * @param scene Defines the scene to inspect
  40985. */
  40986. constructor(scene: Scene);
  40987. /** Creates the inspector window. */
  40988. private _createInspector;
  40989. /**
  40990. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40991. * @param entity defines the entity to select
  40992. * @param lineContainerTitle defines the specific block to highlight
  40993. */
  40994. select(entity: any, lineContainerTitle?: string): void;
  40995. /** Get the inspector from bundle or global */
  40996. private _getGlobalInspector;
  40997. /**
  40998. * Get if the inspector is visible or not.
  40999. * @returns true if visible otherwise, false
  41000. */
  41001. isVisible(): boolean;
  41002. /**
  41003. * Hide the inspector and close its window.
  41004. */
  41005. hide(): void;
  41006. /**
  41007. * Launch the debugLayer.
  41008. * @param config Define the configuration of the inspector
  41009. * @return a promise fulfilled when the debug layer is visible
  41010. */
  41011. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41012. }
  41013. }
  41014. declare module BABYLON {
  41015. /**
  41016. * Class containing static functions to help procedurally build meshes
  41017. */
  41018. export class BoxBuilder {
  41019. /**
  41020. * Creates a box mesh
  41021. * * The parameter `size` sets the size (float) of each box side (default 1)
  41022. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41023. * * 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)
  41024. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41026. * * 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
  41027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41028. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41029. * @param name defines the name of the mesh
  41030. * @param options defines the options used to create the mesh
  41031. * @param scene defines the hosting scene
  41032. * @returns the box mesh
  41033. */
  41034. static CreateBox(name: string, options: {
  41035. size?: number;
  41036. width?: number;
  41037. height?: number;
  41038. depth?: number;
  41039. faceUV?: Vector4[];
  41040. faceColors?: Color4[];
  41041. sideOrientation?: number;
  41042. frontUVs?: Vector4;
  41043. backUVs?: Vector4;
  41044. wrap?: boolean;
  41045. topBaseAt?: number;
  41046. bottomBaseAt?: number;
  41047. updatable?: boolean;
  41048. }, scene?: Nullable<Scene>): Mesh;
  41049. }
  41050. }
  41051. declare module BABYLON {
  41052. /**
  41053. * Class containing static functions to help procedurally build meshes
  41054. */
  41055. export class SphereBuilder {
  41056. /**
  41057. * Creates a sphere mesh
  41058. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41059. * * 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`)
  41060. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41061. * * 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
  41062. * * 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)
  41063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41064. * * 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
  41065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41066. * @param name defines the name of the mesh
  41067. * @param options defines the options used to create the mesh
  41068. * @param scene defines the hosting scene
  41069. * @returns the sphere mesh
  41070. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41071. */
  41072. static CreateSphere(name: string, options: {
  41073. segments?: number;
  41074. diameter?: number;
  41075. diameterX?: number;
  41076. diameterY?: number;
  41077. diameterZ?: number;
  41078. arc?: number;
  41079. slice?: number;
  41080. sideOrientation?: number;
  41081. frontUVs?: Vector4;
  41082. backUVs?: Vector4;
  41083. updatable?: boolean;
  41084. }, scene: any): Mesh;
  41085. }
  41086. }
  41087. declare module BABYLON.Debug {
  41088. /**
  41089. * Used to show the physics impostor around the specific mesh
  41090. */
  41091. export class PhysicsViewer {
  41092. /** @hidden */
  41093. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41094. /** @hidden */
  41095. protected _meshes: Array<Nullable<AbstractMesh>>;
  41096. /** @hidden */
  41097. protected _scene: Nullable<Scene>;
  41098. /** @hidden */
  41099. protected _numMeshes: number;
  41100. /** @hidden */
  41101. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41102. private _renderFunction;
  41103. private _utilityLayer;
  41104. private _debugBoxMesh;
  41105. private _debugSphereMesh;
  41106. private _debugCylinderMesh;
  41107. private _debugMaterial;
  41108. private _debugMeshMeshes;
  41109. /**
  41110. * Creates a new PhysicsViewer
  41111. * @param scene defines the hosting scene
  41112. */
  41113. constructor(scene: Scene);
  41114. /** @hidden */
  41115. protected _updateDebugMeshes(): void;
  41116. /**
  41117. * Renders a specified physic impostor
  41118. * @param impostor defines the impostor to render
  41119. * @param targetMesh defines the mesh represented by the impostor
  41120. * @returns the new debug mesh used to render the impostor
  41121. */
  41122. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  41123. /**
  41124. * Hides a specified physic impostor
  41125. * @param impostor defines the impostor to hide
  41126. */
  41127. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41128. private _getDebugMaterial;
  41129. private _getDebugBoxMesh;
  41130. private _getDebugSphereMesh;
  41131. private _getDebugCylinderMesh;
  41132. private _getDebugMeshMesh;
  41133. private _getDebugMesh;
  41134. /** Releases all resources */
  41135. dispose(): void;
  41136. }
  41137. }
  41138. declare module BABYLON {
  41139. /**
  41140. * Class containing static functions to help procedurally build meshes
  41141. */
  41142. export class LinesBuilder {
  41143. /**
  41144. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41145. * * 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
  41146. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41147. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41148. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41149. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41150. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41151. * * 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
  41152. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41154. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41155. * @param name defines the name of the new line system
  41156. * @param options defines the options used to create the line system
  41157. * @param scene defines the hosting scene
  41158. * @returns a new line system mesh
  41159. */
  41160. static CreateLineSystem(name: string, options: {
  41161. lines: Vector3[][];
  41162. updatable?: boolean;
  41163. instance?: Nullable<LinesMesh>;
  41164. colors?: Nullable<Color4[][]>;
  41165. useVertexAlpha?: boolean;
  41166. }, scene: Nullable<Scene>): LinesMesh;
  41167. /**
  41168. * Creates a line mesh
  41169. * 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
  41170. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41171. * * The parameter `points` is an array successive Vector3
  41172. * * 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
  41173. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41174. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41175. * * When updating an instance, remember that only point positions can change, not the number of points
  41176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41177. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41178. * @param name defines the name of the new line system
  41179. * @param options defines the options used to create the line system
  41180. * @param scene defines the hosting scene
  41181. * @returns a new line mesh
  41182. */
  41183. static CreateLines(name: string, options: {
  41184. points: Vector3[];
  41185. updatable?: boolean;
  41186. instance?: Nullable<LinesMesh>;
  41187. colors?: Color4[];
  41188. useVertexAlpha?: boolean;
  41189. }, scene?: Nullable<Scene>): LinesMesh;
  41190. /**
  41191. * Creates a dashed line mesh
  41192. * * 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
  41193. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41194. * * The parameter `points` is an array successive Vector3
  41195. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41196. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41197. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41198. * * 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
  41199. * * When updating an instance, remember that only point positions can change, not the number of points
  41200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41201. * @param name defines the name of the mesh
  41202. * @param options defines the options used to create the mesh
  41203. * @param scene defines the hosting scene
  41204. * @returns the dashed line mesh
  41205. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41206. */
  41207. static CreateDashedLines(name: string, options: {
  41208. points: Vector3[];
  41209. dashSize?: number;
  41210. gapSize?: number;
  41211. dashNb?: number;
  41212. updatable?: boolean;
  41213. instance?: LinesMesh;
  41214. }, scene?: Nullable<Scene>): LinesMesh;
  41215. }
  41216. }
  41217. declare module BABYLON {
  41218. /**
  41219. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41220. * in order to better appreciate the issue one might have.
  41221. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41222. */
  41223. export class RayHelper {
  41224. /**
  41225. * Defines the ray we are currently tryin to visualize.
  41226. */
  41227. ray: Nullable<Ray>;
  41228. private _renderPoints;
  41229. private _renderLine;
  41230. private _renderFunction;
  41231. private _scene;
  41232. private _updateToMeshFunction;
  41233. private _attachedToMesh;
  41234. private _meshSpaceDirection;
  41235. private _meshSpaceOrigin;
  41236. /**
  41237. * Helper function to create a colored helper in a scene in one line.
  41238. * @param ray Defines the ray we are currently tryin to visualize
  41239. * @param scene Defines the scene the ray is used in
  41240. * @param color Defines the color we want to see the ray in
  41241. * @returns The newly created ray helper.
  41242. */
  41243. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41244. /**
  41245. * Instantiate a new ray helper.
  41246. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41247. * in order to better appreciate the issue one might have.
  41248. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41249. * @param ray Defines the ray we are currently tryin to visualize
  41250. */
  41251. constructor(ray: Ray);
  41252. /**
  41253. * Shows the ray we are willing to debug.
  41254. * @param scene Defines the scene the ray needs to be rendered in
  41255. * @param color Defines the color the ray needs to be rendered in
  41256. */
  41257. show(scene: Scene, color?: Color3): void;
  41258. /**
  41259. * Hides the ray we are debugging.
  41260. */
  41261. hide(): void;
  41262. private _render;
  41263. /**
  41264. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41265. * @param mesh Defines the mesh we want the helper attached to
  41266. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41267. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41268. * @param length Defines the length of the ray
  41269. */
  41270. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41271. /**
  41272. * Detach the ray helper from the mesh it has previously been attached to.
  41273. */
  41274. detachFromMesh(): void;
  41275. private _updateToMesh;
  41276. /**
  41277. * Dispose the helper and release its associated resources.
  41278. */
  41279. dispose(): void;
  41280. }
  41281. }
  41282. declare module BABYLON.Debug {
  41283. /**
  41284. * Class used to render a debug view of a given skeleton
  41285. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41286. */
  41287. export class SkeletonViewer {
  41288. /** defines the skeleton to render */
  41289. skeleton: Skeleton;
  41290. /** defines the mesh attached to the skeleton */
  41291. mesh: AbstractMesh;
  41292. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41293. autoUpdateBonesMatrices: boolean;
  41294. /** defines the rendering group id to use with the viewer */
  41295. renderingGroupId: number;
  41296. /** Gets or sets the color used to render the skeleton */
  41297. color: Color3;
  41298. private _scene;
  41299. private _debugLines;
  41300. private _debugMesh;
  41301. private _isEnabled;
  41302. private _renderFunction;
  41303. private _utilityLayer;
  41304. /**
  41305. * Returns the mesh used to render the bones
  41306. */
  41307. readonly debugMesh: Nullable<LinesMesh>;
  41308. /**
  41309. * Creates a new SkeletonViewer
  41310. * @param skeleton defines the skeleton to render
  41311. * @param mesh defines the mesh attached to the skeleton
  41312. * @param scene defines the hosting scene
  41313. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41314. * @param renderingGroupId defines the rendering group id to use with the viewer
  41315. */
  41316. constructor(
  41317. /** defines the skeleton to render */
  41318. skeleton: Skeleton,
  41319. /** defines the mesh attached to the skeleton */
  41320. mesh: AbstractMesh, scene: Scene,
  41321. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41322. autoUpdateBonesMatrices?: boolean,
  41323. /** defines the rendering group id to use with the viewer */
  41324. renderingGroupId?: number);
  41325. /** Gets or sets a boolean indicating if the viewer is enabled */
  41326. isEnabled: boolean;
  41327. private _getBonePosition;
  41328. private _getLinesForBonesWithLength;
  41329. private _getLinesForBonesNoLength;
  41330. /** Update the viewer to sync with current skeleton state */
  41331. update(): void;
  41332. /** Release associated resources */
  41333. dispose(): void;
  41334. }
  41335. }
  41336. declare module BABYLON {
  41337. /**
  41338. * Options to create the null engine
  41339. */
  41340. export class NullEngineOptions {
  41341. /**
  41342. * Render width (Default: 512)
  41343. */
  41344. renderWidth: number;
  41345. /**
  41346. * Render height (Default: 256)
  41347. */
  41348. renderHeight: number;
  41349. /**
  41350. * Texture size (Default: 512)
  41351. */
  41352. textureSize: number;
  41353. /**
  41354. * If delta time between frames should be constant
  41355. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41356. */
  41357. deterministicLockstep: boolean;
  41358. /**
  41359. * Maximum about of steps between frames (Default: 4)
  41360. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41361. */
  41362. lockstepMaxSteps: number;
  41363. }
  41364. /**
  41365. * The null engine class provides support for headless version of babylon.js.
  41366. * This can be used in server side scenario or for testing purposes
  41367. */
  41368. export class NullEngine extends Engine {
  41369. private _options;
  41370. /**
  41371. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41372. */
  41373. isDeterministicLockStep(): boolean;
  41374. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41375. getLockstepMaxSteps(): number;
  41376. /**
  41377. * Sets hardware scaling, used to save performance if needed
  41378. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41379. */
  41380. getHardwareScalingLevel(): number;
  41381. constructor(options?: NullEngineOptions);
  41382. createVertexBuffer(vertices: FloatArray): DataBuffer;
  41383. createIndexBuffer(indices: IndicesArray): DataBuffer;
  41384. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41385. getRenderWidth(useScreen?: boolean): number;
  41386. getRenderHeight(useScreen?: boolean): number;
  41387. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41388. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41389. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41390. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41391. bindSamplers(effect: Effect): void;
  41392. enableEffect(effect: Effect): void;
  41393. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41394. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41395. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41396. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41397. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41398. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41399. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41400. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41401. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41402. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41403. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41404. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41405. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41406. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41407. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41408. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41409. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41410. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41411. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41412. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41413. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41414. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41415. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41416. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41417. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41418. bindBuffers(vertexBuffers: {
  41419. [key: string]: VertexBuffer;
  41420. }, indexBuffer: DataBuffer, effect: Effect): void;
  41421. wipeCaches(bruteForce?: boolean): void;
  41422. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41423. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41424. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41425. /** @hidden */
  41426. _createTexture(): WebGLTexture;
  41427. /** @hidden */
  41428. _releaseTexture(texture: InternalTexture): void;
  41429. 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;
  41430. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41431. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41432. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41433. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41434. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  41435. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41436. areAllEffectsReady(): boolean;
  41437. /**
  41438. * @hidden
  41439. * Get the current error code of the webGL context
  41440. * @returns the error code
  41441. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41442. */
  41443. getError(): number;
  41444. /** @hidden */
  41445. _getUnpackAlignement(): number;
  41446. /** @hidden */
  41447. _unpackFlipY(value: boolean): void;
  41448. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41449. /**
  41450. * Updates a dynamic vertex buffer.
  41451. * @param vertexBuffer the vertex buffer to update
  41452. * @param data the data used to update the vertex buffer
  41453. * @param byteOffset the byte offset of the data (optional)
  41454. * @param byteLength the byte length of the data (optional)
  41455. */
  41456. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41457. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41458. /** @hidden */
  41459. _bindTexture(channel: number, texture: InternalTexture): void;
  41460. /** @hidden */
  41461. _releaseBuffer(buffer: DataBuffer): boolean;
  41462. releaseEffects(): void;
  41463. displayLoadingUI(): void;
  41464. hideLoadingUI(): void;
  41465. /** @hidden */
  41466. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41467. /** @hidden */
  41468. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41469. /** @hidden */
  41470. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41471. /** @hidden */
  41472. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41473. }
  41474. }
  41475. declare module BABYLON {
  41476. /** @hidden */
  41477. export class _OcclusionDataStorage {
  41478. /** @hidden */
  41479. occlusionInternalRetryCounter: number;
  41480. /** @hidden */
  41481. isOcclusionQueryInProgress: boolean;
  41482. /** @hidden */
  41483. isOccluded: boolean;
  41484. /** @hidden */
  41485. occlusionRetryCount: number;
  41486. /** @hidden */
  41487. occlusionType: number;
  41488. /** @hidden */
  41489. occlusionQueryAlgorithmType: number;
  41490. }
  41491. interface Engine {
  41492. /**
  41493. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41494. * @return the new query
  41495. */
  41496. createQuery(): WebGLQuery;
  41497. /**
  41498. * Delete and release a webGL query
  41499. * @param query defines the query to delete
  41500. * @return the current engine
  41501. */
  41502. deleteQuery(query: WebGLQuery): Engine;
  41503. /**
  41504. * Check if a given query has resolved and got its value
  41505. * @param query defines the query to check
  41506. * @returns true if the query got its value
  41507. */
  41508. isQueryResultAvailable(query: WebGLQuery): boolean;
  41509. /**
  41510. * Gets the value of a given query
  41511. * @param query defines the query to check
  41512. * @returns the value of the query
  41513. */
  41514. getQueryResult(query: WebGLQuery): number;
  41515. /**
  41516. * Initiates an occlusion query
  41517. * @param algorithmType defines the algorithm to use
  41518. * @param query defines the query to use
  41519. * @returns the current engine
  41520. * @see http://doc.babylonjs.com/features/occlusionquery
  41521. */
  41522. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41523. /**
  41524. * Ends an occlusion query
  41525. * @see http://doc.babylonjs.com/features/occlusionquery
  41526. * @param algorithmType defines the algorithm to use
  41527. * @returns the current engine
  41528. */
  41529. endOcclusionQuery(algorithmType: number): Engine;
  41530. /**
  41531. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41532. * Please note that only one query can be issued at a time
  41533. * @returns a time token used to track the time span
  41534. */
  41535. startTimeQuery(): Nullable<_TimeToken>;
  41536. /**
  41537. * Ends a time query
  41538. * @param token defines the token used to measure the time span
  41539. * @returns the time spent (in ns)
  41540. */
  41541. endTimeQuery(token: _TimeToken): int;
  41542. /** @hidden */
  41543. _currentNonTimestampToken: Nullable<_TimeToken>;
  41544. /** @hidden */
  41545. _createTimeQuery(): WebGLQuery;
  41546. /** @hidden */
  41547. _deleteTimeQuery(query: WebGLQuery): void;
  41548. /** @hidden */
  41549. _getGlAlgorithmType(algorithmType: number): number;
  41550. /** @hidden */
  41551. _getTimeQueryResult(query: WebGLQuery): any;
  41552. /** @hidden */
  41553. _getTimeQueryAvailability(query: WebGLQuery): any;
  41554. }
  41555. interface AbstractMesh {
  41556. /**
  41557. * Backing filed
  41558. * @hidden
  41559. */
  41560. __occlusionDataStorage: _OcclusionDataStorage;
  41561. /**
  41562. * Access property
  41563. * @hidden
  41564. */
  41565. _occlusionDataStorage: _OcclusionDataStorage;
  41566. /**
  41567. * 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.
  41568. * The default value is -1 which means don't break the query and wait till the result
  41569. * @see http://doc.babylonjs.com/features/occlusionquery
  41570. */
  41571. occlusionRetryCount: number;
  41572. /**
  41573. * 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:
  41574. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41575. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41576. * * 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.
  41577. * @see http://doc.babylonjs.com/features/occlusionquery
  41578. */
  41579. occlusionType: number;
  41580. /**
  41581. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41582. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41583. * * 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.
  41584. * @see http://doc.babylonjs.com/features/occlusionquery
  41585. */
  41586. occlusionQueryAlgorithmType: number;
  41587. /**
  41588. * 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
  41589. * @see http://doc.babylonjs.com/features/occlusionquery
  41590. */
  41591. isOccluded: boolean;
  41592. /**
  41593. * Flag to check the progress status of the query
  41594. * @see http://doc.babylonjs.com/features/occlusionquery
  41595. */
  41596. isOcclusionQueryInProgress: boolean;
  41597. }
  41598. }
  41599. declare module BABYLON {
  41600. /** @hidden */
  41601. export var _forceTransformFeedbackToBundle: boolean;
  41602. interface Engine {
  41603. /**
  41604. * Creates a webGL transform feedback object
  41605. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41606. * @returns the webGL transform feedback object
  41607. */
  41608. createTransformFeedback(): WebGLTransformFeedback;
  41609. /**
  41610. * Delete a webGL transform feedback object
  41611. * @param value defines the webGL transform feedback object to delete
  41612. */
  41613. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41614. /**
  41615. * Bind a webGL transform feedback object to the webgl context
  41616. * @param value defines the webGL transform feedback object to bind
  41617. */
  41618. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41619. /**
  41620. * Begins a transform feedback operation
  41621. * @param usePoints defines if points or triangles must be used
  41622. */
  41623. beginTransformFeedback(usePoints: boolean): void;
  41624. /**
  41625. * Ends a transform feedback operation
  41626. */
  41627. endTransformFeedback(): void;
  41628. /**
  41629. * Specify the varyings to use with transform feedback
  41630. * @param program defines the associated webGL program
  41631. * @param value defines the list of strings representing the varying names
  41632. */
  41633. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41634. /**
  41635. * Bind a webGL buffer for a transform feedback operation
  41636. * @param value defines the webGL buffer to bind
  41637. */
  41638. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  41639. }
  41640. }
  41641. declare module BABYLON {
  41642. /**
  41643. * Creation options of the multi render target texture.
  41644. */
  41645. export interface IMultiRenderTargetOptions {
  41646. /**
  41647. * Define if the texture needs to create mip maps after render.
  41648. */
  41649. generateMipMaps?: boolean;
  41650. /**
  41651. * Define the types of all the draw buffers we want to create
  41652. */
  41653. types?: number[];
  41654. /**
  41655. * Define the sampling modes of all the draw buffers we want to create
  41656. */
  41657. samplingModes?: number[];
  41658. /**
  41659. * Define if a depth buffer is required
  41660. */
  41661. generateDepthBuffer?: boolean;
  41662. /**
  41663. * Define if a stencil buffer is required
  41664. */
  41665. generateStencilBuffer?: boolean;
  41666. /**
  41667. * Define if a depth texture is required instead of a depth buffer
  41668. */
  41669. generateDepthTexture?: boolean;
  41670. /**
  41671. * Define the number of desired draw buffers
  41672. */
  41673. textureCount?: number;
  41674. /**
  41675. * Define if aspect ratio should be adapted to the texture or stay the scene one
  41676. */
  41677. doNotChangeAspectRatio?: boolean;
  41678. /**
  41679. * Define the default type of the buffers we are creating
  41680. */
  41681. defaultType?: number;
  41682. }
  41683. /**
  41684. * A multi render target, like a render target provides the ability to render to a texture.
  41685. * Unlike the render target, it can render to several draw buffers in one draw.
  41686. * This is specially interesting in deferred rendering or for any effects requiring more than
  41687. * just one color from a single pass.
  41688. */
  41689. export class MultiRenderTarget extends RenderTargetTexture {
  41690. private _internalTextures;
  41691. private _textures;
  41692. private _multiRenderTargetOptions;
  41693. /**
  41694. * Get if draw buffers are currently supported by the used hardware and browser.
  41695. */
  41696. readonly isSupported: boolean;
  41697. /**
  41698. * Get the list of textures generated by the multi render target.
  41699. */
  41700. readonly textures: Texture[];
  41701. /**
  41702. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  41703. */
  41704. readonly depthTexture: Texture;
  41705. /**
  41706. * Set the wrapping mode on U of all the textures we are rendering to.
  41707. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41708. */
  41709. wrapU: number;
  41710. /**
  41711. * Set the wrapping mode on V of all the textures we are rendering to.
  41712. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41713. */
  41714. wrapV: number;
  41715. /**
  41716. * Instantiate a new multi render target texture.
  41717. * A multi render target, like a render target provides the ability to render to a texture.
  41718. * Unlike the render target, it can render to several draw buffers in one draw.
  41719. * This is specially interesting in deferred rendering or for any effects requiring more than
  41720. * just one color from a single pass.
  41721. * @param name Define the name of the texture
  41722. * @param size Define the size of the buffers to render to
  41723. * @param count Define the number of target we are rendering into
  41724. * @param scene Define the scene the texture belongs to
  41725. * @param options Define the options used to create the multi render target
  41726. */
  41727. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  41728. /** @hidden */
  41729. _rebuild(): void;
  41730. private _createInternalTextures;
  41731. private _createTextures;
  41732. /**
  41733. * Define the number of samples used if MSAA is enabled.
  41734. */
  41735. samples: number;
  41736. /**
  41737. * Resize all the textures in the multi render target.
  41738. * Be carrefull as it will recreate all the data in the new texture.
  41739. * @param size Define the new size
  41740. */
  41741. resize(size: any): void;
  41742. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  41743. /**
  41744. * Dispose the render targets and their associated resources
  41745. */
  41746. dispose(): void;
  41747. /**
  41748. * Release all the underlying texture used as draw buffers.
  41749. */
  41750. releaseInternalTextures(): void;
  41751. }
  41752. }
  41753. declare module BABYLON {
  41754. interface Engine {
  41755. /**
  41756. * Unbind a list of render target textures from the webGL context
  41757. * This is used only when drawBuffer extension or webGL2 are active
  41758. * @param textures defines the render target textures to unbind
  41759. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41760. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41761. */
  41762. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  41763. /**
  41764. * Create a multi render target texture
  41765. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  41766. * @param size defines the size of the texture
  41767. * @param options defines the creation options
  41768. * @returns the cube texture as an InternalTexture
  41769. */
  41770. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  41771. /**
  41772. * Update the sample count for a given multiple render target texture
  41773. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41774. * @param textures defines the textures to update
  41775. * @param samples defines the sample count to set
  41776. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41777. */
  41778. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  41779. }
  41780. }
  41781. declare module BABYLON {
  41782. /**
  41783. * Gather the list of clipboard event types as constants.
  41784. */
  41785. export class ClipboardEventTypes {
  41786. /**
  41787. * The clipboard event is fired when a copy command is active (pressed).
  41788. */
  41789. static readonly COPY: number;
  41790. /**
  41791. * The clipboard event is fired when a cut command is active (pressed).
  41792. */
  41793. static readonly CUT: number;
  41794. /**
  41795. * The clipboard event is fired when a paste command is active (pressed).
  41796. */
  41797. static readonly PASTE: number;
  41798. }
  41799. /**
  41800. * This class is used to store clipboard related info for the onClipboardObservable event.
  41801. */
  41802. export class ClipboardInfo {
  41803. /**
  41804. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41805. */
  41806. type: number;
  41807. /**
  41808. * Defines the related dom event
  41809. */
  41810. event: ClipboardEvent;
  41811. /**
  41812. *Creates an instance of ClipboardInfo.
  41813. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41814. * @param event Defines the related dom event
  41815. */
  41816. constructor(
  41817. /**
  41818. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41819. */
  41820. type: number,
  41821. /**
  41822. * Defines the related dom event
  41823. */
  41824. event: ClipboardEvent);
  41825. /**
  41826. * Get the clipboard event's type from the keycode.
  41827. * @param keyCode Defines the keyCode for the current keyboard event.
  41828. * @return {number}
  41829. */
  41830. static GetTypeFromCharacter(keyCode: number): number;
  41831. }
  41832. }
  41833. declare module BABYLON {
  41834. /**
  41835. * Class used to represent data loading progression
  41836. */
  41837. export class SceneLoaderProgressEvent {
  41838. /** defines if data length to load can be evaluated */
  41839. readonly lengthComputable: boolean;
  41840. /** defines the loaded data length */
  41841. readonly loaded: number;
  41842. /** defines the data length to load */
  41843. readonly total: number;
  41844. /**
  41845. * Create a new progress event
  41846. * @param lengthComputable defines if data length to load can be evaluated
  41847. * @param loaded defines the loaded data length
  41848. * @param total defines the data length to load
  41849. */
  41850. constructor(
  41851. /** defines if data length to load can be evaluated */
  41852. lengthComputable: boolean,
  41853. /** defines the loaded data length */
  41854. loaded: number,
  41855. /** defines the data length to load */
  41856. total: number);
  41857. /**
  41858. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41859. * @param event defines the source event
  41860. * @returns a new SceneLoaderProgressEvent
  41861. */
  41862. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41863. }
  41864. /**
  41865. * Interface used by SceneLoader plugins to define supported file extensions
  41866. */
  41867. export interface ISceneLoaderPluginExtensions {
  41868. /**
  41869. * Defines the list of supported extensions
  41870. */
  41871. [extension: string]: {
  41872. isBinary: boolean;
  41873. };
  41874. }
  41875. /**
  41876. * Interface used by SceneLoader plugin factory
  41877. */
  41878. export interface ISceneLoaderPluginFactory {
  41879. /**
  41880. * Defines the name of the factory
  41881. */
  41882. name: string;
  41883. /**
  41884. * Function called to create a new plugin
  41885. * @return the new plugin
  41886. */
  41887. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41888. /**
  41889. * Boolean indicating if the plugin can direct load specific data
  41890. */
  41891. canDirectLoad?: (data: string) => boolean;
  41892. }
  41893. /**
  41894. * Interface used to define a SceneLoader plugin
  41895. */
  41896. export interface ISceneLoaderPlugin {
  41897. /**
  41898. * The friendly name of this plugin.
  41899. */
  41900. name: string;
  41901. /**
  41902. * The file extensions supported by this plugin.
  41903. */
  41904. extensions: string | ISceneLoaderPluginExtensions;
  41905. /**
  41906. * Import meshes into a scene.
  41907. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41908. * @param scene The scene to import into
  41909. * @param data The data to import
  41910. * @param rootUrl The root url for scene and resources
  41911. * @param meshes The meshes array to import into
  41912. * @param particleSystems The particle systems array to import into
  41913. * @param skeletons The skeletons array to import into
  41914. * @param onError The callback when import fails
  41915. * @returns True if successful or false otherwise
  41916. */
  41917. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41918. /**
  41919. * Load into a scene.
  41920. * @param scene The scene to load into
  41921. * @param data The data to import
  41922. * @param rootUrl The root url for scene and resources
  41923. * @param onError The callback when import fails
  41924. * @returns true if successful or false otherwise
  41925. */
  41926. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41927. /**
  41928. * The callback that returns true if the data can be directly loaded.
  41929. */
  41930. canDirectLoad?: (data: string) => boolean;
  41931. /**
  41932. * The callback that allows custom handling of the root url based on the response url.
  41933. */
  41934. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41935. /**
  41936. * Load into an asset container.
  41937. * @param scene The scene to load into
  41938. * @param data The data to import
  41939. * @param rootUrl The root url for scene and resources
  41940. * @param onError The callback when import fails
  41941. * @returns The loaded asset container
  41942. */
  41943. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41944. }
  41945. /**
  41946. * Interface used to define an async SceneLoader plugin
  41947. */
  41948. export interface ISceneLoaderPluginAsync {
  41949. /**
  41950. * The friendly name of this plugin.
  41951. */
  41952. name: string;
  41953. /**
  41954. * The file extensions supported by this plugin.
  41955. */
  41956. extensions: string | ISceneLoaderPluginExtensions;
  41957. /**
  41958. * Import meshes into a scene.
  41959. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41960. * @param scene The scene to import into
  41961. * @param data The data to import
  41962. * @param rootUrl The root url for scene and resources
  41963. * @param onProgress The callback when the load progresses
  41964. * @param fileName Defines the name of the file to load
  41965. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41966. */
  41967. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41968. meshes: AbstractMesh[];
  41969. particleSystems: IParticleSystem[];
  41970. skeletons: Skeleton[];
  41971. animationGroups: AnimationGroup[];
  41972. }>;
  41973. /**
  41974. * Load into a scene.
  41975. * @param scene The scene to load into
  41976. * @param data The data to import
  41977. * @param rootUrl The root url for scene and resources
  41978. * @param onProgress The callback when the load progresses
  41979. * @param fileName Defines the name of the file to load
  41980. * @returns Nothing
  41981. */
  41982. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41983. /**
  41984. * The callback that returns true if the data can be directly loaded.
  41985. */
  41986. canDirectLoad?: (data: string) => boolean;
  41987. /**
  41988. * The callback that allows custom handling of the root url based on the response url.
  41989. */
  41990. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41991. /**
  41992. * Load into an asset container.
  41993. * @param scene The scene to load into
  41994. * @param data The data to import
  41995. * @param rootUrl The root url for scene and resources
  41996. * @param onProgress The callback when the load progresses
  41997. * @param fileName Defines the name of the file to load
  41998. * @returns The loaded asset container
  41999. */
  42000. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42001. }
  42002. /**
  42003. * Class used to load scene from various file formats using registered plugins
  42004. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42005. */
  42006. export class SceneLoader {
  42007. /**
  42008. * No logging while loading
  42009. */
  42010. static readonly NO_LOGGING: number;
  42011. /**
  42012. * Minimal logging while loading
  42013. */
  42014. static readonly MINIMAL_LOGGING: number;
  42015. /**
  42016. * Summary logging while loading
  42017. */
  42018. static readonly SUMMARY_LOGGING: number;
  42019. /**
  42020. * Detailled logging while loading
  42021. */
  42022. static readonly DETAILED_LOGGING: number;
  42023. /**
  42024. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42025. */
  42026. static ForceFullSceneLoadingForIncremental: boolean;
  42027. /**
  42028. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42029. */
  42030. static ShowLoadingScreen: boolean;
  42031. /**
  42032. * Defines the current logging level (while loading the scene)
  42033. * @ignorenaming
  42034. */
  42035. static loggingLevel: number;
  42036. /**
  42037. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42038. */
  42039. static CleanBoneMatrixWeights: boolean;
  42040. /**
  42041. * Event raised when a plugin is used to load a scene
  42042. */
  42043. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42044. private static _registeredPlugins;
  42045. private static _getDefaultPlugin;
  42046. private static _getPluginForExtension;
  42047. private static _getPluginForDirectLoad;
  42048. private static _getPluginForFilename;
  42049. private static _getDirectLoad;
  42050. private static _loadData;
  42051. private static _getFileInfo;
  42052. /**
  42053. * Gets a plugin that can load the given extension
  42054. * @param extension defines the extension to load
  42055. * @returns a plugin or null if none works
  42056. */
  42057. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42058. /**
  42059. * Gets a boolean indicating that the given extension can be loaded
  42060. * @param extension defines the extension to load
  42061. * @returns true if the extension is supported
  42062. */
  42063. static IsPluginForExtensionAvailable(extension: string): boolean;
  42064. /**
  42065. * Adds a new plugin to the list of registered plugins
  42066. * @param plugin defines the plugin to add
  42067. */
  42068. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42069. /**
  42070. * Import meshes into a scene
  42071. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42072. * @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)
  42073. * @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)
  42074. * @param scene the instance of BABYLON.Scene to append to
  42075. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42076. * @param onProgress a callback with a progress event for each file being loaded
  42077. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42078. * @param pluginExtension the extension used to determine the plugin
  42079. * @returns The loaded plugin
  42080. */
  42081. 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>;
  42082. /**
  42083. * Import meshes into a scene
  42084. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42085. * @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)
  42086. * @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)
  42087. * @param scene the instance of BABYLON.Scene to append to
  42088. * @param onProgress a callback with a progress event for each file being loaded
  42089. * @param pluginExtension the extension used to determine the plugin
  42090. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42091. */
  42092. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42093. meshes: AbstractMesh[];
  42094. particleSystems: IParticleSystem[];
  42095. skeletons: Skeleton[];
  42096. animationGroups: AnimationGroup[];
  42097. }>;
  42098. /**
  42099. * Load a scene
  42100. * @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)
  42101. * @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)
  42102. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42103. * @param onSuccess a callback with the scene when import succeeds
  42104. * @param onProgress a callback with a progress event for each file being loaded
  42105. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42106. * @param pluginExtension the extension used to determine the plugin
  42107. * @returns The loaded plugin
  42108. */
  42109. 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>;
  42110. /**
  42111. * Load a scene
  42112. * @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)
  42113. * @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)
  42114. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42115. * @param onProgress a callback with a progress event for each file being loaded
  42116. * @param pluginExtension the extension used to determine the plugin
  42117. * @returns The loaded scene
  42118. */
  42119. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42120. /**
  42121. * Append a scene
  42122. * @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)
  42123. * @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)
  42124. * @param scene is the instance of BABYLON.Scene to append to
  42125. * @param onSuccess a callback with the scene when import succeeds
  42126. * @param onProgress a callback with a progress event for each file being loaded
  42127. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42128. * @param pluginExtension the extension used to determine the plugin
  42129. * @returns The loaded plugin
  42130. */
  42131. 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>;
  42132. /**
  42133. * Append a scene
  42134. * @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)
  42135. * @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)
  42136. * @param scene is the instance of BABYLON.Scene to append to
  42137. * @param onProgress a callback with a progress event for each file being loaded
  42138. * @param pluginExtension the extension used to determine the plugin
  42139. * @returns The given scene
  42140. */
  42141. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42142. /**
  42143. * Load a scene into an asset container
  42144. * @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)
  42145. * @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)
  42146. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42147. * @param onSuccess a callback with the scene when import succeeds
  42148. * @param onProgress a callback with a progress event for each file being loaded
  42149. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42150. * @param pluginExtension the extension used to determine the plugin
  42151. * @returns The loaded plugin
  42152. */
  42153. 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>;
  42154. /**
  42155. * Load a scene into an asset container
  42156. * @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)
  42157. * @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)
  42158. * @param scene is the instance of Scene to append to
  42159. * @param onProgress a callback with a progress event for each file being loaded
  42160. * @param pluginExtension the extension used to determine the plugin
  42161. * @returns The loaded asset container
  42162. */
  42163. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42164. }
  42165. }
  42166. declare module BABYLON {
  42167. /**
  42168. * Google Daydream controller
  42169. */
  42170. export class DaydreamController extends WebVRController {
  42171. /**
  42172. * Base Url for the controller model.
  42173. */
  42174. static MODEL_BASE_URL: string;
  42175. /**
  42176. * File name for the controller model.
  42177. */
  42178. static MODEL_FILENAME: string;
  42179. /**
  42180. * Gamepad Id prefix used to identify Daydream Controller.
  42181. */
  42182. static readonly GAMEPAD_ID_PREFIX: string;
  42183. /**
  42184. * Creates a new DaydreamController from a gamepad
  42185. * @param vrGamepad the gamepad that the controller should be created from
  42186. */
  42187. constructor(vrGamepad: any);
  42188. /**
  42189. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42190. * @param scene scene in which to add meshes
  42191. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42192. */
  42193. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42194. /**
  42195. * Called once for each button that changed state since the last frame
  42196. * @param buttonIdx Which button index changed
  42197. * @param state New state of the button
  42198. * @param changes Which properties on the state changed since last frame
  42199. */
  42200. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42201. }
  42202. }
  42203. declare module BABYLON {
  42204. /**
  42205. * Gear VR Controller
  42206. */
  42207. export class GearVRController extends WebVRController {
  42208. /**
  42209. * Base Url for the controller model.
  42210. */
  42211. static MODEL_BASE_URL: string;
  42212. /**
  42213. * File name for the controller model.
  42214. */
  42215. static MODEL_FILENAME: string;
  42216. /**
  42217. * Gamepad Id prefix used to identify this controller.
  42218. */
  42219. static readonly GAMEPAD_ID_PREFIX: string;
  42220. private readonly _buttonIndexToObservableNameMap;
  42221. /**
  42222. * Creates a new GearVRController from a gamepad
  42223. * @param vrGamepad the gamepad that the controller should be created from
  42224. */
  42225. constructor(vrGamepad: any);
  42226. /**
  42227. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42228. * @param scene scene in which to add meshes
  42229. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42230. */
  42231. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42232. /**
  42233. * Called once for each button that changed state since the last frame
  42234. * @param buttonIdx Which button index changed
  42235. * @param state New state of the button
  42236. * @param changes Which properties on the state changed since last frame
  42237. */
  42238. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42239. }
  42240. }
  42241. declare module BABYLON {
  42242. /**
  42243. * Generic Controller
  42244. */
  42245. export class GenericController extends WebVRController {
  42246. /**
  42247. * Base Url for the controller model.
  42248. */
  42249. static readonly MODEL_BASE_URL: string;
  42250. /**
  42251. * File name for the controller model.
  42252. */
  42253. static readonly MODEL_FILENAME: string;
  42254. /**
  42255. * Creates a new GenericController from a gamepad
  42256. * @param vrGamepad the gamepad that the controller should be created from
  42257. */
  42258. constructor(vrGamepad: any);
  42259. /**
  42260. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42261. * @param scene scene in which to add meshes
  42262. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42263. */
  42264. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42265. /**
  42266. * Called once for each button that changed state since the last frame
  42267. * @param buttonIdx Which button index changed
  42268. * @param state New state of the button
  42269. * @param changes Which properties on the state changed since last frame
  42270. */
  42271. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42272. }
  42273. }
  42274. declare module BABYLON {
  42275. /**
  42276. * Oculus Touch Controller
  42277. */
  42278. export class OculusTouchController extends WebVRController {
  42279. /**
  42280. * Base Url for the controller model.
  42281. */
  42282. static MODEL_BASE_URL: string;
  42283. /**
  42284. * File name for the left controller model.
  42285. */
  42286. static MODEL_LEFT_FILENAME: string;
  42287. /**
  42288. * File name for the right controller model.
  42289. */
  42290. static MODEL_RIGHT_FILENAME: string;
  42291. /**
  42292. * Fired when the secondary trigger on this controller is modified
  42293. */
  42294. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42295. /**
  42296. * Fired when the thumb rest on this controller is modified
  42297. */
  42298. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42299. /**
  42300. * Creates a new OculusTouchController from a gamepad
  42301. * @param vrGamepad the gamepad that the controller should be created from
  42302. */
  42303. constructor(vrGamepad: any);
  42304. /**
  42305. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42306. * @param scene scene in which to add meshes
  42307. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42308. */
  42309. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42310. /**
  42311. * Fired when the A button on this controller is modified
  42312. */
  42313. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42314. /**
  42315. * Fired when the B button on this controller is modified
  42316. */
  42317. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42318. /**
  42319. * Fired when the X button on this controller is modified
  42320. */
  42321. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42322. /**
  42323. * Fired when the Y button on this controller is modified
  42324. */
  42325. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42326. /**
  42327. * Called once for each button that changed state since the last frame
  42328. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42329. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42330. * 2) secondary trigger (same)
  42331. * 3) A (right) X (left), touch, pressed = value
  42332. * 4) B / Y
  42333. * 5) thumb rest
  42334. * @param buttonIdx Which button index changed
  42335. * @param state New state of the button
  42336. * @param changes Which properties on the state changed since last frame
  42337. */
  42338. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42339. }
  42340. }
  42341. declare module BABYLON {
  42342. /**
  42343. * Vive Controller
  42344. */
  42345. export class ViveController extends WebVRController {
  42346. /**
  42347. * Base Url for the controller model.
  42348. */
  42349. static MODEL_BASE_URL: string;
  42350. /**
  42351. * File name for the controller model.
  42352. */
  42353. static MODEL_FILENAME: string;
  42354. /**
  42355. * Creates a new ViveController from a gamepad
  42356. * @param vrGamepad the gamepad that the controller should be created from
  42357. */
  42358. constructor(vrGamepad: any);
  42359. /**
  42360. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42361. * @param scene scene in which to add meshes
  42362. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42363. */
  42364. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42365. /**
  42366. * Fired when the left button on this controller is modified
  42367. */
  42368. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42369. /**
  42370. * Fired when the right button on this controller is modified
  42371. */
  42372. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42373. /**
  42374. * Fired when the menu button on this controller is modified
  42375. */
  42376. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42377. /**
  42378. * Called once for each button that changed state since the last frame
  42379. * Vive mapping:
  42380. * 0: touchpad
  42381. * 1: trigger
  42382. * 2: left AND right buttons
  42383. * 3: menu button
  42384. * @param buttonIdx Which button index changed
  42385. * @param state New state of the button
  42386. * @param changes Which properties on the state changed since last frame
  42387. */
  42388. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42389. }
  42390. }
  42391. declare module BABYLON {
  42392. /**
  42393. * Defines the WindowsMotionController object that the state of the windows motion controller
  42394. */
  42395. export class WindowsMotionController extends WebVRController {
  42396. /**
  42397. * The base url used to load the left and right controller models
  42398. */
  42399. static MODEL_BASE_URL: string;
  42400. /**
  42401. * The name of the left controller model file
  42402. */
  42403. static MODEL_LEFT_FILENAME: string;
  42404. /**
  42405. * The name of the right controller model file
  42406. */
  42407. static MODEL_RIGHT_FILENAME: string;
  42408. /**
  42409. * The controller name prefix for this controller type
  42410. */
  42411. static readonly GAMEPAD_ID_PREFIX: string;
  42412. /**
  42413. * The controller id pattern for this controller type
  42414. */
  42415. private static readonly GAMEPAD_ID_PATTERN;
  42416. private _loadedMeshInfo;
  42417. private readonly _mapping;
  42418. /**
  42419. * Fired when the trackpad on this controller is clicked
  42420. */
  42421. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42422. /**
  42423. * Fired when the trackpad on this controller is modified
  42424. */
  42425. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42426. /**
  42427. * The current x and y values of this controller's trackpad
  42428. */
  42429. trackpad: StickValues;
  42430. /**
  42431. * Creates a new WindowsMotionController from a gamepad
  42432. * @param vrGamepad the gamepad that the controller should be created from
  42433. */
  42434. constructor(vrGamepad: any);
  42435. /**
  42436. * Fired when the trigger on this controller is modified
  42437. */
  42438. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42439. /**
  42440. * Fired when the menu button on this controller is modified
  42441. */
  42442. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42443. /**
  42444. * Fired when the grip button on this controller is modified
  42445. */
  42446. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42447. /**
  42448. * Fired when the thumbstick button on this controller is modified
  42449. */
  42450. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42451. /**
  42452. * Fired when the touchpad button on this controller is modified
  42453. */
  42454. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42455. /**
  42456. * Fired when the touchpad values on this controller are modified
  42457. */
  42458. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42459. private _updateTrackpad;
  42460. /**
  42461. * Called once per frame by the engine.
  42462. */
  42463. update(): void;
  42464. /**
  42465. * Called once for each button that changed state since the last frame
  42466. * @param buttonIdx Which button index changed
  42467. * @param state New state of the button
  42468. * @param changes Which properties on the state changed since last frame
  42469. */
  42470. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42471. /**
  42472. * Moves the buttons on the controller mesh based on their current state
  42473. * @param buttonName the name of the button to move
  42474. * @param buttonValue the value of the button which determines the buttons new position
  42475. */
  42476. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42477. /**
  42478. * Moves the axis on the controller mesh based on its current state
  42479. * @param axis the index of the axis
  42480. * @param axisValue the value of the axis which determines the meshes new position
  42481. * @hidden
  42482. */
  42483. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42484. /**
  42485. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42486. * @param scene scene in which to add meshes
  42487. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42488. */
  42489. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42490. /**
  42491. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42492. * can be transformed by button presses and axes values, based on this._mapping.
  42493. *
  42494. * @param scene scene in which the meshes exist
  42495. * @param meshes list of meshes that make up the controller model to process
  42496. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42497. */
  42498. private processModel;
  42499. private createMeshInfo;
  42500. /**
  42501. * Gets the ray of the controller in the direction the controller is pointing
  42502. * @param length the length the resulting ray should be
  42503. * @returns a ray in the direction the controller is pointing
  42504. */
  42505. getForwardRay(length?: number): Ray;
  42506. /**
  42507. * Disposes of the controller
  42508. */
  42509. dispose(): void;
  42510. }
  42511. }
  42512. declare module BABYLON {
  42513. /**
  42514. * Single axis scale gizmo
  42515. */
  42516. export class AxisScaleGizmo extends Gizmo {
  42517. private _coloredMaterial;
  42518. /**
  42519. * Drag behavior responsible for the gizmos dragging interactions
  42520. */
  42521. dragBehavior: PointerDragBehavior;
  42522. private _pointerObserver;
  42523. /**
  42524. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42525. */
  42526. snapDistance: number;
  42527. /**
  42528. * Event that fires each time the gizmo snaps to a new location.
  42529. * * snapDistance is the the change in distance
  42530. */
  42531. onSnapObservable: Observable<{
  42532. snapDistance: number;
  42533. }>;
  42534. /**
  42535. * If the scaling operation should be done on all axis (default: false)
  42536. */
  42537. uniformScaling: boolean;
  42538. /**
  42539. * Creates an AxisScaleGizmo
  42540. * @param gizmoLayer The utility layer the gizmo will be added to
  42541. * @param dragAxis The axis which the gizmo will be able to scale on
  42542. * @param color The color of the gizmo
  42543. */
  42544. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42545. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42546. /**
  42547. * Disposes of the gizmo
  42548. */
  42549. dispose(): void;
  42550. /**
  42551. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42552. * @param mesh The mesh to replace the default mesh of the gizmo
  42553. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42554. */
  42555. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42556. }
  42557. }
  42558. declare module BABYLON {
  42559. /**
  42560. * Bounding box gizmo
  42561. */
  42562. export class BoundingBoxGizmo extends Gizmo {
  42563. private _lineBoundingBox;
  42564. private _rotateSpheresParent;
  42565. private _scaleBoxesParent;
  42566. private _boundingDimensions;
  42567. private _renderObserver;
  42568. private _pointerObserver;
  42569. private _scaleDragSpeed;
  42570. private _tmpQuaternion;
  42571. private _tmpVector;
  42572. private _tmpRotationMatrix;
  42573. /**
  42574. * 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)
  42575. */
  42576. ignoreChildren: boolean;
  42577. /**
  42578. * 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)
  42579. */
  42580. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42581. /**
  42582. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42583. */
  42584. rotationSphereSize: number;
  42585. /**
  42586. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42587. */
  42588. scaleBoxSize: number;
  42589. /**
  42590. * 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)
  42591. */
  42592. fixedDragMeshScreenSize: boolean;
  42593. /**
  42594. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42595. */
  42596. fixedDragMeshScreenSizeDistanceFactor: number;
  42597. /**
  42598. * Fired when a rotation sphere or scale box is dragged
  42599. */
  42600. onDragStartObservable: Observable<{}>;
  42601. /**
  42602. * Fired when a scale box is dragged
  42603. */
  42604. onScaleBoxDragObservable: Observable<{}>;
  42605. /**
  42606. * Fired when a scale box drag is ended
  42607. */
  42608. onScaleBoxDragEndObservable: Observable<{}>;
  42609. /**
  42610. * Fired when a rotation sphere is dragged
  42611. */
  42612. onRotationSphereDragObservable: Observable<{}>;
  42613. /**
  42614. * Fired when a rotation sphere drag is ended
  42615. */
  42616. onRotationSphereDragEndObservable: Observable<{}>;
  42617. /**
  42618. * 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)
  42619. */
  42620. scalePivot: Nullable<Vector3>;
  42621. /**
  42622. * Mesh used as a pivot to rotate the attached mesh
  42623. */
  42624. private _anchorMesh;
  42625. private _existingMeshScale;
  42626. private _dragMesh;
  42627. private pointerDragBehavior;
  42628. private coloredMaterial;
  42629. private hoverColoredMaterial;
  42630. /**
  42631. * Sets the color of the bounding box gizmo
  42632. * @param color the color to set
  42633. */
  42634. setColor(color: Color3): void;
  42635. /**
  42636. * Creates an BoundingBoxGizmo
  42637. * @param gizmoLayer The utility layer the gizmo will be added to
  42638. * @param color The color of the gizmo
  42639. */
  42640. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42641. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42642. private _selectNode;
  42643. /**
  42644. * Updates the bounding box information for the Gizmo
  42645. */
  42646. updateBoundingBox(): void;
  42647. private _updateRotationSpheres;
  42648. private _updateScaleBoxes;
  42649. /**
  42650. * Enables rotation on the specified axis and disables rotation on the others
  42651. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42652. */
  42653. setEnabledRotationAxis(axis: string): void;
  42654. /**
  42655. * Enables/disables scaling
  42656. * @param enable if scaling should be enabled
  42657. */
  42658. setEnabledScaling(enable: boolean): void;
  42659. private _updateDummy;
  42660. /**
  42661. * Enables a pointer drag behavior on the bounding box of the gizmo
  42662. */
  42663. enableDragBehavior(): void;
  42664. /**
  42665. * Disposes of the gizmo
  42666. */
  42667. dispose(): void;
  42668. /**
  42669. * 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)
  42670. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42671. * @returns the bounding box mesh with the passed in mesh as a child
  42672. */
  42673. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42674. /**
  42675. * CustomMeshes are not supported by this gizmo
  42676. * @param mesh The mesh to replace the default mesh of the gizmo
  42677. */
  42678. setCustomMesh(mesh: Mesh): void;
  42679. }
  42680. }
  42681. declare module BABYLON {
  42682. /**
  42683. * Single plane rotation gizmo
  42684. */
  42685. export class PlaneRotationGizmo extends Gizmo {
  42686. /**
  42687. * Drag behavior responsible for the gizmos dragging interactions
  42688. */
  42689. dragBehavior: PointerDragBehavior;
  42690. private _pointerObserver;
  42691. /**
  42692. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42693. */
  42694. snapDistance: number;
  42695. /**
  42696. * Event that fires each time the gizmo snaps to a new location.
  42697. * * snapDistance is the the change in distance
  42698. */
  42699. onSnapObservable: Observable<{
  42700. snapDistance: number;
  42701. }>;
  42702. /**
  42703. * Creates a PlaneRotationGizmo
  42704. * @param gizmoLayer The utility layer the gizmo will be added to
  42705. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42706. * @param color The color of the gizmo
  42707. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42708. */
  42709. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42710. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42711. /**
  42712. * Disposes of the gizmo
  42713. */
  42714. dispose(): void;
  42715. }
  42716. }
  42717. declare module BABYLON {
  42718. /**
  42719. * Gizmo that enables rotating a mesh along 3 axis
  42720. */
  42721. export class RotationGizmo extends Gizmo {
  42722. /**
  42723. * Internal gizmo used for interactions on the x axis
  42724. */
  42725. xGizmo: PlaneRotationGizmo;
  42726. /**
  42727. * Internal gizmo used for interactions on the y axis
  42728. */
  42729. yGizmo: PlaneRotationGizmo;
  42730. /**
  42731. * Internal gizmo used for interactions on the z axis
  42732. */
  42733. zGizmo: PlaneRotationGizmo;
  42734. /** Fires an event when any of it's sub gizmos are dragged */
  42735. onDragStartObservable: Observable<{}>;
  42736. /** Fires an event when any of it's sub gizmos are released from dragging */
  42737. onDragEndObservable: Observable<{}>;
  42738. attachedMesh: Nullable<AbstractMesh>;
  42739. /**
  42740. * Creates a RotationGizmo
  42741. * @param gizmoLayer The utility layer the gizmo will be added to
  42742. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42743. */
  42744. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42745. updateGizmoRotationToMatchAttachedMesh: boolean;
  42746. /**
  42747. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42748. */
  42749. snapDistance: number;
  42750. /**
  42751. * Ratio for the scale of the gizmo (Default: 1)
  42752. */
  42753. scaleRatio: number;
  42754. /**
  42755. * Disposes of the gizmo
  42756. */
  42757. dispose(): void;
  42758. /**
  42759. * CustomMeshes are not supported by this gizmo
  42760. * @param mesh The mesh to replace the default mesh of the gizmo
  42761. */
  42762. setCustomMesh(mesh: Mesh): void;
  42763. }
  42764. }
  42765. declare module BABYLON {
  42766. /**
  42767. * Gizmo that enables dragging a mesh along 3 axis
  42768. */
  42769. export class PositionGizmo extends Gizmo {
  42770. /**
  42771. * Internal gizmo used for interactions on the x axis
  42772. */
  42773. xGizmo: AxisDragGizmo;
  42774. /**
  42775. * Internal gizmo used for interactions on the y axis
  42776. */
  42777. yGizmo: AxisDragGizmo;
  42778. /**
  42779. * Internal gizmo used for interactions on the z axis
  42780. */
  42781. zGizmo: AxisDragGizmo;
  42782. /** Fires an event when any of it's sub gizmos are dragged */
  42783. onDragStartObservable: Observable<{}>;
  42784. /** Fires an event when any of it's sub gizmos are released from dragging */
  42785. onDragEndObservable: Observable<{}>;
  42786. attachedMesh: Nullable<AbstractMesh>;
  42787. /**
  42788. * Creates a PositionGizmo
  42789. * @param gizmoLayer The utility layer the gizmo will be added to
  42790. */
  42791. constructor(gizmoLayer?: UtilityLayerRenderer);
  42792. updateGizmoRotationToMatchAttachedMesh: boolean;
  42793. /**
  42794. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42795. */
  42796. snapDistance: number;
  42797. /**
  42798. * Ratio for the scale of the gizmo (Default: 1)
  42799. */
  42800. scaleRatio: number;
  42801. /**
  42802. * Disposes of the gizmo
  42803. */
  42804. dispose(): void;
  42805. /**
  42806. * CustomMeshes are not supported by this gizmo
  42807. * @param mesh The mesh to replace the default mesh of the gizmo
  42808. */
  42809. setCustomMesh(mesh: Mesh): void;
  42810. }
  42811. }
  42812. declare module BABYLON {
  42813. /**
  42814. * Class containing static functions to help procedurally build meshes
  42815. */
  42816. export class PolyhedronBuilder {
  42817. /**
  42818. * Creates a polyhedron mesh
  42819. * * 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
  42820. * * The parameter `size` (positive float, default 1) sets the polygon size
  42821. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42822. * * 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`
  42823. * * 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
  42824. * * 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)`)
  42825. * * 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
  42826. * * 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
  42827. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42828. * * 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
  42829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42830. * @param name defines the name of the mesh
  42831. * @param options defines the options used to create the mesh
  42832. * @param scene defines the hosting scene
  42833. * @returns the polyhedron mesh
  42834. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42835. */
  42836. static CreatePolyhedron(name: string, options: {
  42837. type?: number;
  42838. size?: number;
  42839. sizeX?: number;
  42840. sizeY?: number;
  42841. sizeZ?: number;
  42842. custom?: any;
  42843. faceUV?: Vector4[];
  42844. faceColors?: Color4[];
  42845. flat?: boolean;
  42846. updatable?: boolean;
  42847. sideOrientation?: number;
  42848. frontUVs?: Vector4;
  42849. backUVs?: Vector4;
  42850. }, scene?: Nullable<Scene>): Mesh;
  42851. }
  42852. }
  42853. declare module BABYLON {
  42854. /**
  42855. * Gizmo that enables scaling a mesh along 3 axis
  42856. */
  42857. export class ScaleGizmo extends Gizmo {
  42858. /**
  42859. * Internal gizmo used for interactions on the x axis
  42860. */
  42861. xGizmo: AxisScaleGizmo;
  42862. /**
  42863. * Internal gizmo used for interactions on the y axis
  42864. */
  42865. yGizmo: AxisScaleGizmo;
  42866. /**
  42867. * Internal gizmo used for interactions on the z axis
  42868. */
  42869. zGizmo: AxisScaleGizmo;
  42870. /**
  42871. * Internal gizmo used to scale all axis equally
  42872. */
  42873. uniformScaleGizmo: AxisScaleGizmo;
  42874. /** Fires an event when any of it's sub gizmos are dragged */
  42875. onDragStartObservable: Observable<{}>;
  42876. /** Fires an event when any of it's sub gizmos are released from dragging */
  42877. onDragEndObservable: Observable<{}>;
  42878. attachedMesh: Nullable<AbstractMesh>;
  42879. /**
  42880. * Creates a ScaleGizmo
  42881. * @param gizmoLayer The utility layer the gizmo will be added to
  42882. */
  42883. constructor(gizmoLayer?: UtilityLayerRenderer);
  42884. updateGizmoRotationToMatchAttachedMesh: boolean;
  42885. /**
  42886. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42887. */
  42888. snapDistance: number;
  42889. /**
  42890. * Ratio for the scale of the gizmo (Default: 1)
  42891. */
  42892. scaleRatio: number;
  42893. /**
  42894. * Disposes of the gizmo
  42895. */
  42896. dispose(): void;
  42897. }
  42898. }
  42899. declare module BABYLON {
  42900. /**
  42901. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42902. */
  42903. export class GizmoManager implements IDisposable {
  42904. private scene;
  42905. /**
  42906. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42907. */
  42908. gizmos: {
  42909. positionGizmo: Nullable<PositionGizmo>;
  42910. rotationGizmo: Nullable<RotationGizmo>;
  42911. scaleGizmo: Nullable<ScaleGizmo>;
  42912. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42913. };
  42914. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42915. clearGizmoOnEmptyPointerEvent: boolean;
  42916. /** Fires an event when the manager is attached to a mesh */
  42917. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42918. private _gizmosEnabled;
  42919. private _pointerObserver;
  42920. private _attachedMesh;
  42921. private _boundingBoxColor;
  42922. private _defaultUtilityLayer;
  42923. private _defaultKeepDepthUtilityLayer;
  42924. /**
  42925. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42926. */
  42927. boundingBoxDragBehavior: SixDofDragBehavior;
  42928. /**
  42929. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42930. */
  42931. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42932. /**
  42933. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42934. */
  42935. usePointerToAttachGizmos: boolean;
  42936. /**
  42937. * Instatiates a gizmo manager
  42938. * @param scene the scene to overlay the gizmos on top of
  42939. */
  42940. constructor(scene: Scene);
  42941. /**
  42942. * Attaches a set of gizmos to the specified mesh
  42943. * @param mesh The mesh the gizmo's should be attached to
  42944. */
  42945. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42946. /**
  42947. * If the position gizmo is enabled
  42948. */
  42949. positionGizmoEnabled: boolean;
  42950. /**
  42951. * If the rotation gizmo is enabled
  42952. */
  42953. rotationGizmoEnabled: boolean;
  42954. /**
  42955. * If the scale gizmo is enabled
  42956. */
  42957. scaleGizmoEnabled: boolean;
  42958. /**
  42959. * If the boundingBox gizmo is enabled
  42960. */
  42961. boundingBoxGizmoEnabled: boolean;
  42962. /**
  42963. * Disposes of the gizmo manager
  42964. */
  42965. dispose(): void;
  42966. }
  42967. }
  42968. declare module BABYLON {
  42969. /**
  42970. * A directional light is defined by a direction (what a surprise!).
  42971. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  42972. * 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.
  42973. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42974. */
  42975. export class DirectionalLight extends ShadowLight {
  42976. private _shadowFrustumSize;
  42977. /**
  42978. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  42979. */
  42980. /**
  42981. * Specifies a fix frustum size for the shadow generation.
  42982. */
  42983. shadowFrustumSize: number;
  42984. private _shadowOrthoScale;
  42985. /**
  42986. * Gets the shadow projection scale against the optimal computed one.
  42987. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42988. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42989. */
  42990. /**
  42991. * Sets the shadow projection scale against the optimal computed one.
  42992. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42993. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42994. */
  42995. shadowOrthoScale: number;
  42996. /**
  42997. * Automatically compute the projection matrix to best fit (including all the casters)
  42998. * on each frame.
  42999. */
  43000. autoUpdateExtends: boolean;
  43001. private _orthoLeft;
  43002. private _orthoRight;
  43003. private _orthoTop;
  43004. private _orthoBottom;
  43005. /**
  43006. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  43007. * The directional light is emitted from everywhere in the given direction.
  43008. * It can cast shadows.
  43009. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43010. * @param name The friendly name of the light
  43011. * @param direction The direction of the light
  43012. * @param scene The scene the light belongs to
  43013. */
  43014. constructor(name: string, direction: Vector3, scene: Scene);
  43015. /**
  43016. * Returns the string "DirectionalLight".
  43017. * @return The class name
  43018. */
  43019. getClassName(): string;
  43020. /**
  43021. * Returns the integer 1.
  43022. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43023. */
  43024. getTypeID(): number;
  43025. /**
  43026. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  43027. * Returns the DirectionalLight Shadow projection matrix.
  43028. */
  43029. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43030. /**
  43031. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  43032. * Returns the DirectionalLight Shadow projection matrix.
  43033. */
  43034. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  43035. /**
  43036. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  43037. * Returns the DirectionalLight Shadow projection matrix.
  43038. */
  43039. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43040. protected _buildUniformLayout(): void;
  43041. /**
  43042. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  43043. * @param effect The effect to update
  43044. * @param lightIndex The index of the light in the effect to update
  43045. * @returns The directional light
  43046. */
  43047. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  43048. /**
  43049. * Gets the minZ used for shadow according to both the scene and the light.
  43050. *
  43051. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43052. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43053. * @param activeCamera The camera we are returning the min for
  43054. * @returns the depth min z
  43055. */
  43056. getDepthMinZ(activeCamera: Camera): number;
  43057. /**
  43058. * Gets the maxZ used for shadow according to both the scene and the light.
  43059. *
  43060. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43061. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43062. * @param activeCamera The camera we are returning the max for
  43063. * @returns the depth max z
  43064. */
  43065. getDepthMaxZ(activeCamera: Camera): number;
  43066. /**
  43067. * Prepares the list of defines specific to the light type.
  43068. * @param defines the list of defines
  43069. * @param lightIndex defines the index of the light for the effect
  43070. */
  43071. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43072. }
  43073. }
  43074. declare module BABYLON {
  43075. /**
  43076. * Class containing static functions to help procedurally build meshes
  43077. */
  43078. export class HemisphereBuilder {
  43079. /**
  43080. * Creates a hemisphere mesh
  43081. * @param name defines the name of the mesh
  43082. * @param options defines the options used to create the mesh
  43083. * @param scene defines the hosting scene
  43084. * @returns the hemisphere mesh
  43085. */
  43086. static CreateHemisphere(name: string, options: {
  43087. segments?: number;
  43088. diameter?: number;
  43089. sideOrientation?: number;
  43090. }, scene: any): Mesh;
  43091. }
  43092. }
  43093. declare module BABYLON {
  43094. /**
  43095. * A spot light is defined by a position, a direction, an angle, and an exponent.
  43096. * These values define a cone of light starting from the position, emitting toward the direction.
  43097. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  43098. * and the exponent defines the speed of the decay of the light with distance (reach).
  43099. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43100. */
  43101. export class SpotLight extends ShadowLight {
  43102. private _angle;
  43103. private _innerAngle;
  43104. private _cosHalfAngle;
  43105. private _lightAngleScale;
  43106. private _lightAngleOffset;
  43107. /**
  43108. * Gets the cone angle of the spot light in Radians.
  43109. */
  43110. /**
  43111. * Sets the cone angle of the spot light in Radians.
  43112. */
  43113. angle: number;
  43114. /**
  43115. * Only used in gltf falloff mode, this defines the angle where
  43116. * the directional falloff will start before cutting at angle which could be seen
  43117. * as outer angle.
  43118. */
  43119. /**
  43120. * Only used in gltf falloff mode, this defines the angle where
  43121. * the directional falloff will start before cutting at angle which could be seen
  43122. * as outer angle.
  43123. */
  43124. innerAngle: number;
  43125. private _shadowAngleScale;
  43126. /**
  43127. * Allows scaling the angle of the light for shadow generation only.
  43128. */
  43129. /**
  43130. * Allows scaling the angle of the light for shadow generation only.
  43131. */
  43132. shadowAngleScale: number;
  43133. /**
  43134. * The light decay speed with the distance from the emission spot.
  43135. */
  43136. exponent: number;
  43137. private _projectionTextureMatrix;
  43138. /**
  43139. * Allows reading the projecton texture
  43140. */
  43141. readonly projectionTextureMatrix: Matrix;
  43142. protected _projectionTextureLightNear: number;
  43143. /**
  43144. * Gets the near clip of the Spotlight for texture projection.
  43145. */
  43146. /**
  43147. * Sets the near clip of the Spotlight for texture projection.
  43148. */
  43149. projectionTextureLightNear: number;
  43150. protected _projectionTextureLightFar: number;
  43151. /**
  43152. * Gets the far clip of the Spotlight for texture projection.
  43153. */
  43154. /**
  43155. * Sets the far clip of the Spotlight for texture projection.
  43156. */
  43157. projectionTextureLightFar: number;
  43158. protected _projectionTextureUpDirection: Vector3;
  43159. /**
  43160. * Gets the Up vector of the Spotlight for texture projection.
  43161. */
  43162. /**
  43163. * Sets the Up vector of the Spotlight for texture projection.
  43164. */
  43165. projectionTextureUpDirection: Vector3;
  43166. private _projectionTexture;
  43167. /**
  43168. * Gets the projection texture of the light.
  43169. */
  43170. /**
  43171. * Sets the projection texture of the light.
  43172. */
  43173. projectionTexture: Nullable<BaseTexture>;
  43174. private _projectionTextureViewLightDirty;
  43175. private _projectionTextureProjectionLightDirty;
  43176. private _projectionTextureDirty;
  43177. private _projectionTextureViewTargetVector;
  43178. private _projectionTextureViewLightMatrix;
  43179. private _projectionTextureProjectionLightMatrix;
  43180. private _projectionTextureScalingMatrix;
  43181. /**
  43182. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  43183. * It can cast shadows.
  43184. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43185. * @param name The light friendly name
  43186. * @param position The position of the spot light in the scene
  43187. * @param direction The direction of the light in the scene
  43188. * @param angle The cone angle of the light in Radians
  43189. * @param exponent The light decay speed with the distance from the emission spot
  43190. * @param scene The scene the lights belongs to
  43191. */
  43192. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  43193. /**
  43194. * Returns the string "SpotLight".
  43195. * @returns the class name
  43196. */
  43197. getClassName(): string;
  43198. /**
  43199. * Returns the integer 2.
  43200. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43201. */
  43202. getTypeID(): number;
  43203. /**
  43204. * Overrides the direction setter to recompute the projection texture view light Matrix.
  43205. */
  43206. protected _setDirection(value: Vector3): void;
  43207. /**
  43208. * Overrides the position setter to recompute the projection texture view light Matrix.
  43209. */
  43210. protected _setPosition(value: Vector3): void;
  43211. /**
  43212. * 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.
  43213. * Returns the SpotLight.
  43214. */
  43215. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43216. protected _computeProjectionTextureViewLightMatrix(): void;
  43217. protected _computeProjectionTextureProjectionLightMatrix(): void;
  43218. /**
  43219. * Main function for light texture projection matrix computing.
  43220. */
  43221. protected _computeProjectionTextureMatrix(): void;
  43222. protected _buildUniformLayout(): void;
  43223. private _computeAngleValues;
  43224. /**
  43225. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  43226. * @param effect The effect to update
  43227. * @param lightIndex The index of the light in the effect to update
  43228. * @returns The spot light
  43229. */
  43230. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  43231. /**
  43232. * Disposes the light and the associated resources.
  43233. */
  43234. dispose(): void;
  43235. /**
  43236. * Prepares the list of defines specific to the light type.
  43237. * @param defines the list of defines
  43238. * @param lightIndex defines the index of the light for the effect
  43239. */
  43240. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43241. }
  43242. }
  43243. declare module BABYLON {
  43244. /**
  43245. * Gizmo that enables viewing a light
  43246. */
  43247. export class LightGizmo extends Gizmo {
  43248. private _lightMesh;
  43249. private _material;
  43250. /**
  43251. * Creates a LightGizmo
  43252. * @param gizmoLayer The utility layer the gizmo will be added to
  43253. */
  43254. constructor(gizmoLayer?: UtilityLayerRenderer);
  43255. private _light;
  43256. /**
  43257. * The light that the gizmo is attached to
  43258. */
  43259. light: Nullable<Light>;
  43260. /**
  43261. * @hidden
  43262. * Updates the gizmo to match the attached mesh's position/rotation
  43263. */
  43264. protected _update(): void;
  43265. private static _Scale;
  43266. /**
  43267. * Creates the lines for a light mesh
  43268. */
  43269. private static _createLightLines;
  43270. private static _CreateHemisphericLightMesh;
  43271. private static _CreatePointLightMesh;
  43272. private static _CreateSpotLightMesh;
  43273. private static _CreateDirectionalLightMesh;
  43274. }
  43275. }
  43276. declare module BABYLON {
  43277. /** @hidden */
  43278. export var backgroundFragmentDeclaration: {
  43279. name: string;
  43280. shader: string;
  43281. };
  43282. }
  43283. declare module BABYLON {
  43284. /** @hidden */
  43285. export var backgroundUboDeclaration: {
  43286. name: string;
  43287. shader: string;
  43288. };
  43289. }
  43290. declare module BABYLON {
  43291. /** @hidden */
  43292. export var backgroundPixelShader: {
  43293. name: string;
  43294. shader: string;
  43295. };
  43296. }
  43297. declare module BABYLON {
  43298. /** @hidden */
  43299. export var backgroundVertexDeclaration: {
  43300. name: string;
  43301. shader: string;
  43302. };
  43303. }
  43304. declare module BABYLON {
  43305. /** @hidden */
  43306. export var backgroundVertexShader: {
  43307. name: string;
  43308. shader: string;
  43309. };
  43310. }
  43311. declare module BABYLON {
  43312. /**
  43313. * Background material used to create an efficient environement around your scene.
  43314. */
  43315. export class BackgroundMaterial extends PushMaterial {
  43316. /**
  43317. * Standard reflectance value at parallel view angle.
  43318. */
  43319. static StandardReflectance0: number;
  43320. /**
  43321. * Standard reflectance value at grazing angle.
  43322. */
  43323. static StandardReflectance90: number;
  43324. protected _primaryColor: Color3;
  43325. /**
  43326. * Key light Color (multiply against the environement texture)
  43327. */
  43328. primaryColor: Color3;
  43329. protected __perceptualColor: Nullable<Color3>;
  43330. /**
  43331. * Experimental Internal Use Only.
  43332. *
  43333. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43334. * This acts as a helper to set the primary color to a more "human friendly" value.
  43335. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43336. * output color as close as possible from the chosen value.
  43337. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43338. * part of lighting setup.)
  43339. */
  43340. _perceptualColor: Nullable<Color3>;
  43341. protected _primaryColorShadowLevel: float;
  43342. /**
  43343. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43344. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43345. */
  43346. primaryColorShadowLevel: float;
  43347. protected _primaryColorHighlightLevel: float;
  43348. /**
  43349. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43350. * The primary color is used at the level chosen to define what the white area would look.
  43351. */
  43352. primaryColorHighlightLevel: float;
  43353. protected _reflectionTexture: Nullable<BaseTexture>;
  43354. /**
  43355. * Reflection Texture used in the material.
  43356. * Should be author in a specific way for the best result (refer to the documentation).
  43357. */
  43358. reflectionTexture: Nullable<BaseTexture>;
  43359. protected _reflectionBlur: float;
  43360. /**
  43361. * Reflection Texture level of blur.
  43362. *
  43363. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43364. * texture twice.
  43365. */
  43366. reflectionBlur: float;
  43367. protected _diffuseTexture: Nullable<BaseTexture>;
  43368. /**
  43369. * Diffuse Texture used in the material.
  43370. * Should be author in a specific way for the best result (refer to the documentation).
  43371. */
  43372. diffuseTexture: Nullable<BaseTexture>;
  43373. protected _shadowLights: Nullable<IShadowLight[]>;
  43374. /**
  43375. * Specify the list of lights casting shadow on the material.
  43376. * All scene shadow lights will be included if null.
  43377. */
  43378. shadowLights: Nullable<IShadowLight[]>;
  43379. protected _shadowLevel: float;
  43380. /**
  43381. * Helps adjusting the shadow to a softer level if required.
  43382. * 0 means black shadows and 1 means no shadows.
  43383. */
  43384. shadowLevel: float;
  43385. protected _sceneCenter: Vector3;
  43386. /**
  43387. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43388. * It is usually zero but might be interesting to modify according to your setup.
  43389. */
  43390. sceneCenter: Vector3;
  43391. protected _opacityFresnel: boolean;
  43392. /**
  43393. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43394. * This helps ensuring a nice transition when the camera goes under the ground.
  43395. */
  43396. opacityFresnel: boolean;
  43397. protected _reflectionFresnel: boolean;
  43398. /**
  43399. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43400. * This helps adding a mirror texture on the ground.
  43401. */
  43402. reflectionFresnel: boolean;
  43403. protected _reflectionFalloffDistance: number;
  43404. /**
  43405. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43406. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43407. */
  43408. reflectionFalloffDistance: number;
  43409. protected _reflectionAmount: number;
  43410. /**
  43411. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43412. */
  43413. reflectionAmount: number;
  43414. protected _reflectionReflectance0: number;
  43415. /**
  43416. * This specifies the weight of the reflection at grazing angle.
  43417. */
  43418. reflectionReflectance0: number;
  43419. protected _reflectionReflectance90: number;
  43420. /**
  43421. * This specifies the weight of the reflection at a perpendicular point of view.
  43422. */
  43423. reflectionReflectance90: number;
  43424. /**
  43425. * Sets the reflection reflectance fresnel values according to the default standard
  43426. * empirically know to work well :-)
  43427. */
  43428. reflectionStandardFresnelWeight: number;
  43429. protected _useRGBColor: boolean;
  43430. /**
  43431. * Helps to directly use the maps channels instead of their level.
  43432. */
  43433. useRGBColor: boolean;
  43434. protected _enableNoise: boolean;
  43435. /**
  43436. * This helps reducing the banding effect that could occur on the background.
  43437. */
  43438. enableNoise: boolean;
  43439. /**
  43440. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43441. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43442. * Recommended to be keep at 1.0 except for special cases.
  43443. */
  43444. fovMultiplier: number;
  43445. private _fovMultiplier;
  43446. /**
  43447. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43448. */
  43449. useEquirectangularFOV: boolean;
  43450. private _maxSimultaneousLights;
  43451. /**
  43452. * Number of Simultaneous lights allowed on the material.
  43453. */
  43454. maxSimultaneousLights: int;
  43455. /**
  43456. * Default configuration related to image processing available in the Background Material.
  43457. */
  43458. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43459. /**
  43460. * Keep track of the image processing observer to allow dispose and replace.
  43461. */
  43462. private _imageProcessingObserver;
  43463. /**
  43464. * Attaches a new image processing configuration to the PBR Material.
  43465. * @param configuration (if null the scene configuration will be use)
  43466. */
  43467. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43468. /**
  43469. * Gets the image processing configuration used either in this material.
  43470. */
  43471. /**
  43472. * Sets the Default image processing configuration used either in the this material.
  43473. *
  43474. * If sets to null, the scene one is in use.
  43475. */
  43476. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43477. /**
  43478. * Gets wether the color curves effect is enabled.
  43479. */
  43480. /**
  43481. * Sets wether the color curves effect is enabled.
  43482. */
  43483. cameraColorCurvesEnabled: boolean;
  43484. /**
  43485. * Gets wether the color grading effect is enabled.
  43486. */
  43487. /**
  43488. * Gets wether the color grading effect is enabled.
  43489. */
  43490. cameraColorGradingEnabled: boolean;
  43491. /**
  43492. * Gets wether tonemapping is enabled or not.
  43493. */
  43494. /**
  43495. * Sets wether tonemapping is enabled or not
  43496. */
  43497. cameraToneMappingEnabled: boolean;
  43498. /**
  43499. * The camera exposure used on this material.
  43500. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43501. * This corresponds to a photographic exposure.
  43502. */
  43503. /**
  43504. * The camera exposure used on this material.
  43505. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43506. * This corresponds to a photographic exposure.
  43507. */
  43508. cameraExposure: float;
  43509. /**
  43510. * Gets The camera contrast used on this material.
  43511. */
  43512. /**
  43513. * Sets The camera contrast used on this material.
  43514. */
  43515. cameraContrast: float;
  43516. /**
  43517. * Gets the Color Grading 2D Lookup Texture.
  43518. */
  43519. /**
  43520. * Sets the Color Grading 2D Lookup Texture.
  43521. */
  43522. cameraColorGradingTexture: Nullable<BaseTexture>;
  43523. /**
  43524. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43525. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43526. * 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;
  43527. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43528. */
  43529. /**
  43530. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43531. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43532. * 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;
  43533. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43534. */
  43535. cameraColorCurves: Nullable<ColorCurves>;
  43536. /**
  43537. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43538. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43539. */
  43540. switchToBGR: boolean;
  43541. private _renderTargets;
  43542. private _reflectionControls;
  43543. private _white;
  43544. private _primaryShadowColor;
  43545. private _primaryHighlightColor;
  43546. /**
  43547. * Instantiates a Background Material in the given scene
  43548. * @param name The friendly name of the material
  43549. * @param scene The scene to add the material to
  43550. */
  43551. constructor(name: string, scene: Scene);
  43552. /**
  43553. * Gets a boolean indicating that current material needs to register RTT
  43554. */
  43555. readonly hasRenderTargetTextures: boolean;
  43556. /**
  43557. * The entire material has been created in order to prevent overdraw.
  43558. * @returns false
  43559. */
  43560. needAlphaTesting(): boolean;
  43561. /**
  43562. * The entire material has been created in order to prevent overdraw.
  43563. * @returns true if blending is enable
  43564. */
  43565. needAlphaBlending(): boolean;
  43566. /**
  43567. * Checks wether the material is ready to be rendered for a given mesh.
  43568. * @param mesh The mesh to render
  43569. * @param subMesh The submesh to check against
  43570. * @param useInstances Specify wether or not the material is used with instances
  43571. * @returns true if all the dependencies are ready (Textures, Effects...)
  43572. */
  43573. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43574. /**
  43575. * Compute the primary color according to the chosen perceptual color.
  43576. */
  43577. private _computePrimaryColorFromPerceptualColor;
  43578. /**
  43579. * Compute the highlights and shadow colors according to their chosen levels.
  43580. */
  43581. private _computePrimaryColors;
  43582. /**
  43583. * Build the uniform buffer used in the material.
  43584. */
  43585. buildUniformLayout(): void;
  43586. /**
  43587. * Unbind the material.
  43588. */
  43589. unbind(): void;
  43590. /**
  43591. * Bind only the world matrix to the material.
  43592. * @param world The world matrix to bind.
  43593. */
  43594. bindOnlyWorldMatrix(world: Matrix): void;
  43595. /**
  43596. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43597. * @param world The world matrix to bind.
  43598. * @param subMesh The submesh to bind for.
  43599. */
  43600. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43601. /**
  43602. * Dispose the material.
  43603. * @param forceDisposeEffect Force disposal of the associated effect.
  43604. * @param forceDisposeTextures Force disposal of the associated textures.
  43605. */
  43606. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43607. /**
  43608. * Clones the material.
  43609. * @param name The cloned name.
  43610. * @returns The cloned material.
  43611. */
  43612. clone(name: string): BackgroundMaterial;
  43613. /**
  43614. * Serializes the current material to its JSON representation.
  43615. * @returns The JSON representation.
  43616. */
  43617. serialize(): any;
  43618. /**
  43619. * Gets the class name of the material
  43620. * @returns "BackgroundMaterial"
  43621. */
  43622. getClassName(): string;
  43623. /**
  43624. * Parse a JSON input to create back a background material.
  43625. * @param source The JSON data to parse
  43626. * @param scene The scene to create the parsed material in
  43627. * @param rootUrl The root url of the assets the material depends upon
  43628. * @returns the instantiated BackgroundMaterial.
  43629. */
  43630. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43631. }
  43632. }
  43633. declare module BABYLON {
  43634. /**
  43635. * Represents the different options available during the creation of
  43636. * a Environment helper.
  43637. *
  43638. * This can control the default ground, skybox and image processing setup of your scene.
  43639. */
  43640. export interface IEnvironmentHelperOptions {
  43641. /**
  43642. * Specifies wether or not to create a ground.
  43643. * True by default.
  43644. */
  43645. createGround: boolean;
  43646. /**
  43647. * Specifies the ground size.
  43648. * 15 by default.
  43649. */
  43650. groundSize: number;
  43651. /**
  43652. * The texture used on the ground for the main color.
  43653. * Comes from the BabylonJS CDN by default.
  43654. *
  43655. * Remarks: Can be either a texture or a url.
  43656. */
  43657. groundTexture: string | BaseTexture;
  43658. /**
  43659. * The color mixed in the ground texture by default.
  43660. * BabylonJS clearColor by default.
  43661. */
  43662. groundColor: Color3;
  43663. /**
  43664. * Specifies the ground opacity.
  43665. * 1 by default.
  43666. */
  43667. groundOpacity: number;
  43668. /**
  43669. * Enables the ground to receive shadows.
  43670. * True by default.
  43671. */
  43672. enableGroundShadow: boolean;
  43673. /**
  43674. * Helps preventing the shadow to be fully black on the ground.
  43675. * 0.5 by default.
  43676. */
  43677. groundShadowLevel: number;
  43678. /**
  43679. * Creates a mirror texture attach to the ground.
  43680. * false by default.
  43681. */
  43682. enableGroundMirror: boolean;
  43683. /**
  43684. * Specifies the ground mirror size ratio.
  43685. * 0.3 by default as the default kernel is 64.
  43686. */
  43687. groundMirrorSizeRatio: number;
  43688. /**
  43689. * Specifies the ground mirror blur kernel size.
  43690. * 64 by default.
  43691. */
  43692. groundMirrorBlurKernel: number;
  43693. /**
  43694. * Specifies the ground mirror visibility amount.
  43695. * 1 by default
  43696. */
  43697. groundMirrorAmount: number;
  43698. /**
  43699. * Specifies the ground mirror reflectance weight.
  43700. * This uses the standard weight of the background material to setup the fresnel effect
  43701. * of the mirror.
  43702. * 1 by default.
  43703. */
  43704. groundMirrorFresnelWeight: number;
  43705. /**
  43706. * Specifies the ground mirror Falloff distance.
  43707. * This can helps reducing the size of the reflection.
  43708. * 0 by Default.
  43709. */
  43710. groundMirrorFallOffDistance: number;
  43711. /**
  43712. * Specifies the ground mirror texture type.
  43713. * Unsigned Int by Default.
  43714. */
  43715. groundMirrorTextureType: number;
  43716. /**
  43717. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43718. * the shown objects.
  43719. */
  43720. groundYBias: number;
  43721. /**
  43722. * Specifies wether or not to create a skybox.
  43723. * True by default.
  43724. */
  43725. createSkybox: boolean;
  43726. /**
  43727. * Specifies the skybox size.
  43728. * 20 by default.
  43729. */
  43730. skyboxSize: number;
  43731. /**
  43732. * The texture used on the skybox for the main color.
  43733. * Comes from the BabylonJS CDN by default.
  43734. *
  43735. * Remarks: Can be either a texture or a url.
  43736. */
  43737. skyboxTexture: string | BaseTexture;
  43738. /**
  43739. * The color mixed in the skybox texture by default.
  43740. * BabylonJS clearColor by default.
  43741. */
  43742. skyboxColor: Color3;
  43743. /**
  43744. * The background rotation around the Y axis of the scene.
  43745. * This helps aligning the key lights of your scene with the background.
  43746. * 0 by default.
  43747. */
  43748. backgroundYRotation: number;
  43749. /**
  43750. * Compute automatically the size of the elements to best fit with the scene.
  43751. */
  43752. sizeAuto: boolean;
  43753. /**
  43754. * Default position of the rootMesh if autoSize is not true.
  43755. */
  43756. rootPosition: Vector3;
  43757. /**
  43758. * Sets up the image processing in the scene.
  43759. * true by default.
  43760. */
  43761. setupImageProcessing: boolean;
  43762. /**
  43763. * The texture used as your environment texture in the scene.
  43764. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43765. *
  43766. * Remarks: Can be either a texture or a url.
  43767. */
  43768. environmentTexture: string | BaseTexture;
  43769. /**
  43770. * The value of the exposure to apply to the scene.
  43771. * 0.6 by default if setupImageProcessing is true.
  43772. */
  43773. cameraExposure: number;
  43774. /**
  43775. * The value of the contrast to apply to the scene.
  43776. * 1.6 by default if setupImageProcessing is true.
  43777. */
  43778. cameraContrast: number;
  43779. /**
  43780. * Specifies wether or not tonemapping should be enabled in the scene.
  43781. * true by default if setupImageProcessing is true.
  43782. */
  43783. toneMappingEnabled: boolean;
  43784. }
  43785. /**
  43786. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43787. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43788. * It also helps with the default setup of your imageProcessing configuration.
  43789. */
  43790. export class EnvironmentHelper {
  43791. /**
  43792. * Default ground texture URL.
  43793. */
  43794. private static _groundTextureCDNUrl;
  43795. /**
  43796. * Default skybox texture URL.
  43797. */
  43798. private static _skyboxTextureCDNUrl;
  43799. /**
  43800. * Default environment texture URL.
  43801. */
  43802. private static _environmentTextureCDNUrl;
  43803. /**
  43804. * Creates the default options for the helper.
  43805. */
  43806. private static _getDefaultOptions;
  43807. private _rootMesh;
  43808. /**
  43809. * Gets the root mesh created by the helper.
  43810. */
  43811. readonly rootMesh: Mesh;
  43812. private _skybox;
  43813. /**
  43814. * Gets the skybox created by the helper.
  43815. */
  43816. readonly skybox: Nullable<Mesh>;
  43817. private _skyboxTexture;
  43818. /**
  43819. * Gets the skybox texture created by the helper.
  43820. */
  43821. readonly skyboxTexture: Nullable<BaseTexture>;
  43822. private _skyboxMaterial;
  43823. /**
  43824. * Gets the skybox material created by the helper.
  43825. */
  43826. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43827. private _ground;
  43828. /**
  43829. * Gets the ground mesh created by the helper.
  43830. */
  43831. readonly ground: Nullable<Mesh>;
  43832. private _groundTexture;
  43833. /**
  43834. * Gets the ground texture created by the helper.
  43835. */
  43836. readonly groundTexture: Nullable<BaseTexture>;
  43837. private _groundMirror;
  43838. /**
  43839. * Gets the ground mirror created by the helper.
  43840. */
  43841. readonly groundMirror: Nullable<MirrorTexture>;
  43842. /**
  43843. * Gets the ground mirror render list to helps pushing the meshes
  43844. * you wish in the ground reflection.
  43845. */
  43846. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43847. private _groundMaterial;
  43848. /**
  43849. * Gets the ground material created by the helper.
  43850. */
  43851. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43852. /**
  43853. * Stores the creation options.
  43854. */
  43855. private readonly _scene;
  43856. private _options;
  43857. /**
  43858. * This observable will be notified with any error during the creation of the environment,
  43859. * mainly texture creation errors.
  43860. */
  43861. onErrorObservable: Observable<{
  43862. message?: string;
  43863. exception?: any;
  43864. }>;
  43865. /**
  43866. * constructor
  43867. * @param options Defines the options we want to customize the helper
  43868. * @param scene The scene to add the material to
  43869. */
  43870. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43871. /**
  43872. * Updates the background according to the new options
  43873. * @param options
  43874. */
  43875. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43876. /**
  43877. * Sets the primary color of all the available elements.
  43878. * @param color the main color to affect to the ground and the background
  43879. */
  43880. setMainColor(color: Color3): void;
  43881. /**
  43882. * Setup the image processing according to the specified options.
  43883. */
  43884. private _setupImageProcessing;
  43885. /**
  43886. * Setup the environment texture according to the specified options.
  43887. */
  43888. private _setupEnvironmentTexture;
  43889. /**
  43890. * Setup the background according to the specified options.
  43891. */
  43892. private _setupBackground;
  43893. /**
  43894. * Get the scene sizes according to the setup.
  43895. */
  43896. private _getSceneSize;
  43897. /**
  43898. * Setup the ground according to the specified options.
  43899. */
  43900. private _setupGround;
  43901. /**
  43902. * Setup the ground material according to the specified options.
  43903. */
  43904. private _setupGroundMaterial;
  43905. /**
  43906. * Setup the ground diffuse texture according to the specified options.
  43907. */
  43908. private _setupGroundDiffuseTexture;
  43909. /**
  43910. * Setup the ground mirror texture according to the specified options.
  43911. */
  43912. private _setupGroundMirrorTexture;
  43913. /**
  43914. * Setup the ground to receive the mirror texture.
  43915. */
  43916. private _setupMirrorInGroundMaterial;
  43917. /**
  43918. * Setup the skybox according to the specified options.
  43919. */
  43920. private _setupSkybox;
  43921. /**
  43922. * Setup the skybox material according to the specified options.
  43923. */
  43924. private _setupSkyboxMaterial;
  43925. /**
  43926. * Setup the skybox reflection texture according to the specified options.
  43927. */
  43928. private _setupSkyboxReflectionTexture;
  43929. private _errorHandler;
  43930. /**
  43931. * Dispose all the elements created by the Helper.
  43932. */
  43933. dispose(): void;
  43934. }
  43935. }
  43936. declare module BABYLON {
  43937. /**
  43938. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43939. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43940. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43941. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43942. */
  43943. export class PhotoDome extends TransformNode {
  43944. private _useDirectMapping;
  43945. /**
  43946. * The texture being displayed on the sphere
  43947. */
  43948. protected _photoTexture: Texture;
  43949. /**
  43950. * Gets or sets the texture being displayed on the sphere
  43951. */
  43952. photoTexture: Texture;
  43953. /**
  43954. * Observable raised when an error occured while loading the 360 image
  43955. */
  43956. onLoadErrorObservable: Observable<string>;
  43957. /**
  43958. * The skybox material
  43959. */
  43960. protected _material: BackgroundMaterial;
  43961. /**
  43962. * The surface used for the skybox
  43963. */
  43964. protected _mesh: Mesh;
  43965. /**
  43966. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43967. * Also see the options.resolution property.
  43968. */
  43969. fovMultiplier: number;
  43970. /**
  43971. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43972. * @param name Element's name, child elements will append suffixes for their own names.
  43973. * @param urlsOfPhoto defines the url of the photo to display
  43974. * @param options defines an object containing optional or exposed sub element properties
  43975. * @param onError defines a callback called when an error occured while loading the texture
  43976. */
  43977. constructor(name: string, urlOfPhoto: string, options: {
  43978. resolution?: number;
  43979. size?: number;
  43980. useDirectMapping?: boolean;
  43981. faceForward?: boolean;
  43982. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43983. /**
  43984. * Releases resources associated with this node.
  43985. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43986. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43987. */
  43988. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43989. }
  43990. }
  43991. declare module BABYLON {
  43992. /** @hidden */
  43993. export var rgbdDecodePixelShader: {
  43994. name: string;
  43995. shader: string;
  43996. };
  43997. }
  43998. declare module BABYLON {
  43999. /**
  44000. * Class used to host texture specific utilities
  44001. */
  44002. export class BRDFTextureTools {
  44003. /**
  44004. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  44005. * @param texture the texture to expand.
  44006. */
  44007. private static _ExpandDefaultBRDFTexture;
  44008. /**
  44009. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44010. * @param scene defines the hosting scene
  44011. * @returns the environment BRDF texture
  44012. */
  44013. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44014. private static _environmentBRDFBase64Texture;
  44015. }
  44016. }
  44017. declare module BABYLON {
  44018. /**
  44019. * @hidden
  44020. */
  44021. export interface IMaterialClearCoatDefines {
  44022. CLEARCOAT: boolean;
  44023. CLEARCOAT_DEFAULTIOR: boolean;
  44024. CLEARCOAT_TEXTURE: boolean;
  44025. CLEARCOAT_TEXTUREDIRECTUV: number;
  44026. CLEARCOAT_BUMP: boolean;
  44027. CLEARCOAT_BUMPDIRECTUV: number;
  44028. CLEARCOAT_TINT: boolean;
  44029. CLEARCOAT_TINT_TEXTURE: boolean;
  44030. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44031. /** @hidden */
  44032. _areTexturesDirty: boolean;
  44033. }
  44034. /**
  44035. * Define the code related to the clear coat parameters of the pbr material.
  44036. */
  44037. export class PBRClearCoatConfiguration {
  44038. /**
  44039. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44040. * The default fits with a polyurethane material.
  44041. */
  44042. private static readonly _DefaultIndiceOfRefraction;
  44043. private _isEnabled;
  44044. /**
  44045. * Defines if the clear coat is enabled in the material.
  44046. */
  44047. isEnabled: boolean;
  44048. /**
  44049. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44050. */
  44051. intensity: number;
  44052. /**
  44053. * Defines the clear coat layer roughness.
  44054. */
  44055. roughness: number;
  44056. private _indiceOfRefraction;
  44057. /**
  44058. * Defines the indice of refraction of the clear coat.
  44059. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44060. * The default fits with a polyurethane material.
  44061. * Changing the default value is more performance intensive.
  44062. */
  44063. indiceOfRefraction: number;
  44064. private _texture;
  44065. /**
  44066. * Stores the clear coat values in a texture.
  44067. */
  44068. texture: Nullable<BaseTexture>;
  44069. private _bumpTexture;
  44070. /**
  44071. * Define the clear coat specific bump texture.
  44072. */
  44073. bumpTexture: Nullable<BaseTexture>;
  44074. private _isTintEnabled;
  44075. /**
  44076. * Defines if the clear coat tint is enabled in the material.
  44077. */
  44078. isTintEnabled: boolean;
  44079. /**
  44080. * Defines the clear coat tint of the material.
  44081. * This is only use if tint is enabled
  44082. */
  44083. tintColor: Color3;
  44084. /**
  44085. * Defines the distance at which the tint color should be found in the
  44086. * clear coat media.
  44087. * This is only use if tint is enabled
  44088. */
  44089. tintColorAtDistance: number;
  44090. /**
  44091. * Defines the clear coat layer thickness.
  44092. * This is only use if tint is enabled
  44093. */
  44094. tintThickness: number;
  44095. private _tintTexture;
  44096. /**
  44097. * Stores the clear tint values in a texture.
  44098. * rgb is tint
  44099. * a is a thickness factor
  44100. */
  44101. tintTexture: Nullable<BaseTexture>;
  44102. /** @hidden */
  44103. private _internalMarkAllSubMeshesAsTexturesDirty;
  44104. /** @hidden */
  44105. _markAllSubMeshesAsTexturesDirty(): void;
  44106. /**
  44107. * Instantiate a new istance of clear coat configuration.
  44108. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44109. */
  44110. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44111. /**
  44112. * Gets wehter the submesh is ready to be used or not.
  44113. * @param defines the list of "defines" to update.
  44114. * @param scene defines the scene the material belongs to.
  44115. * @param engine defines the engine the material belongs to.
  44116. * @param disableBumpMap defines wether the material disables bump or not.
  44117. * @returns - boolean indicating that the submesh is ready or not.
  44118. */
  44119. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44120. /**
  44121. * Checks to see if a texture is used in the material.
  44122. * @param defines the list of "defines" to update.
  44123. * @param scene defines the scene to the material belongs to.
  44124. */
  44125. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44126. /**
  44127. * Binds the material data.
  44128. * @param uniformBuffer defines the Uniform buffer to fill in.
  44129. * @param scene defines the scene the material belongs to.
  44130. * @param engine defines the engine the material belongs to.
  44131. * @param disableBumpMap defines wether the material disables bump or not.
  44132. * @param isFrozen defines wether the material is frozen or not.
  44133. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44134. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44135. */
  44136. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44137. /**
  44138. * Checks to see if a texture is used in the material.
  44139. * @param texture - Base texture to use.
  44140. * @returns - Boolean specifying if a texture is used in the material.
  44141. */
  44142. hasTexture(texture: BaseTexture): boolean;
  44143. /**
  44144. * Returns an array of the actively used textures.
  44145. * @param activeTextures Array of BaseTextures
  44146. */
  44147. getActiveTextures(activeTextures: BaseTexture[]): void;
  44148. /**
  44149. * Returns the animatable textures.
  44150. * @param animatables Array of animatable textures.
  44151. */
  44152. getAnimatables(animatables: IAnimatable[]): void;
  44153. /**
  44154. * Disposes the resources of the material.
  44155. * @param forceDisposeTextures - Forces the disposal of all textures.
  44156. */
  44157. dispose(forceDisposeTextures?: boolean): void;
  44158. /**
  44159. * Get the current class name of the texture useful for serialization or dynamic coding.
  44160. * @returns "PBRClearCoatConfiguration"
  44161. */
  44162. getClassName(): string;
  44163. /**
  44164. * Add fallbacks to the effect fallbacks list.
  44165. * @param defines defines the Base texture to use.
  44166. * @param fallbacks defines the current fallback list.
  44167. * @param currentRank defines the current fallback rank.
  44168. * @returns the new fallback rank.
  44169. */
  44170. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44171. /**
  44172. * Add the required uniforms to the current list.
  44173. * @param uniforms defines the current uniform list.
  44174. */
  44175. static AddUniforms(uniforms: string[]): void;
  44176. /**
  44177. * Add the required samplers to the current list.
  44178. * @param samplers defines the current sampler list.
  44179. */
  44180. static AddSamplers(samplers: string[]): void;
  44181. /**
  44182. * Add the required uniforms to the current buffer.
  44183. * @param uniformBuffer defines the current uniform buffer.
  44184. */
  44185. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44186. /**
  44187. * Makes a duplicate of the current configuration into another one.
  44188. * @param clearCoatConfiguration define the config where to copy the info
  44189. */
  44190. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44191. /**
  44192. * Serializes this clear coat configuration.
  44193. * @returns - An object with the serialized config.
  44194. */
  44195. serialize(): any;
  44196. /**
  44197. * Parses a Clear Coat Configuration from a serialized object.
  44198. * @param source - Serialized object.
  44199. */
  44200. parse(source: any): void;
  44201. }
  44202. }
  44203. declare module BABYLON {
  44204. /**
  44205. * @hidden
  44206. */
  44207. export interface IMaterialAnisotropicDefines {
  44208. ANISOTROPIC: boolean;
  44209. ANISOTROPIC_TEXTURE: boolean;
  44210. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44211. MAINUV1: boolean;
  44212. _areTexturesDirty: boolean;
  44213. _needUVs: boolean;
  44214. }
  44215. /**
  44216. * Define the code related to the anisotropic parameters of the pbr material.
  44217. */
  44218. export class PBRAnisotropicConfiguration {
  44219. private _isEnabled;
  44220. /**
  44221. * Defines if the anisotropy is enabled in the material.
  44222. */
  44223. isEnabled: boolean;
  44224. /**
  44225. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44226. */
  44227. intensity: number;
  44228. /**
  44229. * Defines if the effect is along the tangents, bitangents or in between.
  44230. * By default, the effect is "strectching" the highlights along the tangents.
  44231. */
  44232. direction: Vector2;
  44233. private _texture;
  44234. /**
  44235. * Stores the anisotropy values in a texture.
  44236. * rg is direction (like normal from -1 to 1)
  44237. * b is a intensity
  44238. */
  44239. texture: Nullable<BaseTexture>;
  44240. /** @hidden */
  44241. private _internalMarkAllSubMeshesAsTexturesDirty;
  44242. /** @hidden */
  44243. _markAllSubMeshesAsTexturesDirty(): void;
  44244. /**
  44245. * Instantiate a new istance of anisotropy configuration.
  44246. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44247. */
  44248. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44249. /**
  44250. * Specifies that the submesh is ready to be used.
  44251. * @param defines the list of "defines" to update.
  44252. * @param scene defines the scene the material belongs to.
  44253. * @returns - boolean indicating that the submesh is ready or not.
  44254. */
  44255. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44256. /**
  44257. * Checks to see if a texture is used in the material.
  44258. * @param defines the list of "defines" to update.
  44259. * @param mesh the mesh we are preparing the defines for.
  44260. * @param scene defines the scene the material belongs to.
  44261. */
  44262. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44263. /**
  44264. * Binds the material data.
  44265. * @param uniformBuffer defines the Uniform buffer to fill in.
  44266. * @param scene defines the scene the material belongs to.
  44267. * @param isFrozen defines wether the material is frozen or not.
  44268. */
  44269. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44270. /**
  44271. * Checks to see if a texture is used in the material.
  44272. * @param texture - Base texture to use.
  44273. * @returns - Boolean specifying if a texture is used in the material.
  44274. */
  44275. hasTexture(texture: BaseTexture): boolean;
  44276. /**
  44277. * Returns an array of the actively used textures.
  44278. * @param activeTextures Array of BaseTextures
  44279. */
  44280. getActiveTextures(activeTextures: BaseTexture[]): void;
  44281. /**
  44282. * Returns the animatable textures.
  44283. * @param animatables Array of animatable textures.
  44284. */
  44285. getAnimatables(animatables: IAnimatable[]): void;
  44286. /**
  44287. * Disposes the resources of the material.
  44288. * @param forceDisposeTextures - Forces the disposal of all textures.
  44289. */
  44290. dispose(forceDisposeTextures?: boolean): void;
  44291. /**
  44292. * Get the current class name of the texture useful for serialization or dynamic coding.
  44293. * @returns "PBRAnisotropicConfiguration"
  44294. */
  44295. getClassName(): string;
  44296. /**
  44297. * Add fallbacks to the effect fallbacks list.
  44298. * @param defines defines the Base texture to use.
  44299. * @param fallbacks defines the current fallback list.
  44300. * @param currentRank defines the current fallback rank.
  44301. * @returns the new fallback rank.
  44302. */
  44303. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44304. /**
  44305. * Add the required uniforms to the current list.
  44306. * @param uniforms defines the current uniform list.
  44307. */
  44308. static AddUniforms(uniforms: string[]): void;
  44309. /**
  44310. * Add the required uniforms to the current buffer.
  44311. * @param uniformBuffer defines the current uniform buffer.
  44312. */
  44313. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44314. /**
  44315. * Add the required samplers to the current list.
  44316. * @param samplers defines the current sampler list.
  44317. */
  44318. static AddSamplers(samplers: string[]): void;
  44319. /**
  44320. * Makes a duplicate of the current configuration into another one.
  44321. * @param anisotropicConfiguration define the config where to copy the info
  44322. */
  44323. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44324. /**
  44325. * Serializes this anisotropy configuration.
  44326. * @returns - An object with the serialized config.
  44327. */
  44328. serialize(): any;
  44329. /**
  44330. * Parses a anisotropy Configuration from a serialized object.
  44331. * @param source - Serialized object.
  44332. */
  44333. parse(source: any): void;
  44334. }
  44335. }
  44336. declare module BABYLON {
  44337. /**
  44338. * @hidden
  44339. */
  44340. export interface IMaterialBRDFDefines {
  44341. BRDF_V_HEIGHT_CORRELATED: boolean;
  44342. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44343. SPHERICAL_HARMONICS: boolean;
  44344. /** @hidden */
  44345. _areMiscDirty: boolean;
  44346. }
  44347. /**
  44348. * Define the code related to the BRDF parameters of the pbr material.
  44349. */
  44350. export class PBRBRDFConfiguration {
  44351. /**
  44352. * Default value used for the energy conservation.
  44353. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44354. */
  44355. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  44356. /**
  44357. * Default value used for the Smith Visibility Height Correlated mode.
  44358. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44359. */
  44360. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  44361. /**
  44362. * Default value used for the IBL diffuse part.
  44363. * This can help switching back to the polynomials mode globally which is a tiny bit
  44364. * less GPU intensive at the drawback of a lower quality.
  44365. */
  44366. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  44367. private _useEnergyConservation;
  44368. /**
  44369. * Defines if the material uses energy conservation.
  44370. */
  44371. useEnergyConservation: boolean;
  44372. private _useSmithVisibilityHeightCorrelated;
  44373. /**
  44374. * LEGACY Mode set to false
  44375. * Defines if the material uses height smith correlated visibility term.
  44376. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44377. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44378. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44379. * Not relying on height correlated will also disable energy conservation.
  44380. */
  44381. useSmithVisibilityHeightCorrelated: boolean;
  44382. private _useSphericalHarmonics;
  44383. /**
  44384. * LEGACY Mode set to false
  44385. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  44386. * diffuse part of the IBL.
  44387. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  44388. * to the ground truth.
  44389. */
  44390. useSphericalHarmonics: boolean;
  44391. /** @hidden */
  44392. private _internalMarkAllSubMeshesAsMiscDirty;
  44393. /** @hidden */
  44394. _markAllSubMeshesAsMiscDirty(): void;
  44395. /**
  44396. * Instantiate a new istance of clear coat configuration.
  44397. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44398. */
  44399. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44400. /**
  44401. * Checks to see if a texture is used in the material.
  44402. * @param defines the list of "defines" to update.
  44403. */
  44404. prepareDefines(defines: IMaterialBRDFDefines): void;
  44405. /**
  44406. * Get the current class name of the texture useful for serialization or dynamic coding.
  44407. * @returns "PBRClearCoatConfiguration"
  44408. */
  44409. getClassName(): string;
  44410. /**
  44411. * Makes a duplicate of the current configuration into another one.
  44412. * @param brdfConfiguration define the config where to copy the info
  44413. */
  44414. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44415. /**
  44416. * Serializes this BRDF configuration.
  44417. * @returns - An object with the serialized config.
  44418. */
  44419. serialize(): any;
  44420. /**
  44421. * Parses a BRDF Configuration from a serialized object.
  44422. * @param source - Serialized object.
  44423. */
  44424. parse(source: any): void;
  44425. }
  44426. }
  44427. declare module BABYLON {
  44428. /**
  44429. * @hidden
  44430. */
  44431. export interface IMaterialSheenDefines {
  44432. SHEEN: boolean;
  44433. SHEEN_TEXTURE: boolean;
  44434. SHEEN_TEXTUREDIRECTUV: number;
  44435. SHEEN_LINKWITHALBEDO: boolean;
  44436. /** @hidden */
  44437. _areTexturesDirty: boolean;
  44438. }
  44439. /**
  44440. * Define the code related to the Sheen parameters of the pbr material.
  44441. */
  44442. export class PBRSheenConfiguration {
  44443. private _isEnabled;
  44444. /**
  44445. * Defines if the material uses sheen.
  44446. */
  44447. isEnabled: boolean;
  44448. private _linkSheenWithAlbedo;
  44449. /**
  44450. * Defines if the sheen is linked to the sheen color.
  44451. */
  44452. linkSheenWithAlbedo: boolean;
  44453. /**
  44454. * Defines the sheen intensity.
  44455. */
  44456. intensity: number;
  44457. /**
  44458. * Defines the sheen color.
  44459. */
  44460. color: Color3;
  44461. private _texture;
  44462. /**
  44463. * Stores the sheen tint values in a texture.
  44464. * rgb is tint
  44465. * a is a intensity
  44466. */
  44467. texture: Nullable<BaseTexture>;
  44468. /** @hidden */
  44469. private _internalMarkAllSubMeshesAsTexturesDirty;
  44470. /** @hidden */
  44471. _markAllSubMeshesAsTexturesDirty(): void;
  44472. /**
  44473. * Instantiate a new istance of clear coat configuration.
  44474. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44475. */
  44476. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44477. /**
  44478. * Specifies that the submesh is ready to be used.
  44479. * @param defines the list of "defines" to update.
  44480. * @param scene defines the scene the material belongs to.
  44481. * @returns - boolean indicating that the submesh is ready or not.
  44482. */
  44483. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44484. /**
  44485. * Checks to see if a texture is used in the material.
  44486. * @param defines the list of "defines" to update.
  44487. * @param scene defines the scene the material belongs to.
  44488. */
  44489. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44490. /**
  44491. * Binds the material data.
  44492. * @param uniformBuffer defines the Uniform buffer to fill in.
  44493. * @param scene defines the scene the material belongs to.
  44494. * @param isFrozen defines wether the material is frozen or not.
  44495. */
  44496. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44497. /**
  44498. * Checks to see if a texture is used in the material.
  44499. * @param texture - Base texture to use.
  44500. * @returns - Boolean specifying if a texture is used in the material.
  44501. */
  44502. hasTexture(texture: BaseTexture): boolean;
  44503. /**
  44504. * Returns an array of the actively used textures.
  44505. * @param activeTextures Array of BaseTextures
  44506. */
  44507. getActiveTextures(activeTextures: BaseTexture[]): void;
  44508. /**
  44509. * Returns the animatable textures.
  44510. * @param animatables Array of animatable textures.
  44511. */
  44512. getAnimatables(animatables: IAnimatable[]): void;
  44513. /**
  44514. * Disposes the resources of the material.
  44515. * @param forceDisposeTextures - Forces the disposal of all textures.
  44516. */
  44517. dispose(forceDisposeTextures?: boolean): void;
  44518. /**
  44519. * Get the current class name of the texture useful for serialization or dynamic coding.
  44520. * @returns "PBRSheenConfiguration"
  44521. */
  44522. getClassName(): string;
  44523. /**
  44524. * Add fallbacks to the effect fallbacks list.
  44525. * @param defines defines the Base texture to use.
  44526. * @param fallbacks defines the current fallback list.
  44527. * @param currentRank defines the current fallback rank.
  44528. * @returns the new fallback rank.
  44529. */
  44530. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44531. /**
  44532. * Add the required uniforms to the current list.
  44533. * @param uniforms defines the current uniform list.
  44534. */
  44535. static AddUniforms(uniforms: string[]): void;
  44536. /**
  44537. * Add the required uniforms to the current buffer.
  44538. * @param uniformBuffer defines the current uniform buffer.
  44539. */
  44540. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44541. /**
  44542. * Add the required samplers to the current list.
  44543. * @param samplers defines the current sampler list.
  44544. */
  44545. static AddSamplers(samplers: string[]): void;
  44546. /**
  44547. * Makes a duplicate of the current configuration into another one.
  44548. * @param sheenConfiguration define the config where to copy the info
  44549. */
  44550. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44551. /**
  44552. * Serializes this BRDF configuration.
  44553. * @returns - An object with the serialized config.
  44554. */
  44555. serialize(): any;
  44556. /**
  44557. * Parses a Sheen Configuration from a serialized object.
  44558. * @param source - Serialized object.
  44559. */
  44560. parse(source: any): void;
  44561. }
  44562. }
  44563. declare module BABYLON {
  44564. /**
  44565. * @hidden
  44566. */
  44567. export interface IMaterialSubSurfaceDefines {
  44568. SUBSURFACE: boolean;
  44569. SS_REFRACTION: boolean;
  44570. SS_TRANSLUCENCY: boolean;
  44571. SS_SCATERRING: boolean;
  44572. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44573. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44574. SS_REFRACTIONMAP_3D: boolean;
  44575. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44576. SS_LODINREFRACTIONALPHA: boolean;
  44577. SS_GAMMAREFRACTION: boolean;
  44578. SS_RGBDREFRACTION: boolean;
  44579. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44580. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44581. /** @hidden */
  44582. _areTexturesDirty: boolean;
  44583. }
  44584. /**
  44585. * Define the code related to the sub surface parameters of the pbr material.
  44586. */
  44587. export class PBRSubSurfaceConfiguration {
  44588. private _isRefractionEnabled;
  44589. /**
  44590. * Defines if the refraction is enabled in the material.
  44591. */
  44592. isRefractionEnabled: boolean;
  44593. private _isTranslucencyEnabled;
  44594. /**
  44595. * Defines if the translucency is enabled in the material.
  44596. */
  44597. isTranslucencyEnabled: boolean;
  44598. private _isScatteringEnabled;
  44599. /**
  44600. * Defines the refraction intensity of the material.
  44601. * The refraction when enabled replaces the Diffuse part of the material.
  44602. * The intensity helps transitionning between diffuse and refraction.
  44603. */
  44604. refractionIntensity: number;
  44605. /**
  44606. * Defines the translucency intensity of the material.
  44607. * When translucency has been enabled, this defines how much of the "translucency"
  44608. * is addded to the diffuse part of the material.
  44609. */
  44610. translucencyIntensity: number;
  44611. /**
  44612. * Defines the scattering intensity of the material.
  44613. * When scattering has been enabled, this defines how much of the "scattered light"
  44614. * is addded to the diffuse part of the material.
  44615. */
  44616. scatteringIntensity: number;
  44617. private _thicknessTexture;
  44618. /**
  44619. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  44620. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  44621. * 0 would mean minimumThickness
  44622. * 1 would mean maximumThickness
  44623. * The other channels might be use as a mask to vary the different effects intensity.
  44624. */
  44625. thicknessTexture: Nullable<BaseTexture>;
  44626. private _refractionTexture;
  44627. /**
  44628. * Defines the texture to use for refraction.
  44629. */
  44630. refractionTexture: Nullable<BaseTexture>;
  44631. private _indexOfRefraction;
  44632. /**
  44633. * Defines the indice of refraction used in the material.
  44634. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  44635. */
  44636. indexOfRefraction: number;
  44637. private _invertRefractionY;
  44638. /**
  44639. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44640. */
  44641. invertRefractionY: boolean;
  44642. private _linkRefractionWithTransparency;
  44643. /**
  44644. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44645. * Materials half opaque for instance using refraction could benefit from this control.
  44646. */
  44647. linkRefractionWithTransparency: boolean;
  44648. /**
  44649. * Defines the minimum thickness stored in the thickness map.
  44650. * If no thickness map is defined, this value will be used to simulate thickness.
  44651. */
  44652. minimumThickness: number;
  44653. /**
  44654. * Defines the maximum thickness stored in the thickness map.
  44655. */
  44656. maximumThickness: number;
  44657. /**
  44658. * Defines the volume tint of the material.
  44659. * This is used for both translucency and scattering.
  44660. */
  44661. tintColor: Color3;
  44662. /**
  44663. * Defines the distance at which the tint color should be found in the media.
  44664. * This is used for refraction only.
  44665. */
  44666. tintColorAtDistance: number;
  44667. /**
  44668. * Defines how far each channel transmit through the media.
  44669. * It is defined as a color to simplify it selection.
  44670. */
  44671. diffusionDistance: Color3;
  44672. private _useMaskFromThicknessTexture;
  44673. /**
  44674. * Stores the intensity of the different subsurface effects in the thickness texture.
  44675. * * the green channel is the translucency intensity.
  44676. * * the blue channel is the scattering intensity.
  44677. * * the alpha channel is the refraction intensity.
  44678. */
  44679. useMaskFromThicknessTexture: boolean;
  44680. /** @hidden */
  44681. private _internalMarkAllSubMeshesAsTexturesDirty;
  44682. /** @hidden */
  44683. _markAllSubMeshesAsTexturesDirty(): void;
  44684. /**
  44685. * Instantiate a new istance of sub surface configuration.
  44686. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44687. */
  44688. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44689. /**
  44690. * Gets wehter the submesh is ready to be used or not.
  44691. * @param defines the list of "defines" to update.
  44692. * @param scene defines the scene the material belongs to.
  44693. * @returns - boolean indicating that the submesh is ready or not.
  44694. */
  44695. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  44696. /**
  44697. * Checks to see if a texture is used in the material.
  44698. * @param defines the list of "defines" to update.
  44699. * @param scene defines the scene to the material belongs to.
  44700. */
  44701. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  44702. /**
  44703. * Binds the material data.
  44704. * @param uniformBuffer defines the Uniform buffer to fill in.
  44705. * @param scene defines the scene the material belongs to.
  44706. * @param engine defines the engine the material belongs to.
  44707. * @param isFrozen defines wether the material is frozen or not.
  44708. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  44709. */
  44710. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  44711. /**
  44712. * Unbinds the material from the mesh.
  44713. * @param activeEffect defines the effect that should be unbound from.
  44714. * @returns true if unbound, otherwise false
  44715. */
  44716. unbind(activeEffect: Effect): boolean;
  44717. /**
  44718. * Returns the texture used for refraction or null if none is used.
  44719. * @param scene defines the scene the material belongs to.
  44720. * @returns - Refraction texture if present. If no refraction texture and refraction
  44721. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44722. */
  44723. private _getRefractionTexture;
  44724. /**
  44725. * Returns true if alpha blending should be disabled.
  44726. */
  44727. readonly disableAlphaBlending: boolean;
  44728. /**
  44729. * Fills the list of render target textures.
  44730. * @param renderTargets the list of render targets to update
  44731. */
  44732. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  44733. /**
  44734. * Checks to see if a texture is used in the material.
  44735. * @param texture - Base texture to use.
  44736. * @returns - Boolean specifying if a texture is used in the material.
  44737. */
  44738. hasTexture(texture: BaseTexture): boolean;
  44739. /**
  44740. * Gets a boolean indicating that current material needs to register RTT
  44741. * @returns true if this uses a render target otherwise false.
  44742. */
  44743. hasRenderTargetTextures(): boolean;
  44744. /**
  44745. * Returns an array of the actively used textures.
  44746. * @param activeTextures Array of BaseTextures
  44747. */
  44748. getActiveTextures(activeTextures: BaseTexture[]): void;
  44749. /**
  44750. * Returns the animatable textures.
  44751. * @param animatables Array of animatable textures.
  44752. */
  44753. getAnimatables(animatables: IAnimatable[]): void;
  44754. /**
  44755. * Disposes the resources of the material.
  44756. * @param forceDisposeTextures - Forces the disposal of all textures.
  44757. */
  44758. dispose(forceDisposeTextures?: boolean): void;
  44759. /**
  44760. * Get the current class name of the texture useful for serialization or dynamic coding.
  44761. * @returns "PBRSubSurfaceConfiguration"
  44762. */
  44763. getClassName(): string;
  44764. /**
  44765. * Add fallbacks to the effect fallbacks list.
  44766. * @param defines defines the Base texture to use.
  44767. * @param fallbacks defines the current fallback list.
  44768. * @param currentRank defines the current fallback rank.
  44769. * @returns the new fallback rank.
  44770. */
  44771. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44772. /**
  44773. * Add the required uniforms to the current list.
  44774. * @param uniforms defines the current uniform list.
  44775. */
  44776. static AddUniforms(uniforms: string[]): void;
  44777. /**
  44778. * Add the required samplers to the current list.
  44779. * @param samplers defines the current sampler list.
  44780. */
  44781. static AddSamplers(samplers: string[]): void;
  44782. /**
  44783. * Add the required uniforms to the current buffer.
  44784. * @param uniformBuffer defines the current uniform buffer.
  44785. */
  44786. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44787. /**
  44788. * Makes a duplicate of the current configuration into another one.
  44789. * @param configuration define the config where to copy the info
  44790. */
  44791. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  44792. /**
  44793. * Serializes this Sub Surface configuration.
  44794. * @returns - An object with the serialized config.
  44795. */
  44796. serialize(): any;
  44797. /**
  44798. * Parses a Sub Surface Configuration from a serialized object.
  44799. * @param source - Serialized object.
  44800. */
  44801. parse(source: any): void;
  44802. }
  44803. }
  44804. declare module BABYLON {
  44805. /** @hidden */
  44806. export var pbrFragmentDeclaration: {
  44807. name: string;
  44808. shader: string;
  44809. };
  44810. }
  44811. declare module BABYLON {
  44812. /** @hidden */
  44813. export var pbrUboDeclaration: {
  44814. name: string;
  44815. shader: string;
  44816. };
  44817. }
  44818. declare module BABYLON {
  44819. /** @hidden */
  44820. export var pbrFragmentExtraDeclaration: {
  44821. name: string;
  44822. shader: string;
  44823. };
  44824. }
  44825. declare module BABYLON {
  44826. /** @hidden */
  44827. export var pbrFragmentSamplersDeclaration: {
  44828. name: string;
  44829. shader: string;
  44830. };
  44831. }
  44832. declare module BABYLON {
  44833. /** @hidden */
  44834. export var pbrHelperFunctions: {
  44835. name: string;
  44836. shader: string;
  44837. };
  44838. }
  44839. declare module BABYLON {
  44840. /** @hidden */
  44841. export var harmonicsFunctions: {
  44842. name: string;
  44843. shader: string;
  44844. };
  44845. }
  44846. declare module BABYLON {
  44847. /** @hidden */
  44848. export var pbrDirectLightingSetupFunctions: {
  44849. name: string;
  44850. shader: string;
  44851. };
  44852. }
  44853. declare module BABYLON {
  44854. /** @hidden */
  44855. export var pbrDirectLightingFalloffFunctions: {
  44856. name: string;
  44857. shader: string;
  44858. };
  44859. }
  44860. declare module BABYLON {
  44861. /** @hidden */
  44862. export var pbrBRDFFunctions: {
  44863. name: string;
  44864. shader: string;
  44865. };
  44866. }
  44867. declare module BABYLON {
  44868. /** @hidden */
  44869. export var pbrDirectLightingFunctions: {
  44870. name: string;
  44871. shader: string;
  44872. };
  44873. }
  44874. declare module BABYLON {
  44875. /** @hidden */
  44876. export var pbrIBLFunctions: {
  44877. name: string;
  44878. shader: string;
  44879. };
  44880. }
  44881. declare module BABYLON {
  44882. /** @hidden */
  44883. export var pbrDebug: {
  44884. name: string;
  44885. shader: string;
  44886. };
  44887. }
  44888. declare module BABYLON {
  44889. /** @hidden */
  44890. export var pbrPixelShader: {
  44891. name: string;
  44892. shader: string;
  44893. };
  44894. }
  44895. declare module BABYLON {
  44896. /** @hidden */
  44897. export var pbrVertexDeclaration: {
  44898. name: string;
  44899. shader: string;
  44900. };
  44901. }
  44902. declare module BABYLON {
  44903. /** @hidden */
  44904. export var pbrVertexShader: {
  44905. name: string;
  44906. shader: string;
  44907. };
  44908. }
  44909. declare module BABYLON {
  44910. /**
  44911. * Manages the defines for the PBR Material.
  44912. * @hidden
  44913. */
  44914. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  44915. PBR: boolean;
  44916. MAINUV1: boolean;
  44917. MAINUV2: boolean;
  44918. UV1: boolean;
  44919. UV2: boolean;
  44920. ALBEDO: boolean;
  44921. ALBEDODIRECTUV: number;
  44922. VERTEXCOLOR: boolean;
  44923. AMBIENT: boolean;
  44924. AMBIENTDIRECTUV: number;
  44925. AMBIENTINGRAYSCALE: boolean;
  44926. OPACITY: boolean;
  44927. VERTEXALPHA: boolean;
  44928. OPACITYDIRECTUV: number;
  44929. OPACITYRGB: boolean;
  44930. ALPHATEST: boolean;
  44931. DEPTHPREPASS: boolean;
  44932. ALPHABLEND: boolean;
  44933. ALPHAFROMALBEDO: boolean;
  44934. ALPHATESTVALUE: string;
  44935. SPECULAROVERALPHA: boolean;
  44936. RADIANCEOVERALPHA: boolean;
  44937. ALPHAFRESNEL: boolean;
  44938. LINEARALPHAFRESNEL: boolean;
  44939. PREMULTIPLYALPHA: boolean;
  44940. EMISSIVE: boolean;
  44941. EMISSIVEDIRECTUV: number;
  44942. REFLECTIVITY: boolean;
  44943. REFLECTIVITYDIRECTUV: number;
  44944. SPECULARTERM: boolean;
  44945. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  44946. MICROSURFACEAUTOMATIC: boolean;
  44947. LODBASEDMICROSFURACE: boolean;
  44948. MICROSURFACEMAP: boolean;
  44949. MICROSURFACEMAPDIRECTUV: number;
  44950. METALLICWORKFLOW: boolean;
  44951. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  44952. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  44953. METALLNESSSTOREINMETALMAPBLUE: boolean;
  44954. AOSTOREINMETALMAPRED: boolean;
  44955. ENVIRONMENTBRDF: boolean;
  44956. ENVIRONMENTBRDF_RGBD: boolean;
  44957. NORMAL: boolean;
  44958. TANGENT: boolean;
  44959. BUMP: boolean;
  44960. BUMPDIRECTUV: number;
  44961. OBJECTSPACE_NORMALMAP: boolean;
  44962. PARALLAX: boolean;
  44963. PARALLAXOCCLUSION: boolean;
  44964. NORMALXYSCALE: boolean;
  44965. LIGHTMAP: boolean;
  44966. LIGHTMAPDIRECTUV: number;
  44967. USELIGHTMAPASSHADOWMAP: boolean;
  44968. GAMMALIGHTMAP: boolean;
  44969. REFLECTION: boolean;
  44970. REFLECTIONMAP_3D: boolean;
  44971. REFLECTIONMAP_SPHERICAL: boolean;
  44972. REFLECTIONMAP_PLANAR: boolean;
  44973. REFLECTIONMAP_CUBIC: boolean;
  44974. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  44975. REFLECTIONMAP_PROJECTION: boolean;
  44976. REFLECTIONMAP_SKYBOX: boolean;
  44977. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  44978. REFLECTIONMAP_EXPLICIT: boolean;
  44979. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  44980. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  44981. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  44982. INVERTCUBICMAP: boolean;
  44983. USESPHERICALFROMREFLECTIONMAP: boolean;
  44984. SPHERICAL_HARMONICS: boolean;
  44985. USESPHERICALINVERTEX: boolean;
  44986. REFLECTIONMAP_OPPOSITEZ: boolean;
  44987. LODINREFLECTIONALPHA: boolean;
  44988. GAMMAREFLECTION: boolean;
  44989. RGBDREFLECTION: boolean;
  44990. RADIANCEOCCLUSION: boolean;
  44991. HORIZONOCCLUSION: boolean;
  44992. INSTANCES: boolean;
  44993. NUM_BONE_INFLUENCERS: number;
  44994. BonesPerMesh: number;
  44995. BONETEXTURE: boolean;
  44996. NONUNIFORMSCALING: boolean;
  44997. MORPHTARGETS: boolean;
  44998. MORPHTARGETS_NORMAL: boolean;
  44999. MORPHTARGETS_TANGENT: boolean;
  45000. NUM_MORPH_INFLUENCERS: number;
  45001. IMAGEPROCESSING: boolean;
  45002. VIGNETTE: boolean;
  45003. VIGNETTEBLENDMODEMULTIPLY: boolean;
  45004. VIGNETTEBLENDMODEOPAQUE: boolean;
  45005. TONEMAPPING: boolean;
  45006. TONEMAPPING_ACES: boolean;
  45007. CONTRAST: boolean;
  45008. COLORCURVES: boolean;
  45009. COLORGRADING: boolean;
  45010. COLORGRADING3D: boolean;
  45011. SAMPLER3DGREENDEPTH: boolean;
  45012. SAMPLER3DBGRMAP: boolean;
  45013. IMAGEPROCESSINGPOSTPROCESS: boolean;
  45014. EXPOSURE: boolean;
  45015. MULTIVIEW: boolean;
  45016. USEPHYSICALLIGHTFALLOFF: boolean;
  45017. USEGLTFLIGHTFALLOFF: boolean;
  45018. TWOSIDEDLIGHTING: boolean;
  45019. SHADOWFLOAT: boolean;
  45020. CLIPPLANE: boolean;
  45021. CLIPPLANE2: boolean;
  45022. CLIPPLANE3: boolean;
  45023. CLIPPLANE4: boolean;
  45024. POINTSIZE: boolean;
  45025. FOG: boolean;
  45026. LOGARITHMICDEPTH: boolean;
  45027. FORCENORMALFORWARD: boolean;
  45028. SPECULARAA: boolean;
  45029. CLEARCOAT: boolean;
  45030. CLEARCOAT_DEFAULTIOR: boolean;
  45031. CLEARCOAT_TEXTURE: boolean;
  45032. CLEARCOAT_TEXTUREDIRECTUV: number;
  45033. CLEARCOAT_BUMP: boolean;
  45034. CLEARCOAT_BUMPDIRECTUV: number;
  45035. CLEARCOAT_TINT: boolean;
  45036. CLEARCOAT_TINT_TEXTURE: boolean;
  45037. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45038. ANISOTROPIC: boolean;
  45039. ANISOTROPIC_TEXTURE: boolean;
  45040. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45041. BRDF_V_HEIGHT_CORRELATED: boolean;
  45042. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45043. SHEEN: boolean;
  45044. SHEEN_TEXTURE: boolean;
  45045. SHEEN_TEXTUREDIRECTUV: number;
  45046. SHEEN_LINKWITHALBEDO: boolean;
  45047. SUBSURFACE: boolean;
  45048. SS_REFRACTION: boolean;
  45049. SS_TRANSLUCENCY: boolean;
  45050. SS_SCATERRING: boolean;
  45051. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45052. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45053. SS_REFRACTIONMAP_3D: boolean;
  45054. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45055. SS_LODINREFRACTIONALPHA: boolean;
  45056. SS_GAMMAREFRACTION: boolean;
  45057. SS_RGBDREFRACTION: boolean;
  45058. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45059. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45060. UNLIT: boolean;
  45061. DEBUGMODE: number;
  45062. /**
  45063. * Initializes the PBR Material defines.
  45064. */
  45065. constructor();
  45066. /**
  45067. * Resets the PBR Material defines.
  45068. */
  45069. reset(): void;
  45070. }
  45071. /**
  45072. * The Physically based material base class of BJS.
  45073. *
  45074. * This offers the main features of a standard PBR material.
  45075. * For more information, please refer to the documentation :
  45076. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45077. */
  45078. export abstract class PBRBaseMaterial extends PushMaterial {
  45079. /**
  45080. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45081. */
  45082. static readonly PBRMATERIAL_OPAQUE: number;
  45083. /**
  45084. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45085. */
  45086. static readonly PBRMATERIAL_ALPHATEST: number;
  45087. /**
  45088. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45089. */
  45090. static readonly PBRMATERIAL_ALPHABLEND: number;
  45091. /**
  45092. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45093. * They are also discarded below the alpha cutoff threshold to improve performances.
  45094. */
  45095. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45096. /**
  45097. * Defines the default value of how much AO map is occluding the analytical lights
  45098. * (point spot...).
  45099. */
  45100. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45101. /**
  45102. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45103. */
  45104. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45105. /**
  45106. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45107. * to enhance interoperability with other engines.
  45108. */
  45109. static readonly LIGHTFALLOFF_GLTF: number;
  45110. /**
  45111. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45112. * to enhance interoperability with other materials.
  45113. */
  45114. static readonly LIGHTFALLOFF_STANDARD: number;
  45115. /**
  45116. * Intensity of the direct lights e.g. the four lights available in your scene.
  45117. * This impacts both the direct diffuse and specular highlights.
  45118. */
  45119. protected _directIntensity: number;
  45120. /**
  45121. * Intensity of the emissive part of the material.
  45122. * This helps controlling the emissive effect without modifying the emissive color.
  45123. */
  45124. protected _emissiveIntensity: number;
  45125. /**
  45126. * Intensity of the environment e.g. how much the environment will light the object
  45127. * either through harmonics for rough material or through the refelction for shiny ones.
  45128. */
  45129. protected _environmentIntensity: number;
  45130. /**
  45131. * This is a special control allowing the reduction of the specular highlights coming from the
  45132. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45133. */
  45134. protected _specularIntensity: number;
  45135. /**
  45136. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45137. */
  45138. private _lightingInfos;
  45139. /**
  45140. * Debug Control allowing disabling the bump map on this material.
  45141. */
  45142. protected _disableBumpMap: boolean;
  45143. /**
  45144. * AKA Diffuse Texture in standard nomenclature.
  45145. */
  45146. protected _albedoTexture: Nullable<BaseTexture>;
  45147. /**
  45148. * AKA Occlusion Texture in other nomenclature.
  45149. */
  45150. protected _ambientTexture: Nullable<BaseTexture>;
  45151. /**
  45152. * AKA Occlusion Texture Intensity in other nomenclature.
  45153. */
  45154. protected _ambientTextureStrength: number;
  45155. /**
  45156. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45157. * 1 means it completely occludes it
  45158. * 0 mean it has no impact
  45159. */
  45160. protected _ambientTextureImpactOnAnalyticalLights: number;
  45161. /**
  45162. * Stores the alpha values in a texture.
  45163. */
  45164. protected _opacityTexture: Nullable<BaseTexture>;
  45165. /**
  45166. * Stores the reflection values in a texture.
  45167. */
  45168. protected _reflectionTexture: Nullable<BaseTexture>;
  45169. /**
  45170. * Stores the emissive values in a texture.
  45171. */
  45172. protected _emissiveTexture: Nullable<BaseTexture>;
  45173. /**
  45174. * AKA Specular texture in other nomenclature.
  45175. */
  45176. protected _reflectivityTexture: Nullable<BaseTexture>;
  45177. /**
  45178. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45179. */
  45180. protected _metallicTexture: Nullable<BaseTexture>;
  45181. /**
  45182. * Specifies the metallic scalar of the metallic/roughness workflow.
  45183. * Can also be used to scale the metalness values of the metallic texture.
  45184. */
  45185. protected _metallic: Nullable<number>;
  45186. /**
  45187. * Specifies the roughness scalar of the metallic/roughness workflow.
  45188. * Can also be used to scale the roughness values of the metallic texture.
  45189. */
  45190. protected _roughness: Nullable<number>;
  45191. /**
  45192. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45193. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45194. */
  45195. protected _microSurfaceTexture: Nullable<BaseTexture>;
  45196. /**
  45197. * Stores surface normal data used to displace a mesh in a texture.
  45198. */
  45199. protected _bumpTexture: Nullable<BaseTexture>;
  45200. /**
  45201. * Stores the pre-calculated light information of a mesh in a texture.
  45202. */
  45203. protected _lightmapTexture: Nullable<BaseTexture>;
  45204. /**
  45205. * The color of a material in ambient lighting.
  45206. */
  45207. protected _ambientColor: Color3;
  45208. /**
  45209. * AKA Diffuse Color in other nomenclature.
  45210. */
  45211. protected _albedoColor: Color3;
  45212. /**
  45213. * AKA Specular Color in other nomenclature.
  45214. */
  45215. protected _reflectivityColor: Color3;
  45216. /**
  45217. * The color applied when light is reflected from a material.
  45218. */
  45219. protected _reflectionColor: Color3;
  45220. /**
  45221. * The color applied when light is emitted from a material.
  45222. */
  45223. protected _emissiveColor: Color3;
  45224. /**
  45225. * AKA Glossiness in other nomenclature.
  45226. */
  45227. protected _microSurface: number;
  45228. /**
  45229. * Specifies that the material will use the light map as a show map.
  45230. */
  45231. protected _useLightmapAsShadowmap: boolean;
  45232. /**
  45233. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45234. * makes the reflect vector face the model (under horizon).
  45235. */
  45236. protected _useHorizonOcclusion: boolean;
  45237. /**
  45238. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45239. * too much the area relying on ambient texture to define their ambient occlusion.
  45240. */
  45241. protected _useRadianceOcclusion: boolean;
  45242. /**
  45243. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45244. */
  45245. protected _useAlphaFromAlbedoTexture: boolean;
  45246. /**
  45247. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45248. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45249. */
  45250. protected _useSpecularOverAlpha: boolean;
  45251. /**
  45252. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45253. */
  45254. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45255. /**
  45256. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45257. */
  45258. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45259. /**
  45260. * Specifies if the metallic texture contains the roughness information in its green channel.
  45261. */
  45262. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45263. /**
  45264. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45265. */
  45266. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45267. /**
  45268. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45269. */
  45270. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45271. /**
  45272. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45273. */
  45274. protected _useAmbientInGrayScale: boolean;
  45275. /**
  45276. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45277. * The material will try to infer what glossiness each pixel should be.
  45278. */
  45279. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45280. /**
  45281. * Defines the falloff type used in this material.
  45282. * It by default is Physical.
  45283. */
  45284. protected _lightFalloff: number;
  45285. /**
  45286. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45287. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45288. */
  45289. protected _useRadianceOverAlpha: boolean;
  45290. /**
  45291. * Allows using an object space normal map (instead of tangent space).
  45292. */
  45293. protected _useObjectSpaceNormalMap: boolean;
  45294. /**
  45295. * Allows using the bump map in parallax mode.
  45296. */
  45297. protected _useParallax: boolean;
  45298. /**
  45299. * Allows using the bump map in parallax occlusion mode.
  45300. */
  45301. protected _useParallaxOcclusion: boolean;
  45302. /**
  45303. * Controls the scale bias of the parallax mode.
  45304. */
  45305. protected _parallaxScaleBias: number;
  45306. /**
  45307. * If sets to true, disables all the lights affecting the material.
  45308. */
  45309. protected _disableLighting: boolean;
  45310. /**
  45311. * Number of Simultaneous lights allowed on the material.
  45312. */
  45313. protected _maxSimultaneousLights: number;
  45314. /**
  45315. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45316. */
  45317. protected _invertNormalMapX: boolean;
  45318. /**
  45319. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45320. */
  45321. protected _invertNormalMapY: boolean;
  45322. /**
  45323. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45324. */
  45325. protected _twoSidedLighting: boolean;
  45326. /**
  45327. * Defines the alpha limits in alpha test mode.
  45328. */
  45329. protected _alphaCutOff: number;
  45330. /**
  45331. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45332. */
  45333. protected _forceAlphaTest: boolean;
  45334. /**
  45335. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45336. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45337. */
  45338. protected _useAlphaFresnel: boolean;
  45339. /**
  45340. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45341. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45342. */
  45343. protected _useLinearAlphaFresnel: boolean;
  45344. /**
  45345. * The transparency mode of the material.
  45346. */
  45347. protected _transparencyMode: Nullable<number>;
  45348. /**
  45349. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45350. * from cos thetav and roughness:
  45351. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45352. */
  45353. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45354. /**
  45355. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45356. */
  45357. protected _forceIrradianceInFragment: boolean;
  45358. /**
  45359. * Force normal to face away from face.
  45360. */
  45361. protected _forceNormalForward: boolean;
  45362. /**
  45363. * Enables specular anti aliasing in the PBR shader.
  45364. * It will both interacts on the Geometry for analytical and IBL lighting.
  45365. * It also prefilter the roughness map based on the bump values.
  45366. */
  45367. protected _enableSpecularAntiAliasing: boolean;
  45368. /**
  45369. * Default configuration related to image processing available in the PBR Material.
  45370. */
  45371. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45372. /**
  45373. * Keep track of the image processing observer to allow dispose and replace.
  45374. */
  45375. private _imageProcessingObserver;
  45376. /**
  45377. * Attaches a new image processing configuration to the PBR Material.
  45378. * @param configuration
  45379. */
  45380. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45381. /**
  45382. * Stores the available render targets.
  45383. */
  45384. private _renderTargets;
  45385. /**
  45386. * Sets the global ambient color for the material used in lighting calculations.
  45387. */
  45388. private _globalAmbientColor;
  45389. /**
  45390. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45391. */
  45392. private _useLogarithmicDepth;
  45393. /**
  45394. * If set to true, no lighting calculations will be applied.
  45395. */
  45396. private _unlit;
  45397. private _debugMode;
  45398. /**
  45399. * @hidden
  45400. * This is reserved for the inspector.
  45401. * Defines the material debug mode.
  45402. * It helps seeing only some components of the material while troubleshooting.
  45403. */
  45404. debugMode: number;
  45405. /**
  45406. * @hidden
  45407. * This is reserved for the inspector.
  45408. * Specify from where on screen the debug mode should start.
  45409. * The value goes from -1 (full screen) to 1 (not visible)
  45410. * It helps with side by side comparison against the final render
  45411. * This defaults to -1
  45412. */
  45413. private debugLimit;
  45414. /**
  45415. * @hidden
  45416. * This is reserved for the inspector.
  45417. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45418. * You can use the factor to better multiply the final value.
  45419. */
  45420. private debugFactor;
  45421. /**
  45422. * Defines the clear coat layer parameters for the material.
  45423. */
  45424. readonly clearCoat: PBRClearCoatConfiguration;
  45425. /**
  45426. * Defines the anisotropic parameters for the material.
  45427. */
  45428. readonly anisotropy: PBRAnisotropicConfiguration;
  45429. /**
  45430. * Defines the BRDF parameters for the material.
  45431. */
  45432. readonly brdf: PBRBRDFConfiguration;
  45433. /**
  45434. * Defines the Sheen parameters for the material.
  45435. */
  45436. readonly sheen: PBRSheenConfiguration;
  45437. /**
  45438. * Defines the SubSurface parameters for the material.
  45439. */
  45440. readonly subSurface: PBRSubSurfaceConfiguration;
  45441. /**
  45442. * Custom callback helping to override the default shader used in the material.
  45443. */
  45444. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  45445. /**
  45446. * Instantiates a new PBRMaterial instance.
  45447. *
  45448. * @param name The material name
  45449. * @param scene The scene the material will be use in.
  45450. */
  45451. constructor(name: string, scene: Scene);
  45452. /**
  45453. * Gets a boolean indicating that current material needs to register RTT
  45454. */
  45455. readonly hasRenderTargetTextures: boolean;
  45456. /**
  45457. * Gets the name of the material class.
  45458. */
  45459. getClassName(): string;
  45460. /**
  45461. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45462. */
  45463. /**
  45464. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45465. */
  45466. useLogarithmicDepth: boolean;
  45467. /**
  45468. * Gets the current transparency mode.
  45469. */
  45470. /**
  45471. * Sets the transparency mode of the material.
  45472. *
  45473. * | Value | Type | Description |
  45474. * | ----- | ----------------------------------- | ----------- |
  45475. * | 0 | OPAQUE | |
  45476. * | 1 | ALPHATEST | |
  45477. * | 2 | ALPHABLEND | |
  45478. * | 3 | ALPHATESTANDBLEND | |
  45479. *
  45480. */
  45481. transparencyMode: Nullable<number>;
  45482. /**
  45483. * Returns true if alpha blending should be disabled.
  45484. */
  45485. private readonly _disableAlphaBlending;
  45486. /**
  45487. * Specifies whether or not this material should be rendered in alpha blend mode.
  45488. */
  45489. needAlphaBlending(): boolean;
  45490. /**
  45491. * Specifies if the mesh will require alpha blending.
  45492. * @param mesh - BJS mesh.
  45493. */
  45494. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45495. /**
  45496. * Specifies whether or not this material should be rendered in alpha test mode.
  45497. */
  45498. needAlphaTesting(): boolean;
  45499. /**
  45500. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45501. */
  45502. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45503. /**
  45504. * Gets the texture used for the alpha test.
  45505. */
  45506. getAlphaTestTexture(): Nullable<BaseTexture>;
  45507. /**
  45508. * Specifies that the submesh is ready to be used.
  45509. * @param mesh - BJS mesh.
  45510. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45511. * @param useInstances - Specifies that instances should be used.
  45512. * @returns - boolean indicating that the submesh is ready or not.
  45513. */
  45514. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45515. /**
  45516. * Specifies if the material uses metallic roughness workflow.
  45517. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45518. */
  45519. isMetallicWorkflow(): boolean;
  45520. private _prepareEffect;
  45521. private _prepareDefines;
  45522. /**
  45523. * Force shader compilation
  45524. */
  45525. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45526. clipPlane: boolean;
  45527. }>): void;
  45528. /**
  45529. * Initializes the uniform buffer layout for the shader.
  45530. */
  45531. buildUniformLayout(): void;
  45532. /**
  45533. * Unbinds the material from the mesh
  45534. */
  45535. unbind(): void;
  45536. /**
  45537. * Binds the submesh data.
  45538. * @param world - The world matrix.
  45539. * @param mesh - The BJS mesh.
  45540. * @param subMesh - A submesh of the BJS mesh.
  45541. */
  45542. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45543. /**
  45544. * Returns the animatable textures.
  45545. * @returns - Array of animatable textures.
  45546. */
  45547. getAnimatables(): IAnimatable[];
  45548. /**
  45549. * Returns the texture used for reflections.
  45550. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45551. */
  45552. private _getReflectionTexture;
  45553. /**
  45554. * Returns an array of the actively used textures.
  45555. * @returns - Array of BaseTextures
  45556. */
  45557. getActiveTextures(): BaseTexture[];
  45558. /**
  45559. * Checks to see if a texture is used in the material.
  45560. * @param texture - Base texture to use.
  45561. * @returns - Boolean specifying if a texture is used in the material.
  45562. */
  45563. hasTexture(texture: BaseTexture): boolean;
  45564. /**
  45565. * Disposes the resources of the material.
  45566. * @param forceDisposeEffect - Forces the disposal of effects.
  45567. * @param forceDisposeTextures - Forces the disposal of all textures.
  45568. */
  45569. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45570. }
  45571. }
  45572. declare module BABYLON {
  45573. /**
  45574. * The Physically based material of BJS.
  45575. *
  45576. * This offers the main features of a standard PBR material.
  45577. * For more information, please refer to the documentation :
  45578. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45579. */
  45580. export class PBRMaterial extends PBRBaseMaterial {
  45581. /**
  45582. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45583. */
  45584. static readonly PBRMATERIAL_OPAQUE: number;
  45585. /**
  45586. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45587. */
  45588. static readonly PBRMATERIAL_ALPHATEST: number;
  45589. /**
  45590. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45591. */
  45592. static readonly PBRMATERIAL_ALPHABLEND: number;
  45593. /**
  45594. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45595. * They are also discarded below the alpha cutoff threshold to improve performances.
  45596. */
  45597. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45598. /**
  45599. * Defines the default value of how much AO map is occluding the analytical lights
  45600. * (point spot...).
  45601. */
  45602. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45603. /**
  45604. * Intensity of the direct lights e.g. the four lights available in your scene.
  45605. * This impacts both the direct diffuse and specular highlights.
  45606. */
  45607. directIntensity: number;
  45608. /**
  45609. * Intensity of the emissive part of the material.
  45610. * This helps controlling the emissive effect without modifying the emissive color.
  45611. */
  45612. emissiveIntensity: number;
  45613. /**
  45614. * Intensity of the environment e.g. how much the environment will light the object
  45615. * either through harmonics for rough material or through the refelction for shiny ones.
  45616. */
  45617. environmentIntensity: number;
  45618. /**
  45619. * This is a special control allowing the reduction of the specular highlights coming from the
  45620. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45621. */
  45622. specularIntensity: number;
  45623. /**
  45624. * Debug Control allowing disabling the bump map on this material.
  45625. */
  45626. disableBumpMap: boolean;
  45627. /**
  45628. * AKA Diffuse Texture in standard nomenclature.
  45629. */
  45630. albedoTexture: BaseTexture;
  45631. /**
  45632. * AKA Occlusion Texture in other nomenclature.
  45633. */
  45634. ambientTexture: BaseTexture;
  45635. /**
  45636. * AKA Occlusion Texture Intensity in other nomenclature.
  45637. */
  45638. ambientTextureStrength: number;
  45639. /**
  45640. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45641. * 1 means it completely occludes it
  45642. * 0 mean it has no impact
  45643. */
  45644. ambientTextureImpactOnAnalyticalLights: number;
  45645. /**
  45646. * Stores the alpha values in a texture.
  45647. */
  45648. opacityTexture: BaseTexture;
  45649. /**
  45650. * Stores the reflection values in a texture.
  45651. */
  45652. reflectionTexture: Nullable<BaseTexture>;
  45653. /**
  45654. * Stores the emissive values in a texture.
  45655. */
  45656. emissiveTexture: BaseTexture;
  45657. /**
  45658. * AKA Specular texture in other nomenclature.
  45659. */
  45660. reflectivityTexture: BaseTexture;
  45661. /**
  45662. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45663. */
  45664. metallicTexture: BaseTexture;
  45665. /**
  45666. * Specifies the metallic scalar of the metallic/roughness workflow.
  45667. * Can also be used to scale the metalness values of the metallic texture.
  45668. */
  45669. metallic: Nullable<number>;
  45670. /**
  45671. * Specifies the roughness scalar of the metallic/roughness workflow.
  45672. * Can also be used to scale the roughness values of the metallic texture.
  45673. */
  45674. roughness: Nullable<number>;
  45675. /**
  45676. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45677. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45678. */
  45679. microSurfaceTexture: BaseTexture;
  45680. /**
  45681. * Stores surface normal data used to displace a mesh in a texture.
  45682. */
  45683. bumpTexture: BaseTexture;
  45684. /**
  45685. * Stores the pre-calculated light information of a mesh in a texture.
  45686. */
  45687. lightmapTexture: BaseTexture;
  45688. /**
  45689. * Stores the refracted light information in a texture.
  45690. */
  45691. refractionTexture: Nullable<BaseTexture>;
  45692. /**
  45693. * The color of a material in ambient lighting.
  45694. */
  45695. ambientColor: Color3;
  45696. /**
  45697. * AKA Diffuse Color in other nomenclature.
  45698. */
  45699. albedoColor: Color3;
  45700. /**
  45701. * AKA Specular Color in other nomenclature.
  45702. */
  45703. reflectivityColor: Color3;
  45704. /**
  45705. * The color reflected from the material.
  45706. */
  45707. reflectionColor: Color3;
  45708. /**
  45709. * The color emitted from the material.
  45710. */
  45711. emissiveColor: Color3;
  45712. /**
  45713. * AKA Glossiness in other nomenclature.
  45714. */
  45715. microSurface: number;
  45716. /**
  45717. * source material index of refraction (IOR)' / 'destination material IOR.
  45718. */
  45719. indexOfRefraction: number;
  45720. /**
  45721. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45722. */
  45723. invertRefractionY: boolean;
  45724. /**
  45725. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45726. * Materials half opaque for instance using refraction could benefit from this control.
  45727. */
  45728. linkRefractionWithTransparency: boolean;
  45729. /**
  45730. * If true, the light map contains occlusion information instead of lighting info.
  45731. */
  45732. useLightmapAsShadowmap: boolean;
  45733. /**
  45734. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45735. */
  45736. useAlphaFromAlbedoTexture: boolean;
  45737. /**
  45738. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45739. */
  45740. forceAlphaTest: boolean;
  45741. /**
  45742. * Defines the alpha limits in alpha test mode.
  45743. */
  45744. alphaCutOff: number;
  45745. /**
  45746. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45747. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45748. */
  45749. useSpecularOverAlpha: boolean;
  45750. /**
  45751. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45752. */
  45753. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45754. /**
  45755. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45756. */
  45757. useRoughnessFromMetallicTextureAlpha: boolean;
  45758. /**
  45759. * Specifies if the metallic texture contains the roughness information in its green channel.
  45760. */
  45761. useRoughnessFromMetallicTextureGreen: boolean;
  45762. /**
  45763. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45764. */
  45765. useMetallnessFromMetallicTextureBlue: boolean;
  45766. /**
  45767. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45768. */
  45769. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45770. /**
  45771. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45772. */
  45773. useAmbientInGrayScale: boolean;
  45774. /**
  45775. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45776. * The material will try to infer what glossiness each pixel should be.
  45777. */
  45778. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45779. /**
  45780. * BJS is using an harcoded light falloff based on a manually sets up range.
  45781. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45782. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45783. */
  45784. /**
  45785. * BJS is using an harcoded light falloff based on a manually sets up range.
  45786. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45787. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45788. */
  45789. usePhysicalLightFalloff: boolean;
  45790. /**
  45791. * In order to support the falloff compatibility with gltf, a special mode has been added
  45792. * to reproduce the gltf light falloff.
  45793. */
  45794. /**
  45795. * In order to support the falloff compatibility with gltf, a special mode has been added
  45796. * to reproduce the gltf light falloff.
  45797. */
  45798. useGLTFLightFalloff: boolean;
  45799. /**
  45800. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45801. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45802. */
  45803. useRadianceOverAlpha: boolean;
  45804. /**
  45805. * Allows using an object space normal map (instead of tangent space).
  45806. */
  45807. useObjectSpaceNormalMap: boolean;
  45808. /**
  45809. * Allows using the bump map in parallax mode.
  45810. */
  45811. useParallax: boolean;
  45812. /**
  45813. * Allows using the bump map in parallax occlusion mode.
  45814. */
  45815. useParallaxOcclusion: boolean;
  45816. /**
  45817. * Controls the scale bias of the parallax mode.
  45818. */
  45819. parallaxScaleBias: number;
  45820. /**
  45821. * If sets to true, disables all the lights affecting the material.
  45822. */
  45823. disableLighting: boolean;
  45824. /**
  45825. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45826. */
  45827. forceIrradianceInFragment: boolean;
  45828. /**
  45829. * Number of Simultaneous lights allowed on the material.
  45830. */
  45831. maxSimultaneousLights: number;
  45832. /**
  45833. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45834. */
  45835. invertNormalMapX: boolean;
  45836. /**
  45837. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45838. */
  45839. invertNormalMapY: boolean;
  45840. /**
  45841. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45842. */
  45843. twoSidedLighting: boolean;
  45844. /**
  45845. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45846. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45847. */
  45848. useAlphaFresnel: boolean;
  45849. /**
  45850. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45851. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45852. */
  45853. useLinearAlphaFresnel: boolean;
  45854. /**
  45855. * Let user defines the brdf lookup texture used for IBL.
  45856. * A default 8bit version is embedded but you could point at :
  45857. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45858. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45859. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45860. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45861. */
  45862. environmentBRDFTexture: Nullable<BaseTexture>;
  45863. /**
  45864. * Force normal to face away from face.
  45865. */
  45866. forceNormalForward: boolean;
  45867. /**
  45868. * Enables specular anti aliasing in the PBR shader.
  45869. * It will both interacts on the Geometry for analytical and IBL lighting.
  45870. * It also prefilter the roughness map based on the bump values.
  45871. */
  45872. enableSpecularAntiAliasing: boolean;
  45873. /**
  45874. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45875. * makes the reflect vector face the model (under horizon).
  45876. */
  45877. useHorizonOcclusion: boolean;
  45878. /**
  45879. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45880. * too much the area relying on ambient texture to define their ambient occlusion.
  45881. */
  45882. useRadianceOcclusion: boolean;
  45883. /**
  45884. * If set to true, no lighting calculations will be applied.
  45885. */
  45886. unlit: boolean;
  45887. /**
  45888. * Gets the image processing configuration used either in this material.
  45889. */
  45890. /**
  45891. * Sets the Default image processing configuration used either in the this material.
  45892. *
  45893. * If sets to null, the scene one is in use.
  45894. */
  45895. imageProcessingConfiguration: ImageProcessingConfiguration;
  45896. /**
  45897. * Gets wether the color curves effect is enabled.
  45898. */
  45899. /**
  45900. * Sets wether the color curves effect is enabled.
  45901. */
  45902. cameraColorCurvesEnabled: boolean;
  45903. /**
  45904. * Gets wether the color grading effect is enabled.
  45905. */
  45906. /**
  45907. * Gets wether the color grading effect is enabled.
  45908. */
  45909. cameraColorGradingEnabled: boolean;
  45910. /**
  45911. * Gets wether tonemapping is enabled or not.
  45912. */
  45913. /**
  45914. * Sets wether tonemapping is enabled or not
  45915. */
  45916. cameraToneMappingEnabled: boolean;
  45917. /**
  45918. * The camera exposure used on this material.
  45919. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45920. * This corresponds to a photographic exposure.
  45921. */
  45922. /**
  45923. * The camera exposure used on this material.
  45924. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45925. * This corresponds to a photographic exposure.
  45926. */
  45927. cameraExposure: number;
  45928. /**
  45929. * Gets The camera contrast used on this material.
  45930. */
  45931. /**
  45932. * Sets The camera contrast used on this material.
  45933. */
  45934. cameraContrast: number;
  45935. /**
  45936. * Gets the Color Grading 2D Lookup Texture.
  45937. */
  45938. /**
  45939. * Sets the Color Grading 2D Lookup Texture.
  45940. */
  45941. cameraColorGradingTexture: Nullable<BaseTexture>;
  45942. /**
  45943. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45944. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45945. * 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;
  45946. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45947. */
  45948. /**
  45949. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45950. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45951. * 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;
  45952. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45953. */
  45954. cameraColorCurves: Nullable<ColorCurves>;
  45955. /**
  45956. * Instantiates a new PBRMaterial instance.
  45957. *
  45958. * @param name The material name
  45959. * @param scene The scene the material will be use in.
  45960. */
  45961. constructor(name: string, scene: Scene);
  45962. /**
  45963. * Returns the name of this material class.
  45964. */
  45965. getClassName(): string;
  45966. /**
  45967. * Makes a duplicate of the current material.
  45968. * @param name - name to use for the new material.
  45969. */
  45970. clone(name: string): PBRMaterial;
  45971. /**
  45972. * Serializes this PBR Material.
  45973. * @returns - An object with the serialized material.
  45974. */
  45975. serialize(): any;
  45976. /**
  45977. * Parses a PBR Material from a serialized object.
  45978. * @param source - Serialized object.
  45979. * @param scene - BJS scene instance.
  45980. * @param rootUrl - url for the scene object
  45981. * @returns - PBRMaterial
  45982. */
  45983. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45984. }
  45985. }
  45986. declare module BABYLON {
  45987. /**
  45988. * Direct draw surface info
  45989. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45990. */
  45991. export interface DDSInfo {
  45992. /**
  45993. * Width of the texture
  45994. */
  45995. width: number;
  45996. /**
  45997. * Width of the texture
  45998. */
  45999. height: number;
  46000. /**
  46001. * Number of Mipmaps for the texture
  46002. * @see https://en.wikipedia.org/wiki/Mipmap
  46003. */
  46004. mipmapCount: number;
  46005. /**
  46006. * If the textures format is a known fourCC format
  46007. * @see https://www.fourcc.org/
  46008. */
  46009. isFourCC: boolean;
  46010. /**
  46011. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46012. */
  46013. isRGB: boolean;
  46014. /**
  46015. * If the texture is a lumincance format
  46016. */
  46017. isLuminance: boolean;
  46018. /**
  46019. * If this is a cube texture
  46020. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46021. */
  46022. isCube: boolean;
  46023. /**
  46024. * If the texture is a compressed format eg. FOURCC_DXT1
  46025. */
  46026. isCompressed: boolean;
  46027. /**
  46028. * The dxgiFormat of the texture
  46029. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46030. */
  46031. dxgiFormat: number;
  46032. /**
  46033. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46034. */
  46035. textureType: number;
  46036. /**
  46037. * Sphericle polynomial created for the dds texture
  46038. */
  46039. sphericalPolynomial?: SphericalPolynomial;
  46040. }
  46041. /**
  46042. * Class used to provide DDS decompression tools
  46043. */
  46044. export class DDSTools {
  46045. /**
  46046. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46047. */
  46048. static StoreLODInAlphaChannel: boolean;
  46049. /**
  46050. * Gets DDS information from an array buffer
  46051. * @param arrayBuffer defines the array buffer to read data from
  46052. * @returns the DDS information
  46053. */
  46054. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46055. private static _FloatView;
  46056. private static _Int32View;
  46057. private static _ToHalfFloat;
  46058. private static _FromHalfFloat;
  46059. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46060. private static _GetHalfFloatRGBAArrayBuffer;
  46061. private static _GetFloatRGBAArrayBuffer;
  46062. private static _GetFloatAsUIntRGBAArrayBuffer;
  46063. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46064. private static _GetRGBAArrayBuffer;
  46065. private static _ExtractLongWordOrder;
  46066. private static _GetRGBArrayBuffer;
  46067. private static _GetLuminanceArrayBuffer;
  46068. /**
  46069. * Uploads DDS Levels to a Babylon Texture
  46070. * @hidden
  46071. */
  46072. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46073. }
  46074. interface Engine {
  46075. /**
  46076. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46077. * @param rootUrl defines the url where the file to load is located
  46078. * @param scene defines the current scene
  46079. * @param lodScale defines scale to apply to the mip map selection
  46080. * @param lodOffset defines offset to apply to the mip map selection
  46081. * @param onLoad defines an optional callback raised when the texture is loaded
  46082. * @param onError defines an optional callback raised if there is an issue to load the texture
  46083. * @param format defines the format of the data
  46084. * @param forcedExtension defines the extension to use to pick the right loader
  46085. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46086. * @returns the cube texture as an InternalTexture
  46087. */
  46088. 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;
  46089. }
  46090. }
  46091. declare module BABYLON {
  46092. /**
  46093. * Implementation of the DDS Texture Loader.
  46094. * @hidden
  46095. */
  46096. export class _DDSTextureLoader implements IInternalTextureLoader {
  46097. /**
  46098. * Defines wether the loader supports cascade loading the different faces.
  46099. */
  46100. readonly supportCascades: boolean;
  46101. /**
  46102. * This returns if the loader support the current file information.
  46103. * @param extension defines the file extension of the file being loaded
  46104. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46105. * @param fallback defines the fallback internal texture if any
  46106. * @param isBase64 defines whether the texture is encoded as a base64
  46107. * @param isBuffer defines whether the texture data are stored as a buffer
  46108. * @returns true if the loader can load the specified file
  46109. */
  46110. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46111. /**
  46112. * Transform the url before loading if required.
  46113. * @param rootUrl the url of the texture
  46114. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46115. * @returns the transformed texture
  46116. */
  46117. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46118. /**
  46119. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46120. * @param rootUrl the url of the texture
  46121. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46122. * @returns the fallback texture
  46123. */
  46124. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46125. /**
  46126. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46127. * @param data contains the texture data
  46128. * @param texture defines the BabylonJS internal texture
  46129. * @param createPolynomials will be true if polynomials have been requested
  46130. * @param onLoad defines the callback to trigger once the texture is ready
  46131. * @param onError defines the callback to trigger in case of error
  46132. */
  46133. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46134. /**
  46135. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46136. * @param data contains the texture data
  46137. * @param texture defines the BabylonJS internal texture
  46138. * @param callback defines the method to call once ready to upload
  46139. */
  46140. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46141. }
  46142. }
  46143. declare module BABYLON {
  46144. /** @hidden */
  46145. export var rgbdEncodePixelShader: {
  46146. name: string;
  46147. shader: string;
  46148. };
  46149. }
  46150. declare module BABYLON {
  46151. /**
  46152. * Raw texture data and descriptor sufficient for WebGL texture upload
  46153. */
  46154. export interface EnvironmentTextureInfo {
  46155. /**
  46156. * Version of the environment map
  46157. */
  46158. version: number;
  46159. /**
  46160. * Width of image
  46161. */
  46162. width: number;
  46163. /**
  46164. * Irradiance information stored in the file.
  46165. */
  46166. irradiance: any;
  46167. /**
  46168. * Specular information stored in the file.
  46169. */
  46170. specular: any;
  46171. }
  46172. /**
  46173. * Sets of helpers addressing the serialization and deserialization of environment texture
  46174. * stored in a BabylonJS env file.
  46175. * Those files are usually stored as .env files.
  46176. */
  46177. export class EnvironmentTextureTools {
  46178. /**
  46179. * Magic number identifying the env file.
  46180. */
  46181. private static _MagicBytes;
  46182. /**
  46183. * Gets the environment info from an env file.
  46184. * @param data The array buffer containing the .env bytes.
  46185. * @returns the environment file info (the json header) if successfully parsed.
  46186. */
  46187. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46188. /**
  46189. * Creates an environment texture from a loaded cube texture.
  46190. * @param texture defines the cube texture to convert in env file
  46191. * @return a promise containing the environment data if succesfull.
  46192. */
  46193. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46194. /**
  46195. * Creates a JSON representation of the spherical data.
  46196. * @param texture defines the texture containing the polynomials
  46197. * @return the JSON representation of the spherical info
  46198. */
  46199. private static _CreateEnvTextureIrradiance;
  46200. /**
  46201. * Uploads the texture info contained in the env file to the GPU.
  46202. * @param texture defines the internal texture to upload to
  46203. * @param arrayBuffer defines the buffer cotaining the data to load
  46204. * @param info defines the texture info retrieved through the GetEnvInfo method
  46205. * @returns a promise
  46206. */
  46207. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46208. /**
  46209. * Uploads the levels of image data to the GPU.
  46210. * @param texture defines the internal texture to upload to
  46211. * @param imageData defines the array buffer views of image data [mipmap][face]
  46212. * @returns a promise
  46213. */
  46214. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46215. /**
  46216. * Uploads spherical polynomials information to the texture.
  46217. * @param texture defines the texture we are trying to upload the information to
  46218. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46219. */
  46220. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46221. /** @hidden */
  46222. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46223. }
  46224. }
  46225. declare module BABYLON {
  46226. /**
  46227. * Implementation of the ENV Texture Loader.
  46228. * @hidden
  46229. */
  46230. export class _ENVTextureLoader implements IInternalTextureLoader {
  46231. /**
  46232. * Defines wether the loader supports cascade loading the different faces.
  46233. */
  46234. readonly supportCascades: boolean;
  46235. /**
  46236. * This returns if the loader support the current file information.
  46237. * @param extension defines the file extension of the file being loaded
  46238. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46239. * @param fallback defines the fallback internal texture if any
  46240. * @param isBase64 defines whether the texture is encoded as a base64
  46241. * @param isBuffer defines whether the texture data are stored as a buffer
  46242. * @returns true if the loader can load the specified file
  46243. */
  46244. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46245. /**
  46246. * Transform the url before loading if required.
  46247. * @param rootUrl the url of the texture
  46248. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46249. * @returns the transformed texture
  46250. */
  46251. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46252. /**
  46253. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46254. * @param rootUrl the url of the texture
  46255. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46256. * @returns the fallback texture
  46257. */
  46258. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46259. /**
  46260. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46261. * @param data contains the texture data
  46262. * @param texture defines the BabylonJS internal texture
  46263. * @param createPolynomials will be true if polynomials have been requested
  46264. * @param onLoad defines the callback to trigger once the texture is ready
  46265. * @param onError defines the callback to trigger in case of error
  46266. */
  46267. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46268. /**
  46269. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46270. * @param data contains the texture data
  46271. * @param texture defines the BabylonJS internal texture
  46272. * @param callback defines the method to call once ready to upload
  46273. */
  46274. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46275. }
  46276. }
  46277. declare module BABYLON {
  46278. /**
  46279. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46280. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46281. */
  46282. export class KhronosTextureContainer {
  46283. /** contents of the KTX container file */
  46284. arrayBuffer: any;
  46285. private static HEADER_LEN;
  46286. private static COMPRESSED_2D;
  46287. private static COMPRESSED_3D;
  46288. private static TEX_2D;
  46289. private static TEX_3D;
  46290. /**
  46291. * Gets the openGL type
  46292. */
  46293. glType: number;
  46294. /**
  46295. * Gets the openGL type size
  46296. */
  46297. glTypeSize: number;
  46298. /**
  46299. * Gets the openGL format
  46300. */
  46301. glFormat: number;
  46302. /**
  46303. * Gets the openGL internal format
  46304. */
  46305. glInternalFormat: number;
  46306. /**
  46307. * Gets the base internal format
  46308. */
  46309. glBaseInternalFormat: number;
  46310. /**
  46311. * Gets image width in pixel
  46312. */
  46313. pixelWidth: number;
  46314. /**
  46315. * Gets image height in pixel
  46316. */
  46317. pixelHeight: number;
  46318. /**
  46319. * Gets image depth in pixels
  46320. */
  46321. pixelDepth: number;
  46322. /**
  46323. * Gets the number of array elements
  46324. */
  46325. numberOfArrayElements: number;
  46326. /**
  46327. * Gets the number of faces
  46328. */
  46329. numberOfFaces: number;
  46330. /**
  46331. * Gets the number of mipmap levels
  46332. */
  46333. numberOfMipmapLevels: number;
  46334. /**
  46335. * Gets the bytes of key value data
  46336. */
  46337. bytesOfKeyValueData: number;
  46338. /**
  46339. * Gets the load type
  46340. */
  46341. loadType: number;
  46342. /**
  46343. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46344. */
  46345. isInvalid: boolean;
  46346. /**
  46347. * Creates a new KhronosTextureContainer
  46348. * @param arrayBuffer contents of the KTX container file
  46349. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46350. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46351. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46352. */
  46353. constructor(
  46354. /** contents of the KTX container file */
  46355. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46356. /**
  46357. * Uploads KTX content to a Babylon Texture.
  46358. * It is assumed that the texture has already been created & is currently bound
  46359. * @hidden
  46360. */
  46361. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46362. private _upload2DCompressedLevels;
  46363. }
  46364. }
  46365. declare module BABYLON {
  46366. /**
  46367. * Implementation of the KTX Texture Loader.
  46368. * @hidden
  46369. */
  46370. export class _KTXTextureLoader implements IInternalTextureLoader {
  46371. /**
  46372. * Defines wether the loader supports cascade loading the different faces.
  46373. */
  46374. readonly supportCascades: boolean;
  46375. /**
  46376. * This returns if the loader support the current file information.
  46377. * @param extension defines the file extension of the file being loaded
  46378. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46379. * @param fallback defines the fallback internal texture if any
  46380. * @param isBase64 defines whether the texture is encoded as a base64
  46381. * @param isBuffer defines whether the texture data are stored as a buffer
  46382. * @returns true if the loader can load the specified file
  46383. */
  46384. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46385. /**
  46386. * Transform the url before loading if required.
  46387. * @param rootUrl the url of the texture
  46388. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46389. * @returns the transformed texture
  46390. */
  46391. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46392. /**
  46393. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46394. * @param rootUrl the url of the texture
  46395. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46396. * @returns the fallback texture
  46397. */
  46398. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46399. /**
  46400. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46401. * @param data contains the texture data
  46402. * @param texture defines the BabylonJS internal texture
  46403. * @param createPolynomials will be true if polynomials have been requested
  46404. * @param onLoad defines the callback to trigger once the texture is ready
  46405. * @param onError defines the callback to trigger in case of error
  46406. */
  46407. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46408. /**
  46409. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46410. * @param data contains the texture data
  46411. * @param texture defines the BabylonJS internal texture
  46412. * @param callback defines the method to call once ready to upload
  46413. */
  46414. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46415. }
  46416. }
  46417. declare module BABYLON {
  46418. /** @hidden */
  46419. export var _forceSceneHelpersToBundle: boolean;
  46420. interface Scene {
  46421. /**
  46422. * Creates a default light for the scene.
  46423. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46424. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46425. */
  46426. createDefaultLight(replace?: boolean): void;
  46427. /**
  46428. * Creates a default camera for the scene.
  46429. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46430. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46431. * @param replace has default false, when true replaces the active camera in the scene
  46432. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46433. */
  46434. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46435. /**
  46436. * Creates a default camera and a default light.
  46437. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46438. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46439. * @param replace has the default false, when true replaces the active camera/light in the scene
  46440. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46441. */
  46442. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46443. /**
  46444. * Creates a new sky box
  46445. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46446. * @param environmentTexture defines the texture to use as environment texture
  46447. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46448. * @param scale defines the overall scale of the skybox
  46449. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46450. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46451. * @returns a new mesh holding the sky box
  46452. */
  46453. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46454. /**
  46455. * Creates a new environment
  46456. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46457. * @param options defines the options you can use to configure the environment
  46458. * @returns the new EnvironmentHelper
  46459. */
  46460. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46461. /**
  46462. * Creates a new VREXperienceHelper
  46463. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46464. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46465. * @returns a new VREXperienceHelper
  46466. */
  46467. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46468. /**
  46469. * Creates a new XREXperienceHelper
  46470. * @see http://doc.babylonjs.com/how_to/webxr
  46471. * @returns a promise for a new XREXperienceHelper
  46472. */
  46473. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46474. }
  46475. }
  46476. declare module BABYLON {
  46477. /**
  46478. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46479. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46480. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46481. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46482. */
  46483. export class VideoDome extends TransformNode {
  46484. /**
  46485. * Define the video source as a Monoscopic panoramic 360 video.
  46486. */
  46487. static readonly MODE_MONOSCOPIC: number;
  46488. /**
  46489. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46490. */
  46491. static readonly MODE_TOPBOTTOM: number;
  46492. /**
  46493. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46494. */
  46495. static readonly MODE_SIDEBYSIDE: number;
  46496. private _useDirectMapping;
  46497. /**
  46498. * The video texture being displayed on the sphere
  46499. */
  46500. protected _videoTexture: VideoTexture;
  46501. /**
  46502. * Gets the video texture being displayed on the sphere
  46503. */
  46504. readonly videoTexture: VideoTexture;
  46505. /**
  46506. * The skybox material
  46507. */
  46508. protected _material: BackgroundMaterial;
  46509. /**
  46510. * The surface used for the skybox
  46511. */
  46512. protected _mesh: Mesh;
  46513. /**
  46514. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46515. * Also see the options.resolution property.
  46516. */
  46517. fovMultiplier: number;
  46518. private _videoMode;
  46519. /**
  46520. * Gets or set the current video mode for the video. It can be:
  46521. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46522. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46523. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46524. */
  46525. videoMode: number;
  46526. /**
  46527. * Oberserver used in Stereoscopic VR Mode.
  46528. */
  46529. private _onBeforeCameraRenderObserver;
  46530. /**
  46531. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46532. * @param name Element's name, child elements will append suffixes for their own names.
  46533. * @param urlsOrVideo defines the url(s) or the video element to use
  46534. * @param options An object containing optional or exposed sub element properties
  46535. */
  46536. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46537. resolution?: number;
  46538. clickToPlay?: boolean;
  46539. autoPlay?: boolean;
  46540. loop?: boolean;
  46541. size?: number;
  46542. poster?: string;
  46543. faceForward?: boolean;
  46544. useDirectMapping?: boolean;
  46545. }, scene: Scene);
  46546. private _changeVideoMode;
  46547. /**
  46548. * Releases resources associated with this node.
  46549. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46550. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46551. */
  46552. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46553. }
  46554. }
  46555. declare module BABYLON {
  46556. /**
  46557. * This class can be used to get instrumentation data from a Babylon engine
  46558. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46559. */
  46560. export class EngineInstrumentation implements IDisposable {
  46561. /**
  46562. * Define the instrumented engine.
  46563. */
  46564. engine: Engine;
  46565. private _captureGPUFrameTime;
  46566. private _gpuFrameTimeToken;
  46567. private _gpuFrameTime;
  46568. private _captureShaderCompilationTime;
  46569. private _shaderCompilationTime;
  46570. private _onBeginFrameObserver;
  46571. private _onEndFrameObserver;
  46572. private _onBeforeShaderCompilationObserver;
  46573. private _onAfterShaderCompilationObserver;
  46574. /**
  46575. * Gets the perf counter used for GPU frame time
  46576. */
  46577. readonly gpuFrameTimeCounter: PerfCounter;
  46578. /**
  46579. * Gets the GPU frame time capture status
  46580. */
  46581. /**
  46582. * Enable or disable the GPU frame time capture
  46583. */
  46584. captureGPUFrameTime: boolean;
  46585. /**
  46586. * Gets the perf counter used for shader compilation time
  46587. */
  46588. readonly shaderCompilationTimeCounter: PerfCounter;
  46589. /**
  46590. * Gets the shader compilation time capture status
  46591. */
  46592. /**
  46593. * Enable or disable the shader compilation time capture
  46594. */
  46595. captureShaderCompilationTime: boolean;
  46596. /**
  46597. * Instantiates a new engine instrumentation.
  46598. * This class can be used to get instrumentation data from a Babylon engine
  46599. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46600. * @param engine Defines the engine to instrument
  46601. */
  46602. constructor(
  46603. /**
  46604. * Define the instrumented engine.
  46605. */
  46606. engine: Engine);
  46607. /**
  46608. * Dispose and release associated resources.
  46609. */
  46610. dispose(): void;
  46611. }
  46612. }
  46613. declare module BABYLON {
  46614. /**
  46615. * This class can be used to get instrumentation data from a Babylon engine
  46616. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46617. */
  46618. export class SceneInstrumentation implements IDisposable {
  46619. /**
  46620. * Defines the scene to instrument
  46621. */
  46622. scene: Scene;
  46623. private _captureActiveMeshesEvaluationTime;
  46624. private _activeMeshesEvaluationTime;
  46625. private _captureRenderTargetsRenderTime;
  46626. private _renderTargetsRenderTime;
  46627. private _captureFrameTime;
  46628. private _frameTime;
  46629. private _captureRenderTime;
  46630. private _renderTime;
  46631. private _captureInterFrameTime;
  46632. private _interFrameTime;
  46633. private _captureParticlesRenderTime;
  46634. private _particlesRenderTime;
  46635. private _captureSpritesRenderTime;
  46636. private _spritesRenderTime;
  46637. private _capturePhysicsTime;
  46638. private _physicsTime;
  46639. private _captureAnimationsTime;
  46640. private _animationsTime;
  46641. private _captureCameraRenderTime;
  46642. private _cameraRenderTime;
  46643. private _onBeforeActiveMeshesEvaluationObserver;
  46644. private _onAfterActiveMeshesEvaluationObserver;
  46645. private _onBeforeRenderTargetsRenderObserver;
  46646. private _onAfterRenderTargetsRenderObserver;
  46647. private _onAfterRenderObserver;
  46648. private _onBeforeDrawPhaseObserver;
  46649. private _onAfterDrawPhaseObserver;
  46650. private _onBeforeAnimationsObserver;
  46651. private _onBeforeParticlesRenderingObserver;
  46652. private _onAfterParticlesRenderingObserver;
  46653. private _onBeforeSpritesRenderingObserver;
  46654. private _onAfterSpritesRenderingObserver;
  46655. private _onBeforePhysicsObserver;
  46656. private _onAfterPhysicsObserver;
  46657. private _onAfterAnimationsObserver;
  46658. private _onBeforeCameraRenderObserver;
  46659. private _onAfterCameraRenderObserver;
  46660. /**
  46661. * Gets the perf counter used for active meshes evaluation time
  46662. */
  46663. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46664. /**
  46665. * Gets the active meshes evaluation time capture status
  46666. */
  46667. /**
  46668. * Enable or disable the active meshes evaluation time capture
  46669. */
  46670. captureActiveMeshesEvaluationTime: boolean;
  46671. /**
  46672. * Gets the perf counter used for render targets render time
  46673. */
  46674. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46675. /**
  46676. * Gets the render targets render time capture status
  46677. */
  46678. /**
  46679. * Enable or disable the render targets render time capture
  46680. */
  46681. captureRenderTargetsRenderTime: boolean;
  46682. /**
  46683. * Gets the perf counter used for particles render time
  46684. */
  46685. readonly particlesRenderTimeCounter: PerfCounter;
  46686. /**
  46687. * Gets the particles render time capture status
  46688. */
  46689. /**
  46690. * Enable or disable the particles render time capture
  46691. */
  46692. captureParticlesRenderTime: boolean;
  46693. /**
  46694. * Gets the perf counter used for sprites render time
  46695. */
  46696. readonly spritesRenderTimeCounter: PerfCounter;
  46697. /**
  46698. * Gets the sprites render time capture status
  46699. */
  46700. /**
  46701. * Enable or disable the sprites render time capture
  46702. */
  46703. captureSpritesRenderTime: boolean;
  46704. /**
  46705. * Gets the perf counter used for physics time
  46706. */
  46707. readonly physicsTimeCounter: PerfCounter;
  46708. /**
  46709. * Gets the physics time capture status
  46710. */
  46711. /**
  46712. * Enable or disable the physics time capture
  46713. */
  46714. capturePhysicsTime: boolean;
  46715. /**
  46716. * Gets the perf counter used for animations time
  46717. */
  46718. readonly animationsTimeCounter: PerfCounter;
  46719. /**
  46720. * Gets the animations time capture status
  46721. */
  46722. /**
  46723. * Enable or disable the animations time capture
  46724. */
  46725. captureAnimationsTime: boolean;
  46726. /**
  46727. * Gets the perf counter used for frame time capture
  46728. */
  46729. readonly frameTimeCounter: PerfCounter;
  46730. /**
  46731. * Gets the frame time capture status
  46732. */
  46733. /**
  46734. * Enable or disable the frame time capture
  46735. */
  46736. captureFrameTime: boolean;
  46737. /**
  46738. * Gets the perf counter used for inter-frames time capture
  46739. */
  46740. readonly interFrameTimeCounter: PerfCounter;
  46741. /**
  46742. * Gets the inter-frames time capture status
  46743. */
  46744. /**
  46745. * Enable or disable the inter-frames time capture
  46746. */
  46747. captureInterFrameTime: boolean;
  46748. /**
  46749. * Gets the perf counter used for render time capture
  46750. */
  46751. readonly renderTimeCounter: PerfCounter;
  46752. /**
  46753. * Gets the render time capture status
  46754. */
  46755. /**
  46756. * Enable or disable the render time capture
  46757. */
  46758. captureRenderTime: boolean;
  46759. /**
  46760. * Gets the perf counter used for camera render time capture
  46761. */
  46762. readonly cameraRenderTimeCounter: PerfCounter;
  46763. /**
  46764. * Gets the camera render time capture status
  46765. */
  46766. /**
  46767. * Enable or disable the camera render time capture
  46768. */
  46769. captureCameraRenderTime: boolean;
  46770. /**
  46771. * Gets the perf counter used for draw calls
  46772. */
  46773. readonly drawCallsCounter: PerfCounter;
  46774. /**
  46775. * Instantiates a new scene instrumentation.
  46776. * This class can be used to get instrumentation data from a Babylon engine
  46777. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46778. * @param scene Defines the scene to instrument
  46779. */
  46780. constructor(
  46781. /**
  46782. * Defines the scene to instrument
  46783. */
  46784. scene: Scene);
  46785. /**
  46786. * Dispose and release associated resources.
  46787. */
  46788. dispose(): void;
  46789. }
  46790. }
  46791. declare module BABYLON {
  46792. /** @hidden */
  46793. export var glowMapGenerationPixelShader: {
  46794. name: string;
  46795. shader: string;
  46796. };
  46797. }
  46798. declare module BABYLON {
  46799. /** @hidden */
  46800. export var glowMapGenerationVertexShader: {
  46801. name: string;
  46802. shader: string;
  46803. };
  46804. }
  46805. declare module BABYLON {
  46806. /**
  46807. * Effect layer options. This helps customizing the behaviour
  46808. * of the effect layer.
  46809. */
  46810. export interface IEffectLayerOptions {
  46811. /**
  46812. * Multiplication factor apply to the canvas size to compute the render target size
  46813. * used to generated the objects (the smaller the faster).
  46814. */
  46815. mainTextureRatio: number;
  46816. /**
  46817. * Enforces a fixed size texture to ensure effect stability across devices.
  46818. */
  46819. mainTextureFixedSize?: number;
  46820. /**
  46821. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46822. */
  46823. alphaBlendingMode: number;
  46824. /**
  46825. * The camera attached to the layer.
  46826. */
  46827. camera: Nullable<Camera>;
  46828. /**
  46829. * The rendering group to draw the layer in.
  46830. */
  46831. renderingGroupId: number;
  46832. }
  46833. /**
  46834. * The effect layer Helps adding post process effect blended with the main pass.
  46835. *
  46836. * This can be for instance use to generate glow or higlight effects on the scene.
  46837. *
  46838. * The effect layer class can not be used directly and is intented to inherited from to be
  46839. * customized per effects.
  46840. */
  46841. export abstract class EffectLayer {
  46842. private _vertexBuffers;
  46843. private _indexBuffer;
  46844. private _cachedDefines;
  46845. private _effectLayerMapGenerationEffect;
  46846. private _effectLayerOptions;
  46847. private _mergeEffect;
  46848. protected _scene: Scene;
  46849. protected _engine: Engine;
  46850. protected _maxSize: number;
  46851. protected _mainTextureDesiredSize: ISize;
  46852. protected _mainTexture: RenderTargetTexture;
  46853. protected _shouldRender: boolean;
  46854. protected _postProcesses: PostProcess[];
  46855. protected _textures: BaseTexture[];
  46856. protected _emissiveTextureAndColor: {
  46857. texture: Nullable<BaseTexture>;
  46858. color: Color4;
  46859. };
  46860. /**
  46861. * The name of the layer
  46862. */
  46863. name: string;
  46864. /**
  46865. * The clear color of the texture used to generate the glow map.
  46866. */
  46867. neutralColor: Color4;
  46868. /**
  46869. * Specifies wether the highlight layer is enabled or not.
  46870. */
  46871. isEnabled: boolean;
  46872. /**
  46873. * Gets the camera attached to the layer.
  46874. */
  46875. readonly camera: Nullable<Camera>;
  46876. /**
  46877. * Gets the rendering group id the layer should render in.
  46878. */
  46879. readonly renderingGroupId: number;
  46880. /**
  46881. * An event triggered when the effect layer has been disposed.
  46882. */
  46883. onDisposeObservable: Observable<EffectLayer>;
  46884. /**
  46885. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46886. */
  46887. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46888. /**
  46889. * An event triggered when the generated texture is being merged in the scene.
  46890. */
  46891. onBeforeComposeObservable: Observable<EffectLayer>;
  46892. /**
  46893. * An event triggered when the generated texture has been merged in the scene.
  46894. */
  46895. onAfterComposeObservable: Observable<EffectLayer>;
  46896. /**
  46897. * An event triggered when the efffect layer changes its size.
  46898. */
  46899. onSizeChangedObservable: Observable<EffectLayer>;
  46900. /** @hidden */
  46901. static _SceneComponentInitialization: (scene: Scene) => void;
  46902. /**
  46903. * Instantiates a new effect Layer and references it in the scene.
  46904. * @param name The name of the layer
  46905. * @param scene The scene to use the layer in
  46906. */
  46907. constructor(
  46908. /** The Friendly of the effect in the scene */
  46909. name: string, scene: Scene);
  46910. /**
  46911. * Get the effect name of the layer.
  46912. * @return The effect name
  46913. */
  46914. abstract getEffectName(): string;
  46915. /**
  46916. * Checks for the readiness of the element composing the layer.
  46917. * @param subMesh the mesh to check for
  46918. * @param useInstances specify wether or not to use instances to render the mesh
  46919. * @return true if ready otherwise, false
  46920. */
  46921. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46922. /**
  46923. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46924. * @returns true if the effect requires stencil during the main canvas render pass.
  46925. */
  46926. abstract needStencil(): boolean;
  46927. /**
  46928. * Create the merge effect. This is the shader use to blit the information back
  46929. * to the main canvas at the end of the scene rendering.
  46930. * @returns The effect containing the shader used to merge the effect on the main canvas
  46931. */
  46932. protected abstract _createMergeEffect(): Effect;
  46933. /**
  46934. * Creates the render target textures and post processes used in the effect layer.
  46935. */
  46936. protected abstract _createTextureAndPostProcesses(): void;
  46937. /**
  46938. * Implementation specific of rendering the generating effect on the main canvas.
  46939. * @param effect The effect used to render through
  46940. */
  46941. protected abstract _internalRender(effect: Effect): void;
  46942. /**
  46943. * Sets the required values for both the emissive texture and and the main color.
  46944. */
  46945. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46946. /**
  46947. * Free any resources and references associated to a mesh.
  46948. * Internal use
  46949. * @param mesh The mesh to free.
  46950. */
  46951. abstract _disposeMesh(mesh: Mesh): void;
  46952. /**
  46953. * Serializes this layer (Glow or Highlight for example)
  46954. * @returns a serialized layer object
  46955. */
  46956. abstract serialize?(): any;
  46957. /**
  46958. * Initializes the effect layer with the required options.
  46959. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46960. */
  46961. protected _init(options: Partial<IEffectLayerOptions>): void;
  46962. /**
  46963. * Generates the index buffer of the full screen quad blending to the main canvas.
  46964. */
  46965. private _generateIndexBuffer;
  46966. /**
  46967. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46968. */
  46969. private _generateVertexBuffer;
  46970. /**
  46971. * Sets the main texture desired size which is the closest power of two
  46972. * of the engine canvas size.
  46973. */
  46974. private _setMainTextureSize;
  46975. /**
  46976. * Creates the main texture for the effect layer.
  46977. */
  46978. protected _createMainTexture(): void;
  46979. /**
  46980. * Adds specific effects defines.
  46981. * @param defines The defines to add specifics to.
  46982. */
  46983. protected _addCustomEffectDefines(defines: string[]): void;
  46984. /**
  46985. * Checks for the readiness of the element composing the layer.
  46986. * @param subMesh the mesh to check for
  46987. * @param useInstances specify wether or not to use instances to render the mesh
  46988. * @param emissiveTexture the associated emissive texture used to generate the glow
  46989. * @return true if ready otherwise, false
  46990. */
  46991. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46992. /**
  46993. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46994. */
  46995. render(): void;
  46996. /**
  46997. * Determine if a given mesh will be used in the current effect.
  46998. * @param mesh mesh to test
  46999. * @returns true if the mesh will be used
  47000. */
  47001. hasMesh(mesh: AbstractMesh): boolean;
  47002. /**
  47003. * Returns true if the layer contains information to display, otherwise false.
  47004. * @returns true if the glow layer should be rendered
  47005. */
  47006. shouldRender(): boolean;
  47007. /**
  47008. * Returns true if the mesh should render, otherwise false.
  47009. * @param mesh The mesh to render
  47010. * @returns true if it should render otherwise false
  47011. */
  47012. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47013. /**
  47014. * Returns true if the mesh can be rendered, otherwise false.
  47015. * @param mesh The mesh to render
  47016. * @param material The material used on the mesh
  47017. * @returns true if it can be rendered otherwise false
  47018. */
  47019. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47020. /**
  47021. * Returns true if the mesh should render, otherwise false.
  47022. * @param mesh The mesh to render
  47023. * @returns true if it should render otherwise false
  47024. */
  47025. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47026. /**
  47027. * Renders the submesh passed in parameter to the generation map.
  47028. */
  47029. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  47030. /**
  47031. * Rebuild the required buffers.
  47032. * @hidden Internal use only.
  47033. */
  47034. _rebuild(): void;
  47035. /**
  47036. * Dispose only the render target textures and post process.
  47037. */
  47038. private _disposeTextureAndPostProcesses;
  47039. /**
  47040. * Dispose the highlight layer and free resources.
  47041. */
  47042. dispose(): void;
  47043. /**
  47044. * Gets the class name of the effect layer
  47045. * @returns the string with the class name of the effect layer
  47046. */
  47047. getClassName(): string;
  47048. /**
  47049. * Creates an effect layer from parsed effect layer data
  47050. * @param parsedEffectLayer defines effect layer data
  47051. * @param scene defines the current scene
  47052. * @param rootUrl defines the root URL containing the effect layer information
  47053. * @returns a parsed effect Layer
  47054. */
  47055. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47056. }
  47057. }
  47058. declare module BABYLON {
  47059. interface AbstractScene {
  47060. /**
  47061. * The list of effect layers (highlights/glow) added to the scene
  47062. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47063. * @see http://doc.babylonjs.com/how_to/glow_layer
  47064. */
  47065. effectLayers: Array<EffectLayer>;
  47066. /**
  47067. * Removes the given effect layer from this scene.
  47068. * @param toRemove defines the effect layer to remove
  47069. * @returns the index of the removed effect layer
  47070. */
  47071. removeEffectLayer(toRemove: EffectLayer): number;
  47072. /**
  47073. * Adds the given effect layer to this scene
  47074. * @param newEffectLayer defines the effect layer to add
  47075. */
  47076. addEffectLayer(newEffectLayer: EffectLayer): void;
  47077. }
  47078. /**
  47079. * Defines the layer scene component responsible to manage any effect layers
  47080. * in a given scene.
  47081. */
  47082. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47083. /**
  47084. * The component name helpfull to identify the component in the list of scene components.
  47085. */
  47086. readonly name: string;
  47087. /**
  47088. * The scene the component belongs to.
  47089. */
  47090. scene: Scene;
  47091. private _engine;
  47092. private _renderEffects;
  47093. private _needStencil;
  47094. private _previousStencilState;
  47095. /**
  47096. * Creates a new instance of the component for the given scene
  47097. * @param scene Defines the scene to register the component in
  47098. */
  47099. constructor(scene: Scene);
  47100. /**
  47101. * Registers the component in a given scene
  47102. */
  47103. register(): void;
  47104. /**
  47105. * Rebuilds the elements related to this component in case of
  47106. * context lost for instance.
  47107. */
  47108. rebuild(): void;
  47109. /**
  47110. * Serializes the component data to the specified json object
  47111. * @param serializationObject The object to serialize to
  47112. */
  47113. serialize(serializationObject: any): void;
  47114. /**
  47115. * Adds all the element from the container to the scene
  47116. * @param container the container holding the elements
  47117. */
  47118. addFromContainer(container: AbstractScene): void;
  47119. /**
  47120. * Removes all the elements in the container from the scene
  47121. * @param container contains the elements to remove
  47122. * @param dispose if the removed element should be disposed (default: false)
  47123. */
  47124. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47125. /**
  47126. * Disposes the component and the associated ressources.
  47127. */
  47128. dispose(): void;
  47129. private _isReadyForMesh;
  47130. private _renderMainTexture;
  47131. private _setStencil;
  47132. private _setStencilBack;
  47133. private _draw;
  47134. private _drawCamera;
  47135. private _drawRenderingGroup;
  47136. }
  47137. }
  47138. declare module BABYLON {
  47139. /** @hidden */
  47140. export var glowMapMergePixelShader: {
  47141. name: string;
  47142. shader: string;
  47143. };
  47144. }
  47145. declare module BABYLON {
  47146. /** @hidden */
  47147. export var glowMapMergeVertexShader: {
  47148. name: string;
  47149. shader: string;
  47150. };
  47151. }
  47152. declare module BABYLON {
  47153. interface AbstractScene {
  47154. /**
  47155. * Return a the first highlight layer of the scene with a given name.
  47156. * @param name The name of the highlight layer to look for.
  47157. * @return The highlight layer if found otherwise null.
  47158. */
  47159. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47160. }
  47161. /**
  47162. * Glow layer options. This helps customizing the behaviour
  47163. * of the glow layer.
  47164. */
  47165. export interface IGlowLayerOptions {
  47166. /**
  47167. * Multiplication factor apply to the canvas size to compute the render target size
  47168. * used to generated the glowing objects (the smaller the faster).
  47169. */
  47170. mainTextureRatio: number;
  47171. /**
  47172. * Enforces a fixed size texture to ensure resize independant blur.
  47173. */
  47174. mainTextureFixedSize?: number;
  47175. /**
  47176. * How big is the kernel of the blur texture.
  47177. */
  47178. blurKernelSize: number;
  47179. /**
  47180. * The camera attached to the layer.
  47181. */
  47182. camera: Nullable<Camera>;
  47183. /**
  47184. * Enable MSAA by chosing the number of samples.
  47185. */
  47186. mainTextureSamples?: number;
  47187. /**
  47188. * The rendering group to draw the layer in.
  47189. */
  47190. renderingGroupId: number;
  47191. }
  47192. /**
  47193. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47194. *
  47195. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47196. * glowy meshes to your scene.
  47197. *
  47198. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47199. */
  47200. export class GlowLayer extends EffectLayer {
  47201. /**
  47202. * Effect Name of the layer.
  47203. */
  47204. static readonly EffectName: string;
  47205. /**
  47206. * The default blur kernel size used for the glow.
  47207. */
  47208. static DefaultBlurKernelSize: number;
  47209. /**
  47210. * The default texture size ratio used for the glow.
  47211. */
  47212. static DefaultTextureRatio: number;
  47213. /**
  47214. * Sets the kernel size of the blur.
  47215. */
  47216. /**
  47217. * Gets the kernel size of the blur.
  47218. */
  47219. blurKernelSize: number;
  47220. /**
  47221. * Sets the glow intensity.
  47222. */
  47223. /**
  47224. * Gets the glow intensity.
  47225. */
  47226. intensity: number;
  47227. private _options;
  47228. private _intensity;
  47229. private _horizontalBlurPostprocess1;
  47230. private _verticalBlurPostprocess1;
  47231. private _horizontalBlurPostprocess2;
  47232. private _verticalBlurPostprocess2;
  47233. private _blurTexture1;
  47234. private _blurTexture2;
  47235. private _postProcesses1;
  47236. private _postProcesses2;
  47237. private _includedOnlyMeshes;
  47238. private _excludedMeshes;
  47239. /**
  47240. * Callback used to let the user override the color selection on a per mesh basis
  47241. */
  47242. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47243. /**
  47244. * Callback used to let the user override the texture selection on a per mesh basis
  47245. */
  47246. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47247. /**
  47248. * Instantiates a new glow Layer and references it to the scene.
  47249. * @param name The name of the layer
  47250. * @param scene The scene to use the layer in
  47251. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47252. */
  47253. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47254. /**
  47255. * Get the effect name of the layer.
  47256. * @return The effect name
  47257. */
  47258. getEffectName(): string;
  47259. /**
  47260. * Create the merge effect. This is the shader use to blit the information back
  47261. * to the main canvas at the end of the scene rendering.
  47262. */
  47263. protected _createMergeEffect(): Effect;
  47264. /**
  47265. * Creates the render target textures and post processes used in the glow layer.
  47266. */
  47267. protected _createTextureAndPostProcesses(): void;
  47268. /**
  47269. * Checks for the readiness of the element composing the layer.
  47270. * @param subMesh the mesh to check for
  47271. * @param useInstances specify wether or not to use instances to render the mesh
  47272. * @param emissiveTexture the associated emissive texture used to generate the glow
  47273. * @return true if ready otherwise, false
  47274. */
  47275. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47276. /**
  47277. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47278. */
  47279. needStencil(): boolean;
  47280. /**
  47281. * Returns true if the mesh can be rendered, otherwise false.
  47282. * @param mesh The mesh to render
  47283. * @param material The material used on the mesh
  47284. * @returns true if it can be rendered otherwise false
  47285. */
  47286. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47287. /**
  47288. * Implementation specific of rendering the generating effect on the main canvas.
  47289. * @param effect The effect used to render through
  47290. */
  47291. protected _internalRender(effect: Effect): void;
  47292. /**
  47293. * Sets the required values for both the emissive texture and and the main color.
  47294. */
  47295. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47296. /**
  47297. * Returns true if the mesh should render, otherwise false.
  47298. * @param mesh The mesh to render
  47299. * @returns true if it should render otherwise false
  47300. */
  47301. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47302. /**
  47303. * Adds specific effects defines.
  47304. * @param defines The defines to add specifics to.
  47305. */
  47306. protected _addCustomEffectDefines(defines: string[]): void;
  47307. /**
  47308. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47309. * @param mesh The mesh to exclude from the glow layer
  47310. */
  47311. addExcludedMesh(mesh: Mesh): void;
  47312. /**
  47313. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47314. * @param mesh The mesh to remove
  47315. */
  47316. removeExcludedMesh(mesh: Mesh): void;
  47317. /**
  47318. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47319. * @param mesh The mesh to include in the glow layer
  47320. */
  47321. addIncludedOnlyMesh(mesh: Mesh): void;
  47322. /**
  47323. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47324. * @param mesh The mesh to remove
  47325. */
  47326. removeIncludedOnlyMesh(mesh: Mesh): void;
  47327. /**
  47328. * Determine if a given mesh will be used in the glow layer
  47329. * @param mesh The mesh to test
  47330. * @returns true if the mesh will be highlighted by the current glow layer
  47331. */
  47332. hasMesh(mesh: AbstractMesh): boolean;
  47333. /**
  47334. * Free any resources and references associated to a mesh.
  47335. * Internal use
  47336. * @param mesh The mesh to free.
  47337. * @hidden
  47338. */
  47339. _disposeMesh(mesh: Mesh): void;
  47340. /**
  47341. * Gets the class name of the effect layer
  47342. * @returns the string with the class name of the effect layer
  47343. */
  47344. getClassName(): string;
  47345. /**
  47346. * Serializes this glow layer
  47347. * @returns a serialized glow layer object
  47348. */
  47349. serialize(): any;
  47350. /**
  47351. * Creates a Glow Layer from parsed glow layer data
  47352. * @param parsedGlowLayer defines glow layer data
  47353. * @param scene defines the current scene
  47354. * @param rootUrl defines the root URL containing the glow layer information
  47355. * @returns a parsed Glow Layer
  47356. */
  47357. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47358. }
  47359. }
  47360. declare module BABYLON {
  47361. /** @hidden */
  47362. export var glowBlurPostProcessPixelShader: {
  47363. name: string;
  47364. shader: string;
  47365. };
  47366. }
  47367. declare module BABYLON {
  47368. interface AbstractScene {
  47369. /**
  47370. * Return a the first highlight layer of the scene with a given name.
  47371. * @param name The name of the highlight layer to look for.
  47372. * @return The highlight layer if found otherwise null.
  47373. */
  47374. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47375. }
  47376. /**
  47377. * Highlight layer options. This helps customizing the behaviour
  47378. * of the highlight layer.
  47379. */
  47380. export interface IHighlightLayerOptions {
  47381. /**
  47382. * Multiplication factor apply to the canvas size to compute the render target size
  47383. * used to generated the glowing objects (the smaller the faster).
  47384. */
  47385. mainTextureRatio: number;
  47386. /**
  47387. * Enforces a fixed size texture to ensure resize independant blur.
  47388. */
  47389. mainTextureFixedSize?: number;
  47390. /**
  47391. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47392. * of the picture to blur (the smaller the faster).
  47393. */
  47394. blurTextureSizeRatio: number;
  47395. /**
  47396. * How big in texel of the blur texture is the vertical blur.
  47397. */
  47398. blurVerticalSize: number;
  47399. /**
  47400. * How big in texel of the blur texture is the horizontal blur.
  47401. */
  47402. blurHorizontalSize: number;
  47403. /**
  47404. * Alpha blending mode used to apply the blur. Default is combine.
  47405. */
  47406. alphaBlendingMode: number;
  47407. /**
  47408. * The camera attached to the layer.
  47409. */
  47410. camera: Nullable<Camera>;
  47411. /**
  47412. * Should we display highlight as a solid stroke?
  47413. */
  47414. isStroke?: boolean;
  47415. /**
  47416. * The rendering group to draw the layer in.
  47417. */
  47418. renderingGroupId: number;
  47419. }
  47420. /**
  47421. * The highlight layer Helps adding a glow effect around a mesh.
  47422. *
  47423. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47424. * glowy meshes to your scene.
  47425. *
  47426. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47427. */
  47428. export class HighlightLayer extends EffectLayer {
  47429. name: string;
  47430. /**
  47431. * Effect Name of the highlight layer.
  47432. */
  47433. static readonly EffectName: string;
  47434. /**
  47435. * The neutral color used during the preparation of the glow effect.
  47436. * This is black by default as the blend operation is a blend operation.
  47437. */
  47438. static NeutralColor: Color4;
  47439. /**
  47440. * Stencil value used for glowing meshes.
  47441. */
  47442. static GlowingMeshStencilReference: number;
  47443. /**
  47444. * Stencil value used for the other meshes in the scene.
  47445. */
  47446. static NormalMeshStencilReference: number;
  47447. /**
  47448. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47449. */
  47450. innerGlow: boolean;
  47451. /**
  47452. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47453. */
  47454. outerGlow: boolean;
  47455. /**
  47456. * Specifies the horizontal size of the blur.
  47457. */
  47458. /**
  47459. * Gets the horizontal size of the blur.
  47460. */
  47461. blurHorizontalSize: number;
  47462. /**
  47463. * Specifies the vertical size of the blur.
  47464. */
  47465. /**
  47466. * Gets the vertical size of the blur.
  47467. */
  47468. blurVerticalSize: number;
  47469. /**
  47470. * An event triggered when the highlight layer is being blurred.
  47471. */
  47472. onBeforeBlurObservable: Observable<HighlightLayer>;
  47473. /**
  47474. * An event triggered when the highlight layer has been blurred.
  47475. */
  47476. onAfterBlurObservable: Observable<HighlightLayer>;
  47477. private _instanceGlowingMeshStencilReference;
  47478. private _options;
  47479. private _downSamplePostprocess;
  47480. private _horizontalBlurPostprocess;
  47481. private _verticalBlurPostprocess;
  47482. private _blurTexture;
  47483. private _meshes;
  47484. private _excludedMeshes;
  47485. /**
  47486. * Instantiates a new highlight Layer and references it to the scene..
  47487. * @param name The name of the layer
  47488. * @param scene The scene to use the layer in
  47489. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47490. */
  47491. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47492. /**
  47493. * Get the effect name of the layer.
  47494. * @return The effect name
  47495. */
  47496. getEffectName(): string;
  47497. /**
  47498. * Create the merge effect. This is the shader use to blit the information back
  47499. * to the main canvas at the end of the scene rendering.
  47500. */
  47501. protected _createMergeEffect(): Effect;
  47502. /**
  47503. * Creates the render target textures and post processes used in the highlight layer.
  47504. */
  47505. protected _createTextureAndPostProcesses(): void;
  47506. /**
  47507. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47508. */
  47509. needStencil(): boolean;
  47510. /**
  47511. * Checks for the readiness of the element composing the layer.
  47512. * @param subMesh the mesh to check for
  47513. * @param useInstances specify wether or not to use instances to render the mesh
  47514. * @param emissiveTexture the associated emissive texture used to generate the glow
  47515. * @return true if ready otherwise, false
  47516. */
  47517. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47518. /**
  47519. * Implementation specific of rendering the generating effect on the main canvas.
  47520. * @param effect The effect used to render through
  47521. */
  47522. protected _internalRender(effect: Effect): void;
  47523. /**
  47524. * Returns true if the layer contains information to display, otherwise false.
  47525. */
  47526. shouldRender(): boolean;
  47527. /**
  47528. * Returns true if the mesh should render, otherwise false.
  47529. * @param mesh The mesh to render
  47530. * @returns true if it should render otherwise false
  47531. */
  47532. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47533. /**
  47534. * Sets the required values for both the emissive texture and and the main color.
  47535. */
  47536. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47537. /**
  47538. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47539. * @param mesh The mesh to exclude from the highlight layer
  47540. */
  47541. addExcludedMesh(mesh: Mesh): void;
  47542. /**
  47543. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47544. * @param mesh The mesh to highlight
  47545. */
  47546. removeExcludedMesh(mesh: Mesh): void;
  47547. /**
  47548. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47549. * @param mesh mesh to test
  47550. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47551. */
  47552. hasMesh(mesh: AbstractMesh): boolean;
  47553. /**
  47554. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47555. * @param mesh The mesh to highlight
  47556. * @param color The color of the highlight
  47557. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47558. */
  47559. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47560. /**
  47561. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47562. * @param mesh The mesh to highlight
  47563. */
  47564. removeMesh(mesh: Mesh): void;
  47565. /**
  47566. * Force the stencil to the normal expected value for none glowing parts
  47567. */
  47568. private _defaultStencilReference;
  47569. /**
  47570. * Free any resources and references associated to a mesh.
  47571. * Internal use
  47572. * @param mesh The mesh to free.
  47573. * @hidden
  47574. */
  47575. _disposeMesh(mesh: Mesh): void;
  47576. /**
  47577. * Dispose the highlight layer and free resources.
  47578. */
  47579. dispose(): void;
  47580. /**
  47581. * Gets the class name of the effect layer
  47582. * @returns the string with the class name of the effect layer
  47583. */
  47584. getClassName(): string;
  47585. /**
  47586. * Serializes this Highlight layer
  47587. * @returns a serialized Highlight layer object
  47588. */
  47589. serialize(): any;
  47590. /**
  47591. * Creates a Highlight layer from parsed Highlight layer data
  47592. * @param parsedHightlightLayer defines the Highlight layer data
  47593. * @param scene defines the current scene
  47594. * @param rootUrl defines the root URL containing the Highlight layer information
  47595. * @returns a parsed Highlight layer
  47596. */
  47597. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47598. }
  47599. }
  47600. declare module BABYLON {
  47601. /** @hidden */
  47602. export var lensFlarePixelShader: {
  47603. name: string;
  47604. shader: string;
  47605. };
  47606. }
  47607. declare module BABYLON {
  47608. /** @hidden */
  47609. export var lensFlareVertexShader: {
  47610. name: string;
  47611. shader: string;
  47612. };
  47613. }
  47614. declare module BABYLON {
  47615. /**
  47616. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47617. * It is usually composed of several `lensFlare`.
  47618. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47619. */
  47620. export class LensFlareSystem {
  47621. /**
  47622. * Define the name of the lens flare system
  47623. */
  47624. name: string;
  47625. /**
  47626. * List of lens flares used in this system.
  47627. */
  47628. lensFlares: LensFlare[];
  47629. /**
  47630. * Define a limit from the border the lens flare can be visible.
  47631. */
  47632. borderLimit: number;
  47633. /**
  47634. * Define a viewport border we do not want to see the lens flare in.
  47635. */
  47636. viewportBorder: number;
  47637. /**
  47638. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47639. */
  47640. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47641. /**
  47642. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47643. */
  47644. layerMask: number;
  47645. /**
  47646. * Define the id of the lens flare system in the scene.
  47647. * (equal to name by default)
  47648. */
  47649. id: string;
  47650. private _scene;
  47651. private _emitter;
  47652. private _vertexBuffers;
  47653. private _indexBuffer;
  47654. private _effect;
  47655. private _positionX;
  47656. private _positionY;
  47657. private _isEnabled;
  47658. /** @hidden */
  47659. static _SceneComponentInitialization: (scene: Scene) => void;
  47660. /**
  47661. * Instantiates a lens flare system.
  47662. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47663. * It is usually composed of several `lensFlare`.
  47664. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47665. * @param name Define the name of the lens flare system in the scene
  47666. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47667. * @param scene Define the scene the lens flare system belongs to
  47668. */
  47669. constructor(
  47670. /**
  47671. * Define the name of the lens flare system
  47672. */
  47673. name: string, emitter: any, scene: Scene);
  47674. /**
  47675. * Define if the lens flare system is enabled.
  47676. */
  47677. isEnabled: boolean;
  47678. /**
  47679. * Get the scene the effects belongs to.
  47680. * @returns the scene holding the lens flare system
  47681. */
  47682. getScene(): Scene;
  47683. /**
  47684. * Get the emitter of the lens flare system.
  47685. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47686. * @returns the emitter of the lens flare system
  47687. */
  47688. getEmitter(): any;
  47689. /**
  47690. * Set the emitter of the lens flare system.
  47691. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47692. * @param newEmitter Define the new emitter of the system
  47693. */
  47694. setEmitter(newEmitter: any): void;
  47695. /**
  47696. * Get the lens flare system emitter position.
  47697. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47698. * @returns the position
  47699. */
  47700. getEmitterPosition(): Vector3;
  47701. /**
  47702. * @hidden
  47703. */
  47704. computeEffectivePosition(globalViewport: Viewport): boolean;
  47705. /** @hidden */
  47706. _isVisible(): boolean;
  47707. /**
  47708. * @hidden
  47709. */
  47710. render(): boolean;
  47711. /**
  47712. * Dispose and release the lens flare with its associated resources.
  47713. */
  47714. dispose(): void;
  47715. /**
  47716. * Parse a lens flare system from a JSON repressentation
  47717. * @param parsedLensFlareSystem Define the JSON to parse
  47718. * @param scene Define the scene the parsed system should be instantiated in
  47719. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47720. * @returns the parsed system
  47721. */
  47722. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47723. /**
  47724. * Serialize the current Lens Flare System into a JSON representation.
  47725. * @returns the serialized JSON
  47726. */
  47727. serialize(): any;
  47728. }
  47729. }
  47730. declare module BABYLON {
  47731. /**
  47732. * This represents one of the lens effect in a `lensFlareSystem`.
  47733. * It controls one of the indiviual texture used in the effect.
  47734. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47735. */
  47736. export class LensFlare {
  47737. /**
  47738. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47739. */
  47740. size: number;
  47741. /**
  47742. * 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.
  47743. */
  47744. position: number;
  47745. /**
  47746. * Define the lens color.
  47747. */
  47748. color: Color3;
  47749. /**
  47750. * Define the lens texture.
  47751. */
  47752. texture: Nullable<Texture>;
  47753. /**
  47754. * Define the alpha mode to render this particular lens.
  47755. */
  47756. alphaMode: number;
  47757. private _system;
  47758. /**
  47759. * Creates a new Lens Flare.
  47760. * This represents one of the lens effect in a `lensFlareSystem`.
  47761. * It controls one of the indiviual texture used in the effect.
  47762. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47763. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47764. * @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.
  47765. * @param color Define the lens color
  47766. * @param imgUrl Define the lens texture url
  47767. * @param system Define the `lensFlareSystem` this flare is part of
  47768. * @returns The newly created Lens Flare
  47769. */
  47770. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47771. /**
  47772. * Instantiates a new Lens Flare.
  47773. * This represents one of the lens effect in a `lensFlareSystem`.
  47774. * It controls one of the indiviual texture used in the effect.
  47775. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47776. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47777. * @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.
  47778. * @param color Define the lens color
  47779. * @param imgUrl Define the lens texture url
  47780. * @param system Define the `lensFlareSystem` this flare is part of
  47781. */
  47782. constructor(
  47783. /**
  47784. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47785. */
  47786. size: number,
  47787. /**
  47788. * 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.
  47789. */
  47790. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47791. /**
  47792. * Dispose and release the lens flare with its associated resources.
  47793. */
  47794. dispose(): void;
  47795. }
  47796. }
  47797. declare module BABYLON {
  47798. interface AbstractScene {
  47799. /**
  47800. * The list of lens flare system added to the scene
  47801. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47802. */
  47803. lensFlareSystems: Array<LensFlareSystem>;
  47804. /**
  47805. * Removes the given lens flare system from this scene.
  47806. * @param toRemove The lens flare system to remove
  47807. * @returns The index of the removed lens flare system
  47808. */
  47809. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47810. /**
  47811. * Adds the given lens flare system to this scene
  47812. * @param newLensFlareSystem The lens flare system to add
  47813. */
  47814. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47815. /**
  47816. * Gets a lens flare system using its name
  47817. * @param name defines the name to look for
  47818. * @returns the lens flare system or null if not found
  47819. */
  47820. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47821. /**
  47822. * Gets a lens flare system using its id
  47823. * @param id defines the id to look for
  47824. * @returns the lens flare system or null if not found
  47825. */
  47826. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47827. }
  47828. /**
  47829. * Defines the lens flare scene component responsible to manage any lens flares
  47830. * in a given scene.
  47831. */
  47832. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47833. /**
  47834. * The component name helpfull to identify the component in the list of scene components.
  47835. */
  47836. readonly name: string;
  47837. /**
  47838. * The scene the component belongs to.
  47839. */
  47840. scene: Scene;
  47841. /**
  47842. * Creates a new instance of the component for the given scene
  47843. * @param scene Defines the scene to register the component in
  47844. */
  47845. constructor(scene: Scene);
  47846. /**
  47847. * Registers the component in a given scene
  47848. */
  47849. register(): void;
  47850. /**
  47851. * Rebuilds the elements related to this component in case of
  47852. * context lost for instance.
  47853. */
  47854. rebuild(): void;
  47855. /**
  47856. * Adds all the element from the container to the scene
  47857. * @param container the container holding the elements
  47858. */
  47859. addFromContainer(container: AbstractScene): void;
  47860. /**
  47861. * Removes all the elements in the container from the scene
  47862. * @param container contains the elements to remove
  47863. * @param dispose if the removed element should be disposed (default: false)
  47864. */
  47865. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47866. /**
  47867. * Serializes the component data to the specified json object
  47868. * @param serializationObject The object to serialize to
  47869. */
  47870. serialize(serializationObject: any): void;
  47871. /**
  47872. * Disposes the component and the associated ressources.
  47873. */
  47874. dispose(): void;
  47875. private _draw;
  47876. }
  47877. }
  47878. declare module BABYLON {
  47879. /**
  47880. * Defines the shadow generator component responsible to manage any shadow generators
  47881. * in a given scene.
  47882. */
  47883. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47884. /**
  47885. * The component name helpfull to identify the component in the list of scene components.
  47886. */
  47887. readonly name: string;
  47888. /**
  47889. * The scene the component belongs to.
  47890. */
  47891. scene: Scene;
  47892. /**
  47893. * Creates a new instance of the component for the given scene
  47894. * @param scene Defines the scene to register the component in
  47895. */
  47896. constructor(scene: Scene);
  47897. /**
  47898. * Registers the component in a given scene
  47899. */
  47900. register(): void;
  47901. /**
  47902. * Rebuilds the elements related to this component in case of
  47903. * context lost for instance.
  47904. */
  47905. rebuild(): void;
  47906. /**
  47907. * Serializes the component data to the specified json object
  47908. * @param serializationObject The object to serialize to
  47909. */
  47910. serialize(serializationObject: any): void;
  47911. /**
  47912. * Adds all the element from the container to the scene
  47913. * @param container the container holding the elements
  47914. */
  47915. addFromContainer(container: AbstractScene): void;
  47916. /**
  47917. * Removes all the elements in the container from the scene
  47918. * @param container contains the elements to remove
  47919. * @param dispose if the removed element should be disposed (default: false)
  47920. */
  47921. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47922. /**
  47923. * Rebuilds the elements related to this component in case of
  47924. * context lost for instance.
  47925. */
  47926. dispose(): void;
  47927. private _gatherRenderTargets;
  47928. }
  47929. }
  47930. declare module BABYLON {
  47931. /**
  47932. * A point light is a light defined by an unique point in world space.
  47933. * The light is emitted in every direction from this point.
  47934. * A good example of a point light is a standard light bulb.
  47935. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47936. */
  47937. export class PointLight extends ShadowLight {
  47938. private _shadowAngle;
  47939. /**
  47940. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47941. * This specifies what angle the shadow will use to be created.
  47942. *
  47943. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47944. */
  47945. /**
  47946. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47947. * This specifies what angle the shadow will use to be created.
  47948. *
  47949. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47950. */
  47951. shadowAngle: number;
  47952. /**
  47953. * Gets the direction if it has been set.
  47954. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47955. */
  47956. /**
  47957. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47958. */
  47959. direction: Vector3;
  47960. /**
  47961. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47962. * A PointLight emits the light in every direction.
  47963. * It can cast shadows.
  47964. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47965. * ```javascript
  47966. * var pointLight = new PointLight("pl", camera.position, scene);
  47967. * ```
  47968. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47969. * @param name The light friendly name
  47970. * @param position The position of the point light in the scene
  47971. * @param scene The scene the lights belongs to
  47972. */
  47973. constructor(name: string, position: Vector3, scene: Scene);
  47974. /**
  47975. * Returns the string "PointLight"
  47976. * @returns the class name
  47977. */
  47978. getClassName(): string;
  47979. /**
  47980. * Returns the integer 0.
  47981. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47982. */
  47983. getTypeID(): number;
  47984. /**
  47985. * Specifies wether or not the shadowmap should be a cube texture.
  47986. * @returns true if the shadowmap needs to be a cube texture.
  47987. */
  47988. needCube(): boolean;
  47989. /**
  47990. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47991. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47992. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47993. */
  47994. getShadowDirection(faceIndex?: number): Vector3;
  47995. /**
  47996. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47997. * - fov = PI / 2
  47998. * - aspect ratio : 1.0
  47999. * - z-near and far equal to the active camera minZ and maxZ.
  48000. * Returns the PointLight.
  48001. */
  48002. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48003. protected _buildUniformLayout(): void;
  48004. /**
  48005. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48006. * @param effect The effect to update
  48007. * @param lightIndex The index of the light in the effect to update
  48008. * @returns The point light
  48009. */
  48010. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48011. /**
  48012. * Prepares the list of defines specific to the light type.
  48013. * @param defines the list of defines
  48014. * @param lightIndex defines the index of the light for the effect
  48015. */
  48016. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48017. }
  48018. }
  48019. declare module BABYLON {
  48020. /**
  48021. * Header information of HDR texture files.
  48022. */
  48023. export interface HDRInfo {
  48024. /**
  48025. * The height of the texture in pixels.
  48026. */
  48027. height: number;
  48028. /**
  48029. * The width of the texture in pixels.
  48030. */
  48031. width: number;
  48032. /**
  48033. * The index of the beginning of the data in the binary file.
  48034. */
  48035. dataPosition: number;
  48036. }
  48037. /**
  48038. * This groups tools to convert HDR texture to native colors array.
  48039. */
  48040. export class HDRTools {
  48041. private static Ldexp;
  48042. private static Rgbe2float;
  48043. private static readStringLine;
  48044. /**
  48045. * Reads header information from an RGBE texture stored in a native array.
  48046. * More information on this format are available here:
  48047. * https://en.wikipedia.org/wiki/RGBE_image_format
  48048. *
  48049. * @param uint8array The binary file stored in native array.
  48050. * @return The header information.
  48051. */
  48052. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48053. /**
  48054. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48055. * This RGBE texture needs to store the information as a panorama.
  48056. *
  48057. * More information on this format are available here:
  48058. * https://en.wikipedia.org/wiki/RGBE_image_format
  48059. *
  48060. * @param buffer The binary file stored in an array buffer.
  48061. * @param size The expected size of the extracted cubemap.
  48062. * @return The Cube Map information.
  48063. */
  48064. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48065. /**
  48066. * Returns the pixels data extracted from an RGBE texture.
  48067. * This pixels will be stored left to right up to down in the R G B order in one array.
  48068. *
  48069. * More information on this format are available here:
  48070. * https://en.wikipedia.org/wiki/RGBE_image_format
  48071. *
  48072. * @param uint8array The binary file stored in an array buffer.
  48073. * @param hdrInfo The header information of the file.
  48074. * @return The pixels data in RGB right to left up to down order.
  48075. */
  48076. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48077. private static RGBE_ReadPixels_RLE;
  48078. }
  48079. }
  48080. declare module BABYLON {
  48081. /**
  48082. * This represents a texture coming from an HDR input.
  48083. *
  48084. * The only supported format is currently panorama picture stored in RGBE format.
  48085. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48086. */
  48087. export class HDRCubeTexture extends BaseTexture {
  48088. private static _facesMapping;
  48089. private _generateHarmonics;
  48090. private _noMipmap;
  48091. private _textureMatrix;
  48092. private _size;
  48093. private _onLoad;
  48094. private _onError;
  48095. /**
  48096. * The texture URL.
  48097. */
  48098. url: string;
  48099. /**
  48100. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48101. */
  48102. coordinatesMode: number;
  48103. protected _isBlocking: boolean;
  48104. /**
  48105. * Sets wether or not the texture is blocking during loading.
  48106. */
  48107. /**
  48108. * Gets wether or not the texture is blocking during loading.
  48109. */
  48110. isBlocking: boolean;
  48111. protected _rotationY: number;
  48112. /**
  48113. * Sets texture matrix rotation angle around Y axis in radians.
  48114. */
  48115. /**
  48116. * Gets texture matrix rotation angle around Y axis radians.
  48117. */
  48118. rotationY: number;
  48119. /**
  48120. * Gets or sets the center of the bounding box associated with the cube texture
  48121. * It must define where the camera used to render the texture was set
  48122. */
  48123. boundingBoxPosition: Vector3;
  48124. private _boundingBoxSize;
  48125. /**
  48126. * Gets or sets the size of the bounding box associated with the cube texture
  48127. * When defined, the cubemap will switch to local mode
  48128. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48129. * @example https://www.babylonjs-playground.com/#RNASML
  48130. */
  48131. boundingBoxSize: Vector3;
  48132. /**
  48133. * Instantiates an HDRTexture from the following parameters.
  48134. *
  48135. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48136. * @param scene The scene the texture will be used in
  48137. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48138. * @param noMipmap Forces to not generate the mipmap if true
  48139. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48140. * @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)
  48141. * @param reserved Reserved flag for internal use.
  48142. */
  48143. 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>);
  48144. /**
  48145. * Get the current class name of the texture useful for serialization or dynamic coding.
  48146. * @returns "HDRCubeTexture"
  48147. */
  48148. getClassName(): string;
  48149. /**
  48150. * Occurs when the file is raw .hdr file.
  48151. */
  48152. private loadTexture;
  48153. clone(): HDRCubeTexture;
  48154. delayLoad(): void;
  48155. /**
  48156. * Get the texture reflection matrix used to rotate/transform the reflection.
  48157. * @returns the reflection matrix
  48158. */
  48159. getReflectionTextureMatrix(): Matrix;
  48160. /**
  48161. * Set the texture reflection matrix used to rotate/transform the reflection.
  48162. * @param value Define the reflection matrix to set
  48163. */
  48164. setReflectionTextureMatrix(value: Matrix): void;
  48165. /**
  48166. * Parses a JSON representation of an HDR Texture in order to create the texture
  48167. * @param parsedTexture Define the JSON representation
  48168. * @param scene Define the scene the texture should be created in
  48169. * @param rootUrl Define the root url in case we need to load relative dependencies
  48170. * @returns the newly created texture after parsing
  48171. */
  48172. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48173. serialize(): any;
  48174. }
  48175. }
  48176. declare module BABYLON {
  48177. /**
  48178. * Class used to control physics engine
  48179. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48180. */
  48181. export class PhysicsEngine implements IPhysicsEngine {
  48182. private _physicsPlugin;
  48183. /**
  48184. * Global value used to control the smallest number supported by the simulation
  48185. */
  48186. static Epsilon: number;
  48187. private _impostors;
  48188. private _joints;
  48189. /**
  48190. * Gets the gravity vector used by the simulation
  48191. */
  48192. gravity: Vector3;
  48193. /**
  48194. * Factory used to create the default physics plugin.
  48195. * @returns The default physics plugin
  48196. */
  48197. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48198. /**
  48199. * Creates a new Physics Engine
  48200. * @param gravity defines the gravity vector used by the simulation
  48201. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48202. */
  48203. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48204. /**
  48205. * Sets the gravity vector used by the simulation
  48206. * @param gravity defines the gravity vector to use
  48207. */
  48208. setGravity(gravity: Vector3): void;
  48209. /**
  48210. * Set the time step of the physics engine.
  48211. * Default is 1/60.
  48212. * To slow it down, enter 1/600 for example.
  48213. * To speed it up, 1/30
  48214. * @param newTimeStep defines the new timestep to apply to this world.
  48215. */
  48216. setTimeStep(newTimeStep?: number): void;
  48217. /**
  48218. * Get the time step of the physics engine.
  48219. * @returns the current time step
  48220. */
  48221. getTimeStep(): number;
  48222. /**
  48223. * Release all resources
  48224. */
  48225. dispose(): void;
  48226. /**
  48227. * Gets the name of the current physics plugin
  48228. * @returns the name of the plugin
  48229. */
  48230. getPhysicsPluginName(): string;
  48231. /**
  48232. * Adding a new impostor for the impostor tracking.
  48233. * This will be done by the impostor itself.
  48234. * @param impostor the impostor to add
  48235. */
  48236. addImpostor(impostor: PhysicsImpostor): void;
  48237. /**
  48238. * Remove an impostor from the engine.
  48239. * This impostor and its mesh will not longer be updated by the physics engine.
  48240. * @param impostor the impostor to remove
  48241. */
  48242. removeImpostor(impostor: PhysicsImpostor): void;
  48243. /**
  48244. * Add a joint to the physics engine
  48245. * @param mainImpostor defines the main impostor to which the joint is added.
  48246. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48247. * @param joint defines the joint that will connect both impostors.
  48248. */
  48249. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48250. /**
  48251. * Removes a joint from the simulation
  48252. * @param mainImpostor defines the impostor used with the joint
  48253. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48254. * @param joint defines the joint to remove
  48255. */
  48256. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48257. /**
  48258. * Called by the scene. No need to call it.
  48259. * @param delta defines the timespam between frames
  48260. */
  48261. _step(delta: number): void;
  48262. /**
  48263. * Gets the current plugin used to run the simulation
  48264. * @returns current plugin
  48265. */
  48266. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48267. /**
  48268. * Gets the list of physic impostors
  48269. * @returns an array of PhysicsImpostor
  48270. */
  48271. getImpostors(): Array<PhysicsImpostor>;
  48272. /**
  48273. * Gets the impostor for a physics enabled object
  48274. * @param object defines the object impersonated by the impostor
  48275. * @returns the PhysicsImpostor or null if not found
  48276. */
  48277. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48278. /**
  48279. * Gets the impostor for a physics body object
  48280. * @param body defines physics body used by the impostor
  48281. * @returns the PhysicsImpostor or null if not found
  48282. */
  48283. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48284. /**
  48285. * Does a raycast in the physics world
  48286. * @param from when should the ray start?
  48287. * @param to when should the ray end?
  48288. * @returns PhysicsRaycastResult
  48289. */
  48290. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48291. }
  48292. }
  48293. declare module BABYLON {
  48294. /** @hidden */
  48295. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48296. private _useDeltaForWorldStep;
  48297. world: any;
  48298. name: string;
  48299. private _physicsMaterials;
  48300. private _fixedTimeStep;
  48301. private _cannonRaycastResult;
  48302. private _raycastResult;
  48303. private _removeAfterStep;
  48304. BJSCANNON: any;
  48305. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48306. setGravity(gravity: Vector3): void;
  48307. setTimeStep(timeStep: number): void;
  48308. getTimeStep(): number;
  48309. executeStep(delta: number): void;
  48310. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48311. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48312. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48313. private _processChildMeshes;
  48314. removePhysicsBody(impostor: PhysicsImpostor): void;
  48315. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48316. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48317. private _addMaterial;
  48318. private _checkWithEpsilon;
  48319. private _createShape;
  48320. private _createHeightmap;
  48321. private _minus90X;
  48322. private _plus90X;
  48323. private _tmpPosition;
  48324. private _tmpDeltaPosition;
  48325. private _tmpUnityRotation;
  48326. private _updatePhysicsBodyTransformation;
  48327. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48328. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48329. isSupported(): boolean;
  48330. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48331. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48332. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48333. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48334. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48335. getBodyMass(impostor: PhysicsImpostor): number;
  48336. getBodyFriction(impostor: PhysicsImpostor): number;
  48337. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48338. getBodyRestitution(impostor: PhysicsImpostor): number;
  48339. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48340. sleepBody(impostor: PhysicsImpostor): void;
  48341. wakeUpBody(impostor: PhysicsImpostor): void;
  48342. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48343. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48344. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48345. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48346. getRadius(impostor: PhysicsImpostor): number;
  48347. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48348. dispose(): void;
  48349. private _extendNamespace;
  48350. /**
  48351. * Does a raycast in the physics world
  48352. * @param from when should the ray start?
  48353. * @param to when should the ray end?
  48354. * @returns PhysicsRaycastResult
  48355. */
  48356. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48357. }
  48358. }
  48359. declare module BABYLON {
  48360. /** @hidden */
  48361. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48362. world: any;
  48363. name: string;
  48364. BJSOIMO: any;
  48365. private _raycastResult;
  48366. constructor(iterations?: number, oimoInjection?: any);
  48367. setGravity(gravity: Vector3): void;
  48368. setTimeStep(timeStep: number): void;
  48369. getTimeStep(): number;
  48370. private _tmpImpostorsArray;
  48371. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48372. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48373. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48374. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48375. private _tmpPositionVector;
  48376. removePhysicsBody(impostor: PhysicsImpostor): void;
  48377. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48378. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48379. isSupported(): boolean;
  48380. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48381. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48382. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48383. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48384. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48385. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48386. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48387. getBodyMass(impostor: PhysicsImpostor): number;
  48388. getBodyFriction(impostor: PhysicsImpostor): number;
  48389. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48390. getBodyRestitution(impostor: PhysicsImpostor): number;
  48391. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48392. sleepBody(impostor: PhysicsImpostor): void;
  48393. wakeUpBody(impostor: PhysicsImpostor): void;
  48394. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48395. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48396. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48397. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48398. getRadius(impostor: PhysicsImpostor): number;
  48399. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48400. dispose(): void;
  48401. /**
  48402. * Does a raycast in the physics world
  48403. * @param from when should the ray start?
  48404. * @param to when should the ray end?
  48405. * @returns PhysicsRaycastResult
  48406. */
  48407. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48408. }
  48409. }
  48410. declare module BABYLON {
  48411. /**
  48412. * Class containing static functions to help procedurally build meshes
  48413. */
  48414. export class RibbonBuilder {
  48415. /**
  48416. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48417. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48418. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48419. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48420. * * 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
  48421. * * 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
  48422. * * 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
  48423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48424. * * 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
  48425. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48426. * * 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
  48427. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48428. * * 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
  48429. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48431. * @param name defines the name of the mesh
  48432. * @param options defines the options used to create the mesh
  48433. * @param scene defines the hosting scene
  48434. * @returns the ribbon mesh
  48435. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48436. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48437. */
  48438. static CreateRibbon(name: string, options: {
  48439. pathArray: Vector3[][];
  48440. closeArray?: boolean;
  48441. closePath?: boolean;
  48442. offset?: number;
  48443. updatable?: boolean;
  48444. sideOrientation?: number;
  48445. frontUVs?: Vector4;
  48446. backUVs?: Vector4;
  48447. instance?: Mesh;
  48448. invertUV?: boolean;
  48449. uvs?: Vector2[];
  48450. colors?: Color4[];
  48451. }, scene?: Nullable<Scene>): Mesh;
  48452. }
  48453. }
  48454. declare module BABYLON {
  48455. /**
  48456. * Class containing static functions to help procedurally build meshes
  48457. */
  48458. export class ShapeBuilder {
  48459. /**
  48460. * 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.
  48461. * * 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.
  48462. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48463. * * 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.
  48464. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48465. * * 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
  48466. * * 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
  48467. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48468. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48469. * * 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
  48470. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48472. * @param name defines the name of the mesh
  48473. * @param options defines the options used to create the mesh
  48474. * @param scene defines the hosting scene
  48475. * @returns the extruded shape mesh
  48476. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48477. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48478. */
  48479. static ExtrudeShape(name: string, options: {
  48480. shape: Vector3[];
  48481. path: Vector3[];
  48482. scale?: number;
  48483. rotation?: number;
  48484. cap?: number;
  48485. updatable?: boolean;
  48486. sideOrientation?: number;
  48487. frontUVs?: Vector4;
  48488. backUVs?: Vector4;
  48489. instance?: Mesh;
  48490. invertUV?: boolean;
  48491. }, scene?: Nullable<Scene>): Mesh;
  48492. /**
  48493. * Creates an custom extruded shape mesh.
  48494. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  48495. * * 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.
  48496. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48497. * * 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
  48498. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  48499. * * 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
  48500. * * It must returns a float value that will be the scale value applied to the shape on each path point
  48501. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  48502. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  48503. * * 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
  48504. * * 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
  48505. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  48506. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48507. * * 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
  48508. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48510. * @param name defines the name of the mesh
  48511. * @param options defines the options used to create the mesh
  48512. * @param scene defines the hosting scene
  48513. * @returns the custom extruded shape mesh
  48514. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  48515. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48516. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48517. */
  48518. static ExtrudeShapeCustom(name: string, options: {
  48519. shape: Vector3[];
  48520. path: Vector3[];
  48521. scaleFunction?: any;
  48522. rotationFunction?: any;
  48523. ribbonCloseArray?: boolean;
  48524. ribbonClosePath?: boolean;
  48525. cap?: number;
  48526. updatable?: boolean;
  48527. sideOrientation?: number;
  48528. frontUVs?: Vector4;
  48529. backUVs?: Vector4;
  48530. instance?: Mesh;
  48531. invertUV?: boolean;
  48532. }, scene?: Nullable<Scene>): Mesh;
  48533. private static _ExtrudeShapeGeneric;
  48534. }
  48535. }
  48536. declare module BABYLON {
  48537. /**
  48538. * AmmoJS Physics plugin
  48539. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48540. * @see https://github.com/kripken/ammo.js/
  48541. */
  48542. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48543. private _useDeltaForWorldStep;
  48544. /**
  48545. * Reference to the Ammo library
  48546. */
  48547. bjsAMMO: any;
  48548. /**
  48549. * Created ammoJS world which physics bodies are added to
  48550. */
  48551. world: any;
  48552. /**
  48553. * Name of the plugin
  48554. */
  48555. name: string;
  48556. private _timeStep;
  48557. private _fixedTimeStep;
  48558. private _maxSteps;
  48559. private _tmpQuaternion;
  48560. private _tmpAmmoTransform;
  48561. private _tmpAmmoQuaternion;
  48562. private _tmpAmmoConcreteContactResultCallback;
  48563. private _collisionConfiguration;
  48564. private _dispatcher;
  48565. private _overlappingPairCache;
  48566. private _solver;
  48567. private _softBodySolver;
  48568. private _tmpAmmoVectorA;
  48569. private _tmpAmmoVectorB;
  48570. private _tmpAmmoVectorC;
  48571. private _tmpAmmoVectorD;
  48572. private _tmpContactCallbackResult;
  48573. private _tmpAmmoVectorRCA;
  48574. private _tmpAmmoVectorRCB;
  48575. private _raycastResult;
  48576. private static readonly DISABLE_COLLISION_FLAG;
  48577. private static readonly KINEMATIC_FLAG;
  48578. private static readonly DISABLE_DEACTIVATION_FLAG;
  48579. /**
  48580. * Initializes the ammoJS plugin
  48581. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48582. * @param ammoInjection can be used to inject your own ammo reference
  48583. */
  48584. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  48585. /**
  48586. * Sets the gravity of the physics world (m/(s^2))
  48587. * @param gravity Gravity to set
  48588. */
  48589. setGravity(gravity: Vector3): void;
  48590. /**
  48591. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48592. * @param timeStep timestep to use in seconds
  48593. */
  48594. setTimeStep(timeStep: number): void;
  48595. /**
  48596. * 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)
  48597. * @param fixedTimeStep fixedTimeStep to use in seconds
  48598. */
  48599. setFixedTimeStep(fixedTimeStep: number): void;
  48600. /**
  48601. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48602. * @param maxSteps the maximum number of steps by the physics engine per frame
  48603. */
  48604. setMaxSteps(maxSteps: number): void;
  48605. /**
  48606. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48607. * @returns the current timestep in seconds
  48608. */
  48609. getTimeStep(): number;
  48610. private _isImpostorInContact;
  48611. private _isImpostorPairInContact;
  48612. private _stepSimulation;
  48613. /**
  48614. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48615. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48616. * After the step the babylon meshes are set to the position of the physics imposters
  48617. * @param delta amount of time to step forward
  48618. * @param impostors array of imposters to update before/after the step
  48619. */
  48620. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48621. /**
  48622. * Update babylon mesh to match physics world object
  48623. * @param impostor imposter to match
  48624. */
  48625. private _afterSoftStep;
  48626. /**
  48627. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48628. * @param impostor imposter to match
  48629. */
  48630. private _ropeStep;
  48631. /**
  48632. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48633. * @param impostor imposter to match
  48634. */
  48635. private _softbodyOrClothStep;
  48636. private _tmpVector;
  48637. private _tmpMatrix;
  48638. /**
  48639. * Applies an impulse on the imposter
  48640. * @param impostor imposter to apply impulse to
  48641. * @param force amount of force to be applied to the imposter
  48642. * @param contactPoint the location to apply the impulse on the imposter
  48643. */
  48644. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48645. /**
  48646. * Applies a force on the imposter
  48647. * @param impostor imposter to apply force
  48648. * @param force amount of force to be applied to the imposter
  48649. * @param contactPoint the location to apply the force on the imposter
  48650. */
  48651. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48652. /**
  48653. * Creates a physics body using the plugin
  48654. * @param impostor the imposter to create the physics body on
  48655. */
  48656. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48657. /**
  48658. * Removes the physics body from the imposter and disposes of the body's memory
  48659. * @param impostor imposter to remove the physics body from
  48660. */
  48661. removePhysicsBody(impostor: PhysicsImpostor): void;
  48662. /**
  48663. * Generates a joint
  48664. * @param impostorJoint the imposter joint to create the joint with
  48665. */
  48666. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48667. /**
  48668. * Removes a joint
  48669. * @param impostorJoint the imposter joint to remove the joint from
  48670. */
  48671. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48672. private _addMeshVerts;
  48673. /**
  48674. * Initialise the soft body vertices to match its object's (mesh) vertices
  48675. * Softbody vertices (nodes) are in world space and to match this
  48676. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  48677. * @param impostor to create the softbody for
  48678. */
  48679. private _softVertexData;
  48680. /**
  48681. * Create an impostor's soft body
  48682. * @param impostor to create the softbody for
  48683. */
  48684. private _createSoftbody;
  48685. /**
  48686. * Create cloth for an impostor
  48687. * @param impostor to create the softbody for
  48688. */
  48689. private _createCloth;
  48690. /**
  48691. * Create rope for an impostor
  48692. * @param impostor to create the softbody for
  48693. */
  48694. private _createRope;
  48695. private _addHullVerts;
  48696. private _createShape;
  48697. /**
  48698. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48699. * @param impostor imposter containing the physics body and babylon object
  48700. */
  48701. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48702. /**
  48703. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48704. * @param impostor imposter containing the physics body and babylon object
  48705. * @param newPosition new position
  48706. * @param newRotation new rotation
  48707. */
  48708. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48709. /**
  48710. * If this plugin is supported
  48711. * @returns true if its supported
  48712. */
  48713. isSupported(): boolean;
  48714. /**
  48715. * Sets the linear velocity of the physics body
  48716. * @param impostor imposter to set the velocity on
  48717. * @param velocity velocity to set
  48718. */
  48719. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48720. /**
  48721. * Sets the angular velocity of the physics body
  48722. * @param impostor imposter to set the velocity on
  48723. * @param velocity velocity to set
  48724. */
  48725. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48726. /**
  48727. * gets the linear velocity
  48728. * @param impostor imposter to get linear velocity from
  48729. * @returns linear velocity
  48730. */
  48731. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48732. /**
  48733. * gets the angular velocity
  48734. * @param impostor imposter to get angular velocity from
  48735. * @returns angular velocity
  48736. */
  48737. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48738. /**
  48739. * Sets the mass of physics body
  48740. * @param impostor imposter to set the mass on
  48741. * @param mass mass to set
  48742. */
  48743. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48744. /**
  48745. * Gets the mass of the physics body
  48746. * @param impostor imposter to get the mass from
  48747. * @returns mass
  48748. */
  48749. getBodyMass(impostor: PhysicsImpostor): number;
  48750. /**
  48751. * Gets friction of the impostor
  48752. * @param impostor impostor to get friction from
  48753. * @returns friction value
  48754. */
  48755. getBodyFriction(impostor: PhysicsImpostor): number;
  48756. /**
  48757. * Sets friction of the impostor
  48758. * @param impostor impostor to set friction on
  48759. * @param friction friction value
  48760. */
  48761. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48762. /**
  48763. * Gets restitution of the impostor
  48764. * @param impostor impostor to get restitution from
  48765. * @returns restitution value
  48766. */
  48767. getBodyRestitution(impostor: PhysicsImpostor): number;
  48768. /**
  48769. * Sets resitution of the impostor
  48770. * @param impostor impostor to set resitution on
  48771. * @param restitution resitution value
  48772. */
  48773. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48774. /**
  48775. * Gets pressure inside the impostor
  48776. * @param impostor impostor to get pressure from
  48777. * @returns pressure value
  48778. */
  48779. getBodyPressure(impostor: PhysicsImpostor): number;
  48780. /**
  48781. * Sets pressure inside a soft body impostor
  48782. * Cloth and rope must remain 0 pressure
  48783. * @param impostor impostor to set pressure on
  48784. * @param pressure pressure value
  48785. */
  48786. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  48787. /**
  48788. * Gets stiffness of the impostor
  48789. * @param impostor impostor to get stiffness from
  48790. * @returns pressure value
  48791. */
  48792. getBodyStiffness(impostor: PhysicsImpostor): number;
  48793. /**
  48794. * Sets stiffness of the impostor
  48795. * @param impostor impostor to set stiffness on
  48796. * @param stiffness stiffness value from 0 to 1
  48797. */
  48798. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  48799. /**
  48800. * Gets velocityIterations of the impostor
  48801. * @param impostor impostor to get velocity iterations from
  48802. * @returns velocityIterations value
  48803. */
  48804. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  48805. /**
  48806. * Sets velocityIterations of the impostor
  48807. * @param impostor impostor to set velocity iterations on
  48808. * @param velocityIterations velocityIterations value
  48809. */
  48810. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  48811. /**
  48812. * Gets positionIterations of the impostor
  48813. * @param impostor impostor to get position iterations from
  48814. * @returns positionIterations value
  48815. */
  48816. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  48817. /**
  48818. * Sets positionIterations of the impostor
  48819. * @param impostor impostor to set position on
  48820. * @param positionIterations positionIterations value
  48821. */
  48822. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  48823. /**
  48824. * Append an anchor to a cloth object
  48825. * @param impostor is the cloth impostor to add anchor to
  48826. * @param otherImpostor is the rigid impostor to anchor to
  48827. * @param width ratio across width from 0 to 1
  48828. * @param height ratio up height from 0 to 1
  48829. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  48830. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48831. */
  48832. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48833. /**
  48834. * Append an hook to a rope object
  48835. * @param impostor is the rope impostor to add hook to
  48836. * @param otherImpostor is the rigid impostor to hook to
  48837. * @param length ratio along the rope from 0 to 1
  48838. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  48839. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48840. */
  48841. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48842. /**
  48843. * Sleeps the physics body and stops it from being active
  48844. * @param impostor impostor to sleep
  48845. */
  48846. sleepBody(impostor: PhysicsImpostor): void;
  48847. /**
  48848. * Activates the physics body
  48849. * @param impostor impostor to activate
  48850. */
  48851. wakeUpBody(impostor: PhysicsImpostor): void;
  48852. /**
  48853. * Updates the distance parameters of the joint
  48854. * @param joint joint to update
  48855. * @param maxDistance maximum distance of the joint
  48856. * @param minDistance minimum distance of the joint
  48857. */
  48858. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48859. /**
  48860. * Sets a motor on the joint
  48861. * @param joint joint to set motor on
  48862. * @param speed speed of the motor
  48863. * @param maxForce maximum force of the motor
  48864. * @param motorIndex index of the motor
  48865. */
  48866. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48867. /**
  48868. * Sets the motors limit
  48869. * @param joint joint to set limit on
  48870. * @param upperLimit upper limit
  48871. * @param lowerLimit lower limit
  48872. */
  48873. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48874. /**
  48875. * Syncs the position and rotation of a mesh with the impostor
  48876. * @param mesh mesh to sync
  48877. * @param impostor impostor to update the mesh with
  48878. */
  48879. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48880. /**
  48881. * Gets the radius of the impostor
  48882. * @param impostor impostor to get radius from
  48883. * @returns the radius
  48884. */
  48885. getRadius(impostor: PhysicsImpostor): number;
  48886. /**
  48887. * Gets the box size of the impostor
  48888. * @param impostor impostor to get box size from
  48889. * @param result the resulting box size
  48890. */
  48891. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48892. /**
  48893. * Disposes of the impostor
  48894. */
  48895. dispose(): void;
  48896. /**
  48897. * Does a raycast in the physics world
  48898. * @param from when should the ray start?
  48899. * @param to when should the ray end?
  48900. * @returns PhysicsRaycastResult
  48901. */
  48902. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48903. }
  48904. }
  48905. declare module BABYLON {
  48906. interface AbstractScene {
  48907. /**
  48908. * The list of reflection probes added to the scene
  48909. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48910. */
  48911. reflectionProbes: Array<ReflectionProbe>;
  48912. /**
  48913. * Removes the given reflection probe from this scene.
  48914. * @param toRemove The reflection probe to remove
  48915. * @returns The index of the removed reflection probe
  48916. */
  48917. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48918. /**
  48919. * Adds the given reflection probe to this scene.
  48920. * @param newReflectionProbe The reflection probe to add
  48921. */
  48922. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48923. }
  48924. /**
  48925. * Class used to generate realtime reflection / refraction cube textures
  48926. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48927. */
  48928. export class ReflectionProbe {
  48929. /** defines the name of the probe */
  48930. name: string;
  48931. private _scene;
  48932. private _renderTargetTexture;
  48933. private _projectionMatrix;
  48934. private _viewMatrix;
  48935. private _target;
  48936. private _add;
  48937. private _attachedMesh;
  48938. private _invertYAxis;
  48939. /** Gets or sets probe position (center of the cube map) */
  48940. position: Vector3;
  48941. /**
  48942. * Creates a new reflection probe
  48943. * @param name defines the name of the probe
  48944. * @param size defines the texture resolution (for each face)
  48945. * @param scene defines the hosting scene
  48946. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48947. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48948. */
  48949. constructor(
  48950. /** defines the name of the probe */
  48951. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48952. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48953. samples: number;
  48954. /** Gets or sets the refresh rate to use (on every frame by default) */
  48955. refreshRate: number;
  48956. /**
  48957. * Gets the hosting scene
  48958. * @returns a Scene
  48959. */
  48960. getScene(): Scene;
  48961. /** Gets the internal CubeTexture used to render to */
  48962. readonly cubeTexture: RenderTargetTexture;
  48963. /** Gets the list of meshes to render */
  48964. readonly renderList: Nullable<AbstractMesh[]>;
  48965. /**
  48966. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48967. * @param mesh defines the mesh to attach to
  48968. */
  48969. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48970. /**
  48971. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48972. * @param renderingGroupId The rendering group id corresponding to its index
  48973. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48974. */
  48975. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48976. /**
  48977. * Clean all associated resources
  48978. */
  48979. dispose(): void;
  48980. /**
  48981. * Converts the reflection probe information to a readable string for debug purpose.
  48982. * @param fullDetails Supports for multiple levels of logging within scene loading
  48983. * @returns the human readable reflection probe info
  48984. */
  48985. toString(fullDetails?: boolean): string;
  48986. /**
  48987. * Get the class name of the relfection probe.
  48988. * @returns "ReflectionProbe"
  48989. */
  48990. getClassName(): string;
  48991. /**
  48992. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48993. * @returns The JSON representation of the texture
  48994. */
  48995. serialize(): any;
  48996. /**
  48997. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48998. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48999. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49000. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49001. * @returns The parsed reflection probe if successful
  49002. */
  49003. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49004. }
  49005. }
  49006. declare module BABYLON {
  49007. /** @hidden */
  49008. export var _BabylonLoaderRegistered: boolean;
  49009. }
  49010. declare module BABYLON {
  49011. /**
  49012. * The Physically based simple base material of BJS.
  49013. *
  49014. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49015. * It is used as the base class for both the specGloss and metalRough conventions.
  49016. */
  49017. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49018. /**
  49019. * Number of Simultaneous lights allowed on the material.
  49020. */
  49021. maxSimultaneousLights: number;
  49022. /**
  49023. * If sets to true, disables all the lights affecting the material.
  49024. */
  49025. disableLighting: boolean;
  49026. /**
  49027. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49028. */
  49029. environmentTexture: BaseTexture;
  49030. /**
  49031. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49032. */
  49033. invertNormalMapX: boolean;
  49034. /**
  49035. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49036. */
  49037. invertNormalMapY: boolean;
  49038. /**
  49039. * Normal map used in the model.
  49040. */
  49041. normalTexture: BaseTexture;
  49042. /**
  49043. * Emissivie color used to self-illuminate the model.
  49044. */
  49045. emissiveColor: Color3;
  49046. /**
  49047. * Emissivie texture used to self-illuminate the model.
  49048. */
  49049. emissiveTexture: BaseTexture;
  49050. /**
  49051. * Occlusion Channel Strenght.
  49052. */
  49053. occlusionStrength: number;
  49054. /**
  49055. * Occlusion Texture of the material (adding extra occlusion effects).
  49056. */
  49057. occlusionTexture: BaseTexture;
  49058. /**
  49059. * Defines the alpha limits in alpha test mode.
  49060. */
  49061. alphaCutOff: number;
  49062. /**
  49063. * Gets the current double sided mode.
  49064. */
  49065. /**
  49066. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49067. */
  49068. doubleSided: boolean;
  49069. /**
  49070. * Stores the pre-calculated light information of a mesh in a texture.
  49071. */
  49072. lightmapTexture: BaseTexture;
  49073. /**
  49074. * If true, the light map contains occlusion information instead of lighting info.
  49075. */
  49076. useLightmapAsShadowmap: boolean;
  49077. /**
  49078. * Instantiates a new PBRMaterial instance.
  49079. *
  49080. * @param name The material name
  49081. * @param scene The scene the material will be use in.
  49082. */
  49083. constructor(name: string, scene: Scene);
  49084. getClassName(): string;
  49085. }
  49086. }
  49087. declare module BABYLON {
  49088. /**
  49089. * The PBR material of BJS following the metal roughness convention.
  49090. *
  49091. * This fits to the PBR convention in the GLTF definition:
  49092. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49093. */
  49094. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49095. /**
  49096. * The base color has two different interpretations depending on the value of metalness.
  49097. * When the material is a metal, the base color is the specific measured reflectance value
  49098. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49099. * of the material.
  49100. */
  49101. baseColor: Color3;
  49102. /**
  49103. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49104. * well as opacity information in the alpha channel.
  49105. */
  49106. baseTexture: BaseTexture;
  49107. /**
  49108. * Specifies the metallic scalar value of the material.
  49109. * Can also be used to scale the metalness values of the metallic texture.
  49110. */
  49111. metallic: number;
  49112. /**
  49113. * Specifies the roughness scalar value of the material.
  49114. * Can also be used to scale the roughness values of the metallic texture.
  49115. */
  49116. roughness: number;
  49117. /**
  49118. * Texture containing both the metallic value in the B channel and the
  49119. * roughness value in the G channel to keep better precision.
  49120. */
  49121. metallicRoughnessTexture: BaseTexture;
  49122. /**
  49123. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49124. *
  49125. * @param name The material name
  49126. * @param scene The scene the material will be use in.
  49127. */
  49128. constructor(name: string, scene: Scene);
  49129. /**
  49130. * Return the currrent class name of the material.
  49131. */
  49132. getClassName(): string;
  49133. /**
  49134. * Makes a duplicate of the current material.
  49135. * @param name - name to use for the new material.
  49136. */
  49137. clone(name: string): PBRMetallicRoughnessMaterial;
  49138. /**
  49139. * Serialize the material to a parsable JSON object.
  49140. */
  49141. serialize(): any;
  49142. /**
  49143. * Parses a JSON object correponding to the serialize function.
  49144. */
  49145. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49146. }
  49147. }
  49148. declare module BABYLON {
  49149. /**
  49150. * The PBR material of BJS following the specular glossiness convention.
  49151. *
  49152. * This fits to the PBR convention in the GLTF definition:
  49153. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49154. */
  49155. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49156. /**
  49157. * Specifies the diffuse color of the material.
  49158. */
  49159. diffuseColor: Color3;
  49160. /**
  49161. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49162. * channel.
  49163. */
  49164. diffuseTexture: BaseTexture;
  49165. /**
  49166. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49167. */
  49168. specularColor: Color3;
  49169. /**
  49170. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49171. */
  49172. glossiness: number;
  49173. /**
  49174. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49175. */
  49176. specularGlossinessTexture: BaseTexture;
  49177. /**
  49178. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49179. *
  49180. * @param name The material name
  49181. * @param scene The scene the material will be use in.
  49182. */
  49183. constructor(name: string, scene: Scene);
  49184. /**
  49185. * Return the currrent class name of the material.
  49186. */
  49187. getClassName(): string;
  49188. /**
  49189. * Makes a duplicate of the current material.
  49190. * @param name - name to use for the new material.
  49191. */
  49192. clone(name: string): PBRSpecularGlossinessMaterial;
  49193. /**
  49194. * Serialize the material to a parsable JSON object.
  49195. */
  49196. serialize(): any;
  49197. /**
  49198. * Parses a JSON object correponding to the serialize function.
  49199. */
  49200. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49201. }
  49202. }
  49203. declare module BABYLON {
  49204. /**
  49205. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49206. * It can help converting any input color in a desired output one. This can then be used to create effects
  49207. * from sepia, black and white to sixties or futuristic rendering...
  49208. *
  49209. * The only supported format is currently 3dl.
  49210. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49211. */
  49212. export class ColorGradingTexture extends BaseTexture {
  49213. /**
  49214. * The current texture matrix. (will always be identity in color grading texture)
  49215. */
  49216. private _textureMatrix;
  49217. /**
  49218. * The texture URL.
  49219. */
  49220. url: string;
  49221. /**
  49222. * Empty line regex stored for GC.
  49223. */
  49224. private static _noneEmptyLineRegex;
  49225. private _engine;
  49226. /**
  49227. * Instantiates a ColorGradingTexture from the following parameters.
  49228. *
  49229. * @param url The location of the color gradind data (currently only supporting 3dl)
  49230. * @param scene The scene the texture will be used in
  49231. */
  49232. constructor(url: string, scene: Scene);
  49233. /**
  49234. * Returns the texture matrix used in most of the material.
  49235. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49236. */
  49237. getTextureMatrix(): Matrix;
  49238. /**
  49239. * Occurs when the file being loaded is a .3dl LUT file.
  49240. */
  49241. private load3dlTexture;
  49242. /**
  49243. * Starts the loading process of the texture.
  49244. */
  49245. private loadTexture;
  49246. /**
  49247. * Clones the color gradind texture.
  49248. */
  49249. clone(): ColorGradingTexture;
  49250. /**
  49251. * Called during delayed load for textures.
  49252. */
  49253. delayLoad(): void;
  49254. /**
  49255. * Parses a color grading texture serialized by Babylon.
  49256. * @param parsedTexture The texture information being parsedTexture
  49257. * @param scene The scene to load the texture in
  49258. * @param rootUrl The root url of the data assets to load
  49259. * @return A color gradind texture
  49260. */
  49261. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49262. /**
  49263. * Serializes the LUT texture to json format.
  49264. */
  49265. serialize(): any;
  49266. }
  49267. }
  49268. declare module BABYLON {
  49269. /**
  49270. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49271. */
  49272. export class EquiRectangularCubeTexture extends BaseTexture {
  49273. /** The six faces of the cube. */
  49274. private static _FacesMapping;
  49275. private _noMipmap;
  49276. private _onLoad;
  49277. private _onError;
  49278. /** The size of the cubemap. */
  49279. private _size;
  49280. /** The buffer of the image. */
  49281. private _buffer;
  49282. /** The width of the input image. */
  49283. private _width;
  49284. /** The height of the input image. */
  49285. private _height;
  49286. /** The URL to the image. */
  49287. url: string;
  49288. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49289. coordinatesMode: number;
  49290. /**
  49291. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49292. * @param url The location of the image
  49293. * @param scene The scene the texture will be used in
  49294. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49295. * @param noMipmap Forces to not generate the mipmap if true
  49296. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49297. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49298. * @param onLoad — defines a callback called when texture is loaded
  49299. * @param onError — defines a callback called if there is an error
  49300. */
  49301. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49302. /**
  49303. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49304. */
  49305. private loadImage;
  49306. /**
  49307. * Convert the image buffer into a cubemap and create a CubeTexture.
  49308. */
  49309. private loadTexture;
  49310. /**
  49311. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49312. * @param buffer The ArrayBuffer that should be converted.
  49313. * @returns The buffer as Float32Array.
  49314. */
  49315. private getFloat32ArrayFromArrayBuffer;
  49316. /**
  49317. * Get the current class name of the texture useful for serialization or dynamic coding.
  49318. * @returns "EquiRectangularCubeTexture"
  49319. */
  49320. getClassName(): string;
  49321. /**
  49322. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49323. * @returns A clone of the current EquiRectangularCubeTexture.
  49324. */
  49325. clone(): EquiRectangularCubeTexture;
  49326. }
  49327. }
  49328. declare module BABYLON {
  49329. /**
  49330. * Based on jsTGALoader - Javascript loader for TGA file
  49331. * By Vincent Thibault
  49332. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49333. */
  49334. export class TGATools {
  49335. private static _TYPE_INDEXED;
  49336. private static _TYPE_RGB;
  49337. private static _TYPE_GREY;
  49338. private static _TYPE_RLE_INDEXED;
  49339. private static _TYPE_RLE_RGB;
  49340. private static _TYPE_RLE_GREY;
  49341. private static _ORIGIN_MASK;
  49342. private static _ORIGIN_SHIFT;
  49343. private static _ORIGIN_BL;
  49344. private static _ORIGIN_BR;
  49345. private static _ORIGIN_UL;
  49346. private static _ORIGIN_UR;
  49347. /**
  49348. * Gets the header of a TGA file
  49349. * @param data defines the TGA data
  49350. * @returns the header
  49351. */
  49352. static GetTGAHeader(data: Uint8Array): any;
  49353. /**
  49354. * Uploads TGA content to a Babylon Texture
  49355. * @hidden
  49356. */
  49357. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49358. /** @hidden */
  49359. 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;
  49360. /** @hidden */
  49361. 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;
  49362. /** @hidden */
  49363. 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;
  49364. /** @hidden */
  49365. 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;
  49366. /** @hidden */
  49367. 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;
  49368. /** @hidden */
  49369. 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;
  49370. }
  49371. }
  49372. declare module BABYLON {
  49373. /**
  49374. * Implementation of the TGA Texture Loader.
  49375. * @hidden
  49376. */
  49377. export class _TGATextureLoader implements IInternalTextureLoader {
  49378. /**
  49379. * Defines wether the loader supports cascade loading the different faces.
  49380. */
  49381. readonly supportCascades: boolean;
  49382. /**
  49383. * This returns if the loader support the current file information.
  49384. * @param extension defines the file extension of the file being loaded
  49385. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49386. * @param fallback defines the fallback internal texture if any
  49387. * @param isBase64 defines whether the texture is encoded as a base64
  49388. * @param isBuffer defines whether the texture data are stored as a buffer
  49389. * @returns true if the loader can load the specified file
  49390. */
  49391. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49392. /**
  49393. * Transform the url before loading if required.
  49394. * @param rootUrl the url of the texture
  49395. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49396. * @returns the transformed texture
  49397. */
  49398. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49399. /**
  49400. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49401. * @param rootUrl the url of the texture
  49402. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49403. * @returns the fallback texture
  49404. */
  49405. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49406. /**
  49407. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49408. * @param data contains the texture data
  49409. * @param texture defines the BabylonJS internal texture
  49410. * @param createPolynomials will be true if polynomials have been requested
  49411. * @param onLoad defines the callback to trigger once the texture is ready
  49412. * @param onError defines the callback to trigger in case of error
  49413. */
  49414. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49415. /**
  49416. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49417. * @param data contains the texture data
  49418. * @param texture defines the BabylonJS internal texture
  49419. * @param callback defines the method to call once ready to upload
  49420. */
  49421. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49422. }
  49423. }
  49424. declare module BABYLON {
  49425. /**
  49426. * 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.
  49427. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49428. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49429. */
  49430. export class CustomProceduralTexture extends ProceduralTexture {
  49431. private _animate;
  49432. private _time;
  49433. private _config;
  49434. private _texturePath;
  49435. /**
  49436. * Instantiates a new Custom Procedural Texture.
  49437. * 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.
  49438. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49439. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49440. * @param name Define the name of the texture
  49441. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49442. * @param size Define the size of the texture to create
  49443. * @param scene Define the scene the texture belongs to
  49444. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49445. * @param generateMipMaps Define if the texture should creates mip maps or not
  49446. */
  49447. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49448. private _loadJson;
  49449. /**
  49450. * Is the texture ready to be used ? (rendered at least once)
  49451. * @returns true if ready, otherwise, false.
  49452. */
  49453. isReady(): boolean;
  49454. /**
  49455. * Render the texture to its associated render target.
  49456. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49457. */
  49458. render(useCameraPostProcess?: boolean): void;
  49459. /**
  49460. * Update the list of dependant textures samplers in the shader.
  49461. */
  49462. updateTextures(): void;
  49463. /**
  49464. * Update the uniform values of the procedural texture in the shader.
  49465. */
  49466. updateShaderUniforms(): void;
  49467. /**
  49468. * Define if the texture animates or not.
  49469. */
  49470. animate: boolean;
  49471. }
  49472. }
  49473. declare module BABYLON {
  49474. /** @hidden */
  49475. export var noisePixelShader: {
  49476. name: string;
  49477. shader: string;
  49478. };
  49479. }
  49480. declare module BABYLON {
  49481. /**
  49482. * Class used to generate noise procedural textures
  49483. */
  49484. export class NoiseProceduralTexture extends ProceduralTexture {
  49485. private _time;
  49486. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49487. brightness: number;
  49488. /** Defines the number of octaves to process */
  49489. octaves: number;
  49490. /** Defines the level of persistence (0.8 by default) */
  49491. persistence: number;
  49492. /** Gets or sets animation speed factor (default is 1) */
  49493. animationSpeedFactor: number;
  49494. /**
  49495. * Creates a new NoiseProceduralTexture
  49496. * @param name defines the name fo the texture
  49497. * @param size defines the size of the texture (default is 256)
  49498. * @param scene defines the hosting scene
  49499. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49500. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49501. */
  49502. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49503. private _updateShaderUniforms;
  49504. protected _getDefines(): string;
  49505. /** Generate the current state of the procedural texture */
  49506. render(useCameraPostProcess?: boolean): void;
  49507. /**
  49508. * Serializes this noise procedural texture
  49509. * @returns a serialized noise procedural texture object
  49510. */
  49511. serialize(): any;
  49512. /**
  49513. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49514. * @param parsedTexture defines parsed texture data
  49515. * @param scene defines the current scene
  49516. * @param rootUrl defines the root URL containing noise procedural texture information
  49517. * @returns a parsed NoiseProceduralTexture
  49518. */
  49519. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49520. }
  49521. }
  49522. declare module BABYLON {
  49523. /**
  49524. * Raw cube texture where the raw buffers are passed in
  49525. */
  49526. export class RawCubeTexture extends CubeTexture {
  49527. /**
  49528. * Creates a cube texture where the raw buffers are passed in.
  49529. * @param scene defines the scene the texture is attached to
  49530. * @param data defines the array of data to use to create each face
  49531. * @param size defines the size of the textures
  49532. * @param format defines the format of the data
  49533. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49534. * @param generateMipMaps defines if the engine should generate the mip levels
  49535. * @param invertY defines if data must be stored with Y axis inverted
  49536. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49537. * @param compression defines the compression used (null by default)
  49538. */
  49539. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49540. /**
  49541. * Updates the raw cube texture.
  49542. * @param data defines the data to store
  49543. * @param format defines the data format
  49544. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49545. * @param invertY defines if data must be stored with Y axis inverted
  49546. * @param compression defines the compression used (null by default)
  49547. * @param level defines which level of the texture to update
  49548. */
  49549. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49550. /**
  49551. * Updates a raw cube texture with RGBD encoded data.
  49552. * @param data defines the array of data [mipmap][face] to use to create each face
  49553. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49554. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49555. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49556. * @returns a promsie that resolves when the operation is complete
  49557. */
  49558. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49559. /**
  49560. * Clones the raw cube texture.
  49561. * @return a new cube texture
  49562. */
  49563. clone(): CubeTexture;
  49564. /** @hidden */
  49565. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49566. }
  49567. }
  49568. declare module BABYLON {
  49569. /**
  49570. * Class used to store 3D textures containing user data
  49571. */
  49572. export class RawTexture3D extends Texture {
  49573. /** Gets or sets the texture format to use */
  49574. format: number;
  49575. private _engine;
  49576. /**
  49577. * Create a new RawTexture3D
  49578. * @param data defines the data of the texture
  49579. * @param width defines the width of the texture
  49580. * @param height defines the height of the texture
  49581. * @param depth defines the depth of the texture
  49582. * @param format defines the texture format to use
  49583. * @param scene defines the hosting scene
  49584. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49585. * @param invertY defines if texture must be stored with Y axis inverted
  49586. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49587. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49588. */
  49589. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49590. /** Gets or sets the texture format to use */
  49591. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49592. /**
  49593. * Update the texture with new data
  49594. * @param data defines the data to store in the texture
  49595. */
  49596. update(data: ArrayBufferView): void;
  49597. }
  49598. }
  49599. declare module BABYLON {
  49600. /**
  49601. * Creates a refraction texture used by refraction channel of the standard material.
  49602. * It is like a mirror but to see through a material.
  49603. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49604. */
  49605. export class RefractionTexture extends RenderTargetTexture {
  49606. /**
  49607. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49608. * 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.
  49609. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49610. */
  49611. refractionPlane: Plane;
  49612. /**
  49613. * Define how deep under the surface we should see.
  49614. */
  49615. depth: number;
  49616. /**
  49617. * Creates a refraction texture used by refraction channel of the standard material.
  49618. * It is like a mirror but to see through a material.
  49619. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49620. * @param name Define the texture name
  49621. * @param size Define the size of the underlying texture
  49622. * @param scene Define the scene the refraction belongs to
  49623. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49624. */
  49625. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49626. /**
  49627. * Clone the refraction texture.
  49628. * @returns the cloned texture
  49629. */
  49630. clone(): RefractionTexture;
  49631. /**
  49632. * Serialize the texture to a JSON representation you could use in Parse later on
  49633. * @returns the serialized JSON representation
  49634. */
  49635. serialize(): any;
  49636. }
  49637. }
  49638. declare module BABYLON {
  49639. /**
  49640. * Defines the options related to the creation of an HtmlElementTexture
  49641. */
  49642. export interface IHtmlElementTextureOptions {
  49643. /**
  49644. * Defines wether mip maps should be created or not.
  49645. */
  49646. generateMipMaps?: boolean;
  49647. /**
  49648. * Defines the sampling mode of the texture.
  49649. */
  49650. samplingMode?: number;
  49651. /**
  49652. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  49653. */
  49654. engine: Nullable<Engine>;
  49655. /**
  49656. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  49657. */
  49658. scene: Nullable<Scene>;
  49659. }
  49660. /**
  49661. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  49662. * To be as efficient as possible depending on your constraints nothing aside the first upload
  49663. * is automatically managed.
  49664. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  49665. * in your application.
  49666. *
  49667. * As the update is not automatic, you need to call them manually.
  49668. */
  49669. export class HtmlElementTexture extends BaseTexture {
  49670. /**
  49671. * The texture URL.
  49672. */
  49673. element: HTMLVideoElement | HTMLCanvasElement;
  49674. private static readonly DefaultOptions;
  49675. private _textureMatrix;
  49676. private _engine;
  49677. private _isVideo;
  49678. private _generateMipMaps;
  49679. private _samplingMode;
  49680. /**
  49681. * Instantiates a HtmlElementTexture from the following parameters.
  49682. *
  49683. * @param name Defines the name of the texture
  49684. * @param element Defines the video or canvas the texture is filled with
  49685. * @param options Defines the other none mandatory texture creation options
  49686. */
  49687. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  49688. private _createInternalTexture;
  49689. /**
  49690. * Returns the texture matrix used in most of the material.
  49691. */
  49692. getTextureMatrix(): Matrix;
  49693. /**
  49694. * Updates the content of the texture.
  49695. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  49696. */
  49697. update(invertY?: Nullable<boolean>): void;
  49698. }
  49699. }
  49700. declare module BABYLON {
  49701. /**
  49702. * Helper class to push actions to a pool of workers.
  49703. */
  49704. export class WorkerPool implements IDisposable {
  49705. private _workerInfos;
  49706. private _pendingActions;
  49707. /**
  49708. * Constructor
  49709. * @param workers Array of workers to use for actions
  49710. */
  49711. constructor(workers: Array<Worker>);
  49712. /**
  49713. * Terminates all workers and clears any pending actions.
  49714. */
  49715. dispose(): void;
  49716. /**
  49717. * Pushes an action to the worker pool. If all the workers are active, the action will be
  49718. * pended until a worker has completed its action.
  49719. * @param action The action to perform. Call onComplete when the action is complete.
  49720. */
  49721. push(action: (worker: Worker, onComplete: () => void) => void): void;
  49722. private _execute;
  49723. }
  49724. }
  49725. declare module BABYLON {
  49726. /**
  49727. * Configuration for Draco compression
  49728. */
  49729. export interface IDracoCompressionConfiguration {
  49730. /**
  49731. * Configuration for the decoder.
  49732. */
  49733. decoder: {
  49734. /**
  49735. * The url to the WebAssembly module.
  49736. */
  49737. wasmUrl?: string;
  49738. /**
  49739. * The url to the WebAssembly binary.
  49740. */
  49741. wasmBinaryUrl?: string;
  49742. /**
  49743. * The url to the fallback JavaScript module.
  49744. */
  49745. fallbackUrl?: string;
  49746. };
  49747. }
  49748. /**
  49749. * Draco compression (https://google.github.io/draco/)
  49750. *
  49751. * This class wraps the Draco module.
  49752. *
  49753. * **Encoder**
  49754. *
  49755. * The encoder is not currently implemented.
  49756. *
  49757. * **Decoder**
  49758. *
  49759. * 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.
  49760. *
  49761. * To update the configuration, use the following code:
  49762. * ```javascript
  49763. * DracoCompression.Configuration = {
  49764. * decoder: {
  49765. * wasmUrl: "<url to the WebAssembly library>",
  49766. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49767. * fallbackUrl: "<url to the fallback JavaScript library>",
  49768. * }
  49769. * };
  49770. * ```
  49771. *
  49772. * 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.
  49773. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49774. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  49775. *
  49776. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  49777. * ```javascript
  49778. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  49779. * ```
  49780. *
  49781. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49782. */
  49783. export class DracoCompression implements IDisposable {
  49784. private _workerPoolPromise?;
  49785. private _decoderModulePromise?;
  49786. /**
  49787. * The configuration. Defaults to the following urls:
  49788. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49789. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49790. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49791. */
  49792. static Configuration: IDracoCompressionConfiguration;
  49793. /**
  49794. * Returns true if the decoder configuration is available.
  49795. */
  49796. static readonly DecoderAvailable: boolean;
  49797. /**
  49798. * Default number of workers to create when creating the draco compression object.
  49799. */
  49800. static DefaultNumWorkers: number;
  49801. private static GetDefaultNumWorkers;
  49802. private static _Default;
  49803. /**
  49804. * Default instance for the draco compression object.
  49805. */
  49806. static readonly Default: DracoCompression;
  49807. /**
  49808. * Constructor
  49809. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  49810. */
  49811. constructor(numWorkers?: number);
  49812. /**
  49813. * Stop all async operations and release resources.
  49814. */
  49815. dispose(): void;
  49816. /**
  49817. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  49818. * @returns a promise that resolves when ready
  49819. */
  49820. whenReadyAsync(): Promise<void>;
  49821. /**
  49822. * Decode Draco compressed mesh data to vertex data.
  49823. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49824. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49825. * @returns A promise that resolves with the decoded vertex data
  49826. */
  49827. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  49828. [kind: string]: number;
  49829. }): Promise<VertexData>;
  49830. }
  49831. }
  49832. declare module BABYLON {
  49833. /**
  49834. * Class for building Constructive Solid Geometry
  49835. */
  49836. export class CSG {
  49837. private polygons;
  49838. /**
  49839. * The world matrix
  49840. */
  49841. matrix: Matrix;
  49842. /**
  49843. * Stores the position
  49844. */
  49845. position: Vector3;
  49846. /**
  49847. * Stores the rotation
  49848. */
  49849. rotation: Vector3;
  49850. /**
  49851. * Stores the rotation quaternion
  49852. */
  49853. rotationQuaternion: Nullable<Quaternion>;
  49854. /**
  49855. * Stores the scaling vector
  49856. */
  49857. scaling: Vector3;
  49858. /**
  49859. * Convert the Mesh to CSG
  49860. * @param mesh The Mesh to convert to CSG
  49861. * @returns A new CSG from the Mesh
  49862. */
  49863. static FromMesh(mesh: Mesh): CSG;
  49864. /**
  49865. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49866. * @param polygons Polygons used to construct a CSG solid
  49867. */
  49868. private static FromPolygons;
  49869. /**
  49870. * Clones, or makes a deep copy, of the CSG
  49871. * @returns A new CSG
  49872. */
  49873. clone(): CSG;
  49874. /**
  49875. * Unions this CSG with another CSG
  49876. * @param csg The CSG to union against this CSG
  49877. * @returns The unioned CSG
  49878. */
  49879. union(csg: CSG): CSG;
  49880. /**
  49881. * Unions this CSG with another CSG in place
  49882. * @param csg The CSG to union against this CSG
  49883. */
  49884. unionInPlace(csg: CSG): void;
  49885. /**
  49886. * Subtracts this CSG with another CSG
  49887. * @param csg The CSG to subtract against this CSG
  49888. * @returns A new CSG
  49889. */
  49890. subtract(csg: CSG): CSG;
  49891. /**
  49892. * Subtracts this CSG with another CSG in place
  49893. * @param csg The CSG to subtact against this CSG
  49894. */
  49895. subtractInPlace(csg: CSG): void;
  49896. /**
  49897. * Intersect this CSG with another CSG
  49898. * @param csg The CSG to intersect against this CSG
  49899. * @returns A new CSG
  49900. */
  49901. intersect(csg: CSG): CSG;
  49902. /**
  49903. * Intersects this CSG with another CSG in place
  49904. * @param csg The CSG to intersect against this CSG
  49905. */
  49906. intersectInPlace(csg: CSG): void;
  49907. /**
  49908. * Return a new CSG solid with solid and empty space switched. This solid is
  49909. * not modified.
  49910. * @returns A new CSG solid with solid and empty space switched
  49911. */
  49912. inverse(): CSG;
  49913. /**
  49914. * Inverses the CSG in place
  49915. */
  49916. inverseInPlace(): void;
  49917. /**
  49918. * This is used to keep meshes transformations so they can be restored
  49919. * when we build back a Babylon Mesh
  49920. * NB : All CSG operations are performed in world coordinates
  49921. * @param csg The CSG to copy the transform attributes from
  49922. * @returns This CSG
  49923. */
  49924. copyTransformAttributes(csg: CSG): CSG;
  49925. /**
  49926. * Build Raw mesh from CSG
  49927. * Coordinates here are in world space
  49928. * @param name The name of the mesh geometry
  49929. * @param scene The Scene
  49930. * @param keepSubMeshes Specifies if the submeshes should be kept
  49931. * @returns A new Mesh
  49932. */
  49933. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49934. /**
  49935. * Build Mesh from CSG taking material and transforms into account
  49936. * @param name The name of the Mesh
  49937. * @param material The material of the Mesh
  49938. * @param scene The Scene
  49939. * @param keepSubMeshes Specifies if submeshes should be kept
  49940. * @returns The new Mesh
  49941. */
  49942. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49943. }
  49944. }
  49945. declare module BABYLON {
  49946. /**
  49947. * Class used to create a trail following a mesh
  49948. */
  49949. export class TrailMesh extends Mesh {
  49950. private _generator;
  49951. private _autoStart;
  49952. private _running;
  49953. private _diameter;
  49954. private _length;
  49955. private _sectionPolygonPointsCount;
  49956. private _sectionVectors;
  49957. private _sectionNormalVectors;
  49958. private _beforeRenderObserver;
  49959. /**
  49960. * @constructor
  49961. * @param name The value used by scene.getMeshByName() to do a lookup.
  49962. * @param generator The mesh to generate a trail.
  49963. * @param scene The scene to add this mesh to.
  49964. * @param diameter Diameter of trailing mesh. Default is 1.
  49965. * @param length Length of trailing mesh. Default is 60.
  49966. * @param autoStart Automatically start trailing mesh. Default true.
  49967. */
  49968. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49969. /**
  49970. * "TrailMesh"
  49971. * @returns "TrailMesh"
  49972. */
  49973. getClassName(): string;
  49974. private _createMesh;
  49975. /**
  49976. * Start trailing mesh.
  49977. */
  49978. start(): void;
  49979. /**
  49980. * Stop trailing mesh.
  49981. */
  49982. stop(): void;
  49983. /**
  49984. * Update trailing mesh geometry.
  49985. */
  49986. update(): void;
  49987. /**
  49988. * Returns a new TrailMesh object.
  49989. * @param name is a string, the name given to the new mesh
  49990. * @param newGenerator use new generator object for cloned trail mesh
  49991. * @returns a new mesh
  49992. */
  49993. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49994. /**
  49995. * Serializes this trail mesh
  49996. * @param serializationObject object to write serialization to
  49997. */
  49998. serialize(serializationObject: any): void;
  49999. /**
  50000. * Parses a serialized trail mesh
  50001. * @param parsedMesh the serialized mesh
  50002. * @param scene the scene to create the trail mesh in
  50003. * @returns the created trail mesh
  50004. */
  50005. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  50006. }
  50007. }
  50008. declare module BABYLON {
  50009. /**
  50010. * Class containing static functions to help procedurally build meshes
  50011. */
  50012. export class TorusKnotBuilder {
  50013. /**
  50014. * Creates a torus knot mesh
  50015. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50016. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50017. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50018. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50019. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50020. * * 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
  50021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50022. * @param name defines the name of the mesh
  50023. * @param options defines the options used to create the mesh
  50024. * @param scene defines the hosting scene
  50025. * @returns the torus knot mesh
  50026. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50027. */
  50028. static CreateTorusKnot(name: string, options: {
  50029. radius?: number;
  50030. tube?: number;
  50031. radialSegments?: number;
  50032. tubularSegments?: number;
  50033. p?: number;
  50034. q?: number;
  50035. updatable?: boolean;
  50036. sideOrientation?: number;
  50037. frontUVs?: Vector4;
  50038. backUVs?: Vector4;
  50039. }, scene: any): Mesh;
  50040. }
  50041. }
  50042. declare module BABYLON {
  50043. /**
  50044. * Polygon
  50045. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  50046. */
  50047. export class Polygon {
  50048. /**
  50049. * Creates a rectangle
  50050. * @param xmin bottom X coord
  50051. * @param ymin bottom Y coord
  50052. * @param xmax top X coord
  50053. * @param ymax top Y coord
  50054. * @returns points that make the resulting rectation
  50055. */
  50056. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  50057. /**
  50058. * Creates a circle
  50059. * @param radius radius of circle
  50060. * @param cx scale in x
  50061. * @param cy scale in y
  50062. * @param numberOfSides number of sides that make up the circle
  50063. * @returns points that make the resulting circle
  50064. */
  50065. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  50066. /**
  50067. * Creates a polygon from input string
  50068. * @param input Input polygon data
  50069. * @returns the parsed points
  50070. */
  50071. static Parse(input: string): Vector2[];
  50072. /**
  50073. * Starts building a polygon from x and y coordinates
  50074. * @param x x coordinate
  50075. * @param y y coordinate
  50076. * @returns the started path2
  50077. */
  50078. static StartingAt(x: number, y: number): Path2;
  50079. }
  50080. /**
  50081. * Builds a polygon
  50082. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  50083. */
  50084. export class PolygonMeshBuilder {
  50085. private _points;
  50086. private _outlinepoints;
  50087. private _holes;
  50088. private _name;
  50089. private _scene;
  50090. private _epoints;
  50091. private _eholes;
  50092. private _addToepoint;
  50093. /**
  50094. * Babylon reference to the earcut plugin.
  50095. */
  50096. bjsEarcut: any;
  50097. /**
  50098. * Creates a PolygonMeshBuilder
  50099. * @param name name of the builder
  50100. * @param contours Path of the polygon
  50101. * @param scene scene to add to when creating the mesh
  50102. * @param earcutInjection can be used to inject your own earcut reference
  50103. */
  50104. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  50105. /**
  50106. * Adds a whole within the polygon
  50107. * @param hole Array of points defining the hole
  50108. * @returns this
  50109. */
  50110. addHole(hole: Vector2[]): PolygonMeshBuilder;
  50111. /**
  50112. * Creates the polygon
  50113. * @param updatable If the mesh should be updatable
  50114. * @param depth The depth of the mesh created
  50115. * @returns the created mesh
  50116. */
  50117. build(updatable?: boolean, depth?: number): Mesh;
  50118. /**
  50119. * Creates the polygon
  50120. * @param depth The depth of the mesh created
  50121. * @returns the created VertexData
  50122. */
  50123. buildVertexData(depth?: number): VertexData;
  50124. /**
  50125. * Adds a side to the polygon
  50126. * @param positions points that make the polygon
  50127. * @param normals normals of the polygon
  50128. * @param uvs uvs of the polygon
  50129. * @param indices indices of the polygon
  50130. * @param bounds bounds of the polygon
  50131. * @param points points of the polygon
  50132. * @param depth depth of the polygon
  50133. * @param flip flip of the polygon
  50134. */
  50135. private addSide;
  50136. }
  50137. }
  50138. declare module BABYLON {
  50139. /**
  50140. * Class containing static functions to help procedurally build meshes
  50141. */
  50142. export class PolygonBuilder {
  50143. /**
  50144. * Creates a polygon mesh
  50145. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50146. * * 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
  50147. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50149. * * 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)
  50150. * * Remember you can only change the shape positions, not their number when updating a polygon
  50151. * @param name defines the name of the mesh
  50152. * @param options defines the options used to create the mesh
  50153. * @param scene defines the hosting scene
  50154. * @param earcutInjection can be used to inject your own earcut reference
  50155. * @returns the polygon mesh
  50156. */
  50157. static CreatePolygon(name: string, options: {
  50158. shape: Vector3[];
  50159. holes?: Vector3[][];
  50160. depth?: number;
  50161. faceUV?: Vector4[];
  50162. faceColors?: Color4[];
  50163. updatable?: boolean;
  50164. sideOrientation?: number;
  50165. frontUVs?: Vector4;
  50166. backUVs?: Vector4;
  50167. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50168. /**
  50169. * Creates an extruded polygon mesh, with depth in the Y direction.
  50170. * * 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)
  50171. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50172. * @param name defines the name of the mesh
  50173. * @param options defines the options used to create the mesh
  50174. * @param scene defines the hosting scene
  50175. * @param earcutInjection can be used to inject your own earcut reference
  50176. * @returns the polygon mesh
  50177. */
  50178. static ExtrudePolygon(name: string, options: {
  50179. shape: Vector3[];
  50180. holes?: Vector3[][];
  50181. depth?: number;
  50182. faceUV?: Vector4[];
  50183. faceColors?: Color4[];
  50184. updatable?: boolean;
  50185. sideOrientation?: number;
  50186. frontUVs?: Vector4;
  50187. backUVs?: Vector4;
  50188. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50189. }
  50190. }
  50191. declare module BABYLON {
  50192. /**
  50193. * Class containing static functions to help procedurally build meshes
  50194. */
  50195. export class LatheBuilder {
  50196. /**
  50197. * Creates lathe mesh.
  50198. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50199. * * 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
  50200. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50201. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50202. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50203. * * 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
  50204. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50205. * * 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
  50206. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50207. * * 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
  50208. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50210. * @param name defines the name of the mesh
  50211. * @param options defines the options used to create the mesh
  50212. * @param scene defines the hosting scene
  50213. * @returns the lathe mesh
  50214. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50215. */
  50216. static CreateLathe(name: string, options: {
  50217. shape: Vector3[];
  50218. radius?: number;
  50219. tessellation?: number;
  50220. clip?: number;
  50221. arc?: number;
  50222. closed?: boolean;
  50223. updatable?: boolean;
  50224. sideOrientation?: number;
  50225. frontUVs?: Vector4;
  50226. backUVs?: Vector4;
  50227. cap?: number;
  50228. invertUV?: boolean;
  50229. }, scene?: Nullable<Scene>): Mesh;
  50230. }
  50231. }
  50232. declare module BABYLON {
  50233. /**
  50234. * Class containing static functions to help procedurally build meshes
  50235. */
  50236. export class TubeBuilder {
  50237. /**
  50238. * Creates a tube mesh.
  50239. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50240. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50241. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50242. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50243. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50244. * * 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)
  50245. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50246. * * 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
  50247. * * 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
  50248. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50249. * * 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
  50250. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50252. * @param name defines the name of the mesh
  50253. * @param options defines the options used to create the mesh
  50254. * @param scene defines the hosting scene
  50255. * @returns the tube mesh
  50256. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50257. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50258. */
  50259. static CreateTube(name: string, options: {
  50260. path: Vector3[];
  50261. radius?: number;
  50262. tessellation?: number;
  50263. radiusFunction?: {
  50264. (i: number, distance: number): number;
  50265. };
  50266. cap?: number;
  50267. arc?: number;
  50268. updatable?: boolean;
  50269. sideOrientation?: number;
  50270. frontUVs?: Vector4;
  50271. backUVs?: Vector4;
  50272. instance?: Mesh;
  50273. invertUV?: boolean;
  50274. }, scene?: Nullable<Scene>): Mesh;
  50275. }
  50276. }
  50277. declare module BABYLON {
  50278. /**
  50279. * Class containing static functions to help procedurally build meshes
  50280. */
  50281. export class IcoSphereBuilder {
  50282. /**
  50283. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50284. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50285. * * 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`)
  50286. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50287. * * 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
  50288. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50289. * * 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
  50290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50291. * @param name defines the name of the mesh
  50292. * @param options defines the options used to create the mesh
  50293. * @param scene defines the hosting scene
  50294. * @returns the icosahedron mesh
  50295. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50296. */
  50297. static CreateIcoSphere(name: string, options: {
  50298. radius?: number;
  50299. radiusX?: number;
  50300. radiusY?: number;
  50301. radiusZ?: number;
  50302. flat?: boolean;
  50303. subdivisions?: number;
  50304. sideOrientation?: number;
  50305. frontUVs?: Vector4;
  50306. backUVs?: Vector4;
  50307. updatable?: boolean;
  50308. }, scene?: Nullable<Scene>): Mesh;
  50309. }
  50310. }
  50311. declare module BABYLON {
  50312. /**
  50313. * Class containing static functions to help procedurally build meshes
  50314. */
  50315. export class DecalBuilder {
  50316. /**
  50317. * Creates a decal mesh.
  50318. * 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
  50319. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50320. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50321. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50322. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50323. * @param name defines the name of the mesh
  50324. * @param sourceMesh defines the mesh where the decal must be applied
  50325. * @param options defines the options used to create the mesh
  50326. * @param scene defines the hosting scene
  50327. * @returns the decal mesh
  50328. * @see https://doc.babylonjs.com/how_to/decals
  50329. */
  50330. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50331. position?: Vector3;
  50332. normal?: Vector3;
  50333. size?: Vector3;
  50334. angle?: number;
  50335. }): Mesh;
  50336. }
  50337. }
  50338. declare module BABYLON {
  50339. /**
  50340. * Class containing static functions to help procedurally build meshes
  50341. */
  50342. export class MeshBuilder {
  50343. /**
  50344. * Creates a box mesh
  50345. * * The parameter `size` sets the size (float) of each box side (default 1)
  50346. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50347. * * 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)
  50348. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50349. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50350. * * 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
  50351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50352. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50353. * @param name defines the name of the mesh
  50354. * @param options defines the options used to create the mesh
  50355. * @param scene defines the hosting scene
  50356. * @returns the box mesh
  50357. */
  50358. static CreateBox(name: string, options: {
  50359. size?: number;
  50360. width?: number;
  50361. height?: number;
  50362. depth?: number;
  50363. faceUV?: Vector4[];
  50364. faceColors?: Color4[];
  50365. sideOrientation?: number;
  50366. frontUVs?: Vector4;
  50367. backUVs?: Vector4;
  50368. updatable?: boolean;
  50369. }, scene?: Nullable<Scene>): Mesh;
  50370. /**
  50371. * Creates a sphere mesh
  50372. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50373. * * 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`)
  50374. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50375. * * 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
  50376. * * 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)
  50377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50378. * * 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
  50379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50380. * @param name defines the name of the mesh
  50381. * @param options defines the options used to create the mesh
  50382. * @param scene defines the hosting scene
  50383. * @returns the sphere mesh
  50384. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50385. */
  50386. static CreateSphere(name: string, options: {
  50387. segments?: number;
  50388. diameter?: number;
  50389. diameterX?: number;
  50390. diameterY?: number;
  50391. diameterZ?: number;
  50392. arc?: number;
  50393. slice?: number;
  50394. sideOrientation?: number;
  50395. frontUVs?: Vector4;
  50396. backUVs?: Vector4;
  50397. updatable?: boolean;
  50398. }, scene?: Nullable<Scene>): Mesh;
  50399. /**
  50400. * Creates a plane polygonal mesh. By default, this is a disc
  50401. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50402. * * 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
  50403. * * 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
  50404. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50405. * * 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
  50406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50407. * @param name defines the name of the mesh
  50408. * @param options defines the options used to create the mesh
  50409. * @param scene defines the hosting scene
  50410. * @returns the plane polygonal mesh
  50411. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50412. */
  50413. static CreateDisc(name: string, options: {
  50414. radius?: number;
  50415. tessellation?: number;
  50416. arc?: number;
  50417. updatable?: boolean;
  50418. sideOrientation?: number;
  50419. frontUVs?: Vector4;
  50420. backUVs?: Vector4;
  50421. }, scene?: Nullable<Scene>): Mesh;
  50422. /**
  50423. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50424. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50425. * * 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`)
  50426. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50427. * * 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
  50428. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50429. * * 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
  50430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50431. * @param name defines the name of the mesh
  50432. * @param options defines the options used to create the mesh
  50433. * @param scene defines the hosting scene
  50434. * @returns the icosahedron mesh
  50435. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50436. */
  50437. static CreateIcoSphere(name: string, options: {
  50438. radius?: number;
  50439. radiusX?: number;
  50440. radiusY?: number;
  50441. radiusZ?: number;
  50442. flat?: boolean;
  50443. subdivisions?: number;
  50444. sideOrientation?: number;
  50445. frontUVs?: Vector4;
  50446. backUVs?: Vector4;
  50447. updatable?: boolean;
  50448. }, scene?: Nullable<Scene>): Mesh;
  50449. /**
  50450. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50451. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50452. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50453. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50454. * * 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
  50455. * * 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
  50456. * * 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
  50457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50458. * * 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
  50459. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50460. * * 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
  50461. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50462. * * 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
  50463. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50465. * @param name defines the name of the mesh
  50466. * @param options defines the options used to create the mesh
  50467. * @param scene defines the hosting scene
  50468. * @returns the ribbon mesh
  50469. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50470. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50471. */
  50472. static CreateRibbon(name: string, options: {
  50473. pathArray: Vector3[][];
  50474. closeArray?: boolean;
  50475. closePath?: boolean;
  50476. offset?: number;
  50477. updatable?: boolean;
  50478. sideOrientation?: number;
  50479. frontUVs?: Vector4;
  50480. backUVs?: Vector4;
  50481. instance?: Mesh;
  50482. invertUV?: boolean;
  50483. uvs?: Vector2[];
  50484. colors?: Color4[];
  50485. }, scene?: Nullable<Scene>): Mesh;
  50486. /**
  50487. * Creates a cylinder or a cone mesh
  50488. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50489. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50490. * * 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.
  50491. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50492. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50493. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50494. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50495. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50496. * * 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).
  50497. * * 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
  50498. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50499. * * 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
  50500. * * 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.
  50501. * * If `enclose` is false, a ring surface is one element.
  50502. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50503. * * 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
  50504. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50505. * * 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
  50506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50507. * @param name defines the name of the mesh
  50508. * @param options defines the options used to create the mesh
  50509. * @param scene defines the hosting scene
  50510. * @returns the cylinder mesh
  50511. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50512. */
  50513. static CreateCylinder(name: string, options: {
  50514. height?: number;
  50515. diameterTop?: number;
  50516. diameterBottom?: number;
  50517. diameter?: number;
  50518. tessellation?: number;
  50519. subdivisions?: number;
  50520. arc?: number;
  50521. faceColors?: Color4[];
  50522. faceUV?: Vector4[];
  50523. updatable?: boolean;
  50524. hasRings?: boolean;
  50525. enclose?: boolean;
  50526. sideOrientation?: number;
  50527. frontUVs?: Vector4;
  50528. backUVs?: Vector4;
  50529. }, scene?: Nullable<Scene>): Mesh;
  50530. /**
  50531. * Creates a torus mesh
  50532. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50533. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50534. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50535. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50536. * * 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
  50537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50538. * @param name defines the name of the mesh
  50539. * @param options defines the options used to create the mesh
  50540. * @param scene defines the hosting scene
  50541. * @returns the torus mesh
  50542. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50543. */
  50544. static CreateTorus(name: string, options: {
  50545. diameter?: number;
  50546. thickness?: number;
  50547. tessellation?: number;
  50548. updatable?: boolean;
  50549. sideOrientation?: number;
  50550. frontUVs?: Vector4;
  50551. backUVs?: Vector4;
  50552. }, scene?: Nullable<Scene>): Mesh;
  50553. /**
  50554. * Creates a torus knot mesh
  50555. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50556. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50557. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50558. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50559. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50560. * * 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
  50561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50562. * @param name defines the name of the mesh
  50563. * @param options defines the options used to create the mesh
  50564. * @param scene defines the hosting scene
  50565. * @returns the torus knot mesh
  50566. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50567. */
  50568. static CreateTorusKnot(name: string, options: {
  50569. radius?: number;
  50570. tube?: number;
  50571. radialSegments?: number;
  50572. tubularSegments?: number;
  50573. p?: number;
  50574. q?: number;
  50575. updatable?: boolean;
  50576. sideOrientation?: number;
  50577. frontUVs?: Vector4;
  50578. backUVs?: Vector4;
  50579. }, scene?: Nullable<Scene>): Mesh;
  50580. /**
  50581. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50582. * * 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
  50583. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50584. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50585. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50586. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50587. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50588. * * 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
  50589. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50591. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50592. * @param name defines the name of the new line system
  50593. * @param options defines the options used to create the line system
  50594. * @param scene defines the hosting scene
  50595. * @returns a new line system mesh
  50596. */
  50597. static CreateLineSystem(name: string, options: {
  50598. lines: Vector3[][];
  50599. updatable?: boolean;
  50600. instance?: Nullable<LinesMesh>;
  50601. colors?: Nullable<Color4[][]>;
  50602. useVertexAlpha?: boolean;
  50603. }, scene: Nullable<Scene>): LinesMesh;
  50604. /**
  50605. * Creates a line mesh
  50606. * 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
  50607. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50608. * * The parameter `points` is an array successive Vector3
  50609. * * 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
  50610. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50611. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50612. * * When updating an instance, remember that only point positions can change, not the number of points
  50613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50614. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50615. * @param name defines the name of the new line system
  50616. * @param options defines the options used to create the line system
  50617. * @param scene defines the hosting scene
  50618. * @returns a new line mesh
  50619. */
  50620. static CreateLines(name: string, options: {
  50621. points: Vector3[];
  50622. updatable?: boolean;
  50623. instance?: Nullable<LinesMesh>;
  50624. colors?: Color4[];
  50625. useVertexAlpha?: boolean;
  50626. }, scene?: Nullable<Scene>): LinesMesh;
  50627. /**
  50628. * Creates a dashed line mesh
  50629. * * 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
  50630. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50631. * * The parameter `points` is an array successive Vector3
  50632. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50633. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50634. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50635. * * 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
  50636. * * When updating an instance, remember that only point positions can change, not the number of points
  50637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50638. * @param name defines the name of the mesh
  50639. * @param options defines the options used to create the mesh
  50640. * @param scene defines the hosting scene
  50641. * @returns the dashed line mesh
  50642. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50643. */
  50644. static CreateDashedLines(name: string, options: {
  50645. points: Vector3[];
  50646. dashSize?: number;
  50647. gapSize?: number;
  50648. dashNb?: number;
  50649. updatable?: boolean;
  50650. instance?: LinesMesh;
  50651. }, scene?: Nullable<Scene>): LinesMesh;
  50652. /**
  50653. * 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.
  50654. * * 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.
  50655. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50656. * * 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.
  50657. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50658. * * 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
  50659. * * 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
  50660. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50662. * * 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
  50663. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50665. * @param name defines the name of the mesh
  50666. * @param options defines the options used to create the mesh
  50667. * @param scene defines the hosting scene
  50668. * @returns the extruded shape mesh
  50669. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50670. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50671. */
  50672. static ExtrudeShape(name: string, options: {
  50673. shape: Vector3[];
  50674. path: Vector3[];
  50675. scale?: number;
  50676. rotation?: number;
  50677. cap?: number;
  50678. updatable?: boolean;
  50679. sideOrientation?: number;
  50680. frontUVs?: Vector4;
  50681. backUVs?: Vector4;
  50682. instance?: Mesh;
  50683. invertUV?: boolean;
  50684. }, scene?: Nullable<Scene>): Mesh;
  50685. /**
  50686. * Creates an custom extruded shape mesh.
  50687. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50688. * * 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.
  50689. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50690. * * 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
  50691. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50692. * * 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
  50693. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50694. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50695. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50696. * * 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
  50697. * * 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
  50698. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50700. * * 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
  50701. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50703. * @param name defines the name of the mesh
  50704. * @param options defines the options used to create the mesh
  50705. * @param scene defines the hosting scene
  50706. * @returns the custom extruded shape mesh
  50707. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50708. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50709. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50710. */
  50711. static ExtrudeShapeCustom(name: string, options: {
  50712. shape: Vector3[];
  50713. path: Vector3[];
  50714. scaleFunction?: any;
  50715. rotationFunction?: any;
  50716. ribbonCloseArray?: boolean;
  50717. ribbonClosePath?: boolean;
  50718. cap?: number;
  50719. updatable?: boolean;
  50720. sideOrientation?: number;
  50721. frontUVs?: Vector4;
  50722. backUVs?: Vector4;
  50723. instance?: Mesh;
  50724. invertUV?: boolean;
  50725. }, scene?: Nullable<Scene>): Mesh;
  50726. /**
  50727. * Creates lathe mesh.
  50728. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50729. * * 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
  50730. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50731. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50732. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50733. * * 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
  50734. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50735. * * 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
  50736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50737. * * 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
  50738. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50740. * @param name defines the name of the mesh
  50741. * @param options defines the options used to create the mesh
  50742. * @param scene defines the hosting scene
  50743. * @returns the lathe mesh
  50744. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50745. */
  50746. static CreateLathe(name: string, options: {
  50747. shape: Vector3[];
  50748. radius?: number;
  50749. tessellation?: number;
  50750. clip?: number;
  50751. arc?: number;
  50752. closed?: boolean;
  50753. updatable?: boolean;
  50754. sideOrientation?: number;
  50755. frontUVs?: Vector4;
  50756. backUVs?: Vector4;
  50757. cap?: number;
  50758. invertUV?: boolean;
  50759. }, scene?: Nullable<Scene>): Mesh;
  50760. /**
  50761. * Creates a plane mesh
  50762. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50763. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50764. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50765. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50766. * * 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
  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 plane mesh
  50772. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50773. */
  50774. static CreatePlane(name: string, options: {
  50775. size?: number;
  50776. width?: number;
  50777. height?: number;
  50778. sideOrientation?: number;
  50779. frontUVs?: Vector4;
  50780. backUVs?: Vector4;
  50781. updatable?: boolean;
  50782. sourcePlane?: Plane;
  50783. }, scene?: Nullable<Scene>): Mesh;
  50784. /**
  50785. * Creates a ground mesh
  50786. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50787. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50789. * @param name defines the name of the mesh
  50790. * @param options defines the options used to create the mesh
  50791. * @param scene defines the hosting scene
  50792. * @returns the ground mesh
  50793. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50794. */
  50795. static CreateGround(name: string, options: {
  50796. width?: number;
  50797. height?: number;
  50798. subdivisions?: number;
  50799. subdivisionsX?: number;
  50800. subdivisionsY?: number;
  50801. updatable?: boolean;
  50802. }, scene?: Nullable<Scene>): Mesh;
  50803. /**
  50804. * Creates a tiled ground mesh
  50805. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50806. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50807. * * 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
  50808. * * 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
  50809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50810. * @param name defines the name of the mesh
  50811. * @param options defines the options used to create the mesh
  50812. * @param scene defines the hosting scene
  50813. * @returns the tiled ground mesh
  50814. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50815. */
  50816. static CreateTiledGround(name: string, options: {
  50817. xmin: number;
  50818. zmin: number;
  50819. xmax: number;
  50820. zmax: number;
  50821. subdivisions?: {
  50822. w: number;
  50823. h: number;
  50824. };
  50825. precision?: {
  50826. w: number;
  50827. h: number;
  50828. };
  50829. updatable?: boolean;
  50830. }, scene?: Nullable<Scene>): Mesh;
  50831. /**
  50832. * Creates a ground mesh from a height map
  50833. * * The parameter `url` sets the URL of the height map image resource.
  50834. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50835. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50836. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50837. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50838. * * 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.
  50839. * * 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).
  50840. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50842. * @param name defines the name of the mesh
  50843. * @param url defines the url to the height map
  50844. * @param options defines the options used to create the mesh
  50845. * @param scene defines the hosting scene
  50846. * @returns the ground mesh
  50847. * @see https://doc.babylonjs.com/babylon101/height_map
  50848. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50849. */
  50850. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50851. width?: number;
  50852. height?: number;
  50853. subdivisions?: number;
  50854. minHeight?: number;
  50855. maxHeight?: number;
  50856. colorFilter?: Color3;
  50857. alphaFilter?: number;
  50858. updatable?: boolean;
  50859. onReady?: (mesh: GroundMesh) => void;
  50860. }, scene?: Nullable<Scene>): GroundMesh;
  50861. /**
  50862. * Creates a polygon mesh
  50863. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50864. * * 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
  50865. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50867. * * 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)
  50868. * * Remember you can only change the shape positions, not their number when updating a polygon
  50869. * @param name defines the name of the mesh
  50870. * @param options defines the options used to create the mesh
  50871. * @param scene defines the hosting scene
  50872. * @param earcutInjection can be used to inject your own earcut reference
  50873. * @returns the polygon mesh
  50874. */
  50875. static CreatePolygon(name: string, options: {
  50876. shape: Vector3[];
  50877. holes?: Vector3[][];
  50878. depth?: number;
  50879. faceUV?: Vector4[];
  50880. faceColors?: Color4[];
  50881. updatable?: boolean;
  50882. sideOrientation?: number;
  50883. frontUVs?: Vector4;
  50884. backUVs?: Vector4;
  50885. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50886. /**
  50887. * Creates an extruded polygon mesh, with depth in the Y direction.
  50888. * * 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)
  50889. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50890. * @param name defines the name of the mesh
  50891. * @param options defines the options used to create the mesh
  50892. * @param scene defines the hosting scene
  50893. * @param earcutInjection can be used to inject your own earcut reference
  50894. * @returns the polygon mesh
  50895. */
  50896. static ExtrudePolygon(name: string, options: {
  50897. shape: Vector3[];
  50898. holes?: Vector3[][];
  50899. depth?: number;
  50900. faceUV?: Vector4[];
  50901. faceColors?: Color4[];
  50902. updatable?: boolean;
  50903. sideOrientation?: number;
  50904. frontUVs?: Vector4;
  50905. backUVs?: Vector4;
  50906. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50907. /**
  50908. * Creates a tube mesh.
  50909. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50910. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50911. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50912. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50913. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50914. * * 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)
  50915. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50916. * * 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
  50917. * * 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
  50918. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50919. * * 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
  50920. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50922. * @param name defines the name of the mesh
  50923. * @param options defines the options used to create the mesh
  50924. * @param scene defines the hosting scene
  50925. * @returns the tube mesh
  50926. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50927. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50928. */
  50929. static CreateTube(name: string, options: {
  50930. path: Vector3[];
  50931. radius?: number;
  50932. tessellation?: number;
  50933. radiusFunction?: {
  50934. (i: number, distance: number): number;
  50935. };
  50936. cap?: number;
  50937. arc?: number;
  50938. updatable?: boolean;
  50939. sideOrientation?: number;
  50940. frontUVs?: Vector4;
  50941. backUVs?: Vector4;
  50942. instance?: Mesh;
  50943. invertUV?: boolean;
  50944. }, scene?: Nullable<Scene>): Mesh;
  50945. /**
  50946. * Creates a polyhedron mesh
  50947. * * 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
  50948. * * The parameter `size` (positive float, default 1) sets the polygon size
  50949. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50950. * * 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`
  50951. * * 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
  50952. * * 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)`)
  50953. * * 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
  50954. * * 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
  50955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50956. * * 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
  50957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50958. * @param name defines the name of the mesh
  50959. * @param options defines the options used to create the mesh
  50960. * @param scene defines the hosting scene
  50961. * @returns the polyhedron mesh
  50962. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50963. */
  50964. static CreatePolyhedron(name: string, options: {
  50965. type?: number;
  50966. size?: number;
  50967. sizeX?: number;
  50968. sizeY?: number;
  50969. sizeZ?: number;
  50970. custom?: any;
  50971. faceUV?: Vector4[];
  50972. faceColors?: Color4[];
  50973. flat?: boolean;
  50974. updatable?: boolean;
  50975. sideOrientation?: number;
  50976. frontUVs?: Vector4;
  50977. backUVs?: Vector4;
  50978. }, scene?: Nullable<Scene>): Mesh;
  50979. /**
  50980. * Creates a decal mesh.
  50981. * 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
  50982. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50983. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50984. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50985. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50986. * @param name defines the name of the mesh
  50987. * @param sourceMesh defines the mesh where the decal must be applied
  50988. * @param options defines the options used to create the mesh
  50989. * @param scene defines the hosting scene
  50990. * @returns the decal mesh
  50991. * @see https://doc.babylonjs.com/how_to/decals
  50992. */
  50993. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50994. position?: Vector3;
  50995. normal?: Vector3;
  50996. size?: Vector3;
  50997. angle?: number;
  50998. }): Mesh;
  50999. }
  51000. }
  51001. declare module BABYLON {
  51002. /**
  51003. * A simplifier interface for future simplification implementations
  51004. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51005. */
  51006. export interface ISimplifier {
  51007. /**
  51008. * Simplification of a given mesh according to the given settings.
  51009. * Since this requires computation, it is assumed that the function runs async.
  51010. * @param settings The settings of the simplification, including quality and distance
  51011. * @param successCallback A callback that will be called after the mesh was simplified.
  51012. * @param errorCallback in case of an error, this callback will be called. optional.
  51013. */
  51014. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  51015. }
  51016. /**
  51017. * Expected simplification settings.
  51018. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  51019. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51020. */
  51021. export interface ISimplificationSettings {
  51022. /**
  51023. * Gets or sets the expected quality
  51024. */
  51025. quality: number;
  51026. /**
  51027. * Gets or sets the distance when this optimized version should be used
  51028. */
  51029. distance: number;
  51030. /**
  51031. * Gets an already optimized mesh
  51032. */
  51033. optimizeMesh?: boolean;
  51034. }
  51035. /**
  51036. * Class used to specify simplification options
  51037. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51038. */
  51039. export class SimplificationSettings implements ISimplificationSettings {
  51040. /** expected quality */
  51041. quality: number;
  51042. /** distance when this optimized version should be used */
  51043. distance: number;
  51044. /** already optimized mesh */
  51045. optimizeMesh?: boolean | undefined;
  51046. /**
  51047. * Creates a SimplificationSettings
  51048. * @param quality expected quality
  51049. * @param distance distance when this optimized version should be used
  51050. * @param optimizeMesh already optimized mesh
  51051. */
  51052. constructor(
  51053. /** expected quality */
  51054. quality: number,
  51055. /** distance when this optimized version should be used */
  51056. distance: number,
  51057. /** already optimized mesh */
  51058. optimizeMesh?: boolean | undefined);
  51059. }
  51060. /**
  51061. * Interface used to define a simplification task
  51062. */
  51063. export interface ISimplificationTask {
  51064. /**
  51065. * Array of settings
  51066. */
  51067. settings: Array<ISimplificationSettings>;
  51068. /**
  51069. * Simplification type
  51070. */
  51071. simplificationType: SimplificationType;
  51072. /**
  51073. * Mesh to simplify
  51074. */
  51075. mesh: Mesh;
  51076. /**
  51077. * Callback called on success
  51078. */
  51079. successCallback?: () => void;
  51080. /**
  51081. * Defines if parallel processing can be used
  51082. */
  51083. parallelProcessing: boolean;
  51084. }
  51085. /**
  51086. * Queue used to order the simplification tasks
  51087. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51088. */
  51089. export class SimplificationQueue {
  51090. private _simplificationArray;
  51091. /**
  51092. * Gets a boolean indicating that the process is still running
  51093. */
  51094. running: boolean;
  51095. /**
  51096. * Creates a new queue
  51097. */
  51098. constructor();
  51099. /**
  51100. * Adds a new simplification task
  51101. * @param task defines a task to add
  51102. */
  51103. addTask(task: ISimplificationTask): void;
  51104. /**
  51105. * Execute next task
  51106. */
  51107. executeNext(): void;
  51108. /**
  51109. * Execute a simplification task
  51110. * @param task defines the task to run
  51111. */
  51112. runSimplification(task: ISimplificationTask): void;
  51113. private getSimplifier;
  51114. }
  51115. /**
  51116. * The implemented types of simplification
  51117. * At the moment only Quadratic Error Decimation is implemented
  51118. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51119. */
  51120. export enum SimplificationType {
  51121. /** Quadratic error decimation */
  51122. QUADRATIC = 0
  51123. }
  51124. }
  51125. declare module BABYLON {
  51126. interface Scene {
  51127. /** @hidden (Backing field) */
  51128. _simplificationQueue: SimplificationQueue;
  51129. /**
  51130. * Gets or sets the simplification queue attached to the scene
  51131. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51132. */
  51133. simplificationQueue: SimplificationQueue;
  51134. }
  51135. interface Mesh {
  51136. /**
  51137. * Simplify the mesh according to the given array of settings.
  51138. * Function will return immediately and will simplify async
  51139. * @param settings a collection of simplification settings
  51140. * @param parallelProcessing should all levels calculate parallel or one after the other
  51141. * @param simplificationType the type of simplification to run
  51142. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  51143. * @returns the current mesh
  51144. */
  51145. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  51146. }
  51147. /**
  51148. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  51149. * created in a scene
  51150. */
  51151. export class SimplicationQueueSceneComponent implements ISceneComponent {
  51152. /**
  51153. * The component name helpfull to identify the component in the list of scene components.
  51154. */
  51155. readonly name: string;
  51156. /**
  51157. * The scene the component belongs to.
  51158. */
  51159. scene: Scene;
  51160. /**
  51161. * Creates a new instance of the component for the given scene
  51162. * @param scene Defines the scene to register the component in
  51163. */
  51164. constructor(scene: Scene);
  51165. /**
  51166. * Registers the component in a given scene
  51167. */
  51168. register(): void;
  51169. /**
  51170. * Rebuilds the elements related to this component in case of
  51171. * context lost for instance.
  51172. */
  51173. rebuild(): void;
  51174. /**
  51175. * Disposes the component and the associated ressources
  51176. */
  51177. dispose(): void;
  51178. private _beforeCameraUpdate;
  51179. }
  51180. }
  51181. declare module BABYLON {
  51182. /**
  51183. * Class used to enable access to IndexedDB
  51184. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51185. */
  51186. export class Database implements IOfflineProvider {
  51187. private _callbackManifestChecked;
  51188. private _currentSceneUrl;
  51189. private _db;
  51190. private _enableSceneOffline;
  51191. private _enableTexturesOffline;
  51192. private _manifestVersionFound;
  51193. private _mustUpdateRessources;
  51194. private _hasReachedQuota;
  51195. private _isSupported;
  51196. private _idbFactory;
  51197. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51198. private static IsUASupportingBlobStorage;
  51199. /**
  51200. * Gets a boolean indicating if Database storate is enabled (off by default)
  51201. */
  51202. static IDBStorageEnabled: boolean;
  51203. /**
  51204. * Gets a boolean indicating if scene must be saved in the database
  51205. */
  51206. readonly enableSceneOffline: boolean;
  51207. /**
  51208. * Gets a boolean indicating if textures must be saved in the database
  51209. */
  51210. readonly enableTexturesOffline: boolean;
  51211. /**
  51212. * Creates a new Database
  51213. * @param urlToScene defines the url to load the scene
  51214. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51215. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51216. */
  51217. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51218. private static _ParseURL;
  51219. private static _ReturnFullUrlLocation;
  51220. private _checkManifestFile;
  51221. /**
  51222. * Open the database and make it available
  51223. * @param successCallback defines the callback to call on success
  51224. * @param errorCallback defines the callback to call on error
  51225. */
  51226. open(successCallback: () => void, errorCallback: () => void): void;
  51227. /**
  51228. * Loads an image from the database
  51229. * @param url defines the url to load from
  51230. * @param image defines the target DOM image
  51231. */
  51232. loadImage(url: string, image: HTMLImageElement): void;
  51233. private _loadImageFromDBAsync;
  51234. private _saveImageIntoDBAsync;
  51235. private _checkVersionFromDB;
  51236. private _loadVersionFromDBAsync;
  51237. private _saveVersionIntoDBAsync;
  51238. /**
  51239. * Loads a file from database
  51240. * @param url defines the URL to load from
  51241. * @param sceneLoaded defines a callback to call on success
  51242. * @param progressCallBack defines a callback to call when progress changed
  51243. * @param errorCallback defines a callback to call on error
  51244. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51245. */
  51246. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51247. private _loadFileAsync;
  51248. private _saveFileAsync;
  51249. /**
  51250. * Validates if xhr data is correct
  51251. * @param xhr defines the request to validate
  51252. * @param dataType defines the expected data type
  51253. * @returns true if data is correct
  51254. */
  51255. private static _ValidateXHRData;
  51256. }
  51257. }
  51258. declare module BABYLON {
  51259. /** @hidden */
  51260. export var gpuUpdateParticlesPixelShader: {
  51261. name: string;
  51262. shader: string;
  51263. };
  51264. }
  51265. declare module BABYLON {
  51266. /** @hidden */
  51267. export var gpuUpdateParticlesVertexShader: {
  51268. name: string;
  51269. shader: string;
  51270. };
  51271. }
  51272. declare module BABYLON {
  51273. /** @hidden */
  51274. export var clipPlaneFragmentDeclaration2: {
  51275. name: string;
  51276. shader: string;
  51277. };
  51278. }
  51279. declare module BABYLON {
  51280. /** @hidden */
  51281. export var gpuRenderParticlesPixelShader: {
  51282. name: string;
  51283. shader: string;
  51284. };
  51285. }
  51286. declare module BABYLON {
  51287. /** @hidden */
  51288. export var clipPlaneVertexDeclaration2: {
  51289. name: string;
  51290. shader: string;
  51291. };
  51292. }
  51293. declare module BABYLON {
  51294. /** @hidden */
  51295. export var gpuRenderParticlesVertexShader: {
  51296. name: string;
  51297. shader: string;
  51298. };
  51299. }
  51300. declare module BABYLON {
  51301. /**
  51302. * This represents a GPU particle system in Babylon
  51303. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51304. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51305. */
  51306. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51307. /**
  51308. * The layer mask we are rendering the particles through.
  51309. */
  51310. layerMask: number;
  51311. private _capacity;
  51312. private _activeCount;
  51313. private _currentActiveCount;
  51314. private _accumulatedCount;
  51315. private _renderEffect;
  51316. private _updateEffect;
  51317. private _buffer0;
  51318. private _buffer1;
  51319. private _spriteBuffer;
  51320. private _updateVAO;
  51321. private _renderVAO;
  51322. private _targetIndex;
  51323. private _sourceBuffer;
  51324. private _targetBuffer;
  51325. private _engine;
  51326. private _currentRenderId;
  51327. private _started;
  51328. private _stopped;
  51329. private _timeDelta;
  51330. private _randomTexture;
  51331. private _randomTexture2;
  51332. private _attributesStrideSize;
  51333. private _updateEffectOptions;
  51334. private _randomTextureSize;
  51335. private _actualFrame;
  51336. private readonly _rawTextureWidth;
  51337. /**
  51338. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51339. */
  51340. static readonly IsSupported: boolean;
  51341. /**
  51342. * An event triggered when the system is disposed.
  51343. */
  51344. onDisposeObservable: Observable<GPUParticleSystem>;
  51345. /**
  51346. * Gets the maximum number of particles active at the same time.
  51347. * @returns The max number of active particles.
  51348. */
  51349. getCapacity(): number;
  51350. /**
  51351. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51352. * to override the particles.
  51353. */
  51354. forceDepthWrite: boolean;
  51355. /**
  51356. * Gets or set the number of active particles
  51357. */
  51358. activeParticleCount: number;
  51359. private _preWarmDone;
  51360. /**
  51361. * Is this system ready to be used/rendered
  51362. * @return true if the system is ready
  51363. */
  51364. isReady(): boolean;
  51365. /**
  51366. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51367. * @returns True if it has been started, otherwise false.
  51368. */
  51369. isStarted(): boolean;
  51370. /**
  51371. * Starts the particle system and begins to emit
  51372. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51373. */
  51374. start(delay?: number): void;
  51375. /**
  51376. * Stops the particle system.
  51377. */
  51378. stop(): void;
  51379. /**
  51380. * Remove all active particles
  51381. */
  51382. reset(): void;
  51383. /**
  51384. * Returns the string "GPUParticleSystem"
  51385. * @returns a string containing the class name
  51386. */
  51387. getClassName(): string;
  51388. private _colorGradientsTexture;
  51389. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51390. /**
  51391. * Adds a new color gradient
  51392. * @param gradient defines the gradient to use (between 0 and 1)
  51393. * @param color1 defines the color to affect to the specified gradient
  51394. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51395. * @returns the current particle system
  51396. */
  51397. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51398. /**
  51399. * Remove a specific color gradient
  51400. * @param gradient defines the gradient to remove
  51401. * @returns the current particle system
  51402. */
  51403. removeColorGradient(gradient: number): GPUParticleSystem;
  51404. private _angularSpeedGradientsTexture;
  51405. private _sizeGradientsTexture;
  51406. private _velocityGradientsTexture;
  51407. private _limitVelocityGradientsTexture;
  51408. private _dragGradientsTexture;
  51409. private _addFactorGradient;
  51410. /**
  51411. * Adds a new size gradient
  51412. * @param gradient defines the gradient to use (between 0 and 1)
  51413. * @param factor defines the size factor to affect to the specified gradient
  51414. * @returns the current particle system
  51415. */
  51416. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51417. /**
  51418. * Remove a specific size gradient
  51419. * @param gradient defines the gradient to remove
  51420. * @returns the current particle system
  51421. */
  51422. removeSizeGradient(gradient: number): GPUParticleSystem;
  51423. /**
  51424. * Adds a new angular speed gradient
  51425. * @param gradient defines the gradient to use (between 0 and 1)
  51426. * @param factor defines the angular speed to affect to the specified gradient
  51427. * @returns the current particle system
  51428. */
  51429. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51430. /**
  51431. * Remove a specific angular speed gradient
  51432. * @param gradient defines the gradient to remove
  51433. * @returns the current particle system
  51434. */
  51435. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51436. /**
  51437. * Adds a new velocity gradient
  51438. * @param gradient defines the gradient to use (between 0 and 1)
  51439. * @param factor defines the velocity to affect to the specified gradient
  51440. * @returns the current particle system
  51441. */
  51442. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51443. /**
  51444. * Remove a specific velocity gradient
  51445. * @param gradient defines the gradient to remove
  51446. * @returns the current particle system
  51447. */
  51448. removeVelocityGradient(gradient: number): GPUParticleSystem;
  51449. /**
  51450. * Adds a new limit velocity gradient
  51451. * @param gradient defines the gradient to use (between 0 and 1)
  51452. * @param factor defines the limit velocity value to affect to the specified gradient
  51453. * @returns the current particle system
  51454. */
  51455. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51456. /**
  51457. * Remove a specific limit velocity gradient
  51458. * @param gradient defines the gradient to remove
  51459. * @returns the current particle system
  51460. */
  51461. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  51462. /**
  51463. * Adds a new drag gradient
  51464. * @param gradient defines the gradient to use (between 0 and 1)
  51465. * @param factor defines the drag value to affect to the specified gradient
  51466. * @returns the current particle system
  51467. */
  51468. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  51469. /**
  51470. * Remove a specific drag gradient
  51471. * @param gradient defines the gradient to remove
  51472. * @returns the current particle system
  51473. */
  51474. removeDragGradient(gradient: number): GPUParticleSystem;
  51475. /**
  51476. * Not supported by GPUParticleSystem
  51477. * @param gradient defines the gradient to use (between 0 and 1)
  51478. * @param factor defines the emit rate value to affect to the specified gradient
  51479. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51480. * @returns the current particle system
  51481. */
  51482. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51483. /**
  51484. * Not supported by GPUParticleSystem
  51485. * @param gradient defines the gradient to remove
  51486. * @returns the current particle system
  51487. */
  51488. removeEmitRateGradient(gradient: number): IParticleSystem;
  51489. /**
  51490. * Not supported by GPUParticleSystem
  51491. * @param gradient defines the gradient to use (between 0 and 1)
  51492. * @param factor defines the start size value to affect to the specified gradient
  51493. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51494. * @returns the current particle system
  51495. */
  51496. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51497. /**
  51498. * Not supported by GPUParticleSystem
  51499. * @param gradient defines the gradient to remove
  51500. * @returns the current particle system
  51501. */
  51502. removeStartSizeGradient(gradient: number): IParticleSystem;
  51503. /**
  51504. * Not supported by GPUParticleSystem
  51505. * @param gradient defines the gradient to use (between 0 and 1)
  51506. * @param min defines the color remap minimal range
  51507. * @param max defines the color remap maximal range
  51508. * @returns the current particle system
  51509. */
  51510. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51511. /**
  51512. * Not supported by GPUParticleSystem
  51513. * @param gradient defines the gradient to remove
  51514. * @returns the current particle system
  51515. */
  51516. removeColorRemapGradient(): IParticleSystem;
  51517. /**
  51518. * Not supported by GPUParticleSystem
  51519. * @param gradient defines the gradient to use (between 0 and 1)
  51520. * @param min defines the alpha remap minimal range
  51521. * @param max defines the alpha remap maximal range
  51522. * @returns the current particle system
  51523. */
  51524. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51525. /**
  51526. * Not supported by GPUParticleSystem
  51527. * @param gradient defines the gradient to remove
  51528. * @returns the current particle system
  51529. */
  51530. removeAlphaRemapGradient(): IParticleSystem;
  51531. /**
  51532. * Not supported by GPUParticleSystem
  51533. * @param gradient defines the gradient to use (between 0 and 1)
  51534. * @param color defines the color to affect to the specified gradient
  51535. * @returns the current particle system
  51536. */
  51537. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51538. /**
  51539. * Not supported by GPUParticleSystem
  51540. * @param gradient defines the gradient to remove
  51541. * @returns the current particle system
  51542. */
  51543. removeRampGradient(): IParticleSystem;
  51544. /**
  51545. * Not supported by GPUParticleSystem
  51546. * @returns the list of ramp gradients
  51547. */
  51548. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51549. /**
  51550. * Not supported by GPUParticleSystem
  51551. * Gets or sets a boolean indicating that ramp gradients must be used
  51552. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51553. */
  51554. useRampGradients: boolean;
  51555. /**
  51556. * Not supported by GPUParticleSystem
  51557. * @param gradient defines the gradient to use (between 0 and 1)
  51558. * @param factor defines the life time factor to affect to the specified gradient
  51559. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51560. * @returns the current particle system
  51561. */
  51562. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51563. /**
  51564. * Not supported by GPUParticleSystem
  51565. * @param gradient defines the gradient to remove
  51566. * @returns the current particle system
  51567. */
  51568. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51569. /**
  51570. * Instantiates a GPU particle system.
  51571. * 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.
  51572. * @param name The name of the particle system
  51573. * @param options The options used to create the system
  51574. * @param scene The scene the particle system belongs to
  51575. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51576. */
  51577. constructor(name: string, options: Partial<{
  51578. capacity: number;
  51579. randomTextureSize: number;
  51580. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51581. protected _reset(): void;
  51582. private _createUpdateVAO;
  51583. private _createRenderVAO;
  51584. private _initialize;
  51585. /** @hidden */
  51586. _recreateUpdateEffect(): void;
  51587. /** @hidden */
  51588. _recreateRenderEffect(): void;
  51589. /**
  51590. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51591. * @param preWarm defines if we are in the pre-warmimg phase
  51592. */
  51593. animate(preWarm?: boolean): void;
  51594. private _createFactorGradientTexture;
  51595. private _createSizeGradientTexture;
  51596. private _createAngularSpeedGradientTexture;
  51597. private _createVelocityGradientTexture;
  51598. private _createLimitVelocityGradientTexture;
  51599. private _createDragGradientTexture;
  51600. private _createColorGradientTexture;
  51601. /**
  51602. * Renders the particle system in its current state
  51603. * @param preWarm defines if the system should only update the particles but not render them
  51604. * @returns the current number of particles
  51605. */
  51606. render(preWarm?: boolean): number;
  51607. /**
  51608. * Rebuilds the particle system
  51609. */
  51610. rebuild(): void;
  51611. private _releaseBuffers;
  51612. private _releaseVAOs;
  51613. /**
  51614. * Disposes the particle system and free the associated resources
  51615. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51616. */
  51617. dispose(disposeTexture?: boolean): void;
  51618. /**
  51619. * Clones the particle system.
  51620. * @param name The name of the cloned object
  51621. * @param newEmitter The new emitter to use
  51622. * @returns the cloned particle system
  51623. */
  51624. clone(name: string, newEmitter: any): GPUParticleSystem;
  51625. /**
  51626. * Serializes the particle system to a JSON object.
  51627. * @returns the JSON object
  51628. */
  51629. serialize(): any;
  51630. /**
  51631. * Parses a JSON object to create a GPU particle system.
  51632. * @param parsedParticleSystem The JSON object to parse
  51633. * @param scene The scene to create the particle system in
  51634. * @param rootUrl The root url to use to load external dependencies like texture
  51635. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51636. * @returns the parsed GPU particle system
  51637. */
  51638. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51639. }
  51640. }
  51641. declare module BABYLON {
  51642. /**
  51643. * Represents a set of particle systems working together to create a specific effect
  51644. */
  51645. export class ParticleSystemSet implements IDisposable {
  51646. private _emitterCreationOptions;
  51647. private _emitterNode;
  51648. /**
  51649. * Gets the particle system list
  51650. */
  51651. systems: IParticleSystem[];
  51652. /**
  51653. * Gets the emitter node used with this set
  51654. */
  51655. readonly emitterNode: Nullable<TransformNode>;
  51656. /**
  51657. * Creates a new emitter mesh as a sphere
  51658. * @param options defines the options used to create the sphere
  51659. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51660. * @param scene defines the hosting scene
  51661. */
  51662. setEmitterAsSphere(options: {
  51663. diameter: number;
  51664. segments: number;
  51665. color: Color3;
  51666. }, renderingGroupId: number, scene: Scene): void;
  51667. /**
  51668. * Starts all particle systems of the set
  51669. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51670. */
  51671. start(emitter?: AbstractMesh): void;
  51672. /**
  51673. * Release all associated resources
  51674. */
  51675. dispose(): void;
  51676. /**
  51677. * Serialize the set into a JSON compatible object
  51678. * @returns a JSON compatible representation of the set
  51679. */
  51680. serialize(): any;
  51681. /**
  51682. * Parse a new ParticleSystemSet from a serialized source
  51683. * @param data defines a JSON compatible representation of the set
  51684. * @param scene defines the hosting scene
  51685. * @param gpu defines if we want GPU particles or CPU particles
  51686. * @returns a new ParticleSystemSet
  51687. */
  51688. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51689. }
  51690. }
  51691. declare module BABYLON {
  51692. /**
  51693. * This class is made for on one-liner static method to help creating particle system set.
  51694. */
  51695. export class ParticleHelper {
  51696. /**
  51697. * Gets or sets base Assets URL
  51698. */
  51699. static BaseAssetsUrl: string;
  51700. /**
  51701. * Create a default particle system that you can tweak
  51702. * @param emitter defines the emitter to use
  51703. * @param capacity defines the system capacity (default is 500 particles)
  51704. * @param scene defines the hosting scene
  51705. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51706. * @returns the new Particle system
  51707. */
  51708. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51709. /**
  51710. * This is the main static method (one-liner) of this helper to create different particle systems
  51711. * @param type This string represents the type to the particle system to create
  51712. * @param scene The scene where the particle system should live
  51713. * @param gpu If the system will use gpu
  51714. * @returns the ParticleSystemSet created
  51715. */
  51716. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51717. /**
  51718. * Static function used to export a particle system to a ParticleSystemSet variable.
  51719. * Please note that the emitter shape is not exported
  51720. * @param systems defines the particle systems to export
  51721. * @returns the created particle system set
  51722. */
  51723. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51724. }
  51725. }
  51726. declare module BABYLON {
  51727. interface Engine {
  51728. /**
  51729. * Create an effect to use with particle systems.
  51730. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51731. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51732. * @param uniformsNames defines a list of attribute names
  51733. * @param samplers defines an array of string used to represent textures
  51734. * @param defines defines the string containing the defines to use to compile the shaders
  51735. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51736. * @param onCompiled defines a function to call when the effect creation is successful
  51737. * @param onError defines a function to call when the effect creation has failed
  51738. * @returns the new Effect
  51739. */
  51740. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  51741. }
  51742. interface Mesh {
  51743. /**
  51744. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  51745. * @returns an array of IParticleSystem
  51746. */
  51747. getEmittedParticleSystems(): IParticleSystem[];
  51748. /**
  51749. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51750. * @returns an array of IParticleSystem
  51751. */
  51752. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51753. }
  51754. /**
  51755. * @hidden
  51756. */
  51757. export var _IDoNeedToBeInTheBuild: number;
  51758. }
  51759. declare module BABYLON {
  51760. interface Scene {
  51761. /** @hidden (Backing field) */
  51762. _physicsEngine: Nullable<IPhysicsEngine>;
  51763. /**
  51764. * Gets the current physics engine
  51765. * @returns a IPhysicsEngine or null if none attached
  51766. */
  51767. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51768. /**
  51769. * Enables physics to the current scene
  51770. * @param gravity defines the scene's gravity for the physics engine
  51771. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51772. * @return a boolean indicating if the physics engine was initialized
  51773. */
  51774. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51775. /**
  51776. * Disables and disposes the physics engine associated with the scene
  51777. */
  51778. disablePhysicsEngine(): void;
  51779. /**
  51780. * Gets a boolean indicating if there is an active physics engine
  51781. * @returns a boolean indicating if there is an active physics engine
  51782. */
  51783. isPhysicsEnabled(): boolean;
  51784. /**
  51785. * Deletes a physics compound impostor
  51786. * @param compound defines the compound to delete
  51787. */
  51788. deleteCompoundImpostor(compound: any): void;
  51789. /**
  51790. * An event triggered when physic simulation is about to be run
  51791. */
  51792. onBeforePhysicsObservable: Observable<Scene>;
  51793. /**
  51794. * An event triggered when physic simulation has been done
  51795. */
  51796. onAfterPhysicsObservable: Observable<Scene>;
  51797. }
  51798. interface AbstractMesh {
  51799. /** @hidden */
  51800. _physicsImpostor: Nullable<PhysicsImpostor>;
  51801. /**
  51802. * Gets or sets impostor used for physic simulation
  51803. * @see http://doc.babylonjs.com/features/physics_engine
  51804. */
  51805. physicsImpostor: Nullable<PhysicsImpostor>;
  51806. /**
  51807. * Gets the current physics impostor
  51808. * @see http://doc.babylonjs.com/features/physics_engine
  51809. * @returns a physics impostor or null
  51810. */
  51811. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51812. /** Apply a physic impulse to the mesh
  51813. * @param force defines the force to apply
  51814. * @param contactPoint defines where to apply the force
  51815. * @returns the current mesh
  51816. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51817. */
  51818. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51819. /**
  51820. * Creates a physic joint between two meshes
  51821. * @param otherMesh defines the other mesh to use
  51822. * @param pivot1 defines the pivot to use on this mesh
  51823. * @param pivot2 defines the pivot to use on the other mesh
  51824. * @param options defines additional options (can be plugin dependent)
  51825. * @returns the current mesh
  51826. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51827. */
  51828. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51829. /** @hidden */
  51830. _disposePhysicsObserver: Nullable<Observer<Node>>;
  51831. }
  51832. /**
  51833. * Defines the physics engine scene component responsible to manage a physics engine
  51834. */
  51835. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51836. /**
  51837. * The component name helpful to identify the component in the list of scene components.
  51838. */
  51839. readonly name: string;
  51840. /**
  51841. * The scene the component belongs to.
  51842. */
  51843. scene: Scene;
  51844. /**
  51845. * Creates a new instance of the component for the given scene
  51846. * @param scene Defines the scene to register the component in
  51847. */
  51848. constructor(scene: Scene);
  51849. /**
  51850. * Registers the component in a given scene
  51851. */
  51852. register(): void;
  51853. /**
  51854. * Rebuilds the elements related to this component in case of
  51855. * context lost for instance.
  51856. */
  51857. rebuild(): void;
  51858. /**
  51859. * Disposes the component and the associated ressources
  51860. */
  51861. dispose(): void;
  51862. }
  51863. }
  51864. declare module BABYLON {
  51865. /**
  51866. * A helper for physics simulations
  51867. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51868. */
  51869. export class PhysicsHelper {
  51870. private _scene;
  51871. private _physicsEngine;
  51872. /**
  51873. * Initializes the Physics helper
  51874. * @param scene Babylon.js scene
  51875. */
  51876. constructor(scene: Scene);
  51877. /**
  51878. * Applies a radial explosion impulse
  51879. * @param origin the origin of the explosion
  51880. * @param radiusOrEventOptions the radius or the options of radial explosion
  51881. * @param strength the explosion strength
  51882. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51883. * @returns A physics radial explosion event, or null
  51884. */
  51885. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51886. /**
  51887. * Applies a radial explosion force
  51888. * @param origin the origin of the explosion
  51889. * @param radiusOrEventOptions the radius or the options of radial explosion
  51890. * @param strength the explosion strength
  51891. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51892. * @returns A physics radial explosion event, or null
  51893. */
  51894. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51895. /**
  51896. * Creates a gravitational field
  51897. * @param origin the origin of the explosion
  51898. * @param radiusOrEventOptions the radius or the options of radial explosion
  51899. * @param strength the explosion strength
  51900. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51901. * @returns A physics gravitational field event, or null
  51902. */
  51903. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  51904. /**
  51905. * Creates a physics updraft event
  51906. * @param origin the origin of the updraft
  51907. * @param radiusOrEventOptions the radius or the options of the updraft
  51908. * @param strength the strength of the updraft
  51909. * @param height the height of the updraft
  51910. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  51911. * @returns A physics updraft event, or null
  51912. */
  51913. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  51914. /**
  51915. * Creates a physics vortex event
  51916. * @param origin the of the vortex
  51917. * @param radiusOrEventOptions the radius or the options of the vortex
  51918. * @param strength the strength of the vortex
  51919. * @param height the height of the vortex
  51920. * @returns a Physics vortex event, or null
  51921. * A physics vortex event or null
  51922. */
  51923. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  51924. }
  51925. /**
  51926. * Represents a physics radial explosion event
  51927. */
  51928. class PhysicsRadialExplosionEvent {
  51929. private _scene;
  51930. private _options;
  51931. private _sphere;
  51932. private _dataFetched;
  51933. /**
  51934. * Initializes a radial explosioin event
  51935. * @param _scene BabylonJS scene
  51936. * @param _options The options for the vortex event
  51937. */
  51938. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  51939. /**
  51940. * Returns the data related to the radial explosion event (sphere).
  51941. * @returns The radial explosion event data
  51942. */
  51943. getData(): PhysicsRadialExplosionEventData;
  51944. /**
  51945. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  51946. * @param impostor A physics imposter
  51947. * @param origin the origin of the explosion
  51948. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  51949. */
  51950. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  51951. /**
  51952. * Triggers affecterd impostors callbacks
  51953. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  51954. */
  51955. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  51956. /**
  51957. * Disposes the sphere.
  51958. * @param force Specifies if the sphere should be disposed by force
  51959. */
  51960. dispose(force?: boolean): void;
  51961. /*** Helpers ***/
  51962. private _prepareSphere;
  51963. private _intersectsWithSphere;
  51964. }
  51965. /**
  51966. * Represents a gravitational field event
  51967. */
  51968. class PhysicsGravitationalFieldEvent {
  51969. private _physicsHelper;
  51970. private _scene;
  51971. private _origin;
  51972. private _options;
  51973. private _tickCallback;
  51974. private _sphere;
  51975. private _dataFetched;
  51976. /**
  51977. * Initializes the physics gravitational field event
  51978. * @param _physicsHelper A physics helper
  51979. * @param _scene BabylonJS scene
  51980. * @param _origin The origin position of the gravitational field event
  51981. * @param _options The options for the vortex event
  51982. */
  51983. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  51984. /**
  51985. * Returns the data related to the gravitational field event (sphere).
  51986. * @returns A gravitational field event
  51987. */
  51988. getData(): PhysicsGravitationalFieldEventData;
  51989. /**
  51990. * Enables the gravitational field.
  51991. */
  51992. enable(): void;
  51993. /**
  51994. * Disables the gravitational field.
  51995. */
  51996. disable(): void;
  51997. /**
  51998. * Disposes the sphere.
  51999. * @param force The force to dispose from the gravitational field event
  52000. */
  52001. dispose(force?: boolean): void;
  52002. private _tick;
  52003. }
  52004. /**
  52005. * Represents a physics updraft event
  52006. */
  52007. class PhysicsUpdraftEvent {
  52008. private _scene;
  52009. private _origin;
  52010. private _options;
  52011. private _physicsEngine;
  52012. private _originTop;
  52013. private _originDirection;
  52014. private _tickCallback;
  52015. private _cylinder;
  52016. private _cylinderPosition;
  52017. private _dataFetched;
  52018. /**
  52019. * Initializes the physics updraft event
  52020. * @param _scene BabylonJS scene
  52021. * @param _origin The origin position of the updraft
  52022. * @param _options The options for the updraft event
  52023. */
  52024. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  52025. /**
  52026. * Returns the data related to the updraft event (cylinder).
  52027. * @returns A physics updraft event
  52028. */
  52029. getData(): PhysicsUpdraftEventData;
  52030. /**
  52031. * Enables the updraft.
  52032. */
  52033. enable(): void;
  52034. /**
  52035. * Disables the updraft.
  52036. */
  52037. disable(): void;
  52038. /**
  52039. * Disposes the cylinder.
  52040. * @param force Specifies if the updraft should be disposed by force
  52041. */
  52042. dispose(force?: boolean): void;
  52043. private getImpostorHitData;
  52044. private _tick;
  52045. /*** Helpers ***/
  52046. private _prepareCylinder;
  52047. private _intersectsWithCylinder;
  52048. }
  52049. /**
  52050. * Represents a physics vortex event
  52051. */
  52052. class PhysicsVortexEvent {
  52053. private _scene;
  52054. private _origin;
  52055. private _options;
  52056. private _physicsEngine;
  52057. private _originTop;
  52058. private _tickCallback;
  52059. private _cylinder;
  52060. private _cylinderPosition;
  52061. private _dataFetched;
  52062. /**
  52063. * Initializes the physics vortex event
  52064. * @param _scene The BabylonJS scene
  52065. * @param _origin The origin position of the vortex
  52066. * @param _options The options for the vortex event
  52067. */
  52068. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  52069. /**
  52070. * Returns the data related to the vortex event (cylinder).
  52071. * @returns The physics vortex event data
  52072. */
  52073. getData(): PhysicsVortexEventData;
  52074. /**
  52075. * Enables the vortex.
  52076. */
  52077. enable(): void;
  52078. /**
  52079. * Disables the cortex.
  52080. */
  52081. disable(): void;
  52082. /**
  52083. * Disposes the sphere.
  52084. * @param force
  52085. */
  52086. dispose(force?: boolean): void;
  52087. private getImpostorHitData;
  52088. private _tick;
  52089. /*** Helpers ***/
  52090. private _prepareCylinder;
  52091. private _intersectsWithCylinder;
  52092. }
  52093. /**
  52094. * Options fot the radial explosion event
  52095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52096. */
  52097. export class PhysicsRadialExplosionEventOptions {
  52098. /**
  52099. * The radius of the sphere for the radial explosion.
  52100. */
  52101. radius: number;
  52102. /**
  52103. * The strenth of the explosion.
  52104. */
  52105. strength: number;
  52106. /**
  52107. * The strenght of the force in correspondence to the distance of the affected object
  52108. */
  52109. falloff: PhysicsRadialImpulseFalloff;
  52110. /**
  52111. * Sphere options for the radial explosion.
  52112. */
  52113. sphere: {
  52114. segments: number;
  52115. diameter: number;
  52116. };
  52117. /**
  52118. * Sphere options for the radial explosion.
  52119. */
  52120. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  52121. }
  52122. /**
  52123. * Options fot the updraft event
  52124. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52125. */
  52126. export class PhysicsUpdraftEventOptions {
  52127. /**
  52128. * The radius of the cylinder for the vortex
  52129. */
  52130. radius: number;
  52131. /**
  52132. * The strenth of the updraft.
  52133. */
  52134. strength: number;
  52135. /**
  52136. * The height of the cylinder for the updraft.
  52137. */
  52138. height: number;
  52139. /**
  52140. * The mode for the the updraft.
  52141. */
  52142. updraftMode: PhysicsUpdraftMode;
  52143. }
  52144. /**
  52145. * Options fot the vortex event
  52146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52147. */
  52148. export class PhysicsVortexEventOptions {
  52149. /**
  52150. * The radius of the cylinder for the vortex
  52151. */
  52152. radius: number;
  52153. /**
  52154. * The strenth of the vortex.
  52155. */
  52156. strength: number;
  52157. /**
  52158. * The height of the cylinder for the vortex.
  52159. */
  52160. height: number;
  52161. /**
  52162. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  52163. */
  52164. centripetalForceThreshold: number;
  52165. /**
  52166. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  52167. */
  52168. centripetalForceMultiplier: number;
  52169. /**
  52170. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  52171. */
  52172. centrifugalForceMultiplier: number;
  52173. /**
  52174. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  52175. */
  52176. updraftForceMultiplier: number;
  52177. }
  52178. /**
  52179. * The strenght of the force in correspondence to the distance of the affected object
  52180. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52181. */
  52182. export enum PhysicsRadialImpulseFalloff {
  52183. /** Defines that impulse is constant in strength across it's whole radius */
  52184. Constant = 0,
  52185. /** Defines that impulse gets weaker if it's further from the origin */
  52186. Linear = 1
  52187. }
  52188. /**
  52189. * The strength of the force in correspondence to the distance of the affected object
  52190. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52191. */
  52192. export enum PhysicsUpdraftMode {
  52193. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52194. Center = 0,
  52195. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52196. Perpendicular = 1
  52197. }
  52198. /**
  52199. * Interface for a physics hit data
  52200. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52201. */
  52202. export interface PhysicsHitData {
  52203. /**
  52204. * The force applied at the contact point
  52205. */
  52206. force: Vector3;
  52207. /**
  52208. * The contact point
  52209. */
  52210. contactPoint: Vector3;
  52211. /**
  52212. * The distance from the origin to the contact point
  52213. */
  52214. distanceFromOrigin: number;
  52215. }
  52216. /**
  52217. * Interface for radial explosion event data
  52218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52219. */
  52220. export interface PhysicsRadialExplosionEventData {
  52221. /**
  52222. * A sphere used for the radial explosion event
  52223. */
  52224. sphere: Mesh;
  52225. }
  52226. /**
  52227. * Interface for gravitational field event data
  52228. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52229. */
  52230. export interface PhysicsGravitationalFieldEventData {
  52231. /**
  52232. * A sphere mesh used for the gravitational field event
  52233. */
  52234. sphere: Mesh;
  52235. }
  52236. /**
  52237. * Interface for updraft event data
  52238. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52239. */
  52240. export interface PhysicsUpdraftEventData {
  52241. /**
  52242. * A cylinder used for the updraft event
  52243. */
  52244. cylinder: Mesh;
  52245. }
  52246. /**
  52247. * Interface for vortex event data
  52248. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52249. */
  52250. export interface PhysicsVortexEventData {
  52251. /**
  52252. * A cylinder used for the vortex event
  52253. */
  52254. cylinder: Mesh;
  52255. }
  52256. /**
  52257. * Interface for an affected physics impostor
  52258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52259. */
  52260. export interface PhysicsAffectedImpostorWithData {
  52261. /**
  52262. * The impostor affected by the effect
  52263. */
  52264. impostor: PhysicsImpostor;
  52265. /**
  52266. * The data about the hit/horce from the explosion
  52267. */
  52268. hitData: PhysicsHitData;
  52269. }
  52270. }
  52271. declare module BABYLON {
  52272. /** @hidden */
  52273. export var blackAndWhitePixelShader: {
  52274. name: string;
  52275. shader: string;
  52276. };
  52277. }
  52278. declare module BABYLON {
  52279. /**
  52280. * Post process used to render in black and white
  52281. */
  52282. export class BlackAndWhitePostProcess extends PostProcess {
  52283. /**
  52284. * Linear about to convert he result to black and white (default: 1)
  52285. */
  52286. degree: number;
  52287. /**
  52288. * Creates a black and white post process
  52289. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  52290. * @param name The name of the effect.
  52291. * @param options The required width/height ratio to downsize to before computing the render pass.
  52292. * @param camera The camera to apply the render pass to.
  52293. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52294. * @param engine The engine which the post process will be applied. (default: current engine)
  52295. * @param reusable If the post process can be reused on the same frame. (default: false)
  52296. */
  52297. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52298. }
  52299. }
  52300. declare module BABYLON {
  52301. /**
  52302. * This represents a set of one or more post processes in Babylon.
  52303. * A post process can be used to apply a shader to a texture after it is rendered.
  52304. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52305. */
  52306. export class PostProcessRenderEffect {
  52307. private _postProcesses;
  52308. private _getPostProcesses;
  52309. private _singleInstance;
  52310. private _cameras;
  52311. private _indicesForCamera;
  52312. /**
  52313. * Name of the effect
  52314. * @hidden
  52315. */
  52316. _name: string;
  52317. /**
  52318. * Instantiates a post process render effect.
  52319. * A post process can be used to apply a shader to a texture after it is rendered.
  52320. * @param engine The engine the effect is tied to
  52321. * @param name The name of the effect
  52322. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  52323. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  52324. */
  52325. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  52326. /**
  52327. * Checks if all the post processes in the effect are supported.
  52328. */
  52329. readonly isSupported: boolean;
  52330. /**
  52331. * Updates the current state of the effect
  52332. * @hidden
  52333. */
  52334. _update(): void;
  52335. /**
  52336. * Attaches the effect on cameras
  52337. * @param cameras The camera to attach to.
  52338. * @hidden
  52339. */
  52340. _attachCameras(cameras: Camera): void;
  52341. /**
  52342. * Attaches the effect on cameras
  52343. * @param cameras The camera to attach to.
  52344. * @hidden
  52345. */
  52346. _attachCameras(cameras: Camera[]): void;
  52347. /**
  52348. * Detaches the effect on cameras
  52349. * @param cameras The camera to detatch from.
  52350. * @hidden
  52351. */
  52352. _detachCameras(cameras: Camera): void;
  52353. /**
  52354. * Detatches the effect on cameras
  52355. * @param cameras The camera to detatch from.
  52356. * @hidden
  52357. */
  52358. _detachCameras(cameras: Camera[]): void;
  52359. /**
  52360. * Enables the effect on given cameras
  52361. * @param cameras The camera to enable.
  52362. * @hidden
  52363. */
  52364. _enable(cameras: Camera): void;
  52365. /**
  52366. * Enables the effect on given cameras
  52367. * @param cameras The camera to enable.
  52368. * @hidden
  52369. */
  52370. _enable(cameras: Nullable<Camera[]>): void;
  52371. /**
  52372. * Disables the effect on the given cameras
  52373. * @param cameras The camera to disable.
  52374. * @hidden
  52375. */
  52376. _disable(cameras: Camera): void;
  52377. /**
  52378. * Disables the effect on the given cameras
  52379. * @param cameras The camera to disable.
  52380. * @hidden
  52381. */
  52382. _disable(cameras: Nullable<Camera[]>): void;
  52383. /**
  52384. * Gets a list of the post processes contained in the effect.
  52385. * @param camera The camera to get the post processes on.
  52386. * @returns The list of the post processes in the effect.
  52387. */
  52388. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52389. }
  52390. }
  52391. declare module BABYLON {
  52392. /** @hidden */
  52393. export var extractHighlightsPixelShader: {
  52394. name: string;
  52395. shader: string;
  52396. };
  52397. }
  52398. declare module BABYLON {
  52399. /**
  52400. * 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.
  52401. */
  52402. export class ExtractHighlightsPostProcess extends PostProcess {
  52403. /**
  52404. * The luminance threshold, pixels below this value will be set to black.
  52405. */
  52406. threshold: number;
  52407. /** @hidden */
  52408. _exposure: number;
  52409. /**
  52410. * Post process which has the input texture to be used when performing highlight extraction
  52411. * @hidden
  52412. */
  52413. _inputPostProcess: Nullable<PostProcess>;
  52414. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52415. }
  52416. }
  52417. declare module BABYLON {
  52418. /** @hidden */
  52419. export var bloomMergePixelShader: {
  52420. name: string;
  52421. shader: string;
  52422. };
  52423. }
  52424. declare module BABYLON {
  52425. /**
  52426. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52427. */
  52428. export class BloomMergePostProcess extends PostProcess {
  52429. /** Weight of the bloom to be added to the original input. */
  52430. weight: number;
  52431. /**
  52432. * Creates a new instance of @see BloomMergePostProcess
  52433. * @param name The name of the effect.
  52434. * @param originalFromInput Post process which's input will be used for the merge.
  52435. * @param blurred Blurred highlights post process which's output will be used.
  52436. * @param weight Weight of the bloom to be added to the original input.
  52437. * @param options The required width/height ratio to downsize to before computing the render pass.
  52438. * @param camera The camera to apply the render pass to.
  52439. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52440. * @param engine The engine which the post process will be applied. (default: current engine)
  52441. * @param reusable If the post process can be reused on the same frame. (default: false)
  52442. * @param textureType Type of textures used when performing the post process. (default: 0)
  52443. * @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)
  52444. */
  52445. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52446. /** Weight of the bloom to be added to the original input. */
  52447. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52448. }
  52449. }
  52450. declare module BABYLON {
  52451. /**
  52452. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52453. */
  52454. export class BloomEffect extends PostProcessRenderEffect {
  52455. private bloomScale;
  52456. /**
  52457. * @hidden Internal
  52458. */
  52459. _effects: Array<PostProcess>;
  52460. /**
  52461. * @hidden Internal
  52462. */
  52463. _downscale: ExtractHighlightsPostProcess;
  52464. private _blurX;
  52465. private _blurY;
  52466. private _merge;
  52467. /**
  52468. * The luminance threshold to find bright areas of the image to bloom.
  52469. */
  52470. threshold: number;
  52471. /**
  52472. * The strength of the bloom.
  52473. */
  52474. weight: number;
  52475. /**
  52476. * Specifies the size of the bloom blur kernel, relative to the final output size
  52477. */
  52478. kernel: number;
  52479. /**
  52480. * Creates a new instance of @see BloomEffect
  52481. * @param scene The scene the effect belongs to.
  52482. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52483. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52484. * @param bloomWeight The the strength of bloom.
  52485. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52486. * @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)
  52487. */
  52488. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52489. /**
  52490. * Disposes each of the internal effects for a given camera.
  52491. * @param camera The camera to dispose the effect on.
  52492. */
  52493. disposeEffects(camera: Camera): void;
  52494. /**
  52495. * @hidden Internal
  52496. */
  52497. _updateEffects(): void;
  52498. /**
  52499. * Internal
  52500. * @returns if all the contained post processes are ready.
  52501. * @hidden
  52502. */
  52503. _isReady(): boolean;
  52504. }
  52505. }
  52506. declare module BABYLON {
  52507. /** @hidden */
  52508. export var chromaticAberrationPixelShader: {
  52509. name: string;
  52510. shader: string;
  52511. };
  52512. }
  52513. declare module BABYLON {
  52514. /**
  52515. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52516. */
  52517. export class ChromaticAberrationPostProcess extends PostProcess {
  52518. /**
  52519. * The amount of seperation of rgb channels (default: 30)
  52520. */
  52521. aberrationAmount: number;
  52522. /**
  52523. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52524. */
  52525. radialIntensity: number;
  52526. /**
  52527. * 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))
  52528. */
  52529. direction: Vector2;
  52530. /**
  52531. * 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))
  52532. */
  52533. centerPosition: Vector2;
  52534. /**
  52535. * Creates a new instance ChromaticAberrationPostProcess
  52536. * @param name The name of the effect.
  52537. * @param screenWidth The width of the screen to apply the effect on.
  52538. * @param screenHeight The height of the screen to apply the effect on.
  52539. * @param options The required width/height ratio to downsize to before computing the render pass.
  52540. * @param camera The camera to apply the render pass to.
  52541. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52542. * @param engine The engine which the post process will be applied. (default: current engine)
  52543. * @param reusable If the post process can be reused on the same frame. (default: false)
  52544. * @param textureType Type of textures used when performing the post process. (default: 0)
  52545. * @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)
  52546. */
  52547. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52548. }
  52549. }
  52550. declare module BABYLON {
  52551. /** @hidden */
  52552. export var circleOfConfusionPixelShader: {
  52553. name: string;
  52554. shader: string;
  52555. };
  52556. }
  52557. declare module BABYLON {
  52558. /**
  52559. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  52560. */
  52561. export class CircleOfConfusionPostProcess extends PostProcess {
  52562. /**
  52563. * 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.
  52564. */
  52565. lensSize: number;
  52566. /**
  52567. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52568. */
  52569. fStop: number;
  52570. /**
  52571. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52572. */
  52573. focusDistance: number;
  52574. /**
  52575. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  52576. */
  52577. focalLength: number;
  52578. private _depthTexture;
  52579. /**
  52580. * Creates a new instance CircleOfConfusionPostProcess
  52581. * @param name The name of the effect.
  52582. * @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.
  52583. * @param options The required width/height ratio to downsize to before computing the render pass.
  52584. * @param camera The camera to apply the render pass to.
  52585. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52586. * @param engine The engine which the post process will be applied. (default: current engine)
  52587. * @param reusable If the post process can be reused on the same frame. (default: false)
  52588. * @param textureType Type of textures used when performing the post process. (default: 0)
  52589. * @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)
  52590. */
  52591. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52592. /**
  52593. * 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.
  52594. */
  52595. depthTexture: RenderTargetTexture;
  52596. }
  52597. }
  52598. declare module BABYLON {
  52599. /** @hidden */
  52600. export var colorCorrectionPixelShader: {
  52601. name: string;
  52602. shader: string;
  52603. };
  52604. }
  52605. declare module BABYLON {
  52606. /**
  52607. *
  52608. * This post-process allows the modification of rendered colors by using
  52609. * a 'look-up table' (LUT). This effect is also called Color Grading.
  52610. *
  52611. * The object needs to be provided an url to a texture containing the color
  52612. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  52613. * Use an image editing software to tweak the LUT to match your needs.
  52614. *
  52615. * For an example of a color LUT, see here:
  52616. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  52617. * For explanations on color grading, see here:
  52618. * @see http://udn.epicgames.com/Three/ColorGrading.html
  52619. *
  52620. */
  52621. export class ColorCorrectionPostProcess extends PostProcess {
  52622. private _colorTableTexture;
  52623. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52624. }
  52625. }
  52626. declare module BABYLON {
  52627. /** @hidden */
  52628. export var convolutionPixelShader: {
  52629. name: string;
  52630. shader: string;
  52631. };
  52632. }
  52633. declare module BABYLON {
  52634. /**
  52635. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  52636. * input texture to perform effects such as edge detection or sharpening
  52637. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52638. */
  52639. export class ConvolutionPostProcess extends PostProcess {
  52640. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52641. kernel: number[];
  52642. /**
  52643. * Creates a new instance ConvolutionPostProcess
  52644. * @param name The name of the effect.
  52645. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  52646. * @param options The required width/height ratio to downsize to before computing the render pass.
  52647. * @param camera The camera to apply the render pass to.
  52648. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52649. * @param engine The engine which the post process will be applied. (default: current engine)
  52650. * @param reusable If the post process can be reused on the same frame. (default: false)
  52651. * @param textureType Type of textures used when performing the post process. (default: 0)
  52652. */
  52653. constructor(name: string,
  52654. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52655. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52656. /**
  52657. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52658. */
  52659. static EdgeDetect0Kernel: number[];
  52660. /**
  52661. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52662. */
  52663. static EdgeDetect1Kernel: number[];
  52664. /**
  52665. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52666. */
  52667. static EdgeDetect2Kernel: number[];
  52668. /**
  52669. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52670. */
  52671. static SharpenKernel: number[];
  52672. /**
  52673. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52674. */
  52675. static EmbossKernel: number[];
  52676. /**
  52677. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52678. */
  52679. static GaussianKernel: number[];
  52680. }
  52681. }
  52682. declare module BABYLON {
  52683. /**
  52684. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  52685. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  52686. * based on samples that have a large difference in distance than the center pixel.
  52687. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  52688. */
  52689. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  52690. direction: Vector2;
  52691. /**
  52692. * Creates a new instance CircleOfConfusionPostProcess
  52693. * @param name The name of the effect.
  52694. * @param scene The scene the effect belongs to.
  52695. * @param direction The direction the blur should be applied.
  52696. * @param kernel The size of the kernel used to blur.
  52697. * @param options The required width/height ratio to downsize to before computing the render pass.
  52698. * @param camera The camera to apply the render pass to.
  52699. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  52700. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  52701. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52702. * @param engine The engine which the post process will be applied. (default: current engine)
  52703. * @param reusable If the post process can be reused on the same frame. (default: false)
  52704. * @param textureType Type of textures used when performing the post process. (default: 0)
  52705. * @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)
  52706. */
  52707. 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);
  52708. }
  52709. }
  52710. declare module BABYLON {
  52711. /** @hidden */
  52712. export var depthOfFieldMergePixelShader: {
  52713. name: string;
  52714. shader: string;
  52715. };
  52716. }
  52717. declare module BABYLON {
  52718. /**
  52719. * Options to be set when merging outputs from the default pipeline.
  52720. */
  52721. export class DepthOfFieldMergePostProcessOptions {
  52722. /**
  52723. * The original image to merge on top of
  52724. */
  52725. originalFromInput: PostProcess;
  52726. /**
  52727. * Parameters to perform the merge of the depth of field effect
  52728. */
  52729. depthOfField?: {
  52730. circleOfConfusion: PostProcess;
  52731. blurSteps: Array<PostProcess>;
  52732. };
  52733. /**
  52734. * Parameters to perform the merge of bloom effect
  52735. */
  52736. bloom?: {
  52737. blurred: PostProcess;
  52738. weight: number;
  52739. };
  52740. }
  52741. /**
  52742. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52743. */
  52744. export class DepthOfFieldMergePostProcess extends PostProcess {
  52745. private blurSteps;
  52746. /**
  52747. * Creates a new instance of DepthOfFieldMergePostProcess
  52748. * @param name The name of the effect.
  52749. * @param originalFromInput Post process which's input will be used for the merge.
  52750. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  52751. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  52752. * @param options The required width/height ratio to downsize to before computing the render pass.
  52753. * @param camera The camera to apply the render pass to.
  52754. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52755. * @param engine The engine which the post process will be applied. (default: current engine)
  52756. * @param reusable If the post process can be reused on the same frame. (default: false)
  52757. * @param textureType Type of textures used when performing the post process. (default: 0)
  52758. * @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)
  52759. */
  52760. 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);
  52761. /**
  52762. * Updates the effect with the current post process compile time values and recompiles the shader.
  52763. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  52764. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  52765. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  52766. * @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
  52767. * @param onCompiled Called when the shader has been compiled.
  52768. * @param onError Called if there is an error when compiling a shader.
  52769. */
  52770. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  52771. }
  52772. }
  52773. declare module BABYLON {
  52774. /**
  52775. * Specifies the level of max blur that should be applied when using the depth of field effect
  52776. */
  52777. export enum DepthOfFieldEffectBlurLevel {
  52778. /**
  52779. * Subtle blur
  52780. */
  52781. Low = 0,
  52782. /**
  52783. * Medium blur
  52784. */
  52785. Medium = 1,
  52786. /**
  52787. * Large blur
  52788. */
  52789. High = 2
  52790. }
  52791. /**
  52792. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52793. */
  52794. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52795. private _circleOfConfusion;
  52796. /**
  52797. * @hidden Internal, blurs from high to low
  52798. */
  52799. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52800. private _depthOfFieldBlurY;
  52801. private _dofMerge;
  52802. /**
  52803. * @hidden Internal post processes in depth of field effect
  52804. */
  52805. _effects: Array<PostProcess>;
  52806. /**
  52807. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52808. */
  52809. focalLength: number;
  52810. /**
  52811. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52812. */
  52813. fStop: number;
  52814. /**
  52815. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52816. */
  52817. focusDistance: number;
  52818. /**
  52819. * 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.
  52820. */
  52821. lensSize: number;
  52822. /**
  52823. * Creates a new instance DepthOfFieldEffect
  52824. * @param scene The scene the effect belongs to.
  52825. * @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.
  52826. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52827. * @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)
  52828. */
  52829. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52830. /**
  52831. * Get the current class name of the current effet
  52832. * @returns "DepthOfFieldEffect"
  52833. */
  52834. getClassName(): string;
  52835. /**
  52836. * 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.
  52837. */
  52838. depthTexture: RenderTargetTexture;
  52839. /**
  52840. * Disposes each of the internal effects for a given camera.
  52841. * @param camera The camera to dispose the effect on.
  52842. */
  52843. disposeEffects(camera: Camera): void;
  52844. /**
  52845. * @hidden Internal
  52846. */
  52847. _updateEffects(): void;
  52848. /**
  52849. * Internal
  52850. * @returns if all the contained post processes are ready.
  52851. * @hidden
  52852. */
  52853. _isReady(): boolean;
  52854. }
  52855. }
  52856. declare module BABYLON {
  52857. /** @hidden */
  52858. export var displayPassPixelShader: {
  52859. name: string;
  52860. shader: string;
  52861. };
  52862. }
  52863. declare module BABYLON {
  52864. /**
  52865. * DisplayPassPostProcess which produces an output the same as it's input
  52866. */
  52867. export class DisplayPassPostProcess extends PostProcess {
  52868. /**
  52869. * Creates the DisplayPassPostProcess
  52870. * @param name The name of the effect.
  52871. * @param options The required width/height ratio to downsize to before computing the render pass.
  52872. * @param camera The camera to apply the render pass to.
  52873. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52874. * @param engine The engine which the post process will be applied. (default: current engine)
  52875. * @param reusable If the post process can be reused on the same frame. (default: false)
  52876. */
  52877. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52878. }
  52879. }
  52880. declare module BABYLON {
  52881. /** @hidden */
  52882. export var filterPixelShader: {
  52883. name: string;
  52884. shader: string;
  52885. };
  52886. }
  52887. declare module BABYLON {
  52888. /**
  52889. * Applies a kernel filter to the image
  52890. */
  52891. export class FilterPostProcess extends PostProcess {
  52892. /** The matrix to be applied to the image */
  52893. kernelMatrix: Matrix;
  52894. /**
  52895. *
  52896. * @param name The name of the effect.
  52897. * @param kernelMatrix The matrix to be applied to the image
  52898. * @param options The required width/height ratio to downsize to before computing the render pass.
  52899. * @param camera The camera to apply the render pass to.
  52900. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52901. * @param engine The engine which the post process will be applied. (default: current engine)
  52902. * @param reusable If the post process can be reused on the same frame. (default: false)
  52903. */
  52904. constructor(name: string,
  52905. /** The matrix to be applied to the image */
  52906. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52907. }
  52908. }
  52909. declare module BABYLON {
  52910. /** @hidden */
  52911. export var fxaaPixelShader: {
  52912. name: string;
  52913. shader: string;
  52914. };
  52915. }
  52916. declare module BABYLON {
  52917. /** @hidden */
  52918. export var fxaaVertexShader: {
  52919. name: string;
  52920. shader: string;
  52921. };
  52922. }
  52923. declare module BABYLON {
  52924. /**
  52925. * Fxaa post process
  52926. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52927. */
  52928. export class FxaaPostProcess extends PostProcess {
  52929. /** @hidden */
  52930. texelWidth: number;
  52931. /** @hidden */
  52932. texelHeight: number;
  52933. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52934. private _getDefines;
  52935. }
  52936. }
  52937. declare module BABYLON {
  52938. /** @hidden */
  52939. export var grainPixelShader: {
  52940. name: string;
  52941. shader: string;
  52942. };
  52943. }
  52944. declare module BABYLON {
  52945. /**
  52946. * The GrainPostProcess adds noise to the image at mid luminance levels
  52947. */
  52948. export class GrainPostProcess extends PostProcess {
  52949. /**
  52950. * The intensity of the grain added (default: 30)
  52951. */
  52952. intensity: number;
  52953. /**
  52954. * If the grain should be randomized on every frame
  52955. */
  52956. animated: boolean;
  52957. /**
  52958. * Creates a new instance of @see GrainPostProcess
  52959. * @param name The name of the effect.
  52960. * @param options The required width/height ratio to downsize to before computing the render pass.
  52961. * @param camera The camera to apply the render pass to.
  52962. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52963. * @param engine The engine which the post process will be applied. (default: current engine)
  52964. * @param reusable If the post process can be reused on the same frame. (default: false)
  52965. * @param textureType Type of textures used when performing the post process. (default: 0)
  52966. * @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)
  52967. */
  52968. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52969. }
  52970. }
  52971. declare module BABYLON {
  52972. /** @hidden */
  52973. export var highlightsPixelShader: {
  52974. name: string;
  52975. shader: string;
  52976. };
  52977. }
  52978. declare module BABYLON {
  52979. /**
  52980. * Extracts highlights from the image
  52981. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52982. */
  52983. export class HighlightsPostProcess extends PostProcess {
  52984. /**
  52985. * Extracts highlights from the image
  52986. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52987. * @param name The name of the effect.
  52988. * @param options The required width/height ratio to downsize to before computing the render pass.
  52989. * @param camera The camera to apply the render pass to.
  52990. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52991. * @param engine The engine which the post process will be applied. (default: current engine)
  52992. * @param reusable If the post process can be reused on the same frame. (default: false)
  52993. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  52994. */
  52995. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52996. }
  52997. }
  52998. declare module BABYLON {
  52999. /** @hidden */
  53000. export var mrtFragmentDeclaration: {
  53001. name: string;
  53002. shader: string;
  53003. };
  53004. }
  53005. declare module BABYLON {
  53006. /** @hidden */
  53007. export var geometryPixelShader: {
  53008. name: string;
  53009. shader: string;
  53010. };
  53011. }
  53012. declare module BABYLON {
  53013. /** @hidden */
  53014. export var geometryVertexShader: {
  53015. name: string;
  53016. shader: string;
  53017. };
  53018. }
  53019. declare module BABYLON {
  53020. /**
  53021. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  53022. */
  53023. export class GeometryBufferRenderer {
  53024. /**
  53025. * Constant used to retrieve the position texture index in the G-Buffer textures array
  53026. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  53027. */
  53028. static readonly POSITION_TEXTURE_TYPE: number;
  53029. /**
  53030. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  53031. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  53032. */
  53033. static readonly VELOCITY_TEXTURE_TYPE: number;
  53034. /**
  53035. * Dictionary used to store the previous transformation matrices of each rendered mesh
  53036. * in order to compute objects velocities when enableVelocity is set to "true"
  53037. * @hidden
  53038. */
  53039. _previousTransformationMatrices: {
  53040. [index: number]: Matrix;
  53041. };
  53042. private _scene;
  53043. private _multiRenderTarget;
  53044. private _ratio;
  53045. private _enablePosition;
  53046. private _enableVelocity;
  53047. private _positionIndex;
  53048. private _velocityIndex;
  53049. protected _effect: Effect;
  53050. protected _cachedDefines: string;
  53051. /**
  53052. * Set the render list (meshes to be rendered) used in the G buffer.
  53053. */
  53054. renderList: Mesh[];
  53055. /**
  53056. * Gets wether or not G buffer are supported by the running hardware.
  53057. * This requires draw buffer supports
  53058. */
  53059. readonly isSupported: boolean;
  53060. /**
  53061. * Returns the index of the given texture type in the G-Buffer textures array
  53062. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  53063. * @returns the index of the given texture type in the G-Buffer textures array
  53064. */
  53065. getTextureIndex(textureType: number): number;
  53066. /**
  53067. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  53068. */
  53069. /**
  53070. * Sets whether or not objects positions are enabled for the G buffer.
  53071. */
  53072. enablePosition: boolean;
  53073. /**
  53074. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  53075. */
  53076. /**
  53077. * Sets wether or not objects velocities are enabled for the G buffer.
  53078. */
  53079. enableVelocity: boolean;
  53080. /**
  53081. * Gets the scene associated with the buffer.
  53082. */
  53083. readonly scene: Scene;
  53084. /**
  53085. * Gets the ratio used by the buffer during its creation.
  53086. * How big is the buffer related to the main canvas.
  53087. */
  53088. readonly ratio: number;
  53089. /** @hidden */
  53090. static _SceneComponentInitialization: (scene: Scene) => void;
  53091. /**
  53092. * Creates a new G Buffer for the scene
  53093. * @param scene The scene the buffer belongs to
  53094. * @param ratio How big is the buffer related to the main canvas.
  53095. */
  53096. constructor(scene: Scene, ratio?: number);
  53097. /**
  53098. * Checks wether everything is ready to render a submesh to the G buffer.
  53099. * @param subMesh the submesh to check readiness for
  53100. * @param useInstances is the mesh drawn using instance or not
  53101. * @returns true if ready otherwise false
  53102. */
  53103. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53104. /**
  53105. * Gets the current underlying G Buffer.
  53106. * @returns the buffer
  53107. */
  53108. getGBuffer(): MultiRenderTarget;
  53109. /**
  53110. * Gets the number of samples used to render the buffer (anti aliasing).
  53111. */
  53112. /**
  53113. * Sets the number of samples used to render the buffer (anti aliasing).
  53114. */
  53115. samples: number;
  53116. /**
  53117. * Disposes the renderer and frees up associated resources.
  53118. */
  53119. dispose(): void;
  53120. protected _createRenderTargets(): void;
  53121. }
  53122. }
  53123. declare module BABYLON {
  53124. interface Scene {
  53125. /** @hidden (Backing field) */
  53126. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53127. /**
  53128. * Gets or Sets the current geometry buffer associated to the scene.
  53129. */
  53130. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53131. /**
  53132. * Enables a GeometryBufferRender and associates it with the scene
  53133. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  53134. * @returns the GeometryBufferRenderer
  53135. */
  53136. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  53137. /**
  53138. * Disables the GeometryBufferRender associated with the scene
  53139. */
  53140. disableGeometryBufferRenderer(): void;
  53141. }
  53142. /**
  53143. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  53144. * in several rendering techniques.
  53145. */
  53146. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  53147. /**
  53148. * The component name helpful to identify the component in the list of scene components.
  53149. */
  53150. readonly name: string;
  53151. /**
  53152. * The scene the component belongs to.
  53153. */
  53154. scene: Scene;
  53155. /**
  53156. * Creates a new instance of the component for the given scene
  53157. * @param scene Defines the scene to register the component in
  53158. */
  53159. constructor(scene: Scene);
  53160. /**
  53161. * Registers the component in a given scene
  53162. */
  53163. register(): void;
  53164. /**
  53165. * Rebuilds the elements related to this component in case of
  53166. * context lost for instance.
  53167. */
  53168. rebuild(): void;
  53169. /**
  53170. * Disposes the component and the associated ressources
  53171. */
  53172. dispose(): void;
  53173. private _gatherRenderTargets;
  53174. }
  53175. }
  53176. declare module BABYLON {
  53177. /** @hidden */
  53178. export var motionBlurPixelShader: {
  53179. name: string;
  53180. shader: string;
  53181. };
  53182. }
  53183. declare module BABYLON {
  53184. /**
  53185. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  53186. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  53187. * As an example, all you have to do is to create the post-process:
  53188. * var mb = new BABYLON.MotionBlurPostProcess(
  53189. * 'mb', // The name of the effect.
  53190. * scene, // The scene containing the objects to blur according to their velocity.
  53191. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  53192. * camera // The camera to apply the render pass to.
  53193. * );
  53194. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  53195. */
  53196. export class MotionBlurPostProcess extends PostProcess {
  53197. /**
  53198. * Defines how much the image is blurred by the movement. Default value is equal to 1
  53199. */
  53200. motionStrength: number;
  53201. /**
  53202. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  53203. */
  53204. /**
  53205. * Sets the number of iterations to be used for motion blur quality
  53206. */
  53207. motionBlurSamples: number;
  53208. private _motionBlurSamples;
  53209. private _geometryBufferRenderer;
  53210. /**
  53211. * Creates a new instance MotionBlurPostProcess
  53212. * @param name The name of the effect.
  53213. * @param scene The scene containing the objects to blur according to their velocity.
  53214. * @param options The required width/height ratio to downsize to before computing the render pass.
  53215. * @param camera The camera to apply the render pass to.
  53216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53217. * @param engine The engine which the post process will be applied. (default: current engine)
  53218. * @param reusable If the post process can be reused on the same frame. (default: false)
  53219. * @param textureType Type of textures used when performing the post process. (default: 0)
  53220. * @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)
  53221. */
  53222. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53223. /**
  53224. * Disposes the post process.
  53225. * @param camera The camera to dispose the post process on.
  53226. */
  53227. dispose(camera?: Camera): void;
  53228. }
  53229. }
  53230. declare module BABYLON {
  53231. /** @hidden */
  53232. export var refractionPixelShader: {
  53233. name: string;
  53234. shader: string;
  53235. };
  53236. }
  53237. declare module BABYLON {
  53238. /**
  53239. * Post process which applies a refractin texture
  53240. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53241. */
  53242. export class RefractionPostProcess extends PostProcess {
  53243. /** the base color of the refraction (used to taint the rendering) */
  53244. color: Color3;
  53245. /** simulated refraction depth */
  53246. depth: number;
  53247. /** the coefficient of the base color (0 to remove base color tainting) */
  53248. colorLevel: number;
  53249. private _refTexture;
  53250. private _ownRefractionTexture;
  53251. /**
  53252. * Gets or sets the refraction texture
  53253. * Please note that you are responsible for disposing the texture if you set it manually
  53254. */
  53255. refractionTexture: Texture;
  53256. /**
  53257. * Initializes the RefractionPostProcess
  53258. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53259. * @param name The name of the effect.
  53260. * @param refractionTextureUrl Url of the refraction texture to use
  53261. * @param color the base color of the refraction (used to taint the rendering)
  53262. * @param depth simulated refraction depth
  53263. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  53264. * @param camera The camera to apply the render pass to.
  53265. * @param options The required width/height ratio to downsize to before computing the render pass.
  53266. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53267. * @param engine The engine which the post process will be applied. (default: current engine)
  53268. * @param reusable If the post process can be reused on the same frame. (default: false)
  53269. */
  53270. constructor(name: string, refractionTextureUrl: string,
  53271. /** the base color of the refraction (used to taint the rendering) */
  53272. color: Color3,
  53273. /** simulated refraction depth */
  53274. depth: number,
  53275. /** the coefficient of the base color (0 to remove base color tainting) */
  53276. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53277. /**
  53278. * Disposes of the post process
  53279. * @param camera Camera to dispose post process on
  53280. */
  53281. dispose(camera: Camera): void;
  53282. }
  53283. }
  53284. declare module BABYLON {
  53285. /** @hidden */
  53286. export var sharpenPixelShader: {
  53287. name: string;
  53288. shader: string;
  53289. };
  53290. }
  53291. declare module BABYLON {
  53292. /**
  53293. * The SharpenPostProcess applies a sharpen kernel to every pixel
  53294. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53295. */
  53296. export class SharpenPostProcess extends PostProcess {
  53297. /**
  53298. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  53299. */
  53300. colorAmount: number;
  53301. /**
  53302. * How much sharpness should be applied (default: 0.3)
  53303. */
  53304. edgeAmount: number;
  53305. /**
  53306. * Creates a new instance ConvolutionPostProcess
  53307. * @param name The name of the effect.
  53308. * @param options The required width/height ratio to downsize to before computing the render pass.
  53309. * @param camera The camera to apply the render pass to.
  53310. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53311. * @param engine The engine which the post process will be applied. (default: current engine)
  53312. * @param reusable If the post process can be reused on the same frame. (default: false)
  53313. * @param textureType Type of textures used when performing the post process. (default: 0)
  53314. * @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)
  53315. */
  53316. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53317. }
  53318. }
  53319. declare module BABYLON {
  53320. /**
  53321. * PostProcessRenderPipeline
  53322. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53323. */
  53324. export class PostProcessRenderPipeline {
  53325. private engine;
  53326. private _renderEffects;
  53327. private _renderEffectsForIsolatedPass;
  53328. /**
  53329. * List of inspectable custom properties (used by the Inspector)
  53330. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  53331. */
  53332. inspectableCustomProperties: IInspectable[];
  53333. /**
  53334. * @hidden
  53335. */
  53336. protected _cameras: Camera[];
  53337. /** @hidden */
  53338. _name: string;
  53339. /**
  53340. * Gets pipeline name
  53341. */
  53342. readonly name: string;
  53343. /**
  53344. * Initializes a PostProcessRenderPipeline
  53345. * @param engine engine to add the pipeline to
  53346. * @param name name of the pipeline
  53347. */
  53348. constructor(engine: Engine, name: string);
  53349. /**
  53350. * Gets the class name
  53351. * @returns "PostProcessRenderPipeline"
  53352. */
  53353. getClassName(): string;
  53354. /**
  53355. * If all the render effects in the pipeline are supported
  53356. */
  53357. readonly isSupported: boolean;
  53358. /**
  53359. * Adds an effect to the pipeline
  53360. * @param renderEffect the effect to add
  53361. */
  53362. addEffect(renderEffect: PostProcessRenderEffect): void;
  53363. /** @hidden */
  53364. _rebuild(): void;
  53365. /** @hidden */
  53366. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53367. /** @hidden */
  53368. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53369. /** @hidden */
  53370. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53371. /** @hidden */
  53372. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53373. /** @hidden */
  53374. _attachCameras(cameras: Camera, unique: boolean): void;
  53375. /** @hidden */
  53376. _attachCameras(cameras: Camera[], unique: boolean): void;
  53377. /** @hidden */
  53378. _detachCameras(cameras: Camera): void;
  53379. /** @hidden */
  53380. _detachCameras(cameras: Nullable<Camera[]>): void;
  53381. /** @hidden */
  53382. _update(): void;
  53383. /** @hidden */
  53384. _reset(): void;
  53385. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53386. /**
  53387. * Disposes of the pipeline
  53388. */
  53389. dispose(): void;
  53390. }
  53391. }
  53392. declare module BABYLON {
  53393. /**
  53394. * PostProcessRenderPipelineManager class
  53395. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53396. */
  53397. export class PostProcessRenderPipelineManager {
  53398. private _renderPipelines;
  53399. /**
  53400. * Initializes a PostProcessRenderPipelineManager
  53401. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53402. */
  53403. constructor();
  53404. /**
  53405. * Gets the list of supported render pipelines
  53406. */
  53407. readonly supportedPipelines: PostProcessRenderPipeline[];
  53408. /**
  53409. * Adds a pipeline to the manager
  53410. * @param renderPipeline The pipeline to add
  53411. */
  53412. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53413. /**
  53414. * Attaches a camera to the pipeline
  53415. * @param renderPipelineName The name of the pipeline to attach to
  53416. * @param cameras the camera to attach
  53417. * @param unique if the camera can be attached multiple times to the pipeline
  53418. */
  53419. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53420. /**
  53421. * Detaches a camera from the pipeline
  53422. * @param renderPipelineName The name of the pipeline to detach from
  53423. * @param cameras the camera to detach
  53424. */
  53425. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53426. /**
  53427. * Enables an effect by name on a pipeline
  53428. * @param renderPipelineName the name of the pipeline to enable the effect in
  53429. * @param renderEffectName the name of the effect to enable
  53430. * @param cameras the cameras that the effect should be enabled on
  53431. */
  53432. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53433. /**
  53434. * Disables an effect by name on a pipeline
  53435. * @param renderPipelineName the name of the pipeline to disable the effect in
  53436. * @param renderEffectName the name of the effect to disable
  53437. * @param cameras the cameras that the effect should be disabled on
  53438. */
  53439. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53440. /**
  53441. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53442. */
  53443. update(): void;
  53444. /** @hidden */
  53445. _rebuild(): void;
  53446. /**
  53447. * Disposes of the manager and pipelines
  53448. */
  53449. dispose(): void;
  53450. }
  53451. }
  53452. declare module BABYLON {
  53453. interface Scene {
  53454. /** @hidden (Backing field) */
  53455. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53456. /**
  53457. * Gets the postprocess render pipeline manager
  53458. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53459. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53460. */
  53461. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53462. }
  53463. /**
  53464. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53465. */
  53466. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53467. /**
  53468. * The component name helpfull to identify the component in the list of scene components.
  53469. */
  53470. readonly name: string;
  53471. /**
  53472. * The scene the component belongs to.
  53473. */
  53474. scene: Scene;
  53475. /**
  53476. * Creates a new instance of the component for the given scene
  53477. * @param scene Defines the scene to register the component in
  53478. */
  53479. constructor(scene: Scene);
  53480. /**
  53481. * Registers the component in a given scene
  53482. */
  53483. register(): void;
  53484. /**
  53485. * Rebuilds the elements related to this component in case of
  53486. * context lost for instance.
  53487. */
  53488. rebuild(): void;
  53489. /**
  53490. * Disposes the component and the associated ressources
  53491. */
  53492. dispose(): void;
  53493. private _gatherRenderTargets;
  53494. }
  53495. }
  53496. declare module BABYLON {
  53497. /**
  53498. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  53499. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53500. */
  53501. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53502. private _scene;
  53503. private _camerasToBeAttached;
  53504. /**
  53505. * ID of the sharpen post process,
  53506. */
  53507. private readonly SharpenPostProcessId;
  53508. /**
  53509. * @ignore
  53510. * ID of the image processing post process;
  53511. */
  53512. readonly ImageProcessingPostProcessId: string;
  53513. /**
  53514. * @ignore
  53515. * ID of the Fast Approximate Anti-Aliasing post process;
  53516. */
  53517. readonly FxaaPostProcessId: string;
  53518. /**
  53519. * ID of the chromatic aberration post process,
  53520. */
  53521. private readonly ChromaticAberrationPostProcessId;
  53522. /**
  53523. * ID of the grain post process
  53524. */
  53525. private readonly GrainPostProcessId;
  53526. /**
  53527. * Sharpen post process which will apply a sharpen convolution to enhance edges
  53528. */
  53529. sharpen: SharpenPostProcess;
  53530. private _sharpenEffect;
  53531. private bloom;
  53532. /**
  53533. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  53534. */
  53535. depthOfField: DepthOfFieldEffect;
  53536. /**
  53537. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53538. */
  53539. fxaa: FxaaPostProcess;
  53540. /**
  53541. * Image post processing pass used to perform operations such as tone mapping or color grading.
  53542. */
  53543. imageProcessing: ImageProcessingPostProcess;
  53544. /**
  53545. * Chromatic aberration post process which will shift rgb colors in the image
  53546. */
  53547. chromaticAberration: ChromaticAberrationPostProcess;
  53548. private _chromaticAberrationEffect;
  53549. /**
  53550. * Grain post process which add noise to the image
  53551. */
  53552. grain: GrainPostProcess;
  53553. private _grainEffect;
  53554. /**
  53555. * Glow post process which adds a glow to emissive areas of the image
  53556. */
  53557. private _glowLayer;
  53558. /**
  53559. * Animations which can be used to tweak settings over a period of time
  53560. */
  53561. animations: Animation[];
  53562. private _imageProcessingConfigurationObserver;
  53563. private _sharpenEnabled;
  53564. private _bloomEnabled;
  53565. private _depthOfFieldEnabled;
  53566. private _depthOfFieldBlurLevel;
  53567. private _fxaaEnabled;
  53568. private _imageProcessingEnabled;
  53569. private _defaultPipelineTextureType;
  53570. private _bloomScale;
  53571. private _chromaticAberrationEnabled;
  53572. private _grainEnabled;
  53573. private _buildAllowed;
  53574. /**
  53575. * Gets active scene
  53576. */
  53577. readonly scene: Scene;
  53578. /**
  53579. * Enable or disable the sharpen process from the pipeline
  53580. */
  53581. sharpenEnabled: boolean;
  53582. private _resizeObserver;
  53583. private _hardwareScaleLevel;
  53584. private _bloomKernel;
  53585. /**
  53586. * Specifies the size of the bloom blur kernel, relative to the final output size
  53587. */
  53588. bloomKernel: number;
  53589. /**
  53590. * Specifies the weight of the bloom in the final rendering
  53591. */
  53592. private _bloomWeight;
  53593. /**
  53594. * Specifies the luma threshold for the area that will be blurred by the bloom
  53595. */
  53596. private _bloomThreshold;
  53597. private _hdr;
  53598. /**
  53599. * The strength of the bloom.
  53600. */
  53601. bloomWeight: number;
  53602. /**
  53603. * The strength of the bloom.
  53604. */
  53605. bloomThreshold: number;
  53606. /**
  53607. * The scale of the bloom, lower value will provide better performance.
  53608. */
  53609. bloomScale: number;
  53610. /**
  53611. * Enable or disable the bloom from the pipeline
  53612. */
  53613. bloomEnabled: boolean;
  53614. private _rebuildBloom;
  53615. /**
  53616. * If the depth of field is enabled.
  53617. */
  53618. depthOfFieldEnabled: boolean;
  53619. /**
  53620. * Blur level of the depth of field effect. (Higher blur will effect performance)
  53621. */
  53622. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  53623. /**
  53624. * If the anti aliasing is enabled.
  53625. */
  53626. fxaaEnabled: boolean;
  53627. private _samples;
  53628. /**
  53629. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53630. */
  53631. samples: number;
  53632. /**
  53633. * If image processing is enabled.
  53634. */
  53635. imageProcessingEnabled: boolean;
  53636. /**
  53637. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  53638. */
  53639. glowLayerEnabled: boolean;
  53640. /**
  53641. * Gets the glow layer (or null if not defined)
  53642. */
  53643. readonly glowLayer: Nullable<GlowLayer>;
  53644. /**
  53645. * Enable or disable the chromaticAberration process from the pipeline
  53646. */
  53647. chromaticAberrationEnabled: boolean;
  53648. /**
  53649. * Enable or disable the grain process from the pipeline
  53650. */
  53651. grainEnabled: boolean;
  53652. /**
  53653. * @constructor
  53654. * @param name - The rendering pipeline name (default: "")
  53655. * @param hdr - If high dynamic range textures should be used (default: true)
  53656. * @param scene - The scene linked to this pipeline (default: the last created scene)
  53657. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  53658. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  53659. */
  53660. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  53661. /**
  53662. * Get the class name
  53663. * @returns "DefaultRenderingPipeline"
  53664. */
  53665. getClassName(): string;
  53666. /**
  53667. * Force the compilation of the entire pipeline.
  53668. */
  53669. prepare(): void;
  53670. private _hasCleared;
  53671. private _prevPostProcess;
  53672. private _prevPrevPostProcess;
  53673. private _setAutoClearAndTextureSharing;
  53674. private _depthOfFieldSceneObserver;
  53675. private _buildPipeline;
  53676. private _disposePostProcesses;
  53677. /**
  53678. * Adds a camera to the pipeline
  53679. * @param camera the camera to be added
  53680. */
  53681. addCamera(camera: Camera): void;
  53682. /**
  53683. * Removes a camera from the pipeline
  53684. * @param camera the camera to remove
  53685. */
  53686. removeCamera(camera: Camera): void;
  53687. /**
  53688. * Dispose of the pipeline and stop all post processes
  53689. */
  53690. dispose(): void;
  53691. /**
  53692. * Serialize the rendering pipeline (Used when exporting)
  53693. * @returns the serialized object
  53694. */
  53695. serialize(): any;
  53696. /**
  53697. * Parse the serialized pipeline
  53698. * @param source Source pipeline.
  53699. * @param scene The scene to load the pipeline to.
  53700. * @param rootUrl The URL of the serialized pipeline.
  53701. * @returns An instantiated pipeline from the serialized object.
  53702. */
  53703. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  53704. }
  53705. }
  53706. declare module BABYLON {
  53707. /** @hidden */
  53708. export var lensHighlightsPixelShader: {
  53709. name: string;
  53710. shader: string;
  53711. };
  53712. }
  53713. declare module BABYLON {
  53714. /** @hidden */
  53715. export var depthOfFieldPixelShader: {
  53716. name: string;
  53717. shader: string;
  53718. };
  53719. }
  53720. declare module BABYLON {
  53721. /**
  53722. * BABYLON.JS Chromatic Aberration GLSL Shader
  53723. * Author: Olivier Guyot
  53724. * Separates very slightly R, G and B colors on the edges of the screen
  53725. * Inspired by Francois Tarlier & Martins Upitis
  53726. */
  53727. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  53728. /**
  53729. * @ignore
  53730. * The chromatic aberration PostProcess id in the pipeline
  53731. */
  53732. LensChromaticAberrationEffect: string;
  53733. /**
  53734. * @ignore
  53735. * The highlights enhancing PostProcess id in the pipeline
  53736. */
  53737. HighlightsEnhancingEffect: string;
  53738. /**
  53739. * @ignore
  53740. * The depth-of-field PostProcess id in the pipeline
  53741. */
  53742. LensDepthOfFieldEffect: string;
  53743. private _scene;
  53744. private _depthTexture;
  53745. private _grainTexture;
  53746. private _chromaticAberrationPostProcess;
  53747. private _highlightsPostProcess;
  53748. private _depthOfFieldPostProcess;
  53749. private _edgeBlur;
  53750. private _grainAmount;
  53751. private _chromaticAberration;
  53752. private _distortion;
  53753. private _highlightsGain;
  53754. private _highlightsThreshold;
  53755. private _dofDistance;
  53756. private _dofAperture;
  53757. private _dofDarken;
  53758. private _dofPentagon;
  53759. private _blurNoise;
  53760. /**
  53761. * @constructor
  53762. *
  53763. * Effect parameters are as follow:
  53764. * {
  53765. * chromatic_aberration: number; // from 0 to x (1 for realism)
  53766. * edge_blur: number; // from 0 to x (1 for realism)
  53767. * distortion: number; // from 0 to x (1 for realism)
  53768. * grain_amount: number; // from 0 to 1
  53769. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  53770. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  53771. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  53772. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  53773. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  53774. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  53775. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  53776. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  53777. * }
  53778. * Note: if an effect parameter is unset, effect is disabled
  53779. *
  53780. * @param name The rendering pipeline name
  53781. * @param parameters - An object containing all parameters (see above)
  53782. * @param scene The scene linked to this pipeline
  53783. * @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)
  53784. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53785. */
  53786. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  53787. /**
  53788. * Get the class name
  53789. * @returns "LensRenderingPipeline"
  53790. */
  53791. getClassName(): string;
  53792. /**
  53793. * Gets associated scene
  53794. */
  53795. readonly scene: Scene;
  53796. /**
  53797. * Gets or sets the edge blur
  53798. */
  53799. edgeBlur: number;
  53800. /**
  53801. * Gets or sets the grain amount
  53802. */
  53803. grainAmount: number;
  53804. /**
  53805. * Gets or sets the chromatic aberration amount
  53806. */
  53807. chromaticAberration: number;
  53808. /**
  53809. * Gets or sets the depth of field aperture
  53810. */
  53811. dofAperture: number;
  53812. /**
  53813. * Gets or sets the edge distortion
  53814. */
  53815. edgeDistortion: number;
  53816. /**
  53817. * Gets or sets the depth of field distortion
  53818. */
  53819. dofDistortion: number;
  53820. /**
  53821. * Gets or sets the darken out of focus amount
  53822. */
  53823. darkenOutOfFocus: number;
  53824. /**
  53825. * Gets or sets a boolean indicating if blur noise is enabled
  53826. */
  53827. blurNoise: boolean;
  53828. /**
  53829. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  53830. */
  53831. pentagonBokeh: boolean;
  53832. /**
  53833. * Gets or sets the highlight grain amount
  53834. */
  53835. highlightsGain: number;
  53836. /**
  53837. * Gets or sets the highlight threshold
  53838. */
  53839. highlightsThreshold: number;
  53840. /**
  53841. * Sets the amount of blur at the edges
  53842. * @param amount blur amount
  53843. */
  53844. setEdgeBlur(amount: number): void;
  53845. /**
  53846. * Sets edge blur to 0
  53847. */
  53848. disableEdgeBlur(): void;
  53849. /**
  53850. * Sets the amout of grain
  53851. * @param amount Amount of grain
  53852. */
  53853. setGrainAmount(amount: number): void;
  53854. /**
  53855. * Set grain amount to 0
  53856. */
  53857. disableGrain(): void;
  53858. /**
  53859. * Sets the chromatic aberration amount
  53860. * @param amount amount of chromatic aberration
  53861. */
  53862. setChromaticAberration(amount: number): void;
  53863. /**
  53864. * Sets chromatic aberration amount to 0
  53865. */
  53866. disableChromaticAberration(): void;
  53867. /**
  53868. * Sets the EdgeDistortion amount
  53869. * @param amount amount of EdgeDistortion
  53870. */
  53871. setEdgeDistortion(amount: number): void;
  53872. /**
  53873. * Sets edge distortion to 0
  53874. */
  53875. disableEdgeDistortion(): void;
  53876. /**
  53877. * Sets the FocusDistance amount
  53878. * @param amount amount of FocusDistance
  53879. */
  53880. setFocusDistance(amount: number): void;
  53881. /**
  53882. * Disables depth of field
  53883. */
  53884. disableDepthOfField(): void;
  53885. /**
  53886. * Sets the Aperture amount
  53887. * @param amount amount of Aperture
  53888. */
  53889. setAperture(amount: number): void;
  53890. /**
  53891. * Sets the DarkenOutOfFocus amount
  53892. * @param amount amount of DarkenOutOfFocus
  53893. */
  53894. setDarkenOutOfFocus(amount: number): void;
  53895. private _pentagonBokehIsEnabled;
  53896. /**
  53897. * Creates a pentagon bokeh effect
  53898. */
  53899. enablePentagonBokeh(): void;
  53900. /**
  53901. * Disables the pentagon bokeh effect
  53902. */
  53903. disablePentagonBokeh(): void;
  53904. /**
  53905. * Enables noise blur
  53906. */
  53907. enableNoiseBlur(): void;
  53908. /**
  53909. * Disables noise blur
  53910. */
  53911. disableNoiseBlur(): void;
  53912. /**
  53913. * Sets the HighlightsGain amount
  53914. * @param amount amount of HighlightsGain
  53915. */
  53916. setHighlightsGain(amount: number): void;
  53917. /**
  53918. * Sets the HighlightsThreshold amount
  53919. * @param amount amount of HighlightsThreshold
  53920. */
  53921. setHighlightsThreshold(amount: number): void;
  53922. /**
  53923. * Disables highlights
  53924. */
  53925. disableHighlights(): void;
  53926. /**
  53927. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  53928. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  53929. */
  53930. dispose(disableDepthRender?: boolean): void;
  53931. private _createChromaticAberrationPostProcess;
  53932. private _createHighlightsPostProcess;
  53933. private _createDepthOfFieldPostProcess;
  53934. private _createGrainTexture;
  53935. }
  53936. }
  53937. declare module BABYLON {
  53938. /** @hidden */
  53939. export var ssao2PixelShader: {
  53940. name: string;
  53941. shader: string;
  53942. };
  53943. }
  53944. declare module BABYLON {
  53945. /** @hidden */
  53946. export var ssaoCombinePixelShader: {
  53947. name: string;
  53948. shader: string;
  53949. };
  53950. }
  53951. declare module BABYLON {
  53952. /**
  53953. * Render pipeline to produce ssao effect
  53954. */
  53955. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53956. /**
  53957. * @ignore
  53958. * The PassPostProcess id in the pipeline that contains the original scene color
  53959. */
  53960. SSAOOriginalSceneColorEffect: string;
  53961. /**
  53962. * @ignore
  53963. * The SSAO PostProcess id in the pipeline
  53964. */
  53965. SSAORenderEffect: string;
  53966. /**
  53967. * @ignore
  53968. * The horizontal blur PostProcess id in the pipeline
  53969. */
  53970. SSAOBlurHRenderEffect: string;
  53971. /**
  53972. * @ignore
  53973. * The vertical blur PostProcess id in the pipeline
  53974. */
  53975. SSAOBlurVRenderEffect: string;
  53976. /**
  53977. * @ignore
  53978. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53979. */
  53980. SSAOCombineRenderEffect: string;
  53981. /**
  53982. * The output strength of the SSAO post-process. Default value is 1.0.
  53983. */
  53984. totalStrength: number;
  53985. /**
  53986. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53987. */
  53988. maxZ: number;
  53989. /**
  53990. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53991. */
  53992. minZAspect: number;
  53993. private _samples;
  53994. /**
  53995. * Number of samples used for the SSAO calculations. Default value is 8
  53996. */
  53997. samples: number;
  53998. private _textureSamples;
  53999. /**
  54000. * Number of samples to use for antialiasing
  54001. */
  54002. textureSamples: number;
  54003. /**
  54004. * Ratio object used for SSAO ratio and blur ratio
  54005. */
  54006. private _ratio;
  54007. /**
  54008. * Dynamically generated sphere sampler.
  54009. */
  54010. private _sampleSphere;
  54011. /**
  54012. * Blur filter offsets
  54013. */
  54014. private _samplerOffsets;
  54015. private _expensiveBlur;
  54016. /**
  54017. * If bilateral blur should be used
  54018. */
  54019. expensiveBlur: boolean;
  54020. /**
  54021. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  54022. */
  54023. radius: number;
  54024. /**
  54025. * The base color of the SSAO post-process
  54026. * The final result is "base + ssao" between [0, 1]
  54027. */
  54028. base: number;
  54029. /**
  54030. * Support test.
  54031. */
  54032. static readonly IsSupported: boolean;
  54033. private _scene;
  54034. private _depthTexture;
  54035. private _normalTexture;
  54036. private _randomTexture;
  54037. private _originalColorPostProcess;
  54038. private _ssaoPostProcess;
  54039. private _blurHPostProcess;
  54040. private _blurVPostProcess;
  54041. private _ssaoCombinePostProcess;
  54042. private _firstUpdate;
  54043. /**
  54044. * Gets active scene
  54045. */
  54046. readonly scene: Scene;
  54047. /**
  54048. * @constructor
  54049. * @param name The rendering pipeline name
  54050. * @param scene The scene linked to this pipeline
  54051. * @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 }
  54052. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54053. */
  54054. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54055. /**
  54056. * Get the class name
  54057. * @returns "SSAO2RenderingPipeline"
  54058. */
  54059. getClassName(): string;
  54060. /**
  54061. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54062. */
  54063. dispose(disableGeometryBufferRenderer?: boolean): void;
  54064. private _createBlurPostProcess;
  54065. /** @hidden */
  54066. _rebuild(): void;
  54067. private _bits;
  54068. private _radicalInverse_VdC;
  54069. private _hammersley;
  54070. private _hemisphereSample_uniform;
  54071. private _generateHemisphere;
  54072. private _createSSAOPostProcess;
  54073. private _createSSAOCombinePostProcess;
  54074. private _createRandomTexture;
  54075. /**
  54076. * Serialize the rendering pipeline (Used when exporting)
  54077. * @returns the serialized object
  54078. */
  54079. serialize(): any;
  54080. /**
  54081. * Parse the serialized pipeline
  54082. * @param source Source pipeline.
  54083. * @param scene The scene to load the pipeline to.
  54084. * @param rootUrl The URL of the serialized pipeline.
  54085. * @returns An instantiated pipeline from the serialized object.
  54086. */
  54087. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  54088. }
  54089. }
  54090. declare module BABYLON {
  54091. /** @hidden */
  54092. export var ssaoPixelShader: {
  54093. name: string;
  54094. shader: string;
  54095. };
  54096. }
  54097. declare module BABYLON {
  54098. /**
  54099. * Render pipeline to produce ssao effect
  54100. */
  54101. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  54102. /**
  54103. * @ignore
  54104. * The PassPostProcess id in the pipeline that contains the original scene color
  54105. */
  54106. SSAOOriginalSceneColorEffect: string;
  54107. /**
  54108. * @ignore
  54109. * The SSAO PostProcess id in the pipeline
  54110. */
  54111. SSAORenderEffect: string;
  54112. /**
  54113. * @ignore
  54114. * The horizontal blur PostProcess id in the pipeline
  54115. */
  54116. SSAOBlurHRenderEffect: string;
  54117. /**
  54118. * @ignore
  54119. * The vertical blur PostProcess id in the pipeline
  54120. */
  54121. SSAOBlurVRenderEffect: string;
  54122. /**
  54123. * @ignore
  54124. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54125. */
  54126. SSAOCombineRenderEffect: string;
  54127. /**
  54128. * The output strength of the SSAO post-process. Default value is 1.0.
  54129. */
  54130. totalStrength: number;
  54131. /**
  54132. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  54133. */
  54134. radius: number;
  54135. /**
  54136. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  54137. * Must not be equal to fallOff and superior to fallOff.
  54138. * Default value is 0.0075
  54139. */
  54140. area: number;
  54141. /**
  54142. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  54143. * Must not be equal to area and inferior to area.
  54144. * Default value is 0.000001
  54145. */
  54146. fallOff: number;
  54147. /**
  54148. * The base color of the SSAO post-process
  54149. * The final result is "base + ssao" between [0, 1]
  54150. */
  54151. base: number;
  54152. private _scene;
  54153. private _depthTexture;
  54154. private _randomTexture;
  54155. private _originalColorPostProcess;
  54156. private _ssaoPostProcess;
  54157. private _blurHPostProcess;
  54158. private _blurVPostProcess;
  54159. private _ssaoCombinePostProcess;
  54160. private _firstUpdate;
  54161. /**
  54162. * Gets active scene
  54163. */
  54164. readonly scene: Scene;
  54165. /**
  54166. * @constructor
  54167. * @param name - The rendering pipeline name
  54168. * @param scene - The scene linked to this pipeline
  54169. * @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 }
  54170. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  54171. */
  54172. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54173. /**
  54174. * Get the class name
  54175. * @returns "SSAORenderingPipeline"
  54176. */
  54177. getClassName(): string;
  54178. /**
  54179. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54180. */
  54181. dispose(disableDepthRender?: boolean): void;
  54182. private _createBlurPostProcess;
  54183. /** @hidden */
  54184. _rebuild(): void;
  54185. private _createSSAOPostProcess;
  54186. private _createSSAOCombinePostProcess;
  54187. private _createRandomTexture;
  54188. }
  54189. }
  54190. declare module BABYLON {
  54191. /** @hidden */
  54192. export var standardPixelShader: {
  54193. name: string;
  54194. shader: string;
  54195. };
  54196. }
  54197. declare module BABYLON {
  54198. /**
  54199. * Standard rendering pipeline
  54200. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54201. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  54202. */
  54203. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54204. /**
  54205. * Public members
  54206. */
  54207. /**
  54208. * Post-process which contains the original scene color before the pipeline applies all the effects
  54209. */
  54210. originalPostProcess: Nullable<PostProcess>;
  54211. /**
  54212. * Post-process used to down scale an image x4
  54213. */
  54214. downSampleX4PostProcess: Nullable<PostProcess>;
  54215. /**
  54216. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  54217. */
  54218. brightPassPostProcess: Nullable<PostProcess>;
  54219. /**
  54220. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  54221. */
  54222. blurHPostProcesses: PostProcess[];
  54223. /**
  54224. * Post-process array storing all the vertical blur post-processes used by the pipeline
  54225. */
  54226. blurVPostProcesses: PostProcess[];
  54227. /**
  54228. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  54229. */
  54230. textureAdderPostProcess: Nullable<PostProcess>;
  54231. /**
  54232. * Post-process used to create volumetric lighting effect
  54233. */
  54234. volumetricLightPostProcess: Nullable<PostProcess>;
  54235. /**
  54236. * Post-process used to smooth the previous volumetric light post-process on the X axis
  54237. */
  54238. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  54239. /**
  54240. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  54241. */
  54242. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  54243. /**
  54244. * Post-process used to merge the volumetric light effect and the real scene color
  54245. */
  54246. volumetricLightMergePostProces: Nullable<PostProcess>;
  54247. /**
  54248. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  54249. */
  54250. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  54251. /**
  54252. * Base post-process used to calculate the average luminance of the final image for HDR
  54253. */
  54254. luminancePostProcess: Nullable<PostProcess>;
  54255. /**
  54256. * Post-processes used to create down sample post-processes in order to get
  54257. * the average luminance of the final image for HDR
  54258. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  54259. */
  54260. luminanceDownSamplePostProcesses: PostProcess[];
  54261. /**
  54262. * Post-process used to create a HDR effect (light adaptation)
  54263. */
  54264. hdrPostProcess: Nullable<PostProcess>;
  54265. /**
  54266. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  54267. */
  54268. textureAdderFinalPostProcess: Nullable<PostProcess>;
  54269. /**
  54270. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  54271. */
  54272. lensFlareFinalPostProcess: Nullable<PostProcess>;
  54273. /**
  54274. * Post-process used to merge the final HDR post-process and the real scene color
  54275. */
  54276. hdrFinalPostProcess: Nullable<PostProcess>;
  54277. /**
  54278. * Post-process used to create a lens flare effect
  54279. */
  54280. lensFlarePostProcess: Nullable<PostProcess>;
  54281. /**
  54282. * Post-process that merges the result of the lens flare post-process and the real scene color
  54283. */
  54284. lensFlareComposePostProcess: Nullable<PostProcess>;
  54285. /**
  54286. * Post-process used to create a motion blur effect
  54287. */
  54288. motionBlurPostProcess: Nullable<PostProcess>;
  54289. /**
  54290. * Post-process used to create a depth of field effect
  54291. */
  54292. depthOfFieldPostProcess: Nullable<PostProcess>;
  54293. /**
  54294. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54295. */
  54296. fxaaPostProcess: Nullable<FxaaPostProcess>;
  54297. /**
  54298. * Represents the brightness threshold in order to configure the illuminated surfaces
  54299. */
  54300. brightThreshold: number;
  54301. /**
  54302. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  54303. */
  54304. blurWidth: number;
  54305. /**
  54306. * Sets if the blur for highlighted surfaces must be only horizontal
  54307. */
  54308. horizontalBlur: boolean;
  54309. /**
  54310. * Gets the overall exposure used by the pipeline
  54311. */
  54312. /**
  54313. * Sets the overall exposure used by the pipeline
  54314. */
  54315. exposure: number;
  54316. /**
  54317. * Texture used typically to simulate "dirty" on camera lens
  54318. */
  54319. lensTexture: Nullable<Texture>;
  54320. /**
  54321. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  54322. */
  54323. volumetricLightCoefficient: number;
  54324. /**
  54325. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  54326. */
  54327. volumetricLightPower: number;
  54328. /**
  54329. * Used the set the blur intensity to smooth the volumetric lights
  54330. */
  54331. volumetricLightBlurScale: number;
  54332. /**
  54333. * Light (spot or directional) used to generate the volumetric lights rays
  54334. * The source light must have a shadow generate so the pipeline can get its
  54335. * depth map
  54336. */
  54337. sourceLight: Nullable<SpotLight | DirectionalLight>;
  54338. /**
  54339. * For eye adaptation, represents the minimum luminance the eye can see
  54340. */
  54341. hdrMinimumLuminance: number;
  54342. /**
  54343. * For eye adaptation, represents the decrease luminance speed
  54344. */
  54345. hdrDecreaseRate: number;
  54346. /**
  54347. * For eye adaptation, represents the increase luminance speed
  54348. */
  54349. hdrIncreaseRate: number;
  54350. /**
  54351. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  54352. */
  54353. /**
  54354. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  54355. */
  54356. hdrAutoExposure: boolean;
  54357. /**
  54358. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  54359. */
  54360. lensColorTexture: Nullable<Texture>;
  54361. /**
  54362. * The overall strengh for the lens flare effect
  54363. */
  54364. lensFlareStrength: number;
  54365. /**
  54366. * Dispersion coefficient for lens flare ghosts
  54367. */
  54368. lensFlareGhostDispersal: number;
  54369. /**
  54370. * Main lens flare halo width
  54371. */
  54372. lensFlareHaloWidth: number;
  54373. /**
  54374. * Based on the lens distortion effect, defines how much the lens flare result
  54375. * is distorted
  54376. */
  54377. lensFlareDistortionStrength: number;
  54378. /**
  54379. * Lens star texture must be used to simulate rays on the flares and is available
  54380. * in the documentation
  54381. */
  54382. lensStarTexture: Nullable<Texture>;
  54383. /**
  54384. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  54385. * flare effect by taking account of the dirt texture
  54386. */
  54387. lensFlareDirtTexture: Nullable<Texture>;
  54388. /**
  54389. * Represents the focal length for the depth of field effect
  54390. */
  54391. depthOfFieldDistance: number;
  54392. /**
  54393. * Represents the blur intensity for the blurred part of the depth of field effect
  54394. */
  54395. depthOfFieldBlurWidth: number;
  54396. /**
  54397. * For motion blur, defines how much the image is blurred by the movement
  54398. */
  54399. motionStrength: number;
  54400. /**
  54401. * List of animations for the pipeline (IAnimatable implementation)
  54402. */
  54403. animations: Animation[];
  54404. /**
  54405. * Private members
  54406. */
  54407. private _scene;
  54408. private _currentDepthOfFieldSource;
  54409. private _basePostProcess;
  54410. private _fixedExposure;
  54411. private _currentExposure;
  54412. private _hdrAutoExposure;
  54413. private _hdrCurrentLuminance;
  54414. private _floatTextureType;
  54415. private _ratio;
  54416. private _bloomEnabled;
  54417. private _depthOfFieldEnabled;
  54418. private _vlsEnabled;
  54419. private _lensFlareEnabled;
  54420. private _hdrEnabled;
  54421. private _motionBlurEnabled;
  54422. private _fxaaEnabled;
  54423. private _motionBlurSamples;
  54424. private _volumetricLightStepsCount;
  54425. private _samples;
  54426. /**
  54427. * @ignore
  54428. * Specifies if the bloom pipeline is enabled
  54429. */
  54430. BloomEnabled: boolean;
  54431. /**
  54432. * @ignore
  54433. * Specifies if the depth of field pipeline is enabed
  54434. */
  54435. DepthOfFieldEnabled: boolean;
  54436. /**
  54437. * @ignore
  54438. * Specifies if the lens flare pipeline is enabed
  54439. */
  54440. LensFlareEnabled: boolean;
  54441. /**
  54442. * @ignore
  54443. * Specifies if the HDR pipeline is enabled
  54444. */
  54445. HDREnabled: boolean;
  54446. /**
  54447. * @ignore
  54448. * Specifies if the volumetric lights scattering effect is enabled
  54449. */
  54450. VLSEnabled: boolean;
  54451. /**
  54452. * @ignore
  54453. * Specifies if the motion blur effect is enabled
  54454. */
  54455. MotionBlurEnabled: boolean;
  54456. /**
  54457. * Specifies if anti-aliasing is enabled
  54458. */
  54459. fxaaEnabled: boolean;
  54460. /**
  54461. * Specifies the number of steps used to calculate the volumetric lights
  54462. * Typically in interval [50, 200]
  54463. */
  54464. volumetricLightStepsCount: number;
  54465. /**
  54466. * Specifies the number of samples used for the motion blur effect
  54467. * Typically in interval [16, 64]
  54468. */
  54469. motionBlurSamples: number;
  54470. /**
  54471. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54472. */
  54473. samples: number;
  54474. /**
  54475. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54476. * @constructor
  54477. * @param name The rendering pipeline name
  54478. * @param scene The scene linked to this pipeline
  54479. * @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)
  54480. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  54481. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54482. */
  54483. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  54484. private _buildPipeline;
  54485. private _createDownSampleX4PostProcess;
  54486. private _createBrightPassPostProcess;
  54487. private _createBlurPostProcesses;
  54488. private _createTextureAdderPostProcess;
  54489. private _createVolumetricLightPostProcess;
  54490. private _createLuminancePostProcesses;
  54491. private _createHdrPostProcess;
  54492. private _createLensFlarePostProcess;
  54493. private _createDepthOfFieldPostProcess;
  54494. private _createMotionBlurPostProcess;
  54495. private _getDepthTexture;
  54496. private _disposePostProcesses;
  54497. /**
  54498. * Dispose of the pipeline and stop all post processes
  54499. */
  54500. dispose(): void;
  54501. /**
  54502. * Serialize the rendering pipeline (Used when exporting)
  54503. * @returns the serialized object
  54504. */
  54505. serialize(): any;
  54506. /**
  54507. * Parse the serialized pipeline
  54508. * @param source Source pipeline.
  54509. * @param scene The scene to load the pipeline to.
  54510. * @param rootUrl The URL of the serialized pipeline.
  54511. * @returns An instantiated pipeline from the serialized object.
  54512. */
  54513. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  54514. /**
  54515. * Luminance steps
  54516. */
  54517. static LuminanceSteps: number;
  54518. }
  54519. }
  54520. declare module BABYLON {
  54521. /** @hidden */
  54522. export var tonemapPixelShader: {
  54523. name: string;
  54524. shader: string;
  54525. };
  54526. }
  54527. declare module BABYLON {
  54528. /** Defines operator used for tonemapping */
  54529. export enum TonemappingOperator {
  54530. /** Hable */
  54531. Hable = 0,
  54532. /** Reinhard */
  54533. Reinhard = 1,
  54534. /** HejiDawson */
  54535. HejiDawson = 2,
  54536. /** Photographic */
  54537. Photographic = 3
  54538. }
  54539. /**
  54540. * Defines a post process to apply tone mapping
  54541. */
  54542. export class TonemapPostProcess extends PostProcess {
  54543. private _operator;
  54544. /** Defines the required exposure adjustement */
  54545. exposureAdjustment: number;
  54546. /**
  54547. * Creates a new TonemapPostProcess
  54548. * @param name defines the name of the postprocess
  54549. * @param _operator defines the operator to use
  54550. * @param exposureAdjustment defines the required exposure adjustement
  54551. * @param camera defines the camera to use (can be null)
  54552. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  54553. * @param engine defines the hosting engine (can be ignore if camera is set)
  54554. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54555. */
  54556. constructor(name: string, _operator: TonemappingOperator,
  54557. /** Defines the required exposure adjustement */
  54558. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  54559. }
  54560. }
  54561. declare module BABYLON {
  54562. /** @hidden */
  54563. export var depthVertexShader: {
  54564. name: string;
  54565. shader: string;
  54566. };
  54567. }
  54568. declare module BABYLON {
  54569. /** @hidden */
  54570. export var volumetricLightScatteringPixelShader: {
  54571. name: string;
  54572. shader: string;
  54573. };
  54574. }
  54575. declare module BABYLON {
  54576. /** @hidden */
  54577. export var volumetricLightScatteringPassPixelShader: {
  54578. name: string;
  54579. shader: string;
  54580. };
  54581. }
  54582. declare module BABYLON {
  54583. /**
  54584. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  54585. */
  54586. export class VolumetricLightScatteringPostProcess extends PostProcess {
  54587. private _volumetricLightScatteringPass;
  54588. private _volumetricLightScatteringRTT;
  54589. private _viewPort;
  54590. private _screenCoordinates;
  54591. private _cachedDefines;
  54592. /**
  54593. * If not undefined, the mesh position is computed from the attached node position
  54594. */
  54595. attachedNode: {
  54596. position: Vector3;
  54597. };
  54598. /**
  54599. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  54600. */
  54601. customMeshPosition: Vector3;
  54602. /**
  54603. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  54604. */
  54605. useCustomMeshPosition: boolean;
  54606. /**
  54607. * If the post-process should inverse the light scattering direction
  54608. */
  54609. invert: boolean;
  54610. /**
  54611. * The internal mesh used by the post-process
  54612. */
  54613. mesh: Mesh;
  54614. /**
  54615. * @hidden
  54616. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  54617. */
  54618. useDiffuseColor: boolean;
  54619. /**
  54620. * Array containing the excluded meshes not rendered in the internal pass
  54621. */
  54622. excludedMeshes: AbstractMesh[];
  54623. /**
  54624. * Controls the overall intensity of the post-process
  54625. */
  54626. exposure: number;
  54627. /**
  54628. * Dissipates each sample's contribution in range [0, 1]
  54629. */
  54630. decay: number;
  54631. /**
  54632. * Controls the overall intensity of each sample
  54633. */
  54634. weight: number;
  54635. /**
  54636. * Controls the density of each sample
  54637. */
  54638. density: number;
  54639. /**
  54640. * @constructor
  54641. * @param name The post-process name
  54642. * @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)
  54643. * @param camera The camera that the post-process will be attached to
  54644. * @param mesh The mesh used to create the light scattering
  54645. * @param samples The post-process quality, default 100
  54646. * @param samplingModeThe post-process filtering mode
  54647. * @param engine The babylon engine
  54648. * @param reusable If the post-process is reusable
  54649. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  54650. */
  54651. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  54652. /**
  54653. * Returns the string "VolumetricLightScatteringPostProcess"
  54654. * @returns "VolumetricLightScatteringPostProcess"
  54655. */
  54656. getClassName(): string;
  54657. private _isReady;
  54658. /**
  54659. * Sets the new light position for light scattering effect
  54660. * @param position The new custom light position
  54661. */
  54662. setCustomMeshPosition(position: Vector3): void;
  54663. /**
  54664. * Returns the light position for light scattering effect
  54665. * @return Vector3 The custom light position
  54666. */
  54667. getCustomMeshPosition(): Vector3;
  54668. /**
  54669. * Disposes the internal assets and detaches the post-process from the camera
  54670. */
  54671. dispose(camera: Camera): void;
  54672. /**
  54673. * Returns the render target texture used by the post-process
  54674. * @return the render target texture used by the post-process
  54675. */
  54676. getPass(): RenderTargetTexture;
  54677. private _meshExcluded;
  54678. private _createPass;
  54679. private _updateMeshScreenCoordinates;
  54680. /**
  54681. * Creates a default mesh for the Volumeric Light Scattering post-process
  54682. * @param name The mesh name
  54683. * @param scene The scene where to create the mesh
  54684. * @return the default mesh
  54685. */
  54686. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  54687. }
  54688. }
  54689. declare module BABYLON {
  54690. interface Scene {
  54691. /** @hidden (Backing field) */
  54692. _boundingBoxRenderer: BoundingBoxRenderer;
  54693. /** @hidden (Backing field) */
  54694. _forceShowBoundingBoxes: boolean;
  54695. /**
  54696. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  54697. */
  54698. forceShowBoundingBoxes: boolean;
  54699. /**
  54700. * Gets the bounding box renderer associated with the scene
  54701. * @returns a BoundingBoxRenderer
  54702. */
  54703. getBoundingBoxRenderer(): BoundingBoxRenderer;
  54704. }
  54705. interface AbstractMesh {
  54706. /** @hidden (Backing field) */
  54707. _showBoundingBox: boolean;
  54708. /**
  54709. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  54710. */
  54711. showBoundingBox: boolean;
  54712. }
  54713. /**
  54714. * Component responsible of rendering the bounding box of the meshes in a scene.
  54715. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  54716. */
  54717. export class BoundingBoxRenderer implements ISceneComponent {
  54718. /**
  54719. * The component name helpfull to identify the component in the list of scene components.
  54720. */
  54721. readonly name: string;
  54722. /**
  54723. * The scene the component belongs to.
  54724. */
  54725. scene: Scene;
  54726. /**
  54727. * Color of the bounding box lines placed in front of an object
  54728. */
  54729. frontColor: Color3;
  54730. /**
  54731. * Color of the bounding box lines placed behind an object
  54732. */
  54733. backColor: Color3;
  54734. /**
  54735. * Defines if the renderer should show the back lines or not
  54736. */
  54737. showBackLines: boolean;
  54738. /**
  54739. * @hidden
  54740. */
  54741. renderList: SmartArray<BoundingBox>;
  54742. private _colorShader;
  54743. private _vertexBuffers;
  54744. private _indexBuffer;
  54745. /**
  54746. * Instantiates a new bounding box renderer in a scene.
  54747. * @param scene the scene the renderer renders in
  54748. */
  54749. constructor(scene: Scene);
  54750. /**
  54751. * Registers the component in a given scene
  54752. */
  54753. register(): void;
  54754. private _evaluateSubMesh;
  54755. private _activeMesh;
  54756. private _prepareRessources;
  54757. private _createIndexBuffer;
  54758. /**
  54759. * Rebuilds the elements related to this component in case of
  54760. * context lost for instance.
  54761. */
  54762. rebuild(): void;
  54763. /**
  54764. * @hidden
  54765. */
  54766. reset(): void;
  54767. /**
  54768. * Render the bounding boxes of a specific rendering group
  54769. * @param renderingGroupId defines the rendering group to render
  54770. */
  54771. render(renderingGroupId: number): void;
  54772. /**
  54773. * In case of occlusion queries, we can render the occlusion bounding box through this method
  54774. * @param mesh Define the mesh to render the occlusion bounding box for
  54775. */
  54776. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  54777. /**
  54778. * Dispose and release the resources attached to this renderer.
  54779. */
  54780. dispose(): void;
  54781. }
  54782. }
  54783. declare module BABYLON {
  54784. /** @hidden */
  54785. export var depthPixelShader: {
  54786. name: string;
  54787. shader: string;
  54788. };
  54789. }
  54790. declare module BABYLON {
  54791. /**
  54792. * This represents a depth renderer in Babylon.
  54793. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54794. */
  54795. export class DepthRenderer {
  54796. private _scene;
  54797. private _depthMap;
  54798. private _effect;
  54799. private _cachedDefines;
  54800. private _camera;
  54801. /**
  54802. * Specifiess that the depth renderer will only be used within
  54803. * the camera it is created for.
  54804. * This can help forcing its rendering during the camera processing.
  54805. */
  54806. useOnlyInActiveCamera: boolean;
  54807. /** @hidden */
  54808. static _SceneComponentInitialization: (scene: Scene) => void;
  54809. /**
  54810. * Instantiates a depth renderer
  54811. * @param scene The scene the renderer belongs to
  54812. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54813. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54814. */
  54815. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  54816. /**
  54817. * Creates the depth rendering effect and checks if the effect is ready.
  54818. * @param subMesh The submesh to be used to render the depth map of
  54819. * @param useInstances If multiple world instances should be used
  54820. * @returns if the depth renderer is ready to render the depth map
  54821. */
  54822. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54823. /**
  54824. * Gets the texture which the depth map will be written to.
  54825. * @returns The depth map texture
  54826. */
  54827. getDepthMap(): RenderTargetTexture;
  54828. /**
  54829. * Disposes of the depth renderer.
  54830. */
  54831. dispose(): void;
  54832. }
  54833. }
  54834. declare module BABYLON {
  54835. interface Scene {
  54836. /** @hidden (Backing field) */
  54837. _depthRenderer: {
  54838. [id: string]: DepthRenderer;
  54839. };
  54840. /**
  54841. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  54842. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  54843. * @returns the created depth renderer
  54844. */
  54845. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  54846. /**
  54847. * Disables a depth renderer for a given camera
  54848. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  54849. */
  54850. disableDepthRenderer(camera?: Nullable<Camera>): void;
  54851. }
  54852. /**
  54853. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  54854. * in several rendering techniques.
  54855. */
  54856. export class DepthRendererSceneComponent implements ISceneComponent {
  54857. /**
  54858. * The component name helpfull to identify the component in the list of scene components.
  54859. */
  54860. readonly name: string;
  54861. /**
  54862. * The scene the component belongs to.
  54863. */
  54864. scene: Scene;
  54865. /**
  54866. * Creates a new instance of the component for the given scene
  54867. * @param scene Defines the scene to register the component in
  54868. */
  54869. constructor(scene: Scene);
  54870. /**
  54871. * Registers the component in a given scene
  54872. */
  54873. register(): void;
  54874. /**
  54875. * Rebuilds the elements related to this component in case of
  54876. * context lost for instance.
  54877. */
  54878. rebuild(): void;
  54879. /**
  54880. * Disposes the component and the associated ressources
  54881. */
  54882. dispose(): void;
  54883. private _gatherRenderTargets;
  54884. private _gatherActiveCameraRenderTargets;
  54885. }
  54886. }
  54887. declare module BABYLON {
  54888. /** @hidden */
  54889. export var outlinePixelShader: {
  54890. name: string;
  54891. shader: string;
  54892. };
  54893. }
  54894. declare module BABYLON {
  54895. /** @hidden */
  54896. export var outlineVertexShader: {
  54897. name: string;
  54898. shader: string;
  54899. };
  54900. }
  54901. declare module BABYLON {
  54902. interface Scene {
  54903. /** @hidden */
  54904. _outlineRenderer: OutlineRenderer;
  54905. /**
  54906. * Gets the outline renderer associated with the scene
  54907. * @returns a OutlineRenderer
  54908. */
  54909. getOutlineRenderer(): OutlineRenderer;
  54910. }
  54911. interface AbstractMesh {
  54912. /** @hidden (Backing field) */
  54913. _renderOutline: boolean;
  54914. /**
  54915. * Gets or sets a boolean indicating if the outline must be rendered as well
  54916. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  54917. */
  54918. renderOutline: boolean;
  54919. /** @hidden (Backing field) */
  54920. _renderOverlay: boolean;
  54921. /**
  54922. * Gets or sets a boolean indicating if the overlay must be rendered as well
  54923. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  54924. */
  54925. renderOverlay: boolean;
  54926. }
  54927. /**
  54928. * This class is responsible to draw bothe outline/overlay of meshes.
  54929. * It should not be used directly but through the available method on mesh.
  54930. */
  54931. export class OutlineRenderer implements ISceneComponent {
  54932. /**
  54933. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  54934. */
  54935. private static _StencilReference;
  54936. /**
  54937. * The name of the component. Each component must have a unique name.
  54938. */
  54939. name: string;
  54940. /**
  54941. * The scene the component belongs to.
  54942. */
  54943. scene: Scene;
  54944. /**
  54945. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  54946. */
  54947. zOffset: number;
  54948. private _engine;
  54949. private _effect;
  54950. private _cachedDefines;
  54951. private _savedDepthWrite;
  54952. /**
  54953. * Instantiates a new outline renderer. (There could be only one per scene).
  54954. * @param scene Defines the scene it belongs to
  54955. */
  54956. constructor(scene: Scene);
  54957. /**
  54958. * Register the component to one instance of a scene.
  54959. */
  54960. register(): void;
  54961. /**
  54962. * Rebuilds the elements related to this component in case of
  54963. * context lost for instance.
  54964. */
  54965. rebuild(): void;
  54966. /**
  54967. * Disposes the component and the associated ressources.
  54968. */
  54969. dispose(): void;
  54970. /**
  54971. * Renders the outline in the canvas.
  54972. * @param subMesh Defines the sumesh to render
  54973. * @param batch Defines the batch of meshes in case of instances
  54974. * @param useOverlay Defines if the rendering is for the overlay or the outline
  54975. */
  54976. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  54977. /**
  54978. * Returns whether or not the outline renderer is ready for a given submesh.
  54979. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  54980. * @param subMesh Defines the submesh to check readyness for
  54981. * @param useInstances Defines wheter wee are trying to render instances or not
  54982. * @returns true if ready otherwise false
  54983. */
  54984. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54985. private _beforeRenderingMesh;
  54986. private _afterRenderingMesh;
  54987. }
  54988. }
  54989. declare module BABYLON {
  54990. /**
  54991. * Defines the list of states available for a task inside a AssetsManager
  54992. */
  54993. export enum AssetTaskState {
  54994. /**
  54995. * Initialization
  54996. */
  54997. INIT = 0,
  54998. /**
  54999. * Running
  55000. */
  55001. RUNNING = 1,
  55002. /**
  55003. * Done
  55004. */
  55005. DONE = 2,
  55006. /**
  55007. * Error
  55008. */
  55009. ERROR = 3
  55010. }
  55011. /**
  55012. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  55013. */
  55014. export abstract class AbstractAssetTask {
  55015. /**
  55016. * Task name
  55017. */ name: string;
  55018. /**
  55019. * Callback called when the task is successful
  55020. */
  55021. onSuccess: (task: any) => void;
  55022. /**
  55023. * Callback called when the task is not successful
  55024. */
  55025. onError: (task: any, message?: string, exception?: any) => void;
  55026. /**
  55027. * Creates a new AssetsManager
  55028. * @param name defines the name of the task
  55029. */
  55030. constructor(
  55031. /**
  55032. * Task name
  55033. */ name: string);
  55034. private _isCompleted;
  55035. private _taskState;
  55036. private _errorObject;
  55037. /**
  55038. * Get if the task is completed
  55039. */
  55040. readonly isCompleted: boolean;
  55041. /**
  55042. * Gets the current state of the task
  55043. */
  55044. readonly taskState: AssetTaskState;
  55045. /**
  55046. * Gets the current error object (if task is in error)
  55047. */
  55048. readonly errorObject: {
  55049. message?: string;
  55050. exception?: any;
  55051. };
  55052. /**
  55053. * Internal only
  55054. * @hidden
  55055. */
  55056. _setErrorObject(message?: string, exception?: any): void;
  55057. /**
  55058. * Execute the current task
  55059. * @param scene defines the scene where you want your assets to be loaded
  55060. * @param onSuccess is a callback called when the task is successfully executed
  55061. * @param onError is a callback called if an error occurs
  55062. */
  55063. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55064. /**
  55065. * Execute the current task
  55066. * @param scene defines the scene where you want your assets to be loaded
  55067. * @param onSuccess is a callback called when the task is successfully executed
  55068. * @param onError is a callback called if an error occurs
  55069. */
  55070. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55071. /**
  55072. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  55073. * This can be used with failed tasks that have the reason for failure fixed.
  55074. */
  55075. reset(): void;
  55076. private onErrorCallback;
  55077. private onDoneCallback;
  55078. }
  55079. /**
  55080. * Define the interface used by progress events raised during assets loading
  55081. */
  55082. export interface IAssetsProgressEvent {
  55083. /**
  55084. * Defines the number of remaining tasks to process
  55085. */
  55086. remainingCount: number;
  55087. /**
  55088. * Defines the total number of tasks
  55089. */
  55090. totalCount: number;
  55091. /**
  55092. * Defines the task that was just processed
  55093. */
  55094. task: AbstractAssetTask;
  55095. }
  55096. /**
  55097. * Class used to share progress information about assets loading
  55098. */
  55099. export class AssetsProgressEvent implements IAssetsProgressEvent {
  55100. /**
  55101. * Defines the number of remaining tasks to process
  55102. */
  55103. remainingCount: number;
  55104. /**
  55105. * Defines the total number of tasks
  55106. */
  55107. totalCount: number;
  55108. /**
  55109. * Defines the task that was just processed
  55110. */
  55111. task: AbstractAssetTask;
  55112. /**
  55113. * Creates a AssetsProgressEvent
  55114. * @param remainingCount defines the number of remaining tasks to process
  55115. * @param totalCount defines the total number of tasks
  55116. * @param task defines the task that was just processed
  55117. */
  55118. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  55119. }
  55120. /**
  55121. * Define a task used by AssetsManager to load meshes
  55122. */
  55123. export class MeshAssetTask extends AbstractAssetTask {
  55124. /**
  55125. * Defines the name of the task
  55126. */
  55127. name: string;
  55128. /**
  55129. * Defines the list of mesh's names you want to load
  55130. */
  55131. meshesNames: any;
  55132. /**
  55133. * Defines the root url to use as a base to load your meshes and associated resources
  55134. */
  55135. rootUrl: string;
  55136. /**
  55137. * Defines the filename of the scene to load from
  55138. */
  55139. sceneFilename: string;
  55140. /**
  55141. * Gets the list of loaded meshes
  55142. */
  55143. loadedMeshes: Array<AbstractMesh>;
  55144. /**
  55145. * Gets the list of loaded particle systems
  55146. */
  55147. loadedParticleSystems: Array<IParticleSystem>;
  55148. /**
  55149. * Gets the list of loaded skeletons
  55150. */
  55151. loadedSkeletons: Array<Skeleton>;
  55152. /**
  55153. * Gets the list of loaded animation groups
  55154. */
  55155. loadedAnimationGroups: Array<AnimationGroup>;
  55156. /**
  55157. * Callback called when the task is successful
  55158. */
  55159. onSuccess: (task: MeshAssetTask) => void;
  55160. /**
  55161. * Callback called when the task is successful
  55162. */
  55163. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  55164. /**
  55165. * Creates a new MeshAssetTask
  55166. * @param name defines the name of the task
  55167. * @param meshesNames defines the list of mesh's names you want to load
  55168. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  55169. * @param sceneFilename defines the filename of the scene to load from
  55170. */
  55171. constructor(
  55172. /**
  55173. * Defines the name of the task
  55174. */
  55175. name: string,
  55176. /**
  55177. * Defines the list of mesh's names you want to load
  55178. */
  55179. meshesNames: any,
  55180. /**
  55181. * Defines the root url to use as a base to load your meshes and associated resources
  55182. */
  55183. rootUrl: string,
  55184. /**
  55185. * Defines the filename of the scene to load from
  55186. */
  55187. sceneFilename: string);
  55188. /**
  55189. * Execute the current task
  55190. * @param scene defines the scene where you want your assets to be loaded
  55191. * @param onSuccess is a callback called when the task is successfully executed
  55192. * @param onError is a callback called if an error occurs
  55193. */
  55194. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55195. }
  55196. /**
  55197. * Define a task used by AssetsManager to load text content
  55198. */
  55199. export class TextFileAssetTask extends AbstractAssetTask {
  55200. /**
  55201. * Defines the name of the task
  55202. */
  55203. name: string;
  55204. /**
  55205. * Defines the location of the file to load
  55206. */
  55207. url: string;
  55208. /**
  55209. * Gets the loaded text string
  55210. */
  55211. text: string;
  55212. /**
  55213. * Callback called when the task is successful
  55214. */
  55215. onSuccess: (task: TextFileAssetTask) => void;
  55216. /**
  55217. * Callback called when the task is successful
  55218. */
  55219. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  55220. /**
  55221. * Creates a new TextFileAssetTask object
  55222. * @param name defines the name of the task
  55223. * @param url defines the location of the file to load
  55224. */
  55225. constructor(
  55226. /**
  55227. * Defines the name of the task
  55228. */
  55229. name: string,
  55230. /**
  55231. * Defines the location of the file to load
  55232. */
  55233. url: string);
  55234. /**
  55235. * Execute the current task
  55236. * @param scene defines the scene where you want your assets to be loaded
  55237. * @param onSuccess is a callback called when the task is successfully executed
  55238. * @param onError is a callback called if an error occurs
  55239. */
  55240. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55241. }
  55242. /**
  55243. * Define a task used by AssetsManager to load binary data
  55244. */
  55245. export class BinaryFileAssetTask extends AbstractAssetTask {
  55246. /**
  55247. * Defines the name of the task
  55248. */
  55249. name: string;
  55250. /**
  55251. * Defines the location of the file to load
  55252. */
  55253. url: string;
  55254. /**
  55255. * Gets the lodaded data (as an array buffer)
  55256. */
  55257. data: ArrayBuffer;
  55258. /**
  55259. * Callback called when the task is successful
  55260. */
  55261. onSuccess: (task: BinaryFileAssetTask) => void;
  55262. /**
  55263. * Callback called when the task is successful
  55264. */
  55265. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  55266. /**
  55267. * Creates a new BinaryFileAssetTask object
  55268. * @param name defines the name of the new task
  55269. * @param url defines the location of the file to load
  55270. */
  55271. constructor(
  55272. /**
  55273. * Defines the name of the task
  55274. */
  55275. name: string,
  55276. /**
  55277. * Defines the location of the file to load
  55278. */
  55279. url: string);
  55280. /**
  55281. * Execute the current task
  55282. * @param scene defines the scene where you want your assets to be loaded
  55283. * @param onSuccess is a callback called when the task is successfully executed
  55284. * @param onError is a callback called if an error occurs
  55285. */
  55286. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55287. }
  55288. /**
  55289. * Define a task used by AssetsManager to load images
  55290. */
  55291. export class ImageAssetTask extends AbstractAssetTask {
  55292. /**
  55293. * Defines the name of the task
  55294. */
  55295. name: string;
  55296. /**
  55297. * Defines the location of the image to load
  55298. */
  55299. url: string;
  55300. /**
  55301. * Gets the loaded images
  55302. */
  55303. image: HTMLImageElement;
  55304. /**
  55305. * Callback called when the task is successful
  55306. */
  55307. onSuccess: (task: ImageAssetTask) => void;
  55308. /**
  55309. * Callback called when the task is successful
  55310. */
  55311. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  55312. /**
  55313. * Creates a new ImageAssetTask
  55314. * @param name defines the name of the task
  55315. * @param url defines the location of the image to load
  55316. */
  55317. constructor(
  55318. /**
  55319. * Defines the name of the task
  55320. */
  55321. name: string,
  55322. /**
  55323. * Defines the location of the image to load
  55324. */
  55325. url: string);
  55326. /**
  55327. * Execute the current task
  55328. * @param scene defines the scene where you want your assets to be loaded
  55329. * @param onSuccess is a callback called when the task is successfully executed
  55330. * @param onError is a callback called if an error occurs
  55331. */
  55332. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55333. }
  55334. /**
  55335. * Defines the interface used by texture loading tasks
  55336. */
  55337. export interface ITextureAssetTask<TEX extends BaseTexture> {
  55338. /**
  55339. * Gets the loaded texture
  55340. */
  55341. texture: TEX;
  55342. }
  55343. /**
  55344. * Define a task used by AssetsManager to load 2D textures
  55345. */
  55346. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  55347. /**
  55348. * Defines the name of the task
  55349. */
  55350. name: string;
  55351. /**
  55352. * Defines the location of the file to load
  55353. */
  55354. url: string;
  55355. /**
  55356. * Defines if mipmap should not be generated (default is false)
  55357. */
  55358. noMipmap?: boolean | undefined;
  55359. /**
  55360. * Defines if texture must be inverted on Y axis (default is false)
  55361. */
  55362. invertY?: boolean | undefined;
  55363. /**
  55364. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55365. */
  55366. samplingMode: number;
  55367. /**
  55368. * Gets the loaded texture
  55369. */
  55370. texture: Texture;
  55371. /**
  55372. * Callback called when the task is successful
  55373. */
  55374. onSuccess: (task: TextureAssetTask) => void;
  55375. /**
  55376. * Callback called when the task is successful
  55377. */
  55378. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  55379. /**
  55380. * Creates a new TextureAssetTask object
  55381. * @param name defines the name of the task
  55382. * @param url defines the location of the file to load
  55383. * @param noMipmap defines if mipmap should not be generated (default is false)
  55384. * @param invertY defines if texture must be inverted on Y axis (default is false)
  55385. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55386. */
  55387. constructor(
  55388. /**
  55389. * Defines the name of the task
  55390. */
  55391. name: string,
  55392. /**
  55393. * Defines the location of the file to load
  55394. */
  55395. url: string,
  55396. /**
  55397. * Defines if mipmap should not be generated (default is false)
  55398. */
  55399. noMipmap?: boolean | undefined,
  55400. /**
  55401. * Defines if texture must be inverted on Y axis (default is false)
  55402. */
  55403. invertY?: boolean | undefined,
  55404. /**
  55405. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55406. */
  55407. samplingMode?: number);
  55408. /**
  55409. * Execute the current task
  55410. * @param scene defines the scene where you want your assets to be loaded
  55411. * @param onSuccess is a callback called when the task is successfully executed
  55412. * @param onError is a callback called if an error occurs
  55413. */
  55414. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55415. }
  55416. /**
  55417. * Define a task used by AssetsManager to load cube textures
  55418. */
  55419. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  55420. /**
  55421. * Defines the name of the task
  55422. */
  55423. name: string;
  55424. /**
  55425. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55426. */
  55427. url: string;
  55428. /**
  55429. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55430. */
  55431. extensions?: string[] | undefined;
  55432. /**
  55433. * Defines if mipmaps should not be generated (default is false)
  55434. */
  55435. noMipmap?: boolean | undefined;
  55436. /**
  55437. * Defines the explicit list of files (undefined by default)
  55438. */
  55439. files?: string[] | undefined;
  55440. /**
  55441. * Gets the loaded texture
  55442. */
  55443. texture: CubeTexture;
  55444. /**
  55445. * Callback called when the task is successful
  55446. */
  55447. onSuccess: (task: CubeTextureAssetTask) => void;
  55448. /**
  55449. * Callback called when the task is successful
  55450. */
  55451. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  55452. /**
  55453. * Creates a new CubeTextureAssetTask
  55454. * @param name defines the name of the task
  55455. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55456. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55457. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55458. * @param files defines the explicit list of files (undefined by default)
  55459. */
  55460. constructor(
  55461. /**
  55462. * Defines the name of the task
  55463. */
  55464. name: string,
  55465. /**
  55466. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55467. */
  55468. url: string,
  55469. /**
  55470. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55471. */
  55472. extensions?: string[] | undefined,
  55473. /**
  55474. * Defines if mipmaps should not be generated (default is false)
  55475. */
  55476. noMipmap?: boolean | undefined,
  55477. /**
  55478. * Defines the explicit list of files (undefined by default)
  55479. */
  55480. files?: string[] | undefined);
  55481. /**
  55482. * Execute the current task
  55483. * @param scene defines the scene where you want your assets to be loaded
  55484. * @param onSuccess is a callback called when the task is successfully executed
  55485. * @param onError is a callback called if an error occurs
  55486. */
  55487. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55488. }
  55489. /**
  55490. * Define a task used by AssetsManager to load HDR cube textures
  55491. */
  55492. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  55493. /**
  55494. * Defines the name of the task
  55495. */
  55496. name: string;
  55497. /**
  55498. * Defines the location of the file to load
  55499. */
  55500. url: string;
  55501. /**
  55502. * Defines the desired size (the more it increases the longer the generation will be)
  55503. */
  55504. size: number;
  55505. /**
  55506. * Defines if mipmaps should not be generated (default is false)
  55507. */
  55508. noMipmap: boolean;
  55509. /**
  55510. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55511. */
  55512. generateHarmonics: boolean;
  55513. /**
  55514. * 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)
  55515. */
  55516. gammaSpace: boolean;
  55517. /**
  55518. * Internal Use Only
  55519. */
  55520. reserved: boolean;
  55521. /**
  55522. * Gets the loaded texture
  55523. */
  55524. texture: HDRCubeTexture;
  55525. /**
  55526. * Callback called when the task is successful
  55527. */
  55528. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  55529. /**
  55530. * Callback called when the task is successful
  55531. */
  55532. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  55533. /**
  55534. * Creates a new HDRCubeTextureAssetTask object
  55535. * @param name defines the name of the task
  55536. * @param url defines the location of the file to load
  55537. * @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.
  55538. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55539. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55540. * @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)
  55541. * @param reserved Internal use only
  55542. */
  55543. constructor(
  55544. /**
  55545. * Defines the name of the task
  55546. */
  55547. name: string,
  55548. /**
  55549. * Defines the location of the file to load
  55550. */
  55551. url: string,
  55552. /**
  55553. * Defines the desired size (the more it increases the longer the generation will be)
  55554. */
  55555. size: number,
  55556. /**
  55557. * Defines if mipmaps should not be generated (default is false)
  55558. */
  55559. noMipmap?: boolean,
  55560. /**
  55561. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55562. */
  55563. generateHarmonics?: boolean,
  55564. /**
  55565. * 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)
  55566. */
  55567. gammaSpace?: boolean,
  55568. /**
  55569. * Internal Use Only
  55570. */
  55571. reserved?: boolean);
  55572. /**
  55573. * Execute the current task
  55574. * @param scene defines the scene where you want your assets to be loaded
  55575. * @param onSuccess is a callback called when the task is successfully executed
  55576. * @param onError is a callback called if an error occurs
  55577. */
  55578. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55579. }
  55580. /**
  55581. * Define a task used by AssetsManager to load Equirectangular cube textures
  55582. */
  55583. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  55584. /**
  55585. * Defines the name of the task
  55586. */
  55587. name: string;
  55588. /**
  55589. * Defines the location of the file to load
  55590. */
  55591. url: string;
  55592. /**
  55593. * Defines the desired size (the more it increases the longer the generation will be)
  55594. */
  55595. size: number;
  55596. /**
  55597. * Defines if mipmaps should not be generated (default is false)
  55598. */
  55599. noMipmap: boolean;
  55600. /**
  55601. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  55602. * but the standard material would require them in Gamma space) (default is true)
  55603. */
  55604. gammaSpace: boolean;
  55605. /**
  55606. * Gets the loaded texture
  55607. */
  55608. texture: EquiRectangularCubeTexture;
  55609. /**
  55610. * Callback called when the task is successful
  55611. */
  55612. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  55613. /**
  55614. * Callback called when the task is successful
  55615. */
  55616. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  55617. /**
  55618. * Creates a new EquiRectangularCubeTextureAssetTask object
  55619. * @param name defines the name of the task
  55620. * @param url defines the location of the file to load
  55621. * @param size defines the desired size (the more it increases the longer the generation will be)
  55622. * If the size is omitted this implies you are using a preprocessed cubemap.
  55623. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55624. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  55625. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  55626. * (default is true)
  55627. */
  55628. constructor(
  55629. /**
  55630. * Defines the name of the task
  55631. */
  55632. name: string,
  55633. /**
  55634. * Defines the location of the file to load
  55635. */
  55636. url: string,
  55637. /**
  55638. * Defines the desired size (the more it increases the longer the generation will be)
  55639. */
  55640. size: number,
  55641. /**
  55642. * Defines if mipmaps should not be generated (default is false)
  55643. */
  55644. noMipmap?: boolean,
  55645. /**
  55646. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  55647. * but the standard material would require them in Gamma space) (default is true)
  55648. */
  55649. gammaSpace?: boolean);
  55650. /**
  55651. * Execute the current task
  55652. * @param scene defines the scene where you want your assets to be loaded
  55653. * @param onSuccess is a callback called when the task is successfully executed
  55654. * @param onError is a callback called if an error occurs
  55655. */
  55656. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55657. }
  55658. /**
  55659. * This class can be used to easily import assets into a scene
  55660. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  55661. */
  55662. export class AssetsManager {
  55663. private _scene;
  55664. private _isLoading;
  55665. protected _tasks: AbstractAssetTask[];
  55666. protected _waitingTasksCount: number;
  55667. protected _totalTasksCount: number;
  55668. /**
  55669. * Callback called when all tasks are processed
  55670. */
  55671. onFinish: (tasks: AbstractAssetTask[]) => void;
  55672. /**
  55673. * Callback called when a task is successful
  55674. */
  55675. onTaskSuccess: (task: AbstractAssetTask) => void;
  55676. /**
  55677. * Callback called when a task had an error
  55678. */
  55679. onTaskError: (task: AbstractAssetTask) => void;
  55680. /**
  55681. * Callback called when a task is done (whatever the result is)
  55682. */
  55683. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  55684. /**
  55685. * Observable called when all tasks are processed
  55686. */
  55687. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  55688. /**
  55689. * Observable called when a task had an error
  55690. */
  55691. onTaskErrorObservable: Observable<AbstractAssetTask>;
  55692. /**
  55693. * Observable called when all tasks were executed
  55694. */
  55695. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  55696. /**
  55697. * Observable called when a task is done (whatever the result is)
  55698. */
  55699. onProgressObservable: Observable<IAssetsProgressEvent>;
  55700. /**
  55701. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  55702. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  55703. */
  55704. useDefaultLoadingScreen: boolean;
  55705. /**
  55706. * Creates a new AssetsManager
  55707. * @param scene defines the scene to work on
  55708. */
  55709. constructor(scene: Scene);
  55710. /**
  55711. * Add a MeshAssetTask to the list of active tasks
  55712. * @param taskName defines the name of the new task
  55713. * @param meshesNames defines the name of meshes to load
  55714. * @param rootUrl defines the root url to use to locate files
  55715. * @param sceneFilename defines the filename of the scene file
  55716. * @returns a new MeshAssetTask object
  55717. */
  55718. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  55719. /**
  55720. * Add a TextFileAssetTask to the list of active tasks
  55721. * @param taskName defines the name of the new task
  55722. * @param url defines the url of the file to load
  55723. * @returns a new TextFileAssetTask object
  55724. */
  55725. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  55726. /**
  55727. * Add a BinaryFileAssetTask to the list of active tasks
  55728. * @param taskName defines the name of the new task
  55729. * @param url defines the url of the file to load
  55730. * @returns a new BinaryFileAssetTask object
  55731. */
  55732. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  55733. /**
  55734. * Add a ImageAssetTask to the list of active tasks
  55735. * @param taskName defines the name of the new task
  55736. * @param url defines the url of the file to load
  55737. * @returns a new ImageAssetTask object
  55738. */
  55739. addImageTask(taskName: string, url: string): ImageAssetTask;
  55740. /**
  55741. * Add a TextureAssetTask to the list of active tasks
  55742. * @param taskName defines the name of the new task
  55743. * @param url defines the url of the file to load
  55744. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55745. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  55746. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55747. * @returns a new TextureAssetTask object
  55748. */
  55749. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  55750. /**
  55751. * Add a CubeTextureAssetTask to the list of active tasks
  55752. * @param taskName defines the name of the new task
  55753. * @param url defines the url of the file to load
  55754. * @param extensions defines the extension to use to load the cube map (can be null)
  55755. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55756. * @param files defines the list of files to load (can be null)
  55757. * @returns a new CubeTextureAssetTask object
  55758. */
  55759. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  55760. /**
  55761. *
  55762. * Add a HDRCubeTextureAssetTask to the list of active tasks
  55763. * @param taskName defines the name of the new task
  55764. * @param url defines the url of the file to load
  55765. * @param size defines the size you want for the cubemap (can be null)
  55766. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55767. * @param generateHarmonics defines if you want to automatically generate (true by default)
  55768. * @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)
  55769. * @param reserved Internal use only
  55770. * @returns a new HDRCubeTextureAssetTask object
  55771. */
  55772. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  55773. /**
  55774. *
  55775. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  55776. * @param taskName defines the name of the new task
  55777. * @param url defines the url of the file to load
  55778. * @param size defines the size you want for the cubemap (can be null)
  55779. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55780. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55781. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55782. * @returns a new EquiRectangularCubeTextureAssetTask object
  55783. */
  55784. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  55785. /**
  55786. * Remove a task from the assets manager.
  55787. * @param task the task to remove
  55788. */
  55789. removeTask(task: AbstractAssetTask): void;
  55790. private _decreaseWaitingTasksCount;
  55791. private _runTask;
  55792. /**
  55793. * Reset the AssetsManager and remove all tasks
  55794. * @return the current instance of the AssetsManager
  55795. */
  55796. reset(): AssetsManager;
  55797. /**
  55798. * Start the loading process
  55799. * @return the current instance of the AssetsManager
  55800. */
  55801. load(): AssetsManager;
  55802. /**
  55803. * Start the loading process as an async operation
  55804. * @return a promise returning the list of failed tasks
  55805. */
  55806. loadAsync(): Promise<void>;
  55807. }
  55808. }
  55809. declare module BABYLON {
  55810. /**
  55811. * Wrapper class for promise with external resolve and reject.
  55812. */
  55813. export class Deferred<T> {
  55814. /**
  55815. * The promise associated with this deferred object.
  55816. */
  55817. readonly promise: Promise<T>;
  55818. private _resolve;
  55819. private _reject;
  55820. /**
  55821. * The resolve method of the promise associated with this deferred object.
  55822. */
  55823. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  55824. /**
  55825. * The reject method of the promise associated with this deferred object.
  55826. */
  55827. readonly reject: (reason?: any) => void;
  55828. /**
  55829. * Constructor for this deferred object.
  55830. */
  55831. constructor();
  55832. }
  55833. }
  55834. declare module BABYLON {
  55835. /**
  55836. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  55837. */
  55838. export class MeshExploder {
  55839. private _centerMesh;
  55840. private _meshes;
  55841. private _meshesOrigins;
  55842. private _toCenterVectors;
  55843. private _scaledDirection;
  55844. private _newPosition;
  55845. private _centerPosition;
  55846. /**
  55847. * Explodes meshes from a center mesh.
  55848. * @param meshes The meshes to explode.
  55849. * @param centerMesh The mesh to be center of explosion.
  55850. */
  55851. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  55852. private _setCenterMesh;
  55853. /**
  55854. * Get class name
  55855. * @returns "MeshExploder"
  55856. */
  55857. getClassName(): string;
  55858. /**
  55859. * "Exploded meshes"
  55860. * @returns Array of meshes with the centerMesh at index 0.
  55861. */
  55862. getMeshes(): Array<Mesh>;
  55863. /**
  55864. * Explodes meshes giving a specific direction
  55865. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  55866. */
  55867. explode(direction?: number): void;
  55868. }
  55869. }
  55870. declare module BABYLON {
  55871. /**
  55872. * Class used to help managing file picking and drag'n'drop
  55873. */
  55874. export class FilesInput {
  55875. /**
  55876. * List of files ready to be loaded
  55877. */
  55878. static readonly FilesToLoad: {
  55879. [key: string]: File;
  55880. };
  55881. /**
  55882. * Callback called when a file is processed
  55883. */
  55884. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  55885. private _engine;
  55886. private _currentScene;
  55887. private _sceneLoadedCallback;
  55888. private _progressCallback;
  55889. private _additionalRenderLoopLogicCallback;
  55890. private _textureLoadingCallback;
  55891. private _startingProcessingFilesCallback;
  55892. private _onReloadCallback;
  55893. private _errorCallback;
  55894. private _elementToMonitor;
  55895. private _sceneFileToLoad;
  55896. private _filesToLoad;
  55897. /**
  55898. * Creates a new FilesInput
  55899. * @param engine defines the rendering engine
  55900. * @param scene defines the hosting scene
  55901. * @param sceneLoadedCallback callback called when scene is loaded
  55902. * @param progressCallback callback called to track progress
  55903. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  55904. * @param textureLoadingCallback callback called when a texture is loading
  55905. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  55906. * @param onReloadCallback callback called when a reload is requested
  55907. * @param errorCallback callback call if an error occurs
  55908. */
  55909. 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);
  55910. private _dragEnterHandler;
  55911. private _dragOverHandler;
  55912. private _dropHandler;
  55913. /**
  55914. * Calls this function to listen to drag'n'drop events on a specific DOM element
  55915. * @param elementToMonitor defines the DOM element to track
  55916. */
  55917. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  55918. /**
  55919. * Release all associated resources
  55920. */
  55921. dispose(): void;
  55922. private renderFunction;
  55923. private drag;
  55924. private drop;
  55925. private _traverseFolder;
  55926. private _processFiles;
  55927. /**
  55928. * Load files from a drop event
  55929. * @param event defines the drop event to use as source
  55930. */
  55931. loadFiles(event: any): void;
  55932. private _processReload;
  55933. /**
  55934. * Reload the current scene from the loaded files
  55935. */
  55936. reload(): void;
  55937. }
  55938. }
  55939. declare module BABYLON {
  55940. /**
  55941. * Defines the root class used to create scene optimization to use with SceneOptimizer
  55942. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55943. */
  55944. export class SceneOptimization {
  55945. /**
  55946. * Defines the priority of this optimization (0 by default which means first in the list)
  55947. */
  55948. priority: number;
  55949. /**
  55950. * Gets a string describing the action executed by the current optimization
  55951. * @returns description string
  55952. */
  55953. getDescription(): string;
  55954. /**
  55955. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55956. * @param scene defines the current scene where to apply this optimization
  55957. * @param optimizer defines the current optimizer
  55958. * @returns true if everything that can be done was applied
  55959. */
  55960. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55961. /**
  55962. * Creates the SceneOptimization object
  55963. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55964. * @param desc defines the description associated with the optimization
  55965. */
  55966. constructor(
  55967. /**
  55968. * Defines the priority of this optimization (0 by default which means first in the list)
  55969. */
  55970. priority?: number);
  55971. }
  55972. /**
  55973. * Defines an optimization used to reduce the size of render target textures
  55974. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55975. */
  55976. export class TextureOptimization extends SceneOptimization {
  55977. /**
  55978. * Defines the priority of this optimization (0 by default which means first in the list)
  55979. */
  55980. priority: number;
  55981. /**
  55982. * 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
  55983. */
  55984. maximumSize: number;
  55985. /**
  55986. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55987. */
  55988. step: number;
  55989. /**
  55990. * Gets a string describing the action executed by the current optimization
  55991. * @returns description string
  55992. */
  55993. getDescription(): string;
  55994. /**
  55995. * Creates the TextureOptimization object
  55996. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55997. * @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
  55998. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55999. */
  56000. constructor(
  56001. /**
  56002. * Defines the priority of this optimization (0 by default which means first in the list)
  56003. */
  56004. priority?: number,
  56005. /**
  56006. * 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
  56007. */
  56008. maximumSize?: number,
  56009. /**
  56010. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56011. */
  56012. step?: number);
  56013. /**
  56014. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56015. * @param scene defines the current scene where to apply this optimization
  56016. * @param optimizer defines the current optimizer
  56017. * @returns true if everything that can be done was applied
  56018. */
  56019. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56020. }
  56021. /**
  56022. * Defines an optimization used to increase or decrease the rendering resolution
  56023. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56024. */
  56025. export class HardwareScalingOptimization extends SceneOptimization {
  56026. /**
  56027. * Defines the priority of this optimization (0 by default which means first in the list)
  56028. */
  56029. priority: number;
  56030. /**
  56031. * Defines the maximum scale to use (2 by default)
  56032. */
  56033. maximumScale: number;
  56034. /**
  56035. * Defines the step to use between two passes (0.5 by default)
  56036. */
  56037. step: number;
  56038. private _currentScale;
  56039. private _directionOffset;
  56040. /**
  56041. * Gets a string describing the action executed by the current optimization
  56042. * @return description string
  56043. */
  56044. getDescription(): string;
  56045. /**
  56046. * Creates the HardwareScalingOptimization object
  56047. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56048. * @param maximumScale defines the maximum scale to use (2 by default)
  56049. * @param step defines the step to use between two passes (0.5 by default)
  56050. */
  56051. constructor(
  56052. /**
  56053. * Defines the priority of this optimization (0 by default which means first in the list)
  56054. */
  56055. priority?: number,
  56056. /**
  56057. * Defines the maximum scale to use (2 by default)
  56058. */
  56059. maximumScale?: number,
  56060. /**
  56061. * Defines the step to use between two passes (0.5 by default)
  56062. */
  56063. step?: number);
  56064. /**
  56065. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56066. * @param scene defines the current scene where to apply this optimization
  56067. * @param optimizer defines the current optimizer
  56068. * @returns true if everything that can be done was applied
  56069. */
  56070. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56071. }
  56072. /**
  56073. * Defines an optimization used to remove shadows
  56074. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56075. */
  56076. export class ShadowsOptimization extends SceneOptimization {
  56077. /**
  56078. * Gets a string describing the action executed by the current optimization
  56079. * @return description string
  56080. */
  56081. getDescription(): string;
  56082. /**
  56083. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56084. * @param scene defines the current scene where to apply this optimization
  56085. * @param optimizer defines the current optimizer
  56086. * @returns true if everything that can be done was applied
  56087. */
  56088. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56089. }
  56090. /**
  56091. * Defines an optimization used to turn post-processes off
  56092. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56093. */
  56094. export class PostProcessesOptimization extends SceneOptimization {
  56095. /**
  56096. * Gets a string describing the action executed by the current optimization
  56097. * @return description string
  56098. */
  56099. getDescription(): string;
  56100. /**
  56101. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56102. * @param scene defines the current scene where to apply this optimization
  56103. * @param optimizer defines the current optimizer
  56104. * @returns true if everything that can be done was applied
  56105. */
  56106. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56107. }
  56108. /**
  56109. * Defines an optimization used to turn lens flares off
  56110. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56111. */
  56112. export class LensFlaresOptimization extends SceneOptimization {
  56113. /**
  56114. * Gets a string describing the action executed by the current optimization
  56115. * @return description string
  56116. */
  56117. getDescription(): string;
  56118. /**
  56119. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56120. * @param scene defines the current scene where to apply this optimization
  56121. * @param optimizer defines the current optimizer
  56122. * @returns true if everything that can be done was applied
  56123. */
  56124. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56125. }
  56126. /**
  56127. * Defines an optimization based on user defined callback.
  56128. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56129. */
  56130. export class CustomOptimization extends SceneOptimization {
  56131. /**
  56132. * Callback called to apply the custom optimization.
  56133. */
  56134. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  56135. /**
  56136. * Callback called to get custom description
  56137. */
  56138. onGetDescription: () => string;
  56139. /**
  56140. * Gets a string describing the action executed by the current optimization
  56141. * @returns description string
  56142. */
  56143. getDescription(): string;
  56144. /**
  56145. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56146. * @param scene defines the current scene where to apply this optimization
  56147. * @param optimizer defines the current optimizer
  56148. * @returns true if everything that can be done was applied
  56149. */
  56150. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56151. }
  56152. /**
  56153. * Defines an optimization used to turn particles off
  56154. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56155. */
  56156. export class ParticlesOptimization extends SceneOptimization {
  56157. /**
  56158. * Gets a string describing the action executed by the current optimization
  56159. * @return description string
  56160. */
  56161. getDescription(): string;
  56162. /**
  56163. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56164. * @param scene defines the current scene where to apply this optimization
  56165. * @param optimizer defines the current optimizer
  56166. * @returns true if everything that can be done was applied
  56167. */
  56168. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56169. }
  56170. /**
  56171. * Defines an optimization used to turn render targets off
  56172. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56173. */
  56174. export class RenderTargetsOptimization extends SceneOptimization {
  56175. /**
  56176. * Gets a string describing the action executed by the current optimization
  56177. * @return description string
  56178. */
  56179. getDescription(): string;
  56180. /**
  56181. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56182. * @param scene defines the current scene where to apply this optimization
  56183. * @param optimizer defines the current optimizer
  56184. * @returns true if everything that can be done was applied
  56185. */
  56186. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56187. }
  56188. /**
  56189. * Defines an optimization used to merge meshes with compatible materials
  56190. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56191. */
  56192. export class MergeMeshesOptimization extends SceneOptimization {
  56193. private static _UpdateSelectionTree;
  56194. /**
  56195. * Gets or sets a boolean which defines if optimization octree has to be updated
  56196. */
  56197. /**
  56198. * Gets or sets a boolean which defines if optimization octree has to be updated
  56199. */
  56200. static UpdateSelectionTree: boolean;
  56201. /**
  56202. * Gets a string describing the action executed by the current optimization
  56203. * @return description string
  56204. */
  56205. getDescription(): string;
  56206. private _canBeMerged;
  56207. /**
  56208. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56209. * @param scene defines the current scene where to apply this optimization
  56210. * @param optimizer defines the current optimizer
  56211. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  56212. * @returns true if everything that can be done was applied
  56213. */
  56214. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  56215. }
  56216. /**
  56217. * Defines a list of options used by SceneOptimizer
  56218. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56219. */
  56220. export class SceneOptimizerOptions {
  56221. /**
  56222. * Defines the target frame rate to reach (60 by default)
  56223. */
  56224. targetFrameRate: number;
  56225. /**
  56226. * Defines the interval between two checkes (2000ms by default)
  56227. */
  56228. trackerDuration: number;
  56229. /**
  56230. * Gets the list of optimizations to apply
  56231. */
  56232. optimizations: SceneOptimization[];
  56233. /**
  56234. * Creates a new list of options used by SceneOptimizer
  56235. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  56236. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  56237. */
  56238. constructor(
  56239. /**
  56240. * Defines the target frame rate to reach (60 by default)
  56241. */
  56242. targetFrameRate?: number,
  56243. /**
  56244. * Defines the interval between two checkes (2000ms by default)
  56245. */
  56246. trackerDuration?: number);
  56247. /**
  56248. * Add a new optimization
  56249. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  56250. * @returns the current SceneOptimizerOptions
  56251. */
  56252. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  56253. /**
  56254. * Add a new custom optimization
  56255. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  56256. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  56257. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56258. * @returns the current SceneOptimizerOptions
  56259. */
  56260. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  56261. /**
  56262. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  56263. * @param targetFrameRate defines the target frame rate (60 by default)
  56264. * @returns a SceneOptimizerOptions object
  56265. */
  56266. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56267. /**
  56268. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  56269. * @param targetFrameRate defines the target frame rate (60 by default)
  56270. * @returns a SceneOptimizerOptions object
  56271. */
  56272. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56273. /**
  56274. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  56275. * @param targetFrameRate defines the target frame rate (60 by default)
  56276. * @returns a SceneOptimizerOptions object
  56277. */
  56278. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56279. }
  56280. /**
  56281. * Class used to run optimizations in order to reach a target frame rate
  56282. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56283. */
  56284. export class SceneOptimizer implements IDisposable {
  56285. private _isRunning;
  56286. private _options;
  56287. private _scene;
  56288. private _currentPriorityLevel;
  56289. private _targetFrameRate;
  56290. private _trackerDuration;
  56291. private _currentFrameRate;
  56292. private _sceneDisposeObserver;
  56293. private _improvementMode;
  56294. /**
  56295. * Defines an observable called when the optimizer reaches the target frame rate
  56296. */
  56297. onSuccessObservable: Observable<SceneOptimizer>;
  56298. /**
  56299. * Defines an observable called when the optimizer enables an optimization
  56300. */
  56301. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  56302. /**
  56303. * Defines an observable called when the optimizer is not able to reach the target frame rate
  56304. */
  56305. onFailureObservable: Observable<SceneOptimizer>;
  56306. /**
  56307. * Gets a boolean indicating if the optimizer is in improvement mode
  56308. */
  56309. readonly isInImprovementMode: boolean;
  56310. /**
  56311. * Gets the current priority level (0 at start)
  56312. */
  56313. readonly currentPriorityLevel: number;
  56314. /**
  56315. * Gets the current frame rate checked by the SceneOptimizer
  56316. */
  56317. readonly currentFrameRate: number;
  56318. /**
  56319. * Gets or sets the current target frame rate (60 by default)
  56320. */
  56321. /**
  56322. * Gets or sets the current target frame rate (60 by default)
  56323. */
  56324. targetFrameRate: number;
  56325. /**
  56326. * Gets or sets the current interval between two checks (every 2000ms by default)
  56327. */
  56328. /**
  56329. * Gets or sets the current interval between two checks (every 2000ms by default)
  56330. */
  56331. trackerDuration: number;
  56332. /**
  56333. * Gets the list of active optimizations
  56334. */
  56335. readonly optimizations: SceneOptimization[];
  56336. /**
  56337. * Creates a new SceneOptimizer
  56338. * @param scene defines the scene to work on
  56339. * @param options defines the options to use with the SceneOptimizer
  56340. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  56341. * @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)
  56342. */
  56343. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  56344. /**
  56345. * Stops the current optimizer
  56346. */
  56347. stop(): void;
  56348. /**
  56349. * Reset the optimizer to initial step (current priority level = 0)
  56350. */
  56351. reset(): void;
  56352. /**
  56353. * Start the optimizer. By default it will try to reach a specific framerate
  56354. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  56355. */
  56356. start(): void;
  56357. private _checkCurrentState;
  56358. /**
  56359. * Release all resources
  56360. */
  56361. dispose(): void;
  56362. /**
  56363. * Helper function to create a SceneOptimizer with one single line of code
  56364. * @param scene defines the scene to work on
  56365. * @param options defines the options to use with the SceneOptimizer
  56366. * @param onSuccess defines a callback to call on success
  56367. * @param onFailure defines a callback to call on failure
  56368. * @returns the new SceneOptimizer object
  56369. */
  56370. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  56371. }
  56372. }
  56373. declare module BABYLON {
  56374. /**
  56375. * Class used to serialize a scene into a string
  56376. */
  56377. export class SceneSerializer {
  56378. /**
  56379. * Clear cache used by a previous serialization
  56380. */
  56381. static ClearCache(): void;
  56382. /**
  56383. * Serialize a scene into a JSON compatible object
  56384. * @param scene defines the scene to serialize
  56385. * @returns a JSON compatible object
  56386. */
  56387. static Serialize(scene: Scene): any;
  56388. /**
  56389. * Serialize a mesh into a JSON compatible object
  56390. * @param toSerialize defines the mesh to serialize
  56391. * @param withParents defines if parents must be serialized as well
  56392. * @param withChildren defines if children must be serialized as well
  56393. * @returns a JSON compatible object
  56394. */
  56395. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  56396. }
  56397. }
  56398. declare module BABYLON {
  56399. /**
  56400. * Class used to host texture specific utilities
  56401. */
  56402. export class TextureTools {
  56403. /**
  56404. * Uses the GPU to create a copy texture rescaled at a given size
  56405. * @param texture Texture to copy from
  56406. * @param width defines the desired width
  56407. * @param height defines the desired height
  56408. * @param useBilinearMode defines if bilinear mode has to be used
  56409. * @return the generated texture
  56410. */
  56411. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  56412. }
  56413. }
  56414. declare module BABYLON {
  56415. /**
  56416. * This represents the different options avilable for the video capture.
  56417. */
  56418. export interface VideoRecorderOptions {
  56419. /** Defines the mime type of the video */
  56420. mimeType: string;
  56421. /** Defines the video the video should be recorded at */
  56422. fps: number;
  56423. /** Defines the chunk size for the recording data */
  56424. recordChunckSize: number;
  56425. /** The audio tracks to attach to the record */
  56426. audioTracks?: MediaStreamTrack[];
  56427. }
  56428. /**
  56429. * This can helps recording videos from BabylonJS.
  56430. * This is based on the available WebRTC functionalities of the browser.
  56431. *
  56432. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  56433. */
  56434. export class VideoRecorder {
  56435. private static readonly _defaultOptions;
  56436. /**
  56437. * Returns wehther or not the VideoRecorder is available in your browser.
  56438. * @param engine Defines the Babylon Engine to check the support for
  56439. * @returns true if supported otherwise false
  56440. */
  56441. static IsSupported(engine: Engine): boolean;
  56442. private readonly _options;
  56443. private _canvas;
  56444. private _mediaRecorder;
  56445. private _recordedChunks;
  56446. private _fileName;
  56447. private _resolve;
  56448. private _reject;
  56449. /**
  56450. * True wether a recording is already in progress.
  56451. */
  56452. readonly isRecording: boolean;
  56453. /**
  56454. * Create a new VideoCapture object which can help converting what you see in Babylon to
  56455. * a video file.
  56456. * @param engine Defines the BabylonJS Engine you wish to record
  56457. * @param options Defines options that can be used to customized the capture
  56458. */
  56459. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  56460. /**
  56461. * Stops the current recording before the default capture timeout passed in the startRecording
  56462. * functions.
  56463. */
  56464. stopRecording(): void;
  56465. /**
  56466. * Starts recording the canvas for a max duration specified in parameters.
  56467. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  56468. * @param maxDuration Defines the maximum recording time in seconds.
  56469. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  56470. * @return a promise callback at the end of the recording with the video data in Blob.
  56471. */
  56472. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  56473. /**
  56474. * Releases internal resources used during the recording.
  56475. */
  56476. dispose(): void;
  56477. private _handleDataAvailable;
  56478. private _handleError;
  56479. private _handleStop;
  56480. }
  56481. }
  56482. declare module BABYLON {
  56483. /**
  56484. * Class containing a set of static utilities functions for screenshots
  56485. */
  56486. export class ScreenshotTools {
  56487. /**
  56488. * Captures a screenshot of the current rendering
  56489. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56490. * @param engine defines the rendering engine
  56491. * @param camera defines the source camera
  56492. * @param size This parameter can be set to a single number or to an object with the
  56493. * following (optional) properties: precision, width, height. If a single number is passed,
  56494. * it will be used for both width and height. If an object is passed, the screenshot size
  56495. * will be derived from the parameters. The precision property is a multiplier allowing
  56496. * rendering at a higher or lower resolution
  56497. * @param successCallback defines the callback receives a single parameter which contains the
  56498. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56499. * src parameter of an <img> to display it
  56500. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  56501. * Check your browser for supported MIME types
  56502. */
  56503. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  56504. /**
  56505. * Generates an image screenshot from the specified camera.
  56506. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56507. * @param engine The engine to use for rendering
  56508. * @param camera The camera to use for rendering
  56509. * @param size This parameter can be set to a single number or to an object with the
  56510. * following (optional) properties: precision, width, height. If a single number is passed,
  56511. * it will be used for both width and height. If an object is passed, the screenshot size
  56512. * will be derived from the parameters. The precision property is a multiplier allowing
  56513. * rendering at a higher or lower resolution
  56514. * @param successCallback The callback receives a single parameter which contains the
  56515. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56516. * src parameter of an <img> to display it
  56517. * @param mimeType The MIME type of the screenshot image (default: image/png).
  56518. * Check your browser for supported MIME types
  56519. * @param samples Texture samples (default: 1)
  56520. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  56521. * @param fileName A name for for the downloaded file.
  56522. */
  56523. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  56524. }
  56525. }
  56526. declare module BABYLON {
  56527. /**
  56528. * A cursor which tracks a point on a path
  56529. */
  56530. export class PathCursor {
  56531. private path;
  56532. /**
  56533. * Stores path cursor callbacks for when an onchange event is triggered
  56534. */
  56535. private _onchange;
  56536. /**
  56537. * The value of the path cursor
  56538. */
  56539. value: number;
  56540. /**
  56541. * The animation array of the path cursor
  56542. */
  56543. animations: Animation[];
  56544. /**
  56545. * Initializes the path cursor
  56546. * @param path The path to track
  56547. */
  56548. constructor(path: Path2);
  56549. /**
  56550. * Gets the cursor point on the path
  56551. * @returns A point on the path cursor at the cursor location
  56552. */
  56553. getPoint(): Vector3;
  56554. /**
  56555. * Moves the cursor ahead by the step amount
  56556. * @param step The amount to move the cursor forward
  56557. * @returns This path cursor
  56558. */
  56559. moveAhead(step?: number): PathCursor;
  56560. /**
  56561. * Moves the cursor behind by the step amount
  56562. * @param step The amount to move the cursor back
  56563. * @returns This path cursor
  56564. */
  56565. moveBack(step?: number): PathCursor;
  56566. /**
  56567. * Moves the cursor by the step amount
  56568. * If the step amount is greater than one, an exception is thrown
  56569. * @param step The amount to move the cursor
  56570. * @returns This path cursor
  56571. */
  56572. move(step: number): PathCursor;
  56573. /**
  56574. * Ensures that the value is limited between zero and one
  56575. * @returns This path cursor
  56576. */
  56577. private ensureLimits;
  56578. /**
  56579. * Runs onchange callbacks on change (used by the animation engine)
  56580. * @returns This path cursor
  56581. */
  56582. private raiseOnChange;
  56583. /**
  56584. * Executes a function on change
  56585. * @param f A path cursor onchange callback
  56586. * @returns This path cursor
  56587. */
  56588. onchange(f: (cursor: PathCursor) => void): PathCursor;
  56589. }
  56590. }
  56591. declare module BABYLON {
  56592. /** @hidden */
  56593. export var blurPixelShader: {
  56594. name: string;
  56595. shader: string;
  56596. };
  56597. }
  56598. declare module BABYLON {
  56599. /** @hidden */
  56600. export var bones300Declaration: {
  56601. name: string;
  56602. shader: string;
  56603. };
  56604. }
  56605. declare module BABYLON {
  56606. /** @hidden */
  56607. export var instances300Declaration: {
  56608. name: string;
  56609. shader: string;
  56610. };
  56611. }
  56612. declare module BABYLON {
  56613. /** @hidden */
  56614. export var pointCloudVertexDeclaration: {
  56615. name: string;
  56616. shader: string;
  56617. };
  56618. }
  56619. // Mixins
  56620. interface Window {
  56621. mozIndexedDB: IDBFactory;
  56622. webkitIndexedDB: IDBFactory;
  56623. msIndexedDB: IDBFactory;
  56624. webkitURL: typeof URL;
  56625. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  56626. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  56627. WebGLRenderingContext: WebGLRenderingContext;
  56628. MSGesture: MSGesture;
  56629. CANNON: any;
  56630. AudioContext: AudioContext;
  56631. webkitAudioContext: AudioContext;
  56632. PointerEvent: any;
  56633. Math: Math;
  56634. Uint8Array: Uint8ArrayConstructor;
  56635. Float32Array: Float32ArrayConstructor;
  56636. mozURL: typeof URL;
  56637. msURL: typeof URL;
  56638. VRFrameData: any; // WebVR, from specs 1.1
  56639. DracoDecoderModule: any;
  56640. setImmediate(handler: (...args: any[]) => void): number;
  56641. }
  56642. interface HTMLCanvasElement {
  56643. requestPointerLock(): void;
  56644. msRequestPointerLock?(): void;
  56645. mozRequestPointerLock?(): void;
  56646. webkitRequestPointerLock?(): void;
  56647. /** Track wether a record is in progress */
  56648. isRecording: boolean;
  56649. /** Capture Stream method defined by some browsers */
  56650. captureStream(fps?: number): MediaStream;
  56651. }
  56652. interface CanvasRenderingContext2D {
  56653. msImageSmoothingEnabled: boolean;
  56654. }
  56655. interface MouseEvent {
  56656. mozMovementX: number;
  56657. mozMovementY: number;
  56658. webkitMovementX: number;
  56659. webkitMovementY: number;
  56660. msMovementX: number;
  56661. msMovementY: number;
  56662. }
  56663. interface Navigator {
  56664. mozGetVRDevices: (any: any) => any;
  56665. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56666. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56667. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56668. webkitGetGamepads(): Gamepad[];
  56669. msGetGamepads(): Gamepad[];
  56670. webkitGamepads(): Gamepad[];
  56671. }
  56672. interface HTMLVideoElement {
  56673. mozSrcObject: any;
  56674. }
  56675. interface Math {
  56676. fround(x: number): number;
  56677. imul(a: number, b: number): number;
  56678. }
  56679. interface WebGLRenderingContext {
  56680. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  56681. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  56682. vertexAttribDivisor(index: number, divisor: number): void;
  56683. createVertexArray(): any;
  56684. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  56685. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  56686. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  56687. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  56688. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  56689. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  56690. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  56691. // Queries
  56692. createQuery(): WebGLQuery;
  56693. deleteQuery(query: WebGLQuery): void;
  56694. beginQuery(target: number, query: WebGLQuery): void;
  56695. endQuery(target: number): void;
  56696. getQueryParameter(query: WebGLQuery, pname: number): any;
  56697. getQuery(target: number, pname: number): any;
  56698. MAX_SAMPLES: number;
  56699. RGBA8: number;
  56700. READ_FRAMEBUFFER: number;
  56701. DRAW_FRAMEBUFFER: number;
  56702. UNIFORM_BUFFER: number;
  56703. HALF_FLOAT_OES: number;
  56704. RGBA16F: number;
  56705. RGBA32F: number;
  56706. R32F: number;
  56707. RG32F: number;
  56708. RGB32F: number;
  56709. R16F: number;
  56710. RG16F: number;
  56711. RGB16F: number;
  56712. RED: number;
  56713. RG: number;
  56714. R8: number;
  56715. RG8: number;
  56716. UNSIGNED_INT_24_8: number;
  56717. DEPTH24_STENCIL8: number;
  56718. /* Multiple Render Targets */
  56719. drawBuffers(buffers: number[]): void;
  56720. readBuffer(src: number): void;
  56721. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  56722. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  56723. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  56724. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  56725. // Occlusion Query
  56726. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  56727. ANY_SAMPLES_PASSED: number;
  56728. QUERY_RESULT_AVAILABLE: number;
  56729. QUERY_RESULT: number;
  56730. }
  56731. interface WebGLProgram {
  56732. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  56733. }
  56734. interface EXT_disjoint_timer_query {
  56735. QUERY_COUNTER_BITS_EXT: number;
  56736. TIME_ELAPSED_EXT: number;
  56737. TIMESTAMP_EXT: number;
  56738. GPU_DISJOINT_EXT: number;
  56739. QUERY_RESULT_EXT: number;
  56740. QUERY_RESULT_AVAILABLE_EXT: number;
  56741. queryCounterEXT(query: WebGLQuery, target: number): void;
  56742. createQueryEXT(): WebGLQuery;
  56743. beginQueryEXT(target: number, query: WebGLQuery): void;
  56744. endQueryEXT(target: number): void;
  56745. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  56746. deleteQueryEXT(query: WebGLQuery): void;
  56747. }
  56748. interface WebGLUniformLocation {
  56749. _currentState: any;
  56750. }
  56751. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  56752. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  56753. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  56754. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56755. interface WebGLRenderingContext {
  56756. readonly RASTERIZER_DISCARD: number;
  56757. readonly DEPTH_COMPONENT24: number;
  56758. readonly TEXTURE_3D: number;
  56759. readonly TEXTURE_2D_ARRAY: number;
  56760. readonly TEXTURE_COMPARE_FUNC: number;
  56761. readonly TEXTURE_COMPARE_MODE: number;
  56762. readonly COMPARE_REF_TO_TEXTURE: number;
  56763. readonly TEXTURE_WRAP_R: number;
  56764. readonly HALF_FLOAT: number;
  56765. readonly RGB8: number;
  56766. readonly RED_INTEGER: number;
  56767. readonly RG_INTEGER: number;
  56768. readonly RGB_INTEGER: number;
  56769. readonly RGBA_INTEGER: number;
  56770. readonly R8_SNORM: number;
  56771. readonly RG8_SNORM: number;
  56772. readonly RGB8_SNORM: number;
  56773. readonly RGBA8_SNORM: number;
  56774. readonly R8I: number;
  56775. readonly RG8I: number;
  56776. readonly RGB8I: number;
  56777. readonly RGBA8I: number;
  56778. readonly R8UI: number;
  56779. readonly RG8UI: number;
  56780. readonly RGB8UI: number;
  56781. readonly RGBA8UI: number;
  56782. readonly R16I: number;
  56783. readonly RG16I: number;
  56784. readonly RGB16I: number;
  56785. readonly RGBA16I: number;
  56786. readonly R16UI: number;
  56787. readonly RG16UI: number;
  56788. readonly RGB16UI: number;
  56789. readonly RGBA16UI: number;
  56790. readonly R32I: number;
  56791. readonly RG32I: number;
  56792. readonly RGB32I: number;
  56793. readonly RGBA32I: number;
  56794. readonly R32UI: number;
  56795. readonly RG32UI: number;
  56796. readonly RGB32UI: number;
  56797. readonly RGBA32UI: number;
  56798. readonly RGB10_A2UI: number;
  56799. readonly R11F_G11F_B10F: number;
  56800. readonly RGB9_E5: number;
  56801. readonly RGB10_A2: number;
  56802. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  56803. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  56804. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  56805. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  56806. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  56807. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  56808. 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;
  56809. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  56810. readonly TRANSFORM_FEEDBACK: number;
  56811. readonly INTERLEAVED_ATTRIBS: number;
  56812. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  56813. createTransformFeedback(): WebGLTransformFeedback;
  56814. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  56815. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  56816. beginTransformFeedback(primitiveMode: number): void;
  56817. endTransformFeedback(): void;
  56818. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  56819. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56820. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56821. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56822. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  56823. }
  56824. interface ImageBitmap {
  56825. readonly width: number;
  56826. readonly height: number;
  56827. close(): void;
  56828. }
  56829. interface WebGLQuery extends WebGLObject {
  56830. }
  56831. declare var WebGLQuery: {
  56832. prototype: WebGLQuery;
  56833. new(): WebGLQuery;
  56834. };
  56835. interface WebGLSampler extends WebGLObject {
  56836. }
  56837. declare var WebGLSampler: {
  56838. prototype: WebGLSampler;
  56839. new(): WebGLSampler;
  56840. };
  56841. interface WebGLSync extends WebGLObject {
  56842. }
  56843. declare var WebGLSync: {
  56844. prototype: WebGLSync;
  56845. new(): WebGLSync;
  56846. };
  56847. interface WebGLTransformFeedback extends WebGLObject {
  56848. }
  56849. declare var WebGLTransformFeedback: {
  56850. prototype: WebGLTransformFeedback;
  56851. new(): WebGLTransformFeedback;
  56852. };
  56853. interface WebGLVertexArrayObject extends WebGLObject {
  56854. }
  56855. declare var WebGLVertexArrayObject: {
  56856. prototype: WebGLVertexArrayObject;
  56857. new(): WebGLVertexArrayObject;
  56858. };
  56859. // Type definitions for WebVR API
  56860. // Project: https://w3c.github.io/webvr/
  56861. // Definitions by: six a <https://github.com/lostfictions>
  56862. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56863. interface VRDisplay extends EventTarget {
  56864. /**
  56865. * Dictionary of capabilities describing the VRDisplay.
  56866. */
  56867. readonly capabilities: VRDisplayCapabilities;
  56868. /**
  56869. * z-depth defining the far plane of the eye view frustum
  56870. * enables mapping of values in the render target depth
  56871. * attachment to scene coordinates. Initially set to 10000.0.
  56872. */
  56873. depthFar: number;
  56874. /**
  56875. * z-depth defining the near plane of the eye view frustum
  56876. * enables mapping of values in the render target depth
  56877. * attachment to scene coordinates. Initially set to 0.01.
  56878. */
  56879. depthNear: number;
  56880. /**
  56881. * An identifier for this distinct VRDisplay. Used as an
  56882. * association point in the Gamepad API.
  56883. */
  56884. readonly displayId: number;
  56885. /**
  56886. * A display name, a user-readable name identifying it.
  56887. */
  56888. readonly displayName: string;
  56889. readonly isConnected: boolean;
  56890. readonly isPresenting: boolean;
  56891. /**
  56892. * If this VRDisplay supports room-scale experiences, the optional
  56893. * stage attribute contains details on the room-scale parameters.
  56894. */
  56895. readonly stageParameters: VRStageParameters | null;
  56896. /**
  56897. * Passing the value returned by `requestAnimationFrame` to
  56898. * `cancelAnimationFrame` will unregister the callback.
  56899. * @param handle Define the hanle of the request to cancel
  56900. */
  56901. cancelAnimationFrame(handle: number): void;
  56902. /**
  56903. * Stops presenting to the VRDisplay.
  56904. * @returns a promise to know when it stopped
  56905. */
  56906. exitPresent(): Promise<void>;
  56907. /**
  56908. * Return the current VREyeParameters for the given eye.
  56909. * @param whichEye Define the eye we want the parameter for
  56910. * @returns the eye parameters
  56911. */
  56912. getEyeParameters(whichEye: string): VREyeParameters;
  56913. /**
  56914. * Populates the passed VRFrameData with the information required to render
  56915. * the current frame.
  56916. * @param frameData Define the data structure to populate
  56917. * @returns true if ok otherwise false
  56918. */
  56919. getFrameData(frameData: VRFrameData): boolean;
  56920. /**
  56921. * Get the layers currently being presented.
  56922. * @returns the list of VR layers
  56923. */
  56924. getLayers(): VRLayer[];
  56925. /**
  56926. * Return a VRPose containing the future predicted pose of the VRDisplay
  56927. * when the current frame will be presented. The value returned will not
  56928. * change until JavaScript has returned control to the browser.
  56929. *
  56930. * The VRPose will contain the position, orientation, velocity,
  56931. * and acceleration of each of these properties.
  56932. * @returns the pose object
  56933. */
  56934. getPose(): VRPose;
  56935. /**
  56936. * Return the current instantaneous pose of the VRDisplay, with no
  56937. * prediction applied.
  56938. * @returns the current instantaneous pose
  56939. */
  56940. getImmediatePose(): VRPose;
  56941. /**
  56942. * The callback passed to `requestAnimationFrame` will be called
  56943. * any time a new frame should be rendered. When the VRDisplay is
  56944. * presenting the callback will be called at the native refresh
  56945. * rate of the HMD. When not presenting this function acts
  56946. * identically to how window.requestAnimationFrame acts. Content should
  56947. * make no assumptions of frame rate or vsync behavior as the HMD runs
  56948. * asynchronously from other displays and at differing refresh rates.
  56949. * @param callback Define the eaction to run next frame
  56950. * @returns the request handle it
  56951. */
  56952. requestAnimationFrame(callback: FrameRequestCallback): number;
  56953. /**
  56954. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  56955. * Repeat calls while already presenting will update the VRLayers being displayed.
  56956. * @param layers Define the list of layer to present
  56957. * @returns a promise to know when the request has been fulfilled
  56958. */
  56959. requestPresent(layers: VRLayer[]): Promise<void>;
  56960. /**
  56961. * Reset the pose for this display, treating its current position and
  56962. * orientation as the "origin/zero" values. VRPose.position,
  56963. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  56964. * updated when calling resetPose(). This should be called in only
  56965. * sitting-space experiences.
  56966. */
  56967. resetPose(): void;
  56968. /**
  56969. * The VRLayer provided to the VRDisplay will be captured and presented
  56970. * in the HMD. Calling this function has the same effect on the source
  56971. * canvas as any other operation that uses its source image, and canvases
  56972. * created without preserveDrawingBuffer set to true will be cleared.
  56973. * @param pose Define the pose to submit
  56974. */
  56975. submitFrame(pose?: VRPose): void;
  56976. }
  56977. declare var VRDisplay: {
  56978. prototype: VRDisplay;
  56979. new(): VRDisplay;
  56980. };
  56981. interface VRLayer {
  56982. leftBounds?: number[] | Float32Array | null;
  56983. rightBounds?: number[] | Float32Array | null;
  56984. source?: HTMLCanvasElement | null;
  56985. }
  56986. interface VRDisplayCapabilities {
  56987. readonly canPresent: boolean;
  56988. readonly hasExternalDisplay: boolean;
  56989. readonly hasOrientation: boolean;
  56990. readonly hasPosition: boolean;
  56991. readonly maxLayers: number;
  56992. }
  56993. interface VREyeParameters {
  56994. /** @deprecated */
  56995. readonly fieldOfView: VRFieldOfView;
  56996. readonly offset: Float32Array;
  56997. readonly renderHeight: number;
  56998. readonly renderWidth: number;
  56999. }
  57000. interface VRFieldOfView {
  57001. readonly downDegrees: number;
  57002. readonly leftDegrees: number;
  57003. readonly rightDegrees: number;
  57004. readonly upDegrees: number;
  57005. }
  57006. interface VRFrameData {
  57007. readonly leftProjectionMatrix: Float32Array;
  57008. readonly leftViewMatrix: Float32Array;
  57009. readonly pose: VRPose;
  57010. readonly rightProjectionMatrix: Float32Array;
  57011. readonly rightViewMatrix: Float32Array;
  57012. readonly timestamp: number;
  57013. }
  57014. interface VRPose {
  57015. readonly angularAcceleration: Float32Array | null;
  57016. readonly angularVelocity: Float32Array | null;
  57017. readonly linearAcceleration: Float32Array | null;
  57018. readonly linearVelocity: Float32Array | null;
  57019. readonly orientation: Float32Array | null;
  57020. readonly position: Float32Array | null;
  57021. readonly timestamp: number;
  57022. }
  57023. interface VRStageParameters {
  57024. sittingToStandingTransform?: Float32Array;
  57025. sizeX?: number;
  57026. sizeY?: number;
  57027. }
  57028. interface Navigator {
  57029. getVRDisplays(): Promise<VRDisplay[]>;
  57030. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  57031. }
  57032. interface Window {
  57033. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  57034. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  57035. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  57036. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57037. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57038. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  57039. }
  57040. interface Gamepad {
  57041. readonly displayId: number;
  57042. }
  57043. interface XRDevice {
  57044. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  57045. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  57046. }
  57047. interface XRSession {
  57048. getInputSources(): Array<any>;
  57049. baseLayer: XRWebGLLayer;
  57050. requestFrameOfReference(type: string): Promise<void>;
  57051. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  57052. end(): Promise<void>;
  57053. requestAnimationFrame: Function;
  57054. addEventListener: Function;
  57055. }
  57056. interface XRSessionCreationOptions {
  57057. outputContext?: WebGLRenderingContext | null;
  57058. immersive?: boolean;
  57059. environmentIntegration?: boolean;
  57060. }
  57061. interface XRLayer {
  57062. getViewport: Function;
  57063. framebufferWidth: number;
  57064. framebufferHeight: number;
  57065. }
  57066. interface XRView {
  57067. projectionMatrix: Float32Array;
  57068. }
  57069. interface XRFrame {
  57070. getDevicePose: Function;
  57071. getInputPose: Function;
  57072. views: Array<XRView>;
  57073. baseLayer: XRLayer;
  57074. }
  57075. interface XRFrameOfReference {
  57076. }
  57077. interface XRWebGLLayer extends XRLayer {
  57078. framebuffer: WebGLFramebuffer;
  57079. }
  57080. declare var XRWebGLLayer: {
  57081. prototype: XRWebGLLayer;
  57082. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  57083. };