babylon.d.ts 2.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080
  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. /** @hidden */
  6091. static _LastCreatedScene: Nullable<Scene>;
  6092. /**
  6093. * Gets the latest created engine
  6094. */
  6095. static readonly LastCreatedEngine: Nullable<Engine>;
  6096. /**
  6097. * Gets the latest created scene
  6098. */
  6099. static readonly LastCreatedScene: Nullable<Scene>;
  6100. }
  6101. }
  6102. declare module BABYLON {
  6103. /**
  6104. * Define options used to create a render target texture
  6105. */
  6106. export class RenderTargetCreationOptions {
  6107. /**
  6108. * Specifies is mipmaps must be generated
  6109. */
  6110. generateMipMaps?: boolean;
  6111. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6112. generateDepthBuffer?: boolean;
  6113. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6114. generateStencilBuffer?: boolean;
  6115. /** Defines texture type (int by default) */
  6116. type?: number;
  6117. /** Defines sampling mode (trilinear by default) */
  6118. samplingMode?: number;
  6119. /** Defines format (RGBA by default) */
  6120. format?: number;
  6121. }
  6122. }
  6123. declare module BABYLON {
  6124. /**
  6125. * @hidden
  6126. **/
  6127. export class _AlphaState {
  6128. private _isAlphaBlendDirty;
  6129. private _isBlendFunctionParametersDirty;
  6130. private _isBlendEquationParametersDirty;
  6131. private _isBlendConstantsDirty;
  6132. private _alphaBlend;
  6133. private _blendFunctionParameters;
  6134. private _blendEquationParameters;
  6135. private _blendConstants;
  6136. /**
  6137. * Initializes the state.
  6138. */
  6139. constructor();
  6140. readonly isDirty: boolean;
  6141. alphaBlend: boolean;
  6142. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6143. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6144. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6145. reset(): void;
  6146. apply(gl: WebGLRenderingContext): void;
  6147. }
  6148. }
  6149. declare module BABYLON {
  6150. /**
  6151. * @hidden
  6152. **/
  6153. export class _DepthCullingState {
  6154. private _isDepthTestDirty;
  6155. private _isDepthMaskDirty;
  6156. private _isDepthFuncDirty;
  6157. private _isCullFaceDirty;
  6158. private _isCullDirty;
  6159. private _isZOffsetDirty;
  6160. private _isFrontFaceDirty;
  6161. private _depthTest;
  6162. private _depthMask;
  6163. private _depthFunc;
  6164. private _cull;
  6165. private _cullFace;
  6166. private _zOffset;
  6167. private _frontFace;
  6168. /**
  6169. * Initializes the state.
  6170. */
  6171. constructor();
  6172. readonly isDirty: boolean;
  6173. zOffset: number;
  6174. cullFace: Nullable<number>;
  6175. cull: Nullable<boolean>;
  6176. depthFunc: Nullable<number>;
  6177. depthMask: boolean;
  6178. depthTest: boolean;
  6179. frontFace: Nullable<number>;
  6180. reset(): void;
  6181. apply(gl: WebGLRenderingContext): void;
  6182. }
  6183. }
  6184. declare module BABYLON {
  6185. /**
  6186. * @hidden
  6187. **/
  6188. export class _StencilState {
  6189. /** 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 */
  6190. static readonly ALWAYS: number;
  6191. /** Passed to stencilOperation to specify that stencil value must be kept */
  6192. static readonly KEEP: number;
  6193. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6194. static readonly REPLACE: number;
  6195. private _isStencilTestDirty;
  6196. private _isStencilMaskDirty;
  6197. private _isStencilFuncDirty;
  6198. private _isStencilOpDirty;
  6199. private _stencilTest;
  6200. private _stencilMask;
  6201. private _stencilFunc;
  6202. private _stencilFuncRef;
  6203. private _stencilFuncMask;
  6204. private _stencilOpStencilFail;
  6205. private _stencilOpDepthFail;
  6206. private _stencilOpStencilDepthPass;
  6207. readonly isDirty: boolean;
  6208. stencilFunc: number;
  6209. stencilFuncRef: number;
  6210. stencilFuncMask: number;
  6211. stencilOpStencilFail: number;
  6212. stencilOpDepthFail: number;
  6213. stencilOpStencilDepthPass: number;
  6214. stencilMask: number;
  6215. stencilTest: boolean;
  6216. constructor();
  6217. reset(): void;
  6218. apply(gl: WebGLRenderingContext): void;
  6219. }
  6220. }
  6221. declare module BABYLON {
  6222. /**
  6223. * @hidden
  6224. **/
  6225. export class _TimeToken {
  6226. _startTimeQuery: Nullable<WebGLQuery>;
  6227. _endTimeQuery: Nullable<WebGLQuery>;
  6228. _timeElapsedQuery: Nullable<WebGLQuery>;
  6229. _timeElapsedQueryEnded: boolean;
  6230. }
  6231. }
  6232. declare module BABYLON {
  6233. /**
  6234. * Class used to store data associated with WebGL texture data for the engine
  6235. * This class should not be used directly
  6236. */
  6237. export class InternalTexture {
  6238. /** hidden */
  6239. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6240. /**
  6241. * The source of the texture data is unknown
  6242. */
  6243. static DATASOURCE_UNKNOWN: number;
  6244. /**
  6245. * Texture data comes from an URL
  6246. */
  6247. static DATASOURCE_URL: number;
  6248. /**
  6249. * Texture data is only used for temporary storage
  6250. */
  6251. static DATASOURCE_TEMP: number;
  6252. /**
  6253. * Texture data comes from raw data (ArrayBuffer)
  6254. */
  6255. static DATASOURCE_RAW: number;
  6256. /**
  6257. * Texture content is dynamic (video or dynamic texture)
  6258. */
  6259. static DATASOURCE_DYNAMIC: number;
  6260. /**
  6261. * Texture content is generated by rendering to it
  6262. */
  6263. static DATASOURCE_RENDERTARGET: number;
  6264. /**
  6265. * Texture content is part of a multi render target process
  6266. */
  6267. static DATASOURCE_MULTIRENDERTARGET: number;
  6268. /**
  6269. * Texture data comes from a cube data file
  6270. */
  6271. static DATASOURCE_CUBE: number;
  6272. /**
  6273. * Texture data comes from a raw cube data
  6274. */
  6275. static DATASOURCE_CUBERAW: number;
  6276. /**
  6277. * Texture data come from a prefiltered cube data file
  6278. */
  6279. static DATASOURCE_CUBEPREFILTERED: number;
  6280. /**
  6281. * Texture content is raw 3D data
  6282. */
  6283. static DATASOURCE_RAW3D: number;
  6284. /**
  6285. * Texture content is a depth texture
  6286. */
  6287. static DATASOURCE_DEPTHTEXTURE: number;
  6288. /**
  6289. * Texture data comes from a raw cube data encoded with RGBD
  6290. */
  6291. static DATASOURCE_CUBERAW_RGBD: number;
  6292. /**
  6293. * Defines if the texture is ready
  6294. */
  6295. isReady: boolean;
  6296. /**
  6297. * Defines if the texture is a cube texture
  6298. */
  6299. isCube: boolean;
  6300. /**
  6301. * Defines if the texture contains 3D data
  6302. */
  6303. is3D: boolean;
  6304. /**
  6305. * Defines if the texture contains multiview data
  6306. */
  6307. isMultiview: boolean;
  6308. /**
  6309. * Gets the URL used to load this texture
  6310. */
  6311. url: string;
  6312. /**
  6313. * Gets the sampling mode of the texture
  6314. */
  6315. samplingMode: number;
  6316. /**
  6317. * Gets a boolean indicating if the texture needs mipmaps generation
  6318. */
  6319. generateMipMaps: boolean;
  6320. /**
  6321. * Gets the number of samples used by the texture (WebGL2+ only)
  6322. */
  6323. samples: number;
  6324. /**
  6325. * Gets the type of the texture (int, float...)
  6326. */
  6327. type: number;
  6328. /**
  6329. * Gets the format of the texture (RGB, RGBA...)
  6330. */
  6331. format: number;
  6332. /**
  6333. * Observable called when the texture is loaded
  6334. */
  6335. onLoadedObservable: Observable<InternalTexture>;
  6336. /**
  6337. * Gets the width of the texture
  6338. */
  6339. width: number;
  6340. /**
  6341. * Gets the height of the texture
  6342. */
  6343. height: number;
  6344. /**
  6345. * Gets the depth of the texture
  6346. */
  6347. depth: number;
  6348. /**
  6349. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6350. */
  6351. baseWidth: number;
  6352. /**
  6353. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6354. */
  6355. baseHeight: number;
  6356. /**
  6357. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6358. */
  6359. baseDepth: number;
  6360. /**
  6361. * Gets a boolean indicating if the texture is inverted on Y axis
  6362. */
  6363. invertY: boolean;
  6364. /** @hidden */
  6365. _invertVScale: boolean;
  6366. /** @hidden */
  6367. _associatedChannel: number;
  6368. /** @hidden */
  6369. _dataSource: number;
  6370. /** @hidden */
  6371. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6372. /** @hidden */
  6373. _bufferView: Nullable<ArrayBufferView>;
  6374. /** @hidden */
  6375. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6376. /** @hidden */
  6377. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6378. /** @hidden */
  6379. _size: number;
  6380. /** @hidden */
  6381. _extension: string;
  6382. /** @hidden */
  6383. _files: Nullable<string[]>;
  6384. /** @hidden */
  6385. _workingCanvas: Nullable<HTMLCanvasElement>;
  6386. /** @hidden */
  6387. _workingContext: Nullable<CanvasRenderingContext2D>;
  6388. /** @hidden */
  6389. _framebuffer: Nullable<WebGLFramebuffer>;
  6390. /** @hidden */
  6391. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6392. /** @hidden */
  6393. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6394. /** @hidden */
  6395. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6396. /** @hidden */
  6397. _attachments: Nullable<number[]>;
  6398. /** @hidden */
  6399. _cachedCoordinatesMode: Nullable<number>;
  6400. /** @hidden */
  6401. _cachedWrapU: Nullable<number>;
  6402. /** @hidden */
  6403. _cachedWrapV: Nullable<number>;
  6404. /** @hidden */
  6405. _cachedWrapR: Nullable<number>;
  6406. /** @hidden */
  6407. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6408. /** @hidden */
  6409. _isDisabled: boolean;
  6410. /** @hidden */
  6411. _compression: Nullable<string>;
  6412. /** @hidden */
  6413. _generateStencilBuffer: boolean;
  6414. /** @hidden */
  6415. _generateDepthBuffer: boolean;
  6416. /** @hidden */
  6417. _comparisonFunction: number;
  6418. /** @hidden */
  6419. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6420. /** @hidden */
  6421. _lodGenerationScale: number;
  6422. /** @hidden */
  6423. _lodGenerationOffset: number;
  6424. /** @hidden */
  6425. _colorTextureArray: Nullable<WebGLTexture>;
  6426. /** @hidden */
  6427. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6428. /** @hidden */
  6429. _lodTextureHigh: Nullable<BaseTexture>;
  6430. /** @hidden */
  6431. _lodTextureMid: Nullable<BaseTexture>;
  6432. /** @hidden */
  6433. _lodTextureLow: Nullable<BaseTexture>;
  6434. /** @hidden */
  6435. _isRGBD: boolean;
  6436. /** @hidden */
  6437. _webGLTexture: Nullable<WebGLTexture>;
  6438. /** @hidden */
  6439. _references: number;
  6440. private _engine;
  6441. /**
  6442. * Gets the Engine the texture belongs to.
  6443. * @returns The babylon engine
  6444. */
  6445. getEngine(): Engine;
  6446. /**
  6447. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6448. */
  6449. readonly dataSource: number;
  6450. /**
  6451. * Creates a new InternalTexture
  6452. * @param engine defines the engine to use
  6453. * @param dataSource defines the type of data that will be used
  6454. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6455. */
  6456. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6457. /**
  6458. * Increments the number of references (ie. the number of Texture that point to it)
  6459. */
  6460. incrementReferences(): void;
  6461. /**
  6462. * Change the size of the texture (not the size of the content)
  6463. * @param width defines the new width
  6464. * @param height defines the new height
  6465. * @param depth defines the new depth (1 by default)
  6466. */
  6467. updateSize(width: int, height: int, depth?: int): void;
  6468. /** @hidden */
  6469. _rebuild(): void;
  6470. /** @hidden */
  6471. _swapAndDie(target: InternalTexture): void;
  6472. /**
  6473. * Dispose the current allocated resources
  6474. */
  6475. dispose(): void;
  6476. }
  6477. }
  6478. declare module BABYLON {
  6479. /**
  6480. * This represents the main contract an easing function should follow.
  6481. * Easing functions are used throughout the animation system.
  6482. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6483. */
  6484. export interface IEasingFunction {
  6485. /**
  6486. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6487. * of the easing function.
  6488. * The link below provides some of the most common examples of easing functions.
  6489. * @see https://easings.net/
  6490. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6491. * @returns the corresponding value on the curve defined by the easing function
  6492. */
  6493. ease(gradient: number): number;
  6494. }
  6495. /**
  6496. * Base class used for every default easing function.
  6497. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6498. */
  6499. export class EasingFunction implements IEasingFunction {
  6500. /**
  6501. * Interpolation follows the mathematical formula associated with the easing function.
  6502. */
  6503. static readonly EASINGMODE_EASEIN: number;
  6504. /**
  6505. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6506. */
  6507. static readonly EASINGMODE_EASEOUT: number;
  6508. /**
  6509. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6510. */
  6511. static readonly EASINGMODE_EASEINOUT: number;
  6512. private _easingMode;
  6513. /**
  6514. * Sets the easing mode of the current function.
  6515. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6516. */
  6517. setEasingMode(easingMode: number): void;
  6518. /**
  6519. * Gets the current easing mode.
  6520. * @returns the easing mode
  6521. */
  6522. getEasingMode(): number;
  6523. /**
  6524. * @hidden
  6525. */
  6526. easeInCore(gradient: number): number;
  6527. /**
  6528. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6529. * of the easing function.
  6530. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6531. * @returns the corresponding value on the curve defined by the easing function
  6532. */
  6533. ease(gradient: number): number;
  6534. }
  6535. /**
  6536. * Easing function with a circle shape (see link below).
  6537. * @see https://easings.net/#easeInCirc
  6538. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6539. */
  6540. export class CircleEase extends EasingFunction implements IEasingFunction {
  6541. /** @hidden */
  6542. easeInCore(gradient: number): number;
  6543. }
  6544. /**
  6545. * Easing function with a ease back shape (see link below).
  6546. * @see https://easings.net/#easeInBack
  6547. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6548. */
  6549. export class BackEase extends EasingFunction implements IEasingFunction {
  6550. /** Defines the amplitude of the function */
  6551. amplitude: number;
  6552. /**
  6553. * Instantiates a back ease easing
  6554. * @see https://easings.net/#easeInBack
  6555. * @param amplitude Defines the amplitude of the function
  6556. */
  6557. constructor(
  6558. /** Defines the amplitude of the function */
  6559. amplitude?: number);
  6560. /** @hidden */
  6561. easeInCore(gradient: number): number;
  6562. }
  6563. /**
  6564. * Easing function with a bouncing shape (see link below).
  6565. * @see https://easings.net/#easeInBounce
  6566. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6567. */
  6568. export class BounceEase extends EasingFunction implements IEasingFunction {
  6569. /** Defines the number of bounces */
  6570. bounces: number;
  6571. /** Defines the amplitude of the bounce */
  6572. bounciness: number;
  6573. /**
  6574. * Instantiates a bounce easing
  6575. * @see https://easings.net/#easeInBounce
  6576. * @param bounces Defines the number of bounces
  6577. * @param bounciness Defines the amplitude of the bounce
  6578. */
  6579. constructor(
  6580. /** Defines the number of bounces */
  6581. bounces?: number,
  6582. /** Defines the amplitude of the bounce */
  6583. bounciness?: number);
  6584. /** @hidden */
  6585. easeInCore(gradient: number): number;
  6586. }
  6587. /**
  6588. * Easing function with a power of 3 shape (see link below).
  6589. * @see https://easings.net/#easeInCubic
  6590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6591. */
  6592. export class CubicEase extends EasingFunction implements IEasingFunction {
  6593. /** @hidden */
  6594. easeInCore(gradient: number): number;
  6595. }
  6596. /**
  6597. * Easing function with an elastic shape (see link below).
  6598. * @see https://easings.net/#easeInElastic
  6599. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6600. */
  6601. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6602. /** Defines the number of oscillations*/
  6603. oscillations: number;
  6604. /** Defines the amplitude of the oscillations*/
  6605. springiness: number;
  6606. /**
  6607. * Instantiates an elastic easing function
  6608. * @see https://easings.net/#easeInElastic
  6609. * @param oscillations Defines the number of oscillations
  6610. * @param springiness Defines the amplitude of the oscillations
  6611. */
  6612. constructor(
  6613. /** Defines the number of oscillations*/
  6614. oscillations?: number,
  6615. /** Defines the amplitude of the oscillations*/
  6616. springiness?: number);
  6617. /** @hidden */
  6618. easeInCore(gradient: number): number;
  6619. }
  6620. /**
  6621. * Easing function with an exponential shape (see link below).
  6622. * @see https://easings.net/#easeInExpo
  6623. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6624. */
  6625. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6626. /** Defines the exponent of the function */
  6627. exponent: number;
  6628. /**
  6629. * Instantiates an exponential easing function
  6630. * @see https://easings.net/#easeInExpo
  6631. * @param exponent Defines the exponent of the function
  6632. */
  6633. constructor(
  6634. /** Defines the exponent of the function */
  6635. exponent?: number);
  6636. /** @hidden */
  6637. easeInCore(gradient: number): number;
  6638. }
  6639. /**
  6640. * Easing function with a power shape (see link below).
  6641. * @see https://easings.net/#easeInQuad
  6642. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6643. */
  6644. export class PowerEase extends EasingFunction implements IEasingFunction {
  6645. /** Defines the power of the function */
  6646. power: number;
  6647. /**
  6648. * Instantiates an power base easing function
  6649. * @see https://easings.net/#easeInQuad
  6650. * @param power Defines the power of the function
  6651. */
  6652. constructor(
  6653. /** Defines the power of the function */
  6654. power?: number);
  6655. /** @hidden */
  6656. easeInCore(gradient: number): number;
  6657. }
  6658. /**
  6659. * Easing function with a power of 2 shape (see link below).
  6660. * @see https://easings.net/#easeInQuad
  6661. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6662. */
  6663. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6664. /** @hidden */
  6665. easeInCore(gradient: number): number;
  6666. }
  6667. /**
  6668. * Easing function with a power of 4 shape (see link below).
  6669. * @see https://easings.net/#easeInQuart
  6670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6671. */
  6672. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6673. /** @hidden */
  6674. easeInCore(gradient: number): number;
  6675. }
  6676. /**
  6677. * Easing function with a power of 5 shape (see link below).
  6678. * @see https://easings.net/#easeInQuint
  6679. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6680. */
  6681. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6682. /** @hidden */
  6683. easeInCore(gradient: number): number;
  6684. }
  6685. /**
  6686. * Easing function with a sin shape (see link below).
  6687. * @see https://easings.net/#easeInSine
  6688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6689. */
  6690. export class SineEase extends EasingFunction implements IEasingFunction {
  6691. /** @hidden */
  6692. easeInCore(gradient: number): number;
  6693. }
  6694. /**
  6695. * Easing function with a bezier shape (see link below).
  6696. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6697. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6698. */
  6699. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6700. /** Defines the x component of the start tangent in the bezier curve */
  6701. x1: number;
  6702. /** Defines the y component of the start tangent in the bezier curve */
  6703. y1: number;
  6704. /** Defines the x component of the end tangent in the bezier curve */
  6705. x2: number;
  6706. /** Defines the y component of the end tangent in the bezier curve */
  6707. y2: number;
  6708. /**
  6709. * Instantiates a bezier function
  6710. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6711. * @param x1 Defines the x component of the start tangent in the bezier curve
  6712. * @param y1 Defines the y component of the start tangent in the bezier curve
  6713. * @param x2 Defines the x component of the end tangent in the bezier curve
  6714. * @param y2 Defines the y component of the end tangent in the bezier curve
  6715. */
  6716. constructor(
  6717. /** Defines the x component of the start tangent in the bezier curve */
  6718. x1?: number,
  6719. /** Defines the y component of the start tangent in the bezier curve */
  6720. y1?: number,
  6721. /** Defines the x component of the end tangent in the bezier curve */
  6722. x2?: number,
  6723. /** Defines the y component of the end tangent in the bezier curve */
  6724. y2?: number);
  6725. /** @hidden */
  6726. easeInCore(gradient: number): number;
  6727. }
  6728. }
  6729. declare module BABYLON {
  6730. /**
  6731. * Defines an interface which represents an animation key frame
  6732. */
  6733. export interface IAnimationKey {
  6734. /**
  6735. * Frame of the key frame
  6736. */
  6737. frame: number;
  6738. /**
  6739. * Value at the specifies key frame
  6740. */
  6741. value: any;
  6742. /**
  6743. * The input tangent for the cubic hermite spline
  6744. */
  6745. inTangent?: any;
  6746. /**
  6747. * The output tangent for the cubic hermite spline
  6748. */
  6749. outTangent?: any;
  6750. /**
  6751. * The animation interpolation type
  6752. */
  6753. interpolation?: AnimationKeyInterpolation;
  6754. }
  6755. /**
  6756. * Enum for the animation key frame interpolation type
  6757. */
  6758. export enum AnimationKeyInterpolation {
  6759. /**
  6760. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6761. */
  6762. STEP = 1
  6763. }
  6764. }
  6765. declare module BABYLON {
  6766. /**
  6767. * Represents the range of an animation
  6768. */
  6769. export class AnimationRange {
  6770. /**The name of the animation range**/
  6771. name: string;
  6772. /**The starting frame of the animation */
  6773. from: number;
  6774. /**The ending frame of the animation*/
  6775. to: number;
  6776. /**
  6777. * Initializes the range of an animation
  6778. * @param name The name of the animation range
  6779. * @param from The starting frame of the animation
  6780. * @param to The ending frame of the animation
  6781. */
  6782. constructor(
  6783. /**The name of the animation range**/
  6784. name: string,
  6785. /**The starting frame of the animation */
  6786. from: number,
  6787. /**The ending frame of the animation*/
  6788. to: number);
  6789. /**
  6790. * Makes a copy of the animation range
  6791. * @returns A copy of the animation range
  6792. */
  6793. clone(): AnimationRange;
  6794. }
  6795. }
  6796. declare module BABYLON {
  6797. /**
  6798. * Composed of a frame, and an action function
  6799. */
  6800. export class AnimationEvent {
  6801. /** The frame for which the event is triggered **/
  6802. frame: number;
  6803. /** The event to perform when triggered **/
  6804. action: (currentFrame: number) => void;
  6805. /** Specifies if the event should be triggered only once**/
  6806. onlyOnce?: boolean | undefined;
  6807. /**
  6808. * Specifies if the animation event is done
  6809. */
  6810. isDone: boolean;
  6811. /**
  6812. * Initializes the animation event
  6813. * @param frame The frame for which the event is triggered
  6814. * @param action The event to perform when triggered
  6815. * @param onlyOnce Specifies if the event should be triggered only once
  6816. */
  6817. constructor(
  6818. /** The frame for which the event is triggered **/
  6819. frame: number,
  6820. /** The event to perform when triggered **/
  6821. action: (currentFrame: number) => void,
  6822. /** Specifies if the event should be triggered only once**/
  6823. onlyOnce?: boolean | undefined);
  6824. /** @hidden */
  6825. _clone(): AnimationEvent;
  6826. }
  6827. }
  6828. declare module BABYLON {
  6829. /**
  6830. * Interface used to define a behavior
  6831. */
  6832. export interface Behavior<T> {
  6833. /** gets or sets behavior's name */
  6834. name: string;
  6835. /**
  6836. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6837. */
  6838. init(): void;
  6839. /**
  6840. * Called when the behavior is attached to a target
  6841. * @param target defines the target where the behavior is attached to
  6842. */
  6843. attach(target: T): void;
  6844. /**
  6845. * Called when the behavior is detached from its target
  6846. */
  6847. detach(): void;
  6848. }
  6849. /**
  6850. * Interface implemented by classes supporting behaviors
  6851. */
  6852. export interface IBehaviorAware<T> {
  6853. /**
  6854. * Attach a behavior
  6855. * @param behavior defines the behavior to attach
  6856. * @returns the current host
  6857. */
  6858. addBehavior(behavior: Behavior<T>): T;
  6859. /**
  6860. * Remove a behavior from the current object
  6861. * @param behavior defines the behavior to detach
  6862. * @returns the current host
  6863. */
  6864. removeBehavior(behavior: Behavior<T>): T;
  6865. /**
  6866. * Gets a behavior using its name to search
  6867. * @param name defines the name to search
  6868. * @returns the behavior or null if not found
  6869. */
  6870. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6871. }
  6872. }
  6873. declare module BABYLON {
  6874. /**
  6875. * @hidden
  6876. */
  6877. export class IntersectionInfo {
  6878. bu: Nullable<number>;
  6879. bv: Nullable<number>;
  6880. distance: number;
  6881. faceId: number;
  6882. subMeshId: number;
  6883. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6884. }
  6885. }
  6886. declare module BABYLON {
  6887. /**
  6888. * Class used to store bounding sphere information
  6889. */
  6890. export class BoundingSphere {
  6891. /**
  6892. * Gets the center of the bounding sphere in local space
  6893. */
  6894. readonly center: Vector3;
  6895. /**
  6896. * Radius of the bounding sphere in local space
  6897. */
  6898. radius: number;
  6899. /**
  6900. * Gets the center of the bounding sphere in world space
  6901. */
  6902. readonly centerWorld: Vector3;
  6903. /**
  6904. * Radius of the bounding sphere in world space
  6905. */
  6906. radiusWorld: number;
  6907. /**
  6908. * Gets the minimum vector in local space
  6909. */
  6910. readonly minimum: Vector3;
  6911. /**
  6912. * Gets the maximum vector in local space
  6913. */
  6914. readonly maximum: Vector3;
  6915. private _worldMatrix;
  6916. private static readonly TmpVector3;
  6917. /**
  6918. * Creates a new bounding sphere
  6919. * @param min defines the minimum vector (in local space)
  6920. * @param max defines the maximum vector (in local space)
  6921. * @param worldMatrix defines the new world matrix
  6922. */
  6923. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6924. /**
  6925. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6926. * @param min defines the new minimum vector (in local space)
  6927. * @param max defines the new maximum vector (in local space)
  6928. * @param worldMatrix defines the new world matrix
  6929. */
  6930. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6931. /**
  6932. * Scale the current bounding sphere by applying a scale factor
  6933. * @param factor defines the scale factor to apply
  6934. * @returns the current bounding box
  6935. */
  6936. scale(factor: number): BoundingSphere;
  6937. /**
  6938. * Gets the world matrix of the bounding box
  6939. * @returns a matrix
  6940. */
  6941. getWorldMatrix(): DeepImmutable<Matrix>;
  6942. /** @hidden */
  6943. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6944. /**
  6945. * Tests if the bounding sphere is intersecting the frustum planes
  6946. * @param frustumPlanes defines the frustum planes to test
  6947. * @returns true if there is an intersection
  6948. */
  6949. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6950. /**
  6951. * Tests if the bounding sphere center is in between the frustum planes.
  6952. * Used for optimistic fast inclusion.
  6953. * @param frustumPlanes defines the frustum planes to test
  6954. * @returns true if the sphere center is in between the frustum planes
  6955. */
  6956. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6957. /**
  6958. * Tests if a point is inside the bounding sphere
  6959. * @param point defines the point to test
  6960. * @returns true if the point is inside the bounding sphere
  6961. */
  6962. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6963. /**
  6964. * Checks if two sphere intersct
  6965. * @param sphere0 sphere 0
  6966. * @param sphere1 sphere 1
  6967. * @returns true if the speres intersect
  6968. */
  6969. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6970. }
  6971. }
  6972. declare module BABYLON {
  6973. /**
  6974. * Class used to store bounding box information
  6975. */
  6976. export class BoundingBox implements ICullable {
  6977. /**
  6978. * Gets the 8 vectors representing the bounding box in local space
  6979. */
  6980. readonly vectors: Vector3[];
  6981. /**
  6982. * Gets the center of the bounding box in local space
  6983. */
  6984. readonly center: Vector3;
  6985. /**
  6986. * Gets the center of the bounding box in world space
  6987. */
  6988. readonly centerWorld: Vector3;
  6989. /**
  6990. * Gets the extend size in local space
  6991. */
  6992. readonly extendSize: Vector3;
  6993. /**
  6994. * Gets the extend size in world space
  6995. */
  6996. readonly extendSizeWorld: Vector3;
  6997. /**
  6998. * Gets the OBB (object bounding box) directions
  6999. */
  7000. readonly directions: Vector3[];
  7001. /**
  7002. * Gets the 8 vectors representing the bounding box in world space
  7003. */
  7004. readonly vectorsWorld: Vector3[];
  7005. /**
  7006. * Gets the minimum vector in world space
  7007. */
  7008. readonly minimumWorld: Vector3;
  7009. /**
  7010. * Gets the maximum vector in world space
  7011. */
  7012. readonly maximumWorld: Vector3;
  7013. /**
  7014. * Gets the minimum vector in local space
  7015. */
  7016. readonly minimum: Vector3;
  7017. /**
  7018. * Gets the maximum vector in local space
  7019. */
  7020. readonly maximum: Vector3;
  7021. private _worldMatrix;
  7022. private static readonly TmpVector3;
  7023. /**
  7024. * @hidden
  7025. */
  7026. _tag: number;
  7027. /**
  7028. * Creates a new bounding box
  7029. * @param min defines the minimum vector (in local space)
  7030. * @param max defines the maximum vector (in local space)
  7031. * @param worldMatrix defines the new world matrix
  7032. */
  7033. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7034. /**
  7035. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7036. * @param min defines the new minimum vector (in local space)
  7037. * @param max defines the new maximum vector (in local space)
  7038. * @param worldMatrix defines the new world matrix
  7039. */
  7040. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7041. /**
  7042. * Scale the current bounding box by applying a scale factor
  7043. * @param factor defines the scale factor to apply
  7044. * @returns the current bounding box
  7045. */
  7046. scale(factor: number): BoundingBox;
  7047. /**
  7048. * Gets the world matrix of the bounding box
  7049. * @returns a matrix
  7050. */
  7051. getWorldMatrix(): DeepImmutable<Matrix>;
  7052. /** @hidden */
  7053. _update(world: DeepImmutable<Matrix>): void;
  7054. /**
  7055. * Tests if the bounding box is intersecting the frustum planes
  7056. * @param frustumPlanes defines the frustum planes to test
  7057. * @returns true if there is an intersection
  7058. */
  7059. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7060. /**
  7061. * Tests if the bounding box is entirely inside the frustum planes
  7062. * @param frustumPlanes defines the frustum planes to test
  7063. * @returns true if there is an inclusion
  7064. */
  7065. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7066. /**
  7067. * Tests if a point is inside the bounding box
  7068. * @param point defines the point to test
  7069. * @returns true if the point is inside the bounding box
  7070. */
  7071. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7072. /**
  7073. * Tests if the bounding box intersects with a bounding sphere
  7074. * @param sphere defines the sphere to test
  7075. * @returns true if there is an intersection
  7076. */
  7077. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7078. /**
  7079. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7080. * @param min defines the min vector to use
  7081. * @param max defines the max vector to use
  7082. * @returns true if there is an intersection
  7083. */
  7084. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7085. /**
  7086. * Tests if two bounding boxes are intersections
  7087. * @param box0 defines the first box to test
  7088. * @param box1 defines the second box to test
  7089. * @returns true if there is an intersection
  7090. */
  7091. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7092. /**
  7093. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7094. * @param minPoint defines the minimum vector of the bounding box
  7095. * @param maxPoint defines the maximum vector of the bounding box
  7096. * @param sphereCenter defines the sphere center
  7097. * @param sphereRadius defines the sphere radius
  7098. * @returns true if there is an intersection
  7099. */
  7100. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7101. /**
  7102. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7103. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7104. * @param frustumPlanes defines the frustum planes to test
  7105. * @return true if there is an inclusion
  7106. */
  7107. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7108. /**
  7109. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7110. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7111. * @param frustumPlanes defines the frustum planes to test
  7112. * @return true if there is an intersection
  7113. */
  7114. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7115. }
  7116. }
  7117. declare module BABYLON {
  7118. /** @hidden */
  7119. export class Collider {
  7120. /** Define if a collision was found */
  7121. collisionFound: boolean;
  7122. /**
  7123. * Define last intersection point in local space
  7124. */
  7125. intersectionPoint: Vector3;
  7126. /**
  7127. * Define last collided mesh
  7128. */
  7129. collidedMesh: Nullable<AbstractMesh>;
  7130. private _collisionPoint;
  7131. private _planeIntersectionPoint;
  7132. private _tempVector;
  7133. private _tempVector2;
  7134. private _tempVector3;
  7135. private _tempVector4;
  7136. private _edge;
  7137. private _baseToVertex;
  7138. private _destinationPoint;
  7139. private _slidePlaneNormal;
  7140. private _displacementVector;
  7141. /** @hidden */
  7142. _radius: Vector3;
  7143. /** @hidden */
  7144. _retry: number;
  7145. private _velocity;
  7146. private _basePoint;
  7147. private _epsilon;
  7148. /** @hidden */
  7149. _velocityWorldLength: number;
  7150. /** @hidden */
  7151. _basePointWorld: Vector3;
  7152. private _velocityWorld;
  7153. private _normalizedVelocity;
  7154. /** @hidden */
  7155. _initialVelocity: Vector3;
  7156. /** @hidden */
  7157. _initialPosition: Vector3;
  7158. private _nearestDistance;
  7159. private _collisionMask;
  7160. collisionMask: number;
  7161. /**
  7162. * Gets the plane normal used to compute the sliding response (in local space)
  7163. */
  7164. readonly slidePlaneNormal: Vector3;
  7165. /** @hidden */
  7166. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7167. /** @hidden */
  7168. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7169. /** @hidden */
  7170. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7171. /** @hidden */
  7172. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7173. /** @hidden */
  7174. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7175. /** @hidden */
  7176. _getResponse(pos: Vector3, vel: Vector3): void;
  7177. }
  7178. }
  7179. declare module BABYLON {
  7180. /**
  7181. * Interface for cullable objects
  7182. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7183. */
  7184. export interface ICullable {
  7185. /**
  7186. * Checks if the object or part of the object is in the frustum
  7187. * @param frustumPlanes Camera near/planes
  7188. * @returns true if the object is in frustum otherwise false
  7189. */
  7190. isInFrustum(frustumPlanes: Plane[]): boolean;
  7191. /**
  7192. * Checks if a cullable object (mesh...) is in the camera frustum
  7193. * Unlike isInFrustum this cheks the full bounding box
  7194. * @param frustumPlanes Camera near/planes
  7195. * @returns true if the object is in frustum otherwise false
  7196. */
  7197. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7198. }
  7199. /**
  7200. * Info for a bounding data of a mesh
  7201. */
  7202. export class BoundingInfo implements ICullable {
  7203. /**
  7204. * Bounding box for the mesh
  7205. */
  7206. readonly boundingBox: BoundingBox;
  7207. /**
  7208. * Bounding sphere for the mesh
  7209. */
  7210. readonly boundingSphere: BoundingSphere;
  7211. private _isLocked;
  7212. private static readonly TmpVector3;
  7213. /**
  7214. * Constructs bounding info
  7215. * @param minimum min vector of the bounding box/sphere
  7216. * @param maximum max vector of the bounding box/sphere
  7217. * @param worldMatrix defines the new world matrix
  7218. */
  7219. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7220. /**
  7221. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7222. * @param min defines the new minimum vector (in local space)
  7223. * @param max defines the new maximum vector (in local space)
  7224. * @param worldMatrix defines the new world matrix
  7225. */
  7226. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7227. /**
  7228. * min vector of the bounding box/sphere
  7229. */
  7230. readonly minimum: Vector3;
  7231. /**
  7232. * max vector of the bounding box/sphere
  7233. */
  7234. readonly maximum: Vector3;
  7235. /**
  7236. * If the info is locked and won't be updated to avoid perf overhead
  7237. */
  7238. isLocked: boolean;
  7239. /**
  7240. * Updates the bounding sphere and box
  7241. * @param world world matrix to be used to update
  7242. */
  7243. update(world: DeepImmutable<Matrix>): void;
  7244. /**
  7245. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7246. * @param center New center of the bounding info
  7247. * @param extend New extend of the bounding info
  7248. * @returns the current bounding info
  7249. */
  7250. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7251. /**
  7252. * Scale the current bounding info by applying a scale factor
  7253. * @param factor defines the scale factor to apply
  7254. * @returns the current bounding info
  7255. */
  7256. scale(factor: number): BoundingInfo;
  7257. /**
  7258. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7259. * @param frustumPlanes defines the frustum to test
  7260. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7261. * @returns true if the bounding info is in the frustum planes
  7262. */
  7263. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7264. /**
  7265. * Gets the world distance between the min and max points of the bounding box
  7266. */
  7267. readonly diagonalLength: number;
  7268. /**
  7269. * Checks if a cullable object (mesh...) is in the camera frustum
  7270. * Unlike isInFrustum this cheks the full bounding box
  7271. * @param frustumPlanes Camera near/planes
  7272. * @returns true if the object is in frustum otherwise false
  7273. */
  7274. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7275. /** @hidden */
  7276. _checkCollision(collider: Collider): boolean;
  7277. /**
  7278. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7279. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7280. * @param point the point to check intersection with
  7281. * @returns if the point intersects
  7282. */
  7283. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7284. /**
  7285. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7286. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7287. * @param boundingInfo the bounding info to check intersection with
  7288. * @param precise if the intersection should be done using OBB
  7289. * @returns if the bounding info intersects
  7290. */
  7291. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7292. }
  7293. }
  7294. declare module BABYLON {
  7295. /**
  7296. * Defines an array and its length.
  7297. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7298. */
  7299. export interface ISmartArrayLike<T> {
  7300. /**
  7301. * The data of the array.
  7302. */
  7303. data: Array<T>;
  7304. /**
  7305. * The active length of the array.
  7306. */
  7307. length: number;
  7308. }
  7309. /**
  7310. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7311. */
  7312. export class SmartArray<T> implements ISmartArrayLike<T> {
  7313. /**
  7314. * The full set of data from the array.
  7315. */
  7316. data: Array<T>;
  7317. /**
  7318. * The active length of the array.
  7319. */
  7320. length: number;
  7321. protected _id: number;
  7322. /**
  7323. * Instantiates a Smart Array.
  7324. * @param capacity defines the default capacity of the array.
  7325. */
  7326. constructor(capacity: number);
  7327. /**
  7328. * Pushes a value at the end of the active data.
  7329. * @param value defines the object to push in the array.
  7330. */
  7331. push(value: T): void;
  7332. /**
  7333. * Iterates over the active data and apply the lambda to them.
  7334. * @param func defines the action to apply on each value.
  7335. */
  7336. forEach(func: (content: T) => void): void;
  7337. /**
  7338. * Sorts the full sets of data.
  7339. * @param compareFn defines the comparison function to apply.
  7340. */
  7341. sort(compareFn: (a: T, b: T) => number): void;
  7342. /**
  7343. * Resets the active data to an empty array.
  7344. */
  7345. reset(): void;
  7346. /**
  7347. * Releases all the data from the array as well as the array.
  7348. */
  7349. dispose(): void;
  7350. /**
  7351. * Concats the active data with a given array.
  7352. * @param array defines the data to concatenate with.
  7353. */
  7354. concat(array: any): void;
  7355. /**
  7356. * Returns the position of a value in the active data.
  7357. * @param value defines the value to find the index for
  7358. * @returns the index if found in the active data otherwise -1
  7359. */
  7360. indexOf(value: T): number;
  7361. /**
  7362. * Returns whether an element is part of the active data.
  7363. * @param value defines the value to look for
  7364. * @returns true if found in the active data otherwise false
  7365. */
  7366. contains(value: T): boolean;
  7367. private static _GlobalId;
  7368. }
  7369. /**
  7370. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7371. * The data in this array can only be present once
  7372. */
  7373. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7374. private _duplicateId;
  7375. /**
  7376. * Pushes a value at the end of the active data.
  7377. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7378. * @param value defines the object to push in the array.
  7379. */
  7380. push(value: T): void;
  7381. /**
  7382. * Pushes a value at the end of the active data.
  7383. * If the data is already present, it won t be added again
  7384. * @param value defines the object to push in the array.
  7385. * @returns true if added false if it was already present
  7386. */
  7387. pushNoDuplicate(value: T): boolean;
  7388. /**
  7389. * Resets the active data to an empty array.
  7390. */
  7391. reset(): void;
  7392. /**
  7393. * Concats the active data with a given array.
  7394. * This ensures no dupplicate will be present in the result.
  7395. * @param array defines the data to concatenate with.
  7396. */
  7397. concatWithNoDuplicate(array: any): void;
  7398. }
  7399. }
  7400. declare module BABYLON {
  7401. /**
  7402. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7403. * separate meshes. This can be use to improve performances.
  7404. * @see http://doc.babylonjs.com/how_to/multi_materials
  7405. */
  7406. export class MultiMaterial extends Material {
  7407. private _subMaterials;
  7408. /**
  7409. * Gets or Sets the list of Materials used within the multi material.
  7410. * They need to be ordered according to the submeshes order in the associated mesh
  7411. */
  7412. subMaterials: Nullable<Material>[];
  7413. /**
  7414. * Function used to align with Node.getChildren()
  7415. * @returns the list of Materials used within the multi material
  7416. */
  7417. getChildren(): Nullable<Material>[];
  7418. /**
  7419. * Instantiates a new Multi Material
  7420. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7421. * separate meshes. This can be use to improve performances.
  7422. * @see http://doc.babylonjs.com/how_to/multi_materials
  7423. * @param name Define the name in the scene
  7424. * @param scene Define the scene the material belongs to
  7425. */
  7426. constructor(name: string, scene: Scene);
  7427. private _hookArray;
  7428. /**
  7429. * Get one of the submaterial by its index in the submaterials array
  7430. * @param index The index to look the sub material at
  7431. * @returns The Material if the index has been defined
  7432. */
  7433. getSubMaterial(index: number): Nullable<Material>;
  7434. /**
  7435. * Get the list of active textures for the whole sub materials list.
  7436. * @returns All the textures that will be used during the rendering
  7437. */
  7438. getActiveTextures(): BaseTexture[];
  7439. /**
  7440. * Gets the current class name of the material e.g. "MultiMaterial"
  7441. * Mainly use in serialization.
  7442. * @returns the class name
  7443. */
  7444. getClassName(): string;
  7445. /**
  7446. * Checks if the material is ready to render the requested sub mesh
  7447. * @param mesh Define the mesh the submesh belongs to
  7448. * @param subMesh Define the sub mesh to look readyness for
  7449. * @param useInstances Define whether or not the material is used with instances
  7450. * @returns true if ready, otherwise false
  7451. */
  7452. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7453. /**
  7454. * Clones the current material and its related sub materials
  7455. * @param name Define the name of the newly cloned material
  7456. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7457. * @returns the cloned material
  7458. */
  7459. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7460. /**
  7461. * Serializes the materials into a JSON representation.
  7462. * @returns the JSON representation
  7463. */
  7464. serialize(): any;
  7465. /**
  7466. * Dispose the material and release its associated resources
  7467. * @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)
  7468. * @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)
  7469. * @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)
  7470. */
  7471. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7472. /**
  7473. * Creates a MultiMaterial from parsed MultiMaterial data.
  7474. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7475. * @param scene defines the hosting scene
  7476. * @returns a new MultiMaterial
  7477. */
  7478. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7479. }
  7480. }
  7481. declare module BABYLON {
  7482. /**
  7483. * Class used to represent data loading progression
  7484. */
  7485. export class SceneLoaderFlags {
  7486. private static _ForceFullSceneLoadingForIncremental;
  7487. private static _ShowLoadingScreen;
  7488. private static _CleanBoneMatrixWeights;
  7489. private static _loggingLevel;
  7490. /**
  7491. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7492. */
  7493. static ForceFullSceneLoadingForIncremental: boolean;
  7494. /**
  7495. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7496. */
  7497. static ShowLoadingScreen: boolean;
  7498. /**
  7499. * Defines the current logging level (while loading the scene)
  7500. * @ignorenaming
  7501. */
  7502. static loggingLevel: number;
  7503. /**
  7504. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7505. */
  7506. static CleanBoneMatrixWeights: boolean;
  7507. }
  7508. }
  7509. declare module BABYLON {
  7510. /**
  7511. * 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.
  7512. * @see https://doc.babylonjs.com/how_to/transformnode
  7513. */
  7514. export class TransformNode extends Node {
  7515. /**
  7516. * Object will not rotate to face the camera
  7517. */
  7518. static BILLBOARDMODE_NONE: number;
  7519. /**
  7520. * Object will rotate to face the camera but only on the x axis
  7521. */
  7522. static BILLBOARDMODE_X: number;
  7523. /**
  7524. * Object will rotate to face the camera but only on the y axis
  7525. */
  7526. static BILLBOARDMODE_Y: number;
  7527. /**
  7528. * Object will rotate to face the camera but only on the z axis
  7529. */
  7530. static BILLBOARDMODE_Z: number;
  7531. /**
  7532. * Object will rotate to face the camera
  7533. */
  7534. static BILLBOARDMODE_ALL: number;
  7535. private _forward;
  7536. private _forwardInverted;
  7537. private _up;
  7538. private _right;
  7539. private _rightInverted;
  7540. private _position;
  7541. private _rotation;
  7542. private _rotationQuaternion;
  7543. protected _scaling: Vector3;
  7544. protected _isDirty: boolean;
  7545. private _transformToBoneReferal;
  7546. private _billboardMode;
  7547. /**
  7548. * Gets or sets the billboard mode. Default is 0.
  7549. *
  7550. * | Value | Type | Description |
  7551. * | --- | --- | --- |
  7552. * | 0 | BILLBOARDMODE_NONE | |
  7553. * | 1 | BILLBOARDMODE_X | |
  7554. * | 2 | BILLBOARDMODE_Y | |
  7555. * | 4 | BILLBOARDMODE_Z | |
  7556. * | 7 | BILLBOARDMODE_ALL | |
  7557. *
  7558. */
  7559. billboardMode: number;
  7560. private _preserveParentRotationForBillboard;
  7561. /**
  7562. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7563. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7564. */
  7565. preserveParentRotationForBillboard: boolean;
  7566. /**
  7567. * 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
  7568. */
  7569. scalingDeterminant: number;
  7570. private _infiniteDistance;
  7571. /**
  7572. * Gets or sets the distance of the object to max, often used by skybox
  7573. */
  7574. infiniteDistance: boolean;
  7575. /**
  7576. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7577. * By default the system will update normals to compensate
  7578. */
  7579. ignoreNonUniformScaling: boolean;
  7580. /**
  7581. * 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
  7582. */
  7583. reIntegrateRotationIntoRotationQuaternion: boolean;
  7584. /** @hidden */
  7585. _poseMatrix: Nullable<Matrix>;
  7586. /** @hidden */
  7587. _localMatrix: Matrix;
  7588. private _usePivotMatrix;
  7589. private _absolutePosition;
  7590. private _pivotMatrix;
  7591. private _pivotMatrixInverse;
  7592. protected _postMultiplyPivotMatrix: boolean;
  7593. protected _isWorldMatrixFrozen: boolean;
  7594. /** @hidden */
  7595. _indexInSceneTransformNodesArray: number;
  7596. /**
  7597. * An event triggered after the world matrix is updated
  7598. */
  7599. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7600. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7601. /**
  7602. * Gets a string identifying the name of the class
  7603. * @returns "TransformNode" string
  7604. */
  7605. getClassName(): string;
  7606. /**
  7607. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7608. */
  7609. position: Vector3;
  7610. /**
  7611. * 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)).
  7612. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7613. */
  7614. rotation: Vector3;
  7615. /**
  7616. * 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)).
  7617. */
  7618. scaling: Vector3;
  7619. /**
  7620. * 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).
  7621. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7622. */
  7623. rotationQuaternion: Nullable<Quaternion>;
  7624. /**
  7625. * The forward direction of that transform in world space.
  7626. */
  7627. readonly forward: Vector3;
  7628. /**
  7629. * The up direction of that transform in world space.
  7630. */
  7631. readonly up: Vector3;
  7632. /**
  7633. * The right direction of that transform in world space.
  7634. */
  7635. readonly right: Vector3;
  7636. /**
  7637. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7638. * @param matrix the matrix to copy the pose from
  7639. * @returns this TransformNode.
  7640. */
  7641. updatePoseMatrix(matrix: Matrix): TransformNode;
  7642. /**
  7643. * Returns the mesh Pose matrix.
  7644. * @returns the pose matrix
  7645. */
  7646. getPoseMatrix(): Matrix;
  7647. /** @hidden */
  7648. _isSynchronized(): boolean;
  7649. /** @hidden */
  7650. _initCache(): void;
  7651. /**
  7652. * Flag the transform node as dirty (Forcing it to update everything)
  7653. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7654. * @returns this transform node
  7655. */
  7656. markAsDirty(property: string): TransformNode;
  7657. /**
  7658. * Returns the current mesh absolute position.
  7659. * Returns a Vector3.
  7660. */
  7661. readonly absolutePosition: Vector3;
  7662. /**
  7663. * Sets a new matrix to apply before all other transformation
  7664. * @param matrix defines the transform matrix
  7665. * @returns the current TransformNode
  7666. */
  7667. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7668. /**
  7669. * Sets a new pivot matrix to the current node
  7670. * @param matrix defines the new pivot matrix to use
  7671. * @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
  7672. * @returns the current TransformNode
  7673. */
  7674. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7675. /**
  7676. * Returns the mesh pivot matrix.
  7677. * Default : Identity.
  7678. * @returns the matrix
  7679. */
  7680. getPivotMatrix(): Matrix;
  7681. /**
  7682. * Prevents the World matrix to be computed any longer.
  7683. * @returns the TransformNode.
  7684. */
  7685. freezeWorldMatrix(): TransformNode;
  7686. /**
  7687. * Allows back the World matrix computation.
  7688. * @returns the TransformNode.
  7689. */
  7690. unfreezeWorldMatrix(): this;
  7691. /**
  7692. * True if the World matrix has been frozen.
  7693. */
  7694. readonly isWorldMatrixFrozen: boolean;
  7695. /**
  7696. * Retuns the mesh absolute position in the World.
  7697. * @returns a Vector3.
  7698. */
  7699. getAbsolutePosition(): Vector3;
  7700. /**
  7701. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7702. * @param absolutePosition the absolute position to set
  7703. * @returns the TransformNode.
  7704. */
  7705. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7706. /**
  7707. * Sets the mesh position in its local space.
  7708. * @param vector3 the position to set in localspace
  7709. * @returns the TransformNode.
  7710. */
  7711. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7712. /**
  7713. * Returns the mesh position in the local space from the current World matrix values.
  7714. * @returns a new Vector3.
  7715. */
  7716. getPositionExpressedInLocalSpace(): Vector3;
  7717. /**
  7718. * Translates the mesh along the passed Vector3 in its local space.
  7719. * @param vector3 the distance to translate in localspace
  7720. * @returns the TransformNode.
  7721. */
  7722. locallyTranslate(vector3: Vector3): TransformNode;
  7723. private static _lookAtVectorCache;
  7724. /**
  7725. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7726. * @param targetPoint the position (must be in same space as current mesh) to look at
  7727. * @param yawCor optional yaw (y-axis) correction in radians
  7728. * @param pitchCor optional pitch (x-axis) correction in radians
  7729. * @param rollCor optional roll (z-axis) correction in radians
  7730. * @param space the choosen space of the target
  7731. * @returns the TransformNode.
  7732. */
  7733. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7734. /**
  7735. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7736. * This Vector3 is expressed in the World space.
  7737. * @param localAxis axis to rotate
  7738. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7739. */
  7740. getDirection(localAxis: Vector3): Vector3;
  7741. /**
  7742. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7743. * localAxis is expressed in the mesh local space.
  7744. * result is computed in the Wordl space from the mesh World matrix.
  7745. * @param localAxis axis to rotate
  7746. * @param result the resulting transformnode
  7747. * @returns this TransformNode.
  7748. */
  7749. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7750. /**
  7751. * Sets this transform node rotation to the given local axis.
  7752. * @param localAxis the axis in local space
  7753. * @param yawCor optional yaw (y-axis) correction in radians
  7754. * @param pitchCor optional pitch (x-axis) correction in radians
  7755. * @param rollCor optional roll (z-axis) correction in radians
  7756. * @returns this TransformNode
  7757. */
  7758. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7759. /**
  7760. * Sets a new pivot point to the current node
  7761. * @param point defines the new pivot point to use
  7762. * @param space defines if the point is in world or local space (local by default)
  7763. * @returns the current TransformNode
  7764. */
  7765. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7766. /**
  7767. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7768. * @returns the pivot point
  7769. */
  7770. getPivotPoint(): Vector3;
  7771. /**
  7772. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7773. * @param result the vector3 to store the result
  7774. * @returns this TransformNode.
  7775. */
  7776. getPivotPointToRef(result: Vector3): TransformNode;
  7777. /**
  7778. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7779. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7780. */
  7781. getAbsolutePivotPoint(): Vector3;
  7782. /**
  7783. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7784. * @param result vector3 to store the result
  7785. * @returns this TransformNode.
  7786. */
  7787. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7788. /**
  7789. * Defines the passed node as the parent of the current node.
  7790. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7791. * @see https://doc.babylonjs.com/how_to/parenting
  7792. * @param node the node ot set as the parent
  7793. * @returns this TransformNode.
  7794. */
  7795. setParent(node: Nullable<Node>): TransformNode;
  7796. private _nonUniformScaling;
  7797. /**
  7798. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7799. */
  7800. readonly nonUniformScaling: boolean;
  7801. /** @hidden */
  7802. _updateNonUniformScalingState(value: boolean): boolean;
  7803. /**
  7804. * Attach the current TransformNode to another TransformNode associated with a bone
  7805. * @param bone Bone affecting the TransformNode
  7806. * @param affectedTransformNode TransformNode associated with the bone
  7807. * @returns this object
  7808. */
  7809. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7810. /**
  7811. * Detach the transform node if its associated with a bone
  7812. * @returns this object
  7813. */
  7814. detachFromBone(): TransformNode;
  7815. private static _rotationAxisCache;
  7816. /**
  7817. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7818. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7819. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7820. * The passed axis is also normalized.
  7821. * @param axis the axis to rotate around
  7822. * @param amount the amount to rotate in radians
  7823. * @param space Space to rotate in (Default: local)
  7824. * @returns the TransformNode.
  7825. */
  7826. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7827. /**
  7828. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7829. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7830. * The passed axis is also normalized. .
  7831. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7832. * @param point the point to rotate around
  7833. * @param axis the axis to rotate around
  7834. * @param amount the amount to rotate in radians
  7835. * @returns the TransformNode
  7836. */
  7837. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7838. /**
  7839. * Translates the mesh along the axis vector for the passed distance in the given space.
  7840. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7841. * @param axis the axis to translate in
  7842. * @param distance the distance to translate
  7843. * @param space Space to rotate in (Default: local)
  7844. * @returns the TransformNode.
  7845. */
  7846. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7847. /**
  7848. * Adds a rotation step to the mesh current rotation.
  7849. * x, y, z are Euler angles expressed in radians.
  7850. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7851. * This means this rotation is made in the mesh local space only.
  7852. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7853. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7854. * ```javascript
  7855. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7856. * ```
  7857. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7858. * 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.
  7859. * @param x Rotation to add
  7860. * @param y Rotation to add
  7861. * @param z Rotation to add
  7862. * @returns the TransformNode.
  7863. */
  7864. addRotation(x: number, y: number, z: number): TransformNode;
  7865. /**
  7866. * @hidden
  7867. */
  7868. protected _getEffectiveParent(): Nullable<Node>;
  7869. /**
  7870. * Computes the world matrix of the node
  7871. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7872. * @returns the world matrix
  7873. */
  7874. computeWorldMatrix(force?: boolean): Matrix;
  7875. protected _afterComputeWorldMatrix(): void;
  7876. /**
  7877. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7878. * @param func callback function to add
  7879. *
  7880. * @returns the TransformNode.
  7881. */
  7882. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7883. /**
  7884. * Removes a registered callback function.
  7885. * @param func callback function to remove
  7886. * @returns the TransformNode.
  7887. */
  7888. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7889. /**
  7890. * Gets the position of the current mesh in camera space
  7891. * @param camera defines the camera to use
  7892. * @returns a position
  7893. */
  7894. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7895. /**
  7896. * Returns the distance from the mesh to the active camera
  7897. * @param camera defines the camera to use
  7898. * @returns the distance
  7899. */
  7900. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7901. /**
  7902. * Clone the current transform node
  7903. * @param name Name of the new clone
  7904. * @param newParent New parent for the clone
  7905. * @param doNotCloneChildren Do not clone children hierarchy
  7906. * @returns the new transform node
  7907. */
  7908. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7909. /**
  7910. * Serializes the objects information.
  7911. * @param currentSerializationObject defines the object to serialize in
  7912. * @returns the serialized object
  7913. */
  7914. serialize(currentSerializationObject?: any): any;
  7915. /**
  7916. * Returns a new TransformNode object parsed from the source provided.
  7917. * @param parsedTransformNode is the source.
  7918. * @param scene the scne the object belongs to
  7919. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7920. * @returns a new TransformNode object parsed from the source provided.
  7921. */
  7922. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7923. /**
  7924. * Get all child-transformNodes of this node
  7925. * @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
  7926. * @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
  7927. * @returns an array of TransformNode
  7928. */
  7929. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7930. /**
  7931. * Releases resources associated with this transform node.
  7932. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7933. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7934. */
  7935. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7936. }
  7937. }
  7938. declare module BABYLON {
  7939. /**
  7940. * Class used to override all child animations of a given target
  7941. */
  7942. export class AnimationPropertiesOverride {
  7943. /**
  7944. * Gets or sets a value indicating if animation blending must be used
  7945. */
  7946. enableBlending: boolean;
  7947. /**
  7948. * Gets or sets the blending speed to use when enableBlending is true
  7949. */
  7950. blendingSpeed: number;
  7951. /**
  7952. * Gets or sets the default loop mode to use
  7953. */
  7954. loopMode: number;
  7955. }
  7956. }
  7957. declare module BABYLON {
  7958. /**
  7959. * Class used to store bone information
  7960. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7961. */
  7962. export class Bone extends Node {
  7963. /**
  7964. * defines the bone name
  7965. */
  7966. name: string;
  7967. private static _tmpVecs;
  7968. private static _tmpQuat;
  7969. private static _tmpMats;
  7970. /**
  7971. * Gets the list of child bones
  7972. */
  7973. children: Bone[];
  7974. /** Gets the animations associated with this bone */
  7975. animations: Animation[];
  7976. /**
  7977. * Gets or sets bone length
  7978. */
  7979. length: number;
  7980. /**
  7981. * @hidden Internal only
  7982. * Set this value to map this bone to a different index in the transform matrices
  7983. * Set this value to -1 to exclude the bone from the transform matrices
  7984. */
  7985. _index: Nullable<number>;
  7986. private _skeleton;
  7987. private _localMatrix;
  7988. private _restPose;
  7989. private _baseMatrix;
  7990. private _absoluteTransform;
  7991. private _invertedAbsoluteTransform;
  7992. private _parent;
  7993. private _scalingDeterminant;
  7994. private _worldTransform;
  7995. private _localScaling;
  7996. private _localRotation;
  7997. private _localPosition;
  7998. private _needToDecompose;
  7999. private _needToCompose;
  8000. /** @hidden */
  8001. _linkedTransformNode: Nullable<TransformNode>;
  8002. /** @hidden */
  8003. _waitingTransformNodeId: Nullable<string>;
  8004. /** @hidden */
  8005. /** @hidden */
  8006. _matrix: Matrix;
  8007. /**
  8008. * Create a new bone
  8009. * @param name defines the bone name
  8010. * @param skeleton defines the parent skeleton
  8011. * @param parentBone defines the parent (can be null if the bone is the root)
  8012. * @param localMatrix defines the local matrix
  8013. * @param restPose defines the rest pose matrix
  8014. * @param baseMatrix defines the base matrix
  8015. * @param index defines index of the bone in the hiearchy
  8016. */
  8017. constructor(
  8018. /**
  8019. * defines the bone name
  8020. */
  8021. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8022. /**
  8023. * Gets the current object class name.
  8024. * @return the class name
  8025. */
  8026. getClassName(): string;
  8027. /**
  8028. * Gets the parent skeleton
  8029. * @returns a skeleton
  8030. */
  8031. getSkeleton(): Skeleton;
  8032. /**
  8033. * Gets parent bone
  8034. * @returns a bone or null if the bone is the root of the bone hierarchy
  8035. */
  8036. getParent(): Nullable<Bone>;
  8037. /**
  8038. * Returns an array containing the root bones
  8039. * @returns an array containing the root bones
  8040. */
  8041. getChildren(): Array<Bone>;
  8042. /**
  8043. * Sets the parent bone
  8044. * @param parent defines the parent (can be null if the bone is the root)
  8045. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8046. */
  8047. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8048. /**
  8049. * Gets the local matrix
  8050. * @returns a matrix
  8051. */
  8052. getLocalMatrix(): Matrix;
  8053. /**
  8054. * Gets the base matrix (initial matrix which remains unchanged)
  8055. * @returns a matrix
  8056. */
  8057. getBaseMatrix(): Matrix;
  8058. /**
  8059. * Gets the rest pose matrix
  8060. * @returns a matrix
  8061. */
  8062. getRestPose(): Matrix;
  8063. /**
  8064. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8065. */
  8066. getWorldMatrix(): Matrix;
  8067. /**
  8068. * Sets the local matrix to rest pose matrix
  8069. */
  8070. returnToRest(): void;
  8071. /**
  8072. * Gets the inverse of the absolute transform matrix.
  8073. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8074. * @returns a matrix
  8075. */
  8076. getInvertedAbsoluteTransform(): Matrix;
  8077. /**
  8078. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8079. * @returns a matrix
  8080. */
  8081. getAbsoluteTransform(): Matrix;
  8082. /**
  8083. * Links with the given transform node.
  8084. * The local matrix of this bone is copied from the transform node every frame.
  8085. * @param transformNode defines the transform node to link to
  8086. */
  8087. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8088. /** Gets or sets current position (in local space) */
  8089. position: Vector3;
  8090. /** Gets or sets current rotation (in local space) */
  8091. rotation: Vector3;
  8092. /** Gets or sets current rotation quaternion (in local space) */
  8093. rotationQuaternion: Quaternion;
  8094. /** Gets or sets current scaling (in local space) */
  8095. scaling: Vector3;
  8096. /**
  8097. * Gets the animation properties override
  8098. */
  8099. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8100. private _decompose;
  8101. private _compose;
  8102. /**
  8103. * Update the base and local matrices
  8104. * @param matrix defines the new base or local matrix
  8105. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8106. * @param updateLocalMatrix defines if the local matrix should be updated
  8107. */
  8108. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8109. /** @hidden */
  8110. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8111. /**
  8112. * Flag the bone as dirty (Forcing it to update everything)
  8113. */
  8114. markAsDirty(): void;
  8115. private _markAsDirtyAndCompose;
  8116. private _markAsDirtyAndDecompose;
  8117. /**
  8118. * Translate the bone in local or world space
  8119. * @param vec The amount to translate the bone
  8120. * @param space The space that the translation is in
  8121. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8122. */
  8123. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8124. /**
  8125. * Set the postion of the bone in local or world space
  8126. * @param position The position to set the bone
  8127. * @param space The space that the position is in
  8128. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8129. */
  8130. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8131. /**
  8132. * Set the absolute position of the bone (world space)
  8133. * @param position The position to set the bone
  8134. * @param mesh The mesh that this bone is attached to
  8135. */
  8136. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8137. /**
  8138. * Scale the bone on the x, y and z axes (in local space)
  8139. * @param x The amount to scale the bone on the x axis
  8140. * @param y The amount to scale the bone on the y axis
  8141. * @param z The amount to scale the bone on the z axis
  8142. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8143. */
  8144. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8145. /**
  8146. * Set the bone scaling in local space
  8147. * @param scale defines the scaling vector
  8148. */
  8149. setScale(scale: Vector3): void;
  8150. /**
  8151. * Gets the current scaling in local space
  8152. * @returns the current scaling vector
  8153. */
  8154. getScale(): Vector3;
  8155. /**
  8156. * Gets the current scaling in local space and stores it in a target vector
  8157. * @param result defines the target vector
  8158. */
  8159. getScaleToRef(result: Vector3): void;
  8160. /**
  8161. * Set the yaw, pitch, and roll of the bone in local or world space
  8162. * @param yaw The rotation of the bone on the y axis
  8163. * @param pitch The rotation of the bone on the x axis
  8164. * @param roll The rotation of the bone on the z axis
  8165. * @param space The space that the axes of rotation are in
  8166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8167. */
  8168. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8169. /**
  8170. * Add a rotation to the bone on an axis in local or world space
  8171. * @param axis The axis to rotate the bone on
  8172. * @param amount The amount to rotate the bone
  8173. * @param space The space that the axis is in
  8174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8175. */
  8176. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8177. /**
  8178. * Set the rotation of the bone to a particular axis angle in local or world space
  8179. * @param axis The axis to rotate the bone on
  8180. * @param angle The angle that the bone should be rotated to
  8181. * @param space The space that the axis is in
  8182. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8183. */
  8184. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8185. /**
  8186. * Set the euler rotation of the bone in local of world space
  8187. * @param rotation The euler rotation that the bone should be set to
  8188. * @param space The space that the rotation is in
  8189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8190. */
  8191. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8192. /**
  8193. * Set the quaternion rotation of the bone in local of world space
  8194. * @param quat The quaternion rotation that the bone should be set to
  8195. * @param space The space that the rotation is in
  8196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8197. */
  8198. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8199. /**
  8200. * Set the rotation matrix of the bone in local of world space
  8201. * @param rotMat The rotation matrix that the bone should be set to
  8202. * @param space The space that the rotation is in
  8203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8204. */
  8205. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8206. private _rotateWithMatrix;
  8207. private _getNegativeRotationToRef;
  8208. /**
  8209. * Get the position of the bone in local or world space
  8210. * @param space The space that the returned position is in
  8211. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8212. * @returns The position of the bone
  8213. */
  8214. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8215. /**
  8216. * Copy the position of the bone to a vector3 in local or world space
  8217. * @param space The space that the returned position is in
  8218. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8219. * @param result The vector3 to copy the position to
  8220. */
  8221. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8222. /**
  8223. * Get the absolute position of the bone (world space)
  8224. * @param mesh The mesh that this bone is attached to
  8225. * @returns The absolute position of the bone
  8226. */
  8227. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8228. /**
  8229. * Copy the absolute position of the bone (world space) to the result param
  8230. * @param mesh The mesh that this bone is attached to
  8231. * @param result The vector3 to copy the absolute position to
  8232. */
  8233. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8234. /**
  8235. * Compute the absolute transforms of this bone and its children
  8236. */
  8237. computeAbsoluteTransforms(): void;
  8238. /**
  8239. * Get the world direction from an axis that is in the local space of the bone
  8240. * @param localAxis The local direction that is used to compute the world direction
  8241. * @param mesh The mesh that this bone is attached to
  8242. * @returns The world direction
  8243. */
  8244. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8245. /**
  8246. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8247. * @param localAxis The local direction that is used to compute the world direction
  8248. * @param mesh The mesh that this bone is attached to
  8249. * @param result The vector3 that the world direction will be copied to
  8250. */
  8251. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8252. /**
  8253. * Get the euler rotation of the bone in local or world space
  8254. * @param space The space that the rotation should be in
  8255. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8256. * @returns The euler rotation
  8257. */
  8258. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8259. /**
  8260. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8261. * @param space The space that the rotation should be in
  8262. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8263. * @param result The vector3 that the rotation should be copied to
  8264. */
  8265. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8266. /**
  8267. * Get the quaternion rotation of the bone in either local or world space
  8268. * @param space The space that the rotation should be in
  8269. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8270. * @returns The quaternion rotation
  8271. */
  8272. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8273. /**
  8274. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8275. * @param space The space that the rotation should be in
  8276. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8277. * @param result The quaternion that the rotation should be copied to
  8278. */
  8279. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8280. /**
  8281. * Get the rotation matrix of the bone in local or world space
  8282. * @param space The space that the rotation should be in
  8283. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8284. * @returns The rotation matrix
  8285. */
  8286. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8287. /**
  8288. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8289. * @param space The space that the rotation should be in
  8290. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8291. * @param result The quaternion that the rotation should be copied to
  8292. */
  8293. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8294. /**
  8295. * Get the world position of a point that is in the local space of the bone
  8296. * @param position The local position
  8297. * @param mesh The mesh that this bone is attached to
  8298. * @returns The world position
  8299. */
  8300. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8301. /**
  8302. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8303. * @param position The local position
  8304. * @param mesh The mesh that this bone is attached to
  8305. * @param result The vector3 that the world position should be copied to
  8306. */
  8307. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8308. /**
  8309. * Get the local position of a point that is in world space
  8310. * @param position The world position
  8311. * @param mesh The mesh that this bone is attached to
  8312. * @returns The local position
  8313. */
  8314. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8315. /**
  8316. * Get the local position of a point that is in world space and copy it to the result param
  8317. * @param position The world position
  8318. * @param mesh The mesh that this bone is attached to
  8319. * @param result The vector3 that the local position should be copied to
  8320. */
  8321. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8322. }
  8323. }
  8324. declare module BABYLON {
  8325. /**
  8326. * Enum that determines the text-wrapping mode to use.
  8327. */
  8328. export enum InspectableType {
  8329. /**
  8330. * Checkbox for booleans
  8331. */
  8332. Checkbox = 0,
  8333. /**
  8334. * Sliders for numbers
  8335. */
  8336. Slider = 1,
  8337. /**
  8338. * Vector3
  8339. */
  8340. Vector3 = 2,
  8341. /**
  8342. * Quaternions
  8343. */
  8344. Quaternion = 3,
  8345. /**
  8346. * Color3
  8347. */
  8348. Color3 = 4
  8349. }
  8350. /**
  8351. * Interface used to define custom inspectable properties.
  8352. * This interface is used by the inspector to display custom property grids
  8353. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8354. */
  8355. export interface IInspectable {
  8356. /**
  8357. * Gets the label to display
  8358. */
  8359. label: string;
  8360. /**
  8361. * Gets the name of the property to edit
  8362. */
  8363. propertyName: string;
  8364. /**
  8365. * Gets the type of the editor to use
  8366. */
  8367. type: InspectableType;
  8368. /**
  8369. * Gets the minimum value of the property when using in "slider" mode
  8370. */
  8371. min?: number;
  8372. /**
  8373. * Gets the maximum value of the property when using in "slider" mode
  8374. */
  8375. max?: number;
  8376. /**
  8377. * Gets the setp to use when using in "slider" mode
  8378. */
  8379. step?: number;
  8380. }
  8381. }
  8382. declare module BABYLON {
  8383. /**
  8384. * This represents the required contract to create a new type of texture loader.
  8385. */
  8386. export interface IInternalTextureLoader {
  8387. /**
  8388. * Defines wether the loader supports cascade loading the different faces.
  8389. */
  8390. supportCascades: boolean;
  8391. /**
  8392. * This returns if the loader support the current file information.
  8393. * @param extension defines the file extension of the file being loaded
  8394. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8395. * @param fallback defines the fallback internal texture if any
  8396. * @param isBase64 defines whether the texture is encoded as a base64
  8397. * @param isBuffer defines whether the texture data are stored as a buffer
  8398. * @returns true if the loader can load the specified file
  8399. */
  8400. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8401. /**
  8402. * Transform the url before loading if required.
  8403. * @param rootUrl the url of the texture
  8404. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8405. * @returns the transformed texture
  8406. */
  8407. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8408. /**
  8409. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8410. * @param rootUrl the url of the texture
  8411. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8412. * @returns the fallback texture
  8413. */
  8414. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8415. /**
  8416. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8417. * @param data contains the texture data
  8418. * @param texture defines the BabylonJS internal texture
  8419. * @param createPolynomials will be true if polynomials have been requested
  8420. * @param onLoad defines the callback to trigger once the texture is ready
  8421. * @param onError defines the callback to trigger in case of error
  8422. */
  8423. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8424. /**
  8425. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8426. * @param data contains the texture data
  8427. * @param texture defines the BabylonJS internal texture
  8428. * @param callback defines the method to call once ready to upload
  8429. */
  8430. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8431. }
  8432. }
  8433. declare module BABYLON {
  8434. interface Engine {
  8435. /**
  8436. * Creates a depth stencil cube texture.
  8437. * This is only available in WebGL 2.
  8438. * @param size The size of face edge in the cube texture.
  8439. * @param options The options defining the cube texture.
  8440. * @returns The cube texture
  8441. */
  8442. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8443. /**
  8444. * Creates a cube texture
  8445. * @param rootUrl defines the url where the files to load is located
  8446. * @param scene defines the current scene
  8447. * @param files defines the list of files to load (1 per face)
  8448. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8449. * @param onLoad defines an optional callback raised when the texture is loaded
  8450. * @param onError defines an optional callback raised if there is an issue to load the texture
  8451. * @param format defines the format of the data
  8452. * @param forcedExtension defines the extension to use to pick the right loader
  8453. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8454. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8455. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8456. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8457. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8458. * @returns the cube texture as an InternalTexture
  8459. */
  8460. 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;
  8461. /**
  8462. * Creates a cube texture
  8463. * @param rootUrl defines the url where the files to load is located
  8464. * @param scene defines the current scene
  8465. * @param files defines the list of files to load (1 per face)
  8466. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8467. * @param onLoad defines an optional callback raised when the texture is loaded
  8468. * @param onError defines an optional callback raised if there is an issue to load the texture
  8469. * @param format defines the format of the data
  8470. * @param forcedExtension defines the extension to use to pick the right loader
  8471. * @returns the cube texture as an InternalTexture
  8472. */
  8473. 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;
  8474. /**
  8475. * Creates a cube texture
  8476. * @param rootUrl defines the url where the files to load is located
  8477. * @param scene defines the current scene
  8478. * @param files defines the list of files to load (1 per face)
  8479. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8480. * @param onLoad defines an optional callback raised when the texture is loaded
  8481. * @param onError defines an optional callback raised if there is an issue to load the texture
  8482. * @param format defines the format of the data
  8483. * @param forcedExtension defines the extension to use to pick the right loader
  8484. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8485. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8486. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8487. * @returns the cube texture as an InternalTexture
  8488. */
  8489. 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;
  8490. /** @hidden */
  8491. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8492. /** @hidden */
  8493. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8494. /** @hidden */
  8495. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8496. /** @hidden */
  8497. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8498. }
  8499. }
  8500. declare module BABYLON {
  8501. /**
  8502. * Class for creating a cube texture
  8503. */
  8504. export class CubeTexture extends BaseTexture {
  8505. private _delayedOnLoad;
  8506. /**
  8507. * The url of the texture
  8508. */
  8509. url: string;
  8510. /**
  8511. * Gets or sets the center of the bounding box associated with the cube texture.
  8512. * It must define where the camera used to render the texture was set
  8513. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8514. */
  8515. boundingBoxPosition: Vector3;
  8516. private _boundingBoxSize;
  8517. /**
  8518. * Gets or sets the size of the bounding box associated with the cube texture
  8519. * When defined, the cubemap will switch to local mode
  8520. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8521. * @example https://www.babylonjs-playground.com/#RNASML
  8522. */
  8523. /**
  8524. * Returns the bounding box size
  8525. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8526. */
  8527. boundingBoxSize: Vector3;
  8528. protected _rotationY: number;
  8529. /**
  8530. * Sets texture matrix rotation angle around Y axis in radians.
  8531. */
  8532. /**
  8533. * Gets texture matrix rotation angle around Y axis radians.
  8534. */
  8535. rotationY: number;
  8536. /**
  8537. * Are mip maps generated for this texture or not.
  8538. */
  8539. readonly noMipmap: boolean;
  8540. private _noMipmap;
  8541. private _files;
  8542. private _extensions;
  8543. private _textureMatrix;
  8544. private _format;
  8545. private _createPolynomials;
  8546. /** @hidden */
  8547. _prefiltered: boolean;
  8548. /**
  8549. * Creates a cube texture from an array of image urls
  8550. * @param files defines an array of image urls
  8551. * @param scene defines the hosting scene
  8552. * @param noMipmap specifies if mip maps are not used
  8553. * @returns a cube texture
  8554. */
  8555. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8556. /**
  8557. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8558. * @param url defines the url of the prefiltered texture
  8559. * @param scene defines the scene the texture is attached to
  8560. * @param forcedExtension defines the extension of the file if different from the url
  8561. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8562. * @return the prefiltered texture
  8563. */
  8564. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8565. /**
  8566. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8567. * as prefiltered data.
  8568. * @param rootUrl defines the url of the texture or the root name of the six images
  8569. * @param scene defines the scene the texture is attached to
  8570. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8571. * @param noMipmap defines if mipmaps should be created or not
  8572. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8573. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8574. * @param onError defines a callback triggered in case of error during load
  8575. * @param format defines the internal format to use for the texture once loaded
  8576. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8577. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8578. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8579. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8580. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8581. * @return the cube texture
  8582. */
  8583. 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);
  8584. /**
  8585. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8586. */
  8587. readonly isPrefiltered: boolean;
  8588. /**
  8589. * Get the current class name of the texture useful for serialization or dynamic coding.
  8590. * @returns "CubeTexture"
  8591. */
  8592. getClassName(): string;
  8593. /**
  8594. * Update the url (and optional buffer) of this texture if url was null during construction.
  8595. * @param url the url of the texture
  8596. * @param forcedExtension defines the extension to use
  8597. * @param onLoad callback called when the texture is loaded (defaults to null)
  8598. */
  8599. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8600. /**
  8601. * Delays loading of the cube texture
  8602. * @param forcedExtension defines the extension to use
  8603. */
  8604. delayLoad(forcedExtension?: string): void;
  8605. /**
  8606. * Returns the reflection texture matrix
  8607. * @returns the reflection texture matrix
  8608. */
  8609. getReflectionTextureMatrix(): Matrix;
  8610. /**
  8611. * Sets the reflection texture matrix
  8612. * @param value Reflection texture matrix
  8613. */
  8614. setReflectionTextureMatrix(value: Matrix): void;
  8615. /**
  8616. * Parses text to create a cube texture
  8617. * @param parsedTexture define the serialized text to read from
  8618. * @param scene defines the hosting scene
  8619. * @param rootUrl defines the root url of the cube texture
  8620. * @returns a cube texture
  8621. */
  8622. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8623. /**
  8624. * Makes a clone, or deep copy, of the cube texture
  8625. * @returns a new cube texture
  8626. */
  8627. clone(): CubeTexture;
  8628. }
  8629. }
  8630. declare module BABYLON {
  8631. /** @hidden */
  8632. export var postprocessVertexShader: {
  8633. name: string;
  8634. shader: string;
  8635. };
  8636. }
  8637. declare module BABYLON {
  8638. /**
  8639. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8640. * This is the base of the follow, arc rotate cameras and Free camera
  8641. * @see http://doc.babylonjs.com/features/cameras
  8642. */
  8643. export class TargetCamera extends Camera {
  8644. private static _RigCamTransformMatrix;
  8645. private static _TargetTransformMatrix;
  8646. private static _TargetFocalPoint;
  8647. /**
  8648. * Define the current direction the camera is moving to
  8649. */
  8650. cameraDirection: Vector3;
  8651. /**
  8652. * Define the current rotation the camera is rotating to
  8653. */
  8654. cameraRotation: Vector2;
  8655. /**
  8656. * When set, the up vector of the camera will be updated by the rotation of the camera
  8657. */
  8658. updateUpVectorFromRotation: boolean;
  8659. private _tmpQuaternion;
  8660. /**
  8661. * Define the current rotation of the camera
  8662. */
  8663. rotation: Vector3;
  8664. /**
  8665. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8666. */
  8667. rotationQuaternion: Quaternion;
  8668. /**
  8669. * Define the current speed of the camera
  8670. */
  8671. speed: number;
  8672. /**
  8673. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8674. * around all axis.
  8675. */
  8676. noRotationConstraint: boolean;
  8677. /**
  8678. * Define the current target of the camera as an object or a position.
  8679. */
  8680. lockedTarget: any;
  8681. /** @hidden */
  8682. _currentTarget: Vector3;
  8683. /** @hidden */
  8684. _initialFocalDistance: number;
  8685. /** @hidden */
  8686. _viewMatrix: Matrix;
  8687. /** @hidden */
  8688. _camMatrix: Matrix;
  8689. /** @hidden */
  8690. _cameraTransformMatrix: Matrix;
  8691. /** @hidden */
  8692. _cameraRotationMatrix: Matrix;
  8693. /** @hidden */
  8694. _referencePoint: Vector3;
  8695. /** @hidden */
  8696. _transformedReferencePoint: Vector3;
  8697. protected _globalCurrentTarget: Vector3;
  8698. protected _globalCurrentUpVector: Vector3;
  8699. /** @hidden */
  8700. _reset: () => void;
  8701. private _defaultUp;
  8702. /**
  8703. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8704. * This is the base of the follow, arc rotate cameras and Free camera
  8705. * @see http://doc.babylonjs.com/features/cameras
  8706. * @param name Defines the name of the camera in the scene
  8707. * @param position Defines the start position of the camera in the scene
  8708. * @param scene Defines the scene the camera belongs to
  8709. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8710. */
  8711. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8712. /**
  8713. * Gets the position in front of the camera at a given distance.
  8714. * @param distance The distance from the camera we want the position to be
  8715. * @returns the position
  8716. */
  8717. getFrontPosition(distance: number): Vector3;
  8718. /** @hidden */
  8719. _getLockedTargetPosition(): Nullable<Vector3>;
  8720. private _storedPosition;
  8721. private _storedRotation;
  8722. private _storedRotationQuaternion;
  8723. /**
  8724. * Store current camera state of the camera (fov, position, rotation, etc..)
  8725. * @returns the camera
  8726. */
  8727. storeState(): Camera;
  8728. /**
  8729. * Restored camera state. You must call storeState() first
  8730. * @returns whether it was successful or not
  8731. * @hidden
  8732. */
  8733. _restoreStateValues(): boolean;
  8734. /** @hidden */
  8735. _initCache(): void;
  8736. /** @hidden */
  8737. _updateCache(ignoreParentClass?: boolean): void;
  8738. /** @hidden */
  8739. _isSynchronizedViewMatrix(): boolean;
  8740. /** @hidden */
  8741. _computeLocalCameraSpeed(): number;
  8742. /**
  8743. * Defines the target the camera should look at.
  8744. * This will automatically adapt alpha beta and radius to fit within the new target.
  8745. * @param target Defines the new target as a Vector or a mesh
  8746. */
  8747. setTarget(target: Vector3): void;
  8748. /**
  8749. * Return the current target position of the camera. This value is expressed in local space.
  8750. * @returns the target position
  8751. */
  8752. getTarget(): Vector3;
  8753. /** @hidden */
  8754. _decideIfNeedsToMove(): boolean;
  8755. /** @hidden */
  8756. _updatePosition(): void;
  8757. /** @hidden */
  8758. _checkInputs(): void;
  8759. protected _updateCameraRotationMatrix(): void;
  8760. /**
  8761. * 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)
  8762. * @returns the current camera
  8763. */
  8764. private _rotateUpVectorWithCameraRotationMatrix;
  8765. private _cachedRotationZ;
  8766. private _cachedQuaternionRotationZ;
  8767. /** @hidden */
  8768. _getViewMatrix(): Matrix;
  8769. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8770. /**
  8771. * @hidden
  8772. */
  8773. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8774. /**
  8775. * @hidden
  8776. */
  8777. _updateRigCameras(): void;
  8778. private _getRigCamPositionAndTarget;
  8779. /**
  8780. * Gets the current object class name.
  8781. * @return the class name
  8782. */
  8783. getClassName(): string;
  8784. }
  8785. }
  8786. declare module BABYLON {
  8787. /**
  8788. * @ignore
  8789. * This is a list of all the different input types that are available in the application.
  8790. * Fo instance: ArcRotateCameraGamepadInput...
  8791. */
  8792. export var CameraInputTypes: {};
  8793. /**
  8794. * This is the contract to implement in order to create a new input class.
  8795. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8796. */
  8797. export interface ICameraInput<TCamera extends Camera> {
  8798. /**
  8799. * Defines the camera the input is attached to.
  8800. */
  8801. camera: Nullable<TCamera>;
  8802. /**
  8803. * Gets the class name of the current intput.
  8804. * @returns the class name
  8805. */
  8806. getClassName(): string;
  8807. /**
  8808. * Get the friendly name associated with the input class.
  8809. * @returns the input friendly name
  8810. */
  8811. getSimpleName(): string;
  8812. /**
  8813. * Attach the input controls to a specific dom element to get the input from.
  8814. * @param element Defines the element the controls should be listened from
  8815. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8816. */
  8817. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8818. /**
  8819. * Detach the current controls from the specified dom element.
  8820. * @param element Defines the element to stop listening the inputs from
  8821. */
  8822. detachControl(element: Nullable<HTMLElement>): void;
  8823. /**
  8824. * Update the current camera state depending on the inputs that have been used this frame.
  8825. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8826. */
  8827. checkInputs?: () => void;
  8828. }
  8829. /**
  8830. * Represents a map of input types to input instance or input index to input instance.
  8831. */
  8832. export interface CameraInputsMap<TCamera extends Camera> {
  8833. /**
  8834. * Accessor to the input by input type.
  8835. */
  8836. [name: string]: ICameraInput<TCamera>;
  8837. /**
  8838. * Accessor to the input by input index.
  8839. */
  8840. [idx: number]: ICameraInput<TCamera>;
  8841. }
  8842. /**
  8843. * This represents the input manager used within a camera.
  8844. * It helps dealing with all the different kind of input attached to a camera.
  8845. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8846. */
  8847. export class CameraInputsManager<TCamera extends Camera> {
  8848. /**
  8849. * Defines the list of inputs attahed to the camera.
  8850. */
  8851. attached: CameraInputsMap<TCamera>;
  8852. /**
  8853. * Defines the dom element the camera is collecting inputs from.
  8854. * This is null if the controls have not been attached.
  8855. */
  8856. attachedElement: Nullable<HTMLElement>;
  8857. /**
  8858. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8859. */
  8860. noPreventDefault: boolean;
  8861. /**
  8862. * Defined the camera the input manager belongs to.
  8863. */
  8864. camera: TCamera;
  8865. /**
  8866. * Update the current camera state depending on the inputs that have been used this frame.
  8867. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8868. */
  8869. checkInputs: () => void;
  8870. /**
  8871. * Instantiate a new Camera Input Manager.
  8872. * @param camera Defines the camera the input manager blongs to
  8873. */
  8874. constructor(camera: TCamera);
  8875. /**
  8876. * Add an input method to a camera
  8877. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8878. * @param input camera input method
  8879. */
  8880. add(input: ICameraInput<TCamera>): void;
  8881. /**
  8882. * Remove a specific input method from a camera
  8883. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8884. * @param inputToRemove camera input method
  8885. */
  8886. remove(inputToRemove: ICameraInput<TCamera>): void;
  8887. /**
  8888. * Remove a specific input type from a camera
  8889. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8890. * @param inputType the type of the input to remove
  8891. */
  8892. removeByType(inputType: string): void;
  8893. private _addCheckInputs;
  8894. /**
  8895. * Attach the input controls to the currently attached dom element to listen the events from.
  8896. * @param input Defines the input to attach
  8897. */
  8898. attachInput(input: ICameraInput<TCamera>): void;
  8899. /**
  8900. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8901. * @param element Defines the dom element to collect the events from
  8902. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8903. */
  8904. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8905. /**
  8906. * Detach the current manager inputs controls from a specific dom element.
  8907. * @param element Defines the dom element to collect the events from
  8908. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8909. */
  8910. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8911. /**
  8912. * Rebuild the dynamic inputCheck function from the current list of
  8913. * defined inputs in the manager.
  8914. */
  8915. rebuildInputCheck(): void;
  8916. /**
  8917. * Remove all attached input methods from a camera
  8918. */
  8919. clear(): void;
  8920. /**
  8921. * Serialize the current input manager attached to a camera.
  8922. * This ensures than once parsed,
  8923. * the input associated to the camera will be identical to the current ones
  8924. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8925. */
  8926. serialize(serializedCamera: any): void;
  8927. /**
  8928. * Parses an input manager serialized JSON to restore the previous list of inputs
  8929. * and states associated to a camera.
  8930. * @param parsedCamera Defines the JSON to parse
  8931. */
  8932. parse(parsedCamera: any): void;
  8933. }
  8934. }
  8935. declare module BABYLON {
  8936. /**
  8937. * Gather the list of keyboard event types as constants.
  8938. */
  8939. export class KeyboardEventTypes {
  8940. /**
  8941. * The keydown event is fired when a key becomes active (pressed).
  8942. */
  8943. static readonly KEYDOWN: number;
  8944. /**
  8945. * The keyup event is fired when a key has been released.
  8946. */
  8947. static readonly KEYUP: number;
  8948. }
  8949. /**
  8950. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8951. */
  8952. export class KeyboardInfo {
  8953. /**
  8954. * Defines the type of event (KeyboardEventTypes)
  8955. */
  8956. type: number;
  8957. /**
  8958. * Defines the related dom event
  8959. */
  8960. event: KeyboardEvent;
  8961. /**
  8962. * Instantiates a new keyboard info.
  8963. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8964. * @param type Defines the type of event (KeyboardEventTypes)
  8965. * @param event Defines the related dom event
  8966. */
  8967. constructor(
  8968. /**
  8969. * Defines the type of event (KeyboardEventTypes)
  8970. */
  8971. type: number,
  8972. /**
  8973. * Defines the related dom event
  8974. */
  8975. event: KeyboardEvent);
  8976. }
  8977. /**
  8978. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8979. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8980. */
  8981. export class KeyboardInfoPre extends KeyboardInfo {
  8982. /**
  8983. * Defines the type of event (KeyboardEventTypes)
  8984. */
  8985. type: number;
  8986. /**
  8987. * Defines the related dom event
  8988. */
  8989. event: KeyboardEvent;
  8990. /**
  8991. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8992. */
  8993. skipOnPointerObservable: boolean;
  8994. /**
  8995. * Instantiates a new keyboard pre info.
  8996. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8997. * @param type Defines the type of event (KeyboardEventTypes)
  8998. * @param event Defines the related dom event
  8999. */
  9000. constructor(
  9001. /**
  9002. * Defines the type of event (KeyboardEventTypes)
  9003. */
  9004. type: number,
  9005. /**
  9006. * Defines the related dom event
  9007. */
  9008. event: KeyboardEvent);
  9009. }
  9010. }
  9011. declare module BABYLON {
  9012. /**
  9013. * Manage the keyboard inputs to control the movement of a free camera.
  9014. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9015. */
  9016. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9017. /**
  9018. * Defines the camera the input is attached to.
  9019. */
  9020. camera: FreeCamera;
  9021. /**
  9022. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9023. */
  9024. keysUp: number[];
  9025. /**
  9026. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9027. */
  9028. keysDown: number[];
  9029. /**
  9030. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9031. */
  9032. keysLeft: number[];
  9033. /**
  9034. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9035. */
  9036. keysRight: number[];
  9037. private _keys;
  9038. private _onCanvasBlurObserver;
  9039. private _onKeyboardObserver;
  9040. private _engine;
  9041. private _scene;
  9042. /**
  9043. * Attach the input controls to a specific dom element to get the input from.
  9044. * @param element Defines the element the controls should be listened from
  9045. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9046. */
  9047. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9048. /**
  9049. * Detach the current controls from the specified dom element.
  9050. * @param element Defines the element to stop listening the inputs from
  9051. */
  9052. detachControl(element: Nullable<HTMLElement>): void;
  9053. /**
  9054. * Update the current camera state depending on the inputs that have been used this frame.
  9055. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9056. */
  9057. checkInputs(): void;
  9058. /**
  9059. * Gets the class name of the current intput.
  9060. * @returns the class name
  9061. */
  9062. getClassName(): string;
  9063. /** @hidden */
  9064. _onLostFocus(): void;
  9065. /**
  9066. * Get the friendly name associated with the input class.
  9067. * @returns the input friendly name
  9068. */
  9069. getSimpleName(): string;
  9070. }
  9071. }
  9072. declare module BABYLON {
  9073. /**
  9074. * Interface describing all the common properties and methods a shadow light needs to implement.
  9075. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9076. * as well as binding the different shadow properties to the effects.
  9077. */
  9078. export interface IShadowLight extends Light {
  9079. /**
  9080. * The light id in the scene (used in scene.findLighById for instance)
  9081. */
  9082. id: string;
  9083. /**
  9084. * The position the shdow will be casted from.
  9085. */
  9086. position: Vector3;
  9087. /**
  9088. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9089. */
  9090. direction: Vector3;
  9091. /**
  9092. * The transformed position. Position of the light in world space taking parenting in account.
  9093. */
  9094. transformedPosition: Vector3;
  9095. /**
  9096. * The transformed direction. Direction of the light in world space taking parenting in account.
  9097. */
  9098. transformedDirection: Vector3;
  9099. /**
  9100. * The friendly name of the light in the scene.
  9101. */
  9102. name: string;
  9103. /**
  9104. * Defines the shadow projection clipping minimum z value.
  9105. */
  9106. shadowMinZ: number;
  9107. /**
  9108. * Defines the shadow projection clipping maximum z value.
  9109. */
  9110. shadowMaxZ: number;
  9111. /**
  9112. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9113. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9114. */
  9115. computeTransformedInformation(): boolean;
  9116. /**
  9117. * Gets the scene the light belongs to.
  9118. * @returns The scene
  9119. */
  9120. getScene(): Scene;
  9121. /**
  9122. * Callback defining a custom Projection Matrix Builder.
  9123. * This can be used to override the default projection matrix computation.
  9124. */
  9125. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9126. /**
  9127. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9128. * @param matrix The materix to updated with the projection information
  9129. * @param viewMatrix The transform matrix of the light
  9130. * @param renderList The list of mesh to render in the map
  9131. * @returns The current light
  9132. */
  9133. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9134. /**
  9135. * Gets the current depth scale used in ESM.
  9136. * @returns The scale
  9137. */
  9138. getDepthScale(): number;
  9139. /**
  9140. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9141. * @returns true if a cube texture needs to be use
  9142. */
  9143. needCube(): boolean;
  9144. /**
  9145. * Detects if the projection matrix requires to be recomputed this frame.
  9146. * @returns true if it requires to be recomputed otherwise, false.
  9147. */
  9148. needProjectionMatrixCompute(): boolean;
  9149. /**
  9150. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9151. */
  9152. forceProjectionMatrixCompute(): void;
  9153. /**
  9154. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9155. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9156. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9157. */
  9158. getShadowDirection(faceIndex?: number): Vector3;
  9159. /**
  9160. * Gets the minZ used for shadow according to both the scene and the light.
  9161. * @param activeCamera The camera we are returning the min for
  9162. * @returns the depth min z
  9163. */
  9164. getDepthMinZ(activeCamera: Camera): number;
  9165. /**
  9166. * Gets the maxZ used for shadow according to both the scene and the light.
  9167. * @param activeCamera The camera we are returning the max for
  9168. * @returns the depth max z
  9169. */
  9170. getDepthMaxZ(activeCamera: Camera): number;
  9171. }
  9172. /**
  9173. * Base implementation IShadowLight
  9174. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9175. */
  9176. export abstract class ShadowLight extends Light implements IShadowLight {
  9177. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9178. protected _position: Vector3;
  9179. protected _setPosition(value: Vector3): void;
  9180. /**
  9181. * Sets the position the shadow will be casted from. Also use as the light position for both
  9182. * point and spot lights.
  9183. */
  9184. /**
  9185. * Sets the position the shadow will be casted from. Also use as the light position for both
  9186. * point and spot lights.
  9187. */
  9188. position: Vector3;
  9189. protected _direction: Vector3;
  9190. protected _setDirection(value: Vector3): void;
  9191. /**
  9192. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9193. * Also use as the light direction on spot and directional lights.
  9194. */
  9195. /**
  9196. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9197. * Also use as the light direction on spot and directional lights.
  9198. */
  9199. direction: Vector3;
  9200. private _shadowMinZ;
  9201. /**
  9202. * Gets the shadow projection clipping minimum z value.
  9203. */
  9204. /**
  9205. * Sets the shadow projection clipping minimum z value.
  9206. */
  9207. shadowMinZ: number;
  9208. private _shadowMaxZ;
  9209. /**
  9210. * Sets the shadow projection clipping maximum z value.
  9211. */
  9212. /**
  9213. * Gets the shadow projection clipping maximum z value.
  9214. */
  9215. shadowMaxZ: number;
  9216. /**
  9217. * Callback defining a custom Projection Matrix Builder.
  9218. * This can be used to override the default projection matrix computation.
  9219. */
  9220. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9221. /**
  9222. * The transformed position. Position of the light in world space taking parenting in account.
  9223. */
  9224. transformedPosition: Vector3;
  9225. /**
  9226. * The transformed direction. Direction of the light in world space taking parenting in account.
  9227. */
  9228. transformedDirection: Vector3;
  9229. private _needProjectionMatrixCompute;
  9230. /**
  9231. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9232. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9233. */
  9234. computeTransformedInformation(): boolean;
  9235. /**
  9236. * Return the depth scale used for the shadow map.
  9237. * @returns the depth scale.
  9238. */
  9239. getDepthScale(): number;
  9240. /**
  9241. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9242. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9243. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9244. */
  9245. getShadowDirection(faceIndex?: number): Vector3;
  9246. /**
  9247. * Returns the ShadowLight absolute position in the World.
  9248. * @returns the position vector in world space
  9249. */
  9250. getAbsolutePosition(): Vector3;
  9251. /**
  9252. * Sets the ShadowLight direction toward the passed target.
  9253. * @param target The point to target in local space
  9254. * @returns the updated ShadowLight direction
  9255. */
  9256. setDirectionToTarget(target: Vector3): Vector3;
  9257. /**
  9258. * Returns the light rotation in euler definition.
  9259. * @returns the x y z rotation in local space.
  9260. */
  9261. getRotation(): Vector3;
  9262. /**
  9263. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9264. * @returns true if a cube texture needs to be use
  9265. */
  9266. needCube(): boolean;
  9267. /**
  9268. * Detects if the projection matrix requires to be recomputed this frame.
  9269. * @returns true if it requires to be recomputed otherwise, false.
  9270. */
  9271. needProjectionMatrixCompute(): boolean;
  9272. /**
  9273. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9274. */
  9275. forceProjectionMatrixCompute(): void;
  9276. /** @hidden */
  9277. _initCache(): void;
  9278. /** @hidden */
  9279. _isSynchronized(): boolean;
  9280. /**
  9281. * Computes the world matrix of the node
  9282. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9283. * @returns the world matrix
  9284. */
  9285. computeWorldMatrix(force?: boolean): Matrix;
  9286. /**
  9287. * Gets the minZ used for shadow according to both the scene and the light.
  9288. * @param activeCamera The camera we are returning the min for
  9289. * @returns the depth min z
  9290. */
  9291. getDepthMinZ(activeCamera: Camera): number;
  9292. /**
  9293. * Gets the maxZ used for shadow according to both the scene and the light.
  9294. * @param activeCamera The camera we are returning the max for
  9295. * @returns the depth max z
  9296. */
  9297. getDepthMaxZ(activeCamera: Camera): number;
  9298. /**
  9299. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9300. * @param matrix The materix to updated with the projection information
  9301. * @param viewMatrix The transform matrix of the light
  9302. * @param renderList The list of mesh to render in the map
  9303. * @returns The current light
  9304. */
  9305. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9306. }
  9307. }
  9308. declare module BABYLON {
  9309. /**
  9310. * "Static Class" containing the most commonly used helper while dealing with material for
  9311. * rendering purpose.
  9312. *
  9313. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9314. *
  9315. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9316. */
  9317. export class MaterialHelper {
  9318. /**
  9319. * Bind the current view position to an effect.
  9320. * @param effect The effect to be bound
  9321. * @param scene The scene the eyes position is used from
  9322. */
  9323. static BindEyePosition(effect: Effect, scene: Scene): void;
  9324. /**
  9325. * Helps preparing the defines values about the UVs in used in the effect.
  9326. * UVs are shared as much as we can accross channels in the shaders.
  9327. * @param texture The texture we are preparing the UVs for
  9328. * @param defines The defines to update
  9329. * @param key The channel key "diffuse", "specular"... used in the shader
  9330. */
  9331. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9332. /**
  9333. * Binds a texture matrix value to its corrsponding uniform
  9334. * @param texture The texture to bind the matrix for
  9335. * @param uniformBuffer The uniform buffer receivin the data
  9336. * @param key The channel key "diffuse", "specular"... used in the shader
  9337. */
  9338. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9339. /**
  9340. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9341. * @param mesh defines the current mesh
  9342. * @param scene defines the current scene
  9343. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9344. * @param pointsCloud defines if point cloud rendering has to be turned on
  9345. * @param fogEnabled defines if fog has to be turned on
  9346. * @param alphaTest defines if alpha testing has to be turned on
  9347. * @param defines defines the current list of defines
  9348. */
  9349. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9350. /**
  9351. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9352. * @param scene defines the current scene
  9353. * @param engine defines the current engine
  9354. * @param defines specifies the list of active defines
  9355. * @param useInstances defines if instances have to be turned on
  9356. * @param useClipPlane defines if clip plane have to be turned on
  9357. */
  9358. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9359. /**
  9360. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9361. * @param mesh The mesh containing the geometry data we will draw
  9362. * @param defines The defines to update
  9363. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9364. * @param useBones Precise whether bones should be used or not (override mesh info)
  9365. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9366. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9367. * @returns false if defines are considered not dirty and have not been checked
  9368. */
  9369. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9370. /**
  9371. * Prepares the defines related to multiview
  9372. * @param scene The scene we are intending to draw
  9373. * @param defines The defines to update
  9374. */
  9375. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9376. /**
  9377. * Prepares the defines related to the light information passed in parameter
  9378. * @param scene The scene we are intending to draw
  9379. * @param mesh The mesh the effect is compiling for
  9380. * @param defines The defines to update
  9381. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9382. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9383. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9384. * @returns true if normals will be required for the rest of the effect
  9385. */
  9386. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9387. /**
  9388. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9389. * that won t be acctive due to defines being turned off.
  9390. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9391. * @param samplersList The samplers list
  9392. * @param defines The defines helping in the list generation
  9393. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9394. */
  9395. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9396. /**
  9397. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9398. * @param defines The defines to update while falling back
  9399. * @param fallbacks The authorized effect fallbacks
  9400. * @param maxSimultaneousLights The maximum number of lights allowed
  9401. * @param rank the current rank of the Effect
  9402. * @returns The newly affected rank
  9403. */
  9404. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9405. /**
  9406. * Prepares the list of attributes required for morph targets according to the effect defines.
  9407. * @param attribs The current list of supported attribs
  9408. * @param mesh The mesh to prepare the morph targets attributes for
  9409. * @param defines The current Defines of the effect
  9410. */
  9411. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9412. /**
  9413. * Prepares the list of attributes required for bones according to the effect defines.
  9414. * @param attribs The current list of supported attribs
  9415. * @param mesh The mesh to prepare the bones attributes for
  9416. * @param defines The current Defines of the effect
  9417. * @param fallbacks The current efffect fallback strategy
  9418. */
  9419. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9420. /**
  9421. * Prepares the list of attributes required for instances according to the effect defines.
  9422. * @param attribs The current list of supported attribs
  9423. * @param defines The current Defines of the effect
  9424. */
  9425. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9426. /**
  9427. * Binds the light shadow information to the effect for the given mesh.
  9428. * @param light The light containing the generator
  9429. * @param scene The scene the lights belongs to
  9430. * @param mesh The mesh we are binding the information to render
  9431. * @param lightIndex The light index in the effect used to render the mesh
  9432. * @param effect The effect we are binding the data to
  9433. */
  9434. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9435. /**
  9436. * Binds the light information to the effect.
  9437. * @param light The light containing the generator
  9438. * @param effect The effect we are binding the data to
  9439. * @param lightIndex The light index in the effect used to render
  9440. */
  9441. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9442. /**
  9443. * Binds the lights information from the scene to the effect for the given mesh.
  9444. * @param scene The scene the lights belongs to
  9445. * @param mesh The mesh we are binding the information to render
  9446. * @param effect The effect we are binding the data to
  9447. * @param defines The generated defines for the effect
  9448. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9449. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9450. */
  9451. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9452. private static _tempFogColor;
  9453. /**
  9454. * Binds the fog information from the scene to the effect for the given mesh.
  9455. * @param scene The scene the lights belongs to
  9456. * @param mesh The mesh we are binding the information to render
  9457. * @param effect The effect we are binding the data to
  9458. * @param linearSpace Defines if the fog effect is applied in linear space
  9459. */
  9460. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9461. /**
  9462. * Binds the bones information from the mesh to the effect.
  9463. * @param mesh The mesh we are binding the information to render
  9464. * @param effect The effect we are binding the data to
  9465. */
  9466. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9467. /**
  9468. * Binds the morph targets information from the mesh to the effect.
  9469. * @param abstractMesh The mesh we are binding the information to render
  9470. * @param effect The effect we are binding the data to
  9471. */
  9472. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9473. /**
  9474. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9475. * @param defines The generated defines used in the effect
  9476. * @param effect The effect we are binding the data to
  9477. * @param scene The scene we are willing to render with logarithmic scale for
  9478. */
  9479. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9480. /**
  9481. * Binds the clip plane information from the scene to the effect.
  9482. * @param scene The scene the clip plane information are extracted from
  9483. * @param effect The effect we are binding the data to
  9484. */
  9485. static BindClipPlane(effect: Effect, scene: Scene): void;
  9486. }
  9487. }
  9488. declare module BABYLON {
  9489. /** @hidden */
  9490. export var kernelBlurVaryingDeclaration: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module BABYLON {
  9496. /** @hidden */
  9497. export var kernelBlurFragment: {
  9498. name: string;
  9499. shader: string;
  9500. };
  9501. }
  9502. declare module BABYLON {
  9503. /** @hidden */
  9504. export var kernelBlurFragment2: {
  9505. name: string;
  9506. shader: string;
  9507. };
  9508. }
  9509. declare module BABYLON {
  9510. /** @hidden */
  9511. export var kernelBlurPixelShader: {
  9512. name: string;
  9513. shader: string;
  9514. };
  9515. }
  9516. declare module BABYLON {
  9517. /** @hidden */
  9518. export var kernelBlurVertex: {
  9519. name: string;
  9520. shader: string;
  9521. };
  9522. }
  9523. declare module BABYLON {
  9524. /** @hidden */
  9525. export var kernelBlurVertexShader: {
  9526. name: string;
  9527. shader: string;
  9528. };
  9529. }
  9530. declare module BABYLON {
  9531. /**
  9532. * The Blur Post Process which blurs an image based on a kernel and direction.
  9533. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9534. */
  9535. export class BlurPostProcess extends PostProcess {
  9536. /** The direction in which to blur the image. */
  9537. direction: Vector2;
  9538. private blockCompilation;
  9539. protected _kernel: number;
  9540. protected _idealKernel: number;
  9541. protected _packedFloat: boolean;
  9542. private _staticDefines;
  9543. /**
  9544. * Sets the length in pixels of the blur sample region
  9545. */
  9546. /**
  9547. * Gets the length in pixels of the blur sample region
  9548. */
  9549. kernel: number;
  9550. /**
  9551. * Sets wether or not the blur needs to unpack/repack floats
  9552. */
  9553. /**
  9554. * Gets wether or not the blur is unpacking/repacking floats
  9555. */
  9556. packedFloat: boolean;
  9557. /**
  9558. * Creates a new instance BlurPostProcess
  9559. * @param name The name of the effect.
  9560. * @param direction The direction in which to blur the image.
  9561. * @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.
  9562. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9563. * @param camera The camera to apply the render pass to.
  9564. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9565. * @param engine The engine which the post process will be applied. (default: current engine)
  9566. * @param reusable If the post process can be reused on the same frame. (default: false)
  9567. * @param textureType Type of textures used when performing the post process. (default: 0)
  9568. * @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)
  9569. */
  9570. constructor(name: string,
  9571. /** The direction in which to blur the image. */
  9572. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9573. /**
  9574. * Updates the effect with the current post process compile time values and recompiles the shader.
  9575. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9576. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9577. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9578. * @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
  9579. * @param onCompiled Called when the shader has been compiled.
  9580. * @param onError Called if there is an error when compiling a shader.
  9581. */
  9582. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9583. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9584. /**
  9585. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9586. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9587. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9588. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9589. * The gaps between physical kernels are compensated for in the weighting of the samples
  9590. * @param idealKernel Ideal blur kernel.
  9591. * @return Nearest best kernel.
  9592. */
  9593. protected _nearestBestKernel(idealKernel: number): number;
  9594. /**
  9595. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9596. * @param x The point on the Gaussian distribution to sample.
  9597. * @return the value of the Gaussian function at x.
  9598. */
  9599. protected _gaussianWeight(x: number): number;
  9600. /**
  9601. * Generates a string that can be used as a floating point number in GLSL.
  9602. * @param x Value to print.
  9603. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9604. * @return GLSL float string.
  9605. */
  9606. protected _glslFloat(x: number, decimalFigures?: number): string;
  9607. }
  9608. }
  9609. declare module BABYLON {
  9610. /** @hidden */
  9611. export var shadowMapPixelShader: {
  9612. name: string;
  9613. shader: string;
  9614. };
  9615. }
  9616. declare module BABYLON {
  9617. /** @hidden */
  9618. export var bonesDeclaration: {
  9619. name: string;
  9620. shader: string;
  9621. };
  9622. }
  9623. declare module BABYLON {
  9624. /** @hidden */
  9625. export var morphTargetsVertexGlobalDeclaration: {
  9626. name: string;
  9627. shader: string;
  9628. };
  9629. }
  9630. declare module BABYLON {
  9631. /** @hidden */
  9632. export var morphTargetsVertexDeclaration: {
  9633. name: string;
  9634. shader: string;
  9635. };
  9636. }
  9637. declare module BABYLON {
  9638. /** @hidden */
  9639. export var instancesDeclaration: {
  9640. name: string;
  9641. shader: string;
  9642. };
  9643. }
  9644. declare module BABYLON {
  9645. /** @hidden */
  9646. export var helperFunctions: {
  9647. name: string;
  9648. shader: string;
  9649. };
  9650. }
  9651. declare module BABYLON {
  9652. /** @hidden */
  9653. export var morphTargetsVertex: {
  9654. name: string;
  9655. shader: string;
  9656. };
  9657. }
  9658. declare module BABYLON {
  9659. /** @hidden */
  9660. export var instancesVertex: {
  9661. name: string;
  9662. shader: string;
  9663. };
  9664. }
  9665. declare module BABYLON {
  9666. /** @hidden */
  9667. export var bonesVertex: {
  9668. name: string;
  9669. shader: string;
  9670. };
  9671. }
  9672. declare module BABYLON {
  9673. /** @hidden */
  9674. export var shadowMapVertexShader: {
  9675. name: string;
  9676. shader: string;
  9677. };
  9678. }
  9679. declare module BABYLON {
  9680. /** @hidden */
  9681. export var depthBoxBlurPixelShader: {
  9682. name: string;
  9683. shader: string;
  9684. };
  9685. }
  9686. declare module BABYLON {
  9687. /**
  9688. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9689. */
  9690. export interface ICustomShaderOptions {
  9691. /**
  9692. * Gets or sets the custom shader name to use
  9693. */
  9694. shaderName: string;
  9695. /**
  9696. * The list of attribute names used in the shader
  9697. */
  9698. attributes?: string[];
  9699. /**
  9700. * The list of unifrom names used in the shader
  9701. */
  9702. uniforms?: string[];
  9703. /**
  9704. * The list of sampler names used in the shader
  9705. */
  9706. samplers?: string[];
  9707. /**
  9708. * The list of defines used in the shader
  9709. */
  9710. defines?: string[];
  9711. }
  9712. /**
  9713. * Interface to implement to create a shadow generator compatible with BJS.
  9714. */
  9715. export interface IShadowGenerator {
  9716. /**
  9717. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9718. * @returns The render target texture if present otherwise, null
  9719. */
  9720. getShadowMap(): Nullable<RenderTargetTexture>;
  9721. /**
  9722. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9723. * @returns The render target texture if the shadow map is present otherwise, null
  9724. */
  9725. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9726. /**
  9727. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9728. * @param subMesh The submesh we want to render in the shadow map
  9729. * @param useInstances Defines wether will draw in the map using instances
  9730. * @returns true if ready otherwise, false
  9731. */
  9732. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9733. /**
  9734. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9735. * @param defines Defines of the material we want to update
  9736. * @param lightIndex Index of the light in the enabled light list of the material
  9737. */
  9738. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9739. /**
  9740. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9741. * defined in the generator but impacting the effect).
  9742. * It implies the unifroms available on the materials are the standard BJS ones.
  9743. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9744. * @param effect The effect we are binfing the information for
  9745. */
  9746. bindShadowLight(lightIndex: string, effect: Effect): void;
  9747. /**
  9748. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9749. * (eq to shadow prjection matrix * light transform matrix)
  9750. * @returns The transform matrix used to create the shadow map
  9751. */
  9752. getTransformMatrix(): Matrix;
  9753. /**
  9754. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9755. * Cube and 2D textures for instance.
  9756. */
  9757. recreateShadowMap(): void;
  9758. /**
  9759. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9760. * @param onCompiled Callback triggered at the and of the effects compilation
  9761. * @param options Sets of optional options forcing the compilation with different modes
  9762. */
  9763. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9764. useInstances: boolean;
  9765. }>): void;
  9766. /**
  9767. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9768. * @param options Sets of optional options forcing the compilation with different modes
  9769. * @returns A promise that resolves when the compilation completes
  9770. */
  9771. forceCompilationAsync(options?: Partial<{
  9772. useInstances: boolean;
  9773. }>): Promise<void>;
  9774. /**
  9775. * Serializes the shadow generator setup to a json object.
  9776. * @returns The serialized JSON object
  9777. */
  9778. serialize(): any;
  9779. /**
  9780. * Disposes the Shadow map and related Textures and effects.
  9781. */
  9782. dispose(): void;
  9783. }
  9784. /**
  9785. * Default implementation IShadowGenerator.
  9786. * This is the main object responsible of generating shadows in the framework.
  9787. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9788. */
  9789. export class ShadowGenerator implements IShadowGenerator {
  9790. /**
  9791. * Shadow generator mode None: no filtering applied.
  9792. */
  9793. static readonly FILTER_NONE: number;
  9794. /**
  9795. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9796. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9797. */
  9798. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9799. /**
  9800. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9801. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9802. */
  9803. static readonly FILTER_POISSONSAMPLING: number;
  9804. /**
  9805. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9806. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9807. */
  9808. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9809. /**
  9810. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9811. * edge artifacts on steep falloff.
  9812. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9813. */
  9814. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9815. /**
  9816. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9817. * edge artifacts on steep falloff.
  9818. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9819. */
  9820. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9821. /**
  9822. * Shadow generator mode PCF: Percentage Closer Filtering
  9823. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9824. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9825. */
  9826. static readonly FILTER_PCF: number;
  9827. /**
  9828. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9829. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9830. * Contact Hardening
  9831. */
  9832. static readonly FILTER_PCSS: number;
  9833. /**
  9834. * Reserved for PCF and PCSS
  9835. * Highest Quality.
  9836. *
  9837. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9838. *
  9839. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9840. */
  9841. static readonly QUALITY_HIGH: number;
  9842. /**
  9843. * Reserved for PCF and PCSS
  9844. * Good tradeoff for quality/perf cross devices
  9845. *
  9846. * Execute PCF on a 3*3 kernel.
  9847. *
  9848. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9849. */
  9850. static readonly QUALITY_MEDIUM: number;
  9851. /**
  9852. * Reserved for PCF and PCSS
  9853. * The lowest quality but the fastest.
  9854. *
  9855. * Execute PCF on a 1*1 kernel.
  9856. *
  9857. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9858. */
  9859. static readonly QUALITY_LOW: number;
  9860. /** Gets or sets the custom shader name to use */
  9861. customShaderOptions: ICustomShaderOptions;
  9862. /**
  9863. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9864. */
  9865. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9866. /**
  9867. * Observable triggered before a mesh is rendered in the shadow map.
  9868. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9869. */
  9870. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9871. private _bias;
  9872. /**
  9873. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9874. */
  9875. /**
  9876. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9877. */
  9878. bias: number;
  9879. private _normalBias;
  9880. /**
  9881. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9882. */
  9883. /**
  9884. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9885. */
  9886. normalBias: number;
  9887. private _blurBoxOffset;
  9888. /**
  9889. * Gets the blur box offset: offset applied during the blur pass.
  9890. * Only useful if useKernelBlur = false
  9891. */
  9892. /**
  9893. * Sets the blur box offset: offset applied during the blur pass.
  9894. * Only useful if useKernelBlur = false
  9895. */
  9896. blurBoxOffset: number;
  9897. private _blurScale;
  9898. /**
  9899. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9900. * 2 means half of the size.
  9901. */
  9902. /**
  9903. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9904. * 2 means half of the size.
  9905. */
  9906. blurScale: number;
  9907. private _blurKernel;
  9908. /**
  9909. * Gets the blur kernel: kernel size of the blur pass.
  9910. * Only useful if useKernelBlur = true
  9911. */
  9912. /**
  9913. * Sets the blur kernel: kernel size of the blur pass.
  9914. * Only useful if useKernelBlur = true
  9915. */
  9916. blurKernel: number;
  9917. private _useKernelBlur;
  9918. /**
  9919. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9920. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9921. */
  9922. /**
  9923. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9924. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9925. */
  9926. useKernelBlur: boolean;
  9927. private _depthScale;
  9928. /**
  9929. * Gets the depth scale used in ESM mode.
  9930. */
  9931. /**
  9932. * Sets the depth scale used in ESM mode.
  9933. * This can override the scale stored on the light.
  9934. */
  9935. depthScale: number;
  9936. private _filter;
  9937. /**
  9938. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9939. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9940. */
  9941. /**
  9942. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9943. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9944. */
  9945. filter: number;
  9946. /**
  9947. * Gets if the current filter is set to Poisson Sampling.
  9948. */
  9949. /**
  9950. * Sets the current filter to Poisson Sampling.
  9951. */
  9952. usePoissonSampling: boolean;
  9953. /**
  9954. * Gets if the current filter is set to ESM.
  9955. */
  9956. /**
  9957. * Sets the current filter is to ESM.
  9958. */
  9959. useExponentialShadowMap: boolean;
  9960. /**
  9961. * Gets if the current filter is set to filtered ESM.
  9962. */
  9963. /**
  9964. * Gets if the current filter is set to filtered ESM.
  9965. */
  9966. useBlurExponentialShadowMap: boolean;
  9967. /**
  9968. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9969. * exponential to prevent steep falloff artifacts).
  9970. */
  9971. /**
  9972. * Sets the current filter to "close ESM" (using the inverse of the
  9973. * exponential to prevent steep falloff artifacts).
  9974. */
  9975. useCloseExponentialShadowMap: boolean;
  9976. /**
  9977. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9978. * exponential to prevent steep falloff artifacts).
  9979. */
  9980. /**
  9981. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9982. * exponential to prevent steep falloff artifacts).
  9983. */
  9984. useBlurCloseExponentialShadowMap: boolean;
  9985. /**
  9986. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9987. */
  9988. /**
  9989. * Sets the current filter to "PCF" (percentage closer filtering).
  9990. */
  9991. usePercentageCloserFiltering: boolean;
  9992. private _filteringQuality;
  9993. /**
  9994. * Gets the PCF or PCSS Quality.
  9995. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9996. */
  9997. /**
  9998. * Sets the PCF or PCSS Quality.
  9999. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10000. */
  10001. filteringQuality: number;
  10002. /**
  10003. * Gets if the current filter is set to "PCSS" (contact hardening).
  10004. */
  10005. /**
  10006. * Sets the current filter to "PCSS" (contact hardening).
  10007. */
  10008. useContactHardeningShadow: boolean;
  10009. private _contactHardeningLightSizeUVRatio;
  10010. /**
  10011. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10012. * Using a ratio helps keeping shape stability independently of the map size.
  10013. *
  10014. * It does not account for the light projection as it was having too much
  10015. * instability during the light setup or during light position changes.
  10016. *
  10017. * Only valid if useContactHardeningShadow is true.
  10018. */
  10019. /**
  10020. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10021. * Using a ratio helps keeping shape stability independently of the map size.
  10022. *
  10023. * It does not account for the light projection as it was having too much
  10024. * instability during the light setup or during light position changes.
  10025. *
  10026. * Only valid if useContactHardeningShadow is true.
  10027. */
  10028. contactHardeningLightSizeUVRatio: number;
  10029. private _darkness;
  10030. /**
  10031. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10032. * 0 means strongest and 1 would means no shadow.
  10033. * @returns the darkness.
  10034. */
  10035. getDarkness(): number;
  10036. /**
  10037. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10038. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10039. * @returns the shadow generator allowing fluent coding.
  10040. */
  10041. setDarkness(darkness: number): ShadowGenerator;
  10042. private _transparencyShadow;
  10043. /**
  10044. * Sets the ability to have transparent shadow (boolean).
  10045. * @param transparent True if transparent else False
  10046. * @returns the shadow generator allowing fluent coding
  10047. */
  10048. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10049. private _shadowMap;
  10050. private _shadowMap2;
  10051. /**
  10052. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10053. * @returns The render target texture if present otherwise, null
  10054. */
  10055. getShadowMap(): Nullable<RenderTargetTexture>;
  10056. /**
  10057. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10058. * @returns The render target texture if the shadow map is present otherwise, null
  10059. */
  10060. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10061. /**
  10062. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10063. * @param mesh Mesh to add
  10064. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10065. * @returns the Shadow Generator itself
  10066. */
  10067. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10068. /**
  10069. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10070. * @param mesh Mesh to remove
  10071. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10072. * @returns the Shadow Generator itself
  10073. */
  10074. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10075. /**
  10076. * Controls the extent to which the shadows fade out at the edge of the frustum
  10077. * Used only by directionals and spots
  10078. */
  10079. frustumEdgeFalloff: number;
  10080. private _light;
  10081. /**
  10082. * Returns the associated light object.
  10083. * @returns the light generating the shadow
  10084. */
  10085. getLight(): IShadowLight;
  10086. /**
  10087. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10088. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10089. * It might on the other hand introduce peter panning.
  10090. */
  10091. forceBackFacesOnly: boolean;
  10092. private _scene;
  10093. private _lightDirection;
  10094. private _effect;
  10095. private _viewMatrix;
  10096. private _projectionMatrix;
  10097. private _transformMatrix;
  10098. private _cachedPosition;
  10099. private _cachedDirection;
  10100. private _cachedDefines;
  10101. private _currentRenderID;
  10102. private _boxBlurPostprocess;
  10103. private _kernelBlurXPostprocess;
  10104. private _kernelBlurYPostprocess;
  10105. private _blurPostProcesses;
  10106. private _mapSize;
  10107. private _currentFaceIndex;
  10108. private _currentFaceIndexCache;
  10109. private _textureType;
  10110. private _defaultTextureMatrix;
  10111. /** @hidden */
  10112. static _SceneComponentInitialization: (scene: Scene) => void;
  10113. /**
  10114. * Creates a ShadowGenerator object.
  10115. * A ShadowGenerator is the required tool to use the shadows.
  10116. * Each light casting shadows needs to use its own ShadowGenerator.
  10117. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10118. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10119. * @param light The light object generating the shadows.
  10120. * @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.
  10121. */
  10122. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10123. private _initializeGenerator;
  10124. private _initializeShadowMap;
  10125. private _initializeBlurRTTAndPostProcesses;
  10126. private _renderForShadowMap;
  10127. private _renderSubMeshForShadowMap;
  10128. private _applyFilterValues;
  10129. /**
  10130. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10131. * @param onCompiled Callback triggered at the and of the effects compilation
  10132. * @param options Sets of optional options forcing the compilation with different modes
  10133. */
  10134. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10135. useInstances: boolean;
  10136. }>): void;
  10137. /**
  10138. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10139. * @param options Sets of optional options forcing the compilation with different modes
  10140. * @returns A promise that resolves when the compilation completes
  10141. */
  10142. forceCompilationAsync(options?: Partial<{
  10143. useInstances: boolean;
  10144. }>): Promise<void>;
  10145. /**
  10146. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10147. * @param subMesh The submesh we want to render in the shadow map
  10148. * @param useInstances Defines wether will draw in the map using instances
  10149. * @returns true if ready otherwise, false
  10150. */
  10151. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10152. /**
  10153. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10154. * @param defines Defines of the material we want to update
  10155. * @param lightIndex Index of the light in the enabled light list of the material
  10156. */
  10157. prepareDefines(defines: any, lightIndex: number): void;
  10158. /**
  10159. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10160. * defined in the generator but impacting the effect).
  10161. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10162. * @param effect The effect we are binfing the information for
  10163. */
  10164. bindShadowLight(lightIndex: string, effect: Effect): void;
  10165. /**
  10166. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10167. * (eq to shadow prjection matrix * light transform matrix)
  10168. * @returns The transform matrix used to create the shadow map
  10169. */
  10170. getTransformMatrix(): Matrix;
  10171. /**
  10172. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10173. * Cube and 2D textures for instance.
  10174. */
  10175. recreateShadowMap(): void;
  10176. private _disposeBlurPostProcesses;
  10177. private _disposeRTTandPostProcesses;
  10178. /**
  10179. * Disposes the ShadowGenerator.
  10180. * Returns nothing.
  10181. */
  10182. dispose(): void;
  10183. /**
  10184. * Serializes the shadow generator setup to a json object.
  10185. * @returns The serialized JSON object
  10186. */
  10187. serialize(): any;
  10188. /**
  10189. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10190. * @param parsedShadowGenerator The JSON object to parse
  10191. * @param scene The scene to create the shadow map for
  10192. * @returns The parsed shadow generator
  10193. */
  10194. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10195. }
  10196. }
  10197. declare module BABYLON {
  10198. /**
  10199. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10200. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10201. * 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.
  10202. */
  10203. export abstract class Light extends Node {
  10204. /**
  10205. * Falloff Default: light is falling off following the material specification:
  10206. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10207. */
  10208. static readonly FALLOFF_DEFAULT: number;
  10209. /**
  10210. * Falloff Physical: light is falling off following the inverse squared distance law.
  10211. */
  10212. static readonly FALLOFF_PHYSICAL: number;
  10213. /**
  10214. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10215. * to enhance interoperability with other engines.
  10216. */
  10217. static readonly FALLOFF_GLTF: number;
  10218. /**
  10219. * Falloff Standard: light is falling off like in the standard material
  10220. * to enhance interoperability with other materials.
  10221. */
  10222. static readonly FALLOFF_STANDARD: number;
  10223. /**
  10224. * If every light affecting the material is in this lightmapMode,
  10225. * material.lightmapTexture adds or multiplies
  10226. * (depends on material.useLightmapAsShadowmap)
  10227. * after every other light calculations.
  10228. */
  10229. static readonly LIGHTMAP_DEFAULT: number;
  10230. /**
  10231. * material.lightmapTexture as only diffuse lighting from this light
  10232. * adds only specular lighting from this light
  10233. * adds dynamic shadows
  10234. */
  10235. static readonly LIGHTMAP_SPECULAR: number;
  10236. /**
  10237. * material.lightmapTexture as only lighting
  10238. * no light calculation from this light
  10239. * only adds dynamic shadows from this light
  10240. */
  10241. static readonly LIGHTMAP_SHADOWSONLY: number;
  10242. /**
  10243. * Each light type uses the default quantity according to its type:
  10244. * point/spot lights use luminous intensity
  10245. * directional lights use illuminance
  10246. */
  10247. static readonly INTENSITYMODE_AUTOMATIC: number;
  10248. /**
  10249. * lumen (lm)
  10250. */
  10251. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10252. /**
  10253. * candela (lm/sr)
  10254. */
  10255. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10256. /**
  10257. * lux (lm/m^2)
  10258. */
  10259. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10260. /**
  10261. * nit (cd/m^2)
  10262. */
  10263. static readonly INTENSITYMODE_LUMINANCE: number;
  10264. /**
  10265. * Light type const id of the point light.
  10266. */
  10267. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10268. /**
  10269. * Light type const id of the directional light.
  10270. */
  10271. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10272. /**
  10273. * Light type const id of the spot light.
  10274. */
  10275. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10276. /**
  10277. * Light type const id of the hemispheric light.
  10278. */
  10279. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10280. /**
  10281. * Diffuse gives the basic color to an object.
  10282. */
  10283. diffuse: Color3;
  10284. /**
  10285. * Specular produces a highlight color on an object.
  10286. * Note: This is note affecting PBR materials.
  10287. */
  10288. specular: Color3;
  10289. /**
  10290. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10291. * falling off base on range or angle.
  10292. * This can be set to any values in Light.FALLOFF_x.
  10293. *
  10294. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10295. * other types of materials.
  10296. */
  10297. falloffType: number;
  10298. /**
  10299. * Strength of the light.
  10300. * Note: By default it is define in the framework own unit.
  10301. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10302. */
  10303. intensity: number;
  10304. private _range;
  10305. protected _inverseSquaredRange: number;
  10306. /**
  10307. * Defines how far from the source the light is impacting in scene units.
  10308. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10309. */
  10310. /**
  10311. * Defines how far from the source the light is impacting in scene units.
  10312. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10313. */
  10314. range: number;
  10315. /**
  10316. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10317. * of light.
  10318. */
  10319. private _photometricScale;
  10320. private _intensityMode;
  10321. /**
  10322. * Gets the photometric scale used to interpret the intensity.
  10323. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10324. */
  10325. /**
  10326. * Sets the photometric scale used to interpret the intensity.
  10327. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10328. */
  10329. intensityMode: number;
  10330. private _radius;
  10331. /**
  10332. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10333. */
  10334. /**
  10335. * sets the light radius used by PBR Materials to simulate soft area lights.
  10336. */
  10337. radius: number;
  10338. private _renderPriority;
  10339. /**
  10340. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10341. * exceeding the number allowed of the materials.
  10342. */
  10343. renderPriority: number;
  10344. private _shadowEnabled;
  10345. /**
  10346. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10347. * the current shadow generator.
  10348. */
  10349. /**
  10350. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10351. * the current shadow generator.
  10352. */
  10353. shadowEnabled: boolean;
  10354. private _includedOnlyMeshes;
  10355. /**
  10356. * Gets the only meshes impacted by this light.
  10357. */
  10358. /**
  10359. * Sets the only meshes impacted by this light.
  10360. */
  10361. includedOnlyMeshes: AbstractMesh[];
  10362. private _excludedMeshes;
  10363. /**
  10364. * Gets the meshes not impacted by this light.
  10365. */
  10366. /**
  10367. * Sets the meshes not impacted by this light.
  10368. */
  10369. excludedMeshes: AbstractMesh[];
  10370. private _excludeWithLayerMask;
  10371. /**
  10372. * Gets the layer id use to find what meshes are not impacted by the light.
  10373. * Inactive if 0
  10374. */
  10375. /**
  10376. * Sets the layer id use to find what meshes are not impacted by the light.
  10377. * Inactive if 0
  10378. */
  10379. excludeWithLayerMask: number;
  10380. private _includeOnlyWithLayerMask;
  10381. /**
  10382. * Gets the layer id use to find what meshes are impacted by the light.
  10383. * Inactive if 0
  10384. */
  10385. /**
  10386. * Sets the layer id use to find what meshes are impacted by the light.
  10387. * Inactive if 0
  10388. */
  10389. includeOnlyWithLayerMask: number;
  10390. private _lightmapMode;
  10391. /**
  10392. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10393. */
  10394. /**
  10395. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10396. */
  10397. lightmapMode: number;
  10398. /**
  10399. * Shadow generator associted to the light.
  10400. * @hidden Internal use only.
  10401. */
  10402. _shadowGenerator: Nullable<IShadowGenerator>;
  10403. /**
  10404. * @hidden Internal use only.
  10405. */
  10406. _excludedMeshesIds: string[];
  10407. /**
  10408. * @hidden Internal use only.
  10409. */
  10410. _includedOnlyMeshesIds: string[];
  10411. /**
  10412. * The current light unifom buffer.
  10413. * @hidden Internal use only.
  10414. */
  10415. _uniformBuffer: UniformBuffer;
  10416. /**
  10417. * Creates a Light object in the scene.
  10418. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10419. * @param name The firendly name of the light
  10420. * @param scene The scene the light belongs too
  10421. */
  10422. constructor(name: string, scene: Scene);
  10423. protected abstract _buildUniformLayout(): void;
  10424. /**
  10425. * Sets the passed Effect "effect" with the Light information.
  10426. * @param effect The effect to update
  10427. * @param lightIndex The index of the light in the effect to update
  10428. * @returns The light
  10429. */
  10430. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10431. /**
  10432. * Returns the string "Light".
  10433. * @returns the class name
  10434. */
  10435. getClassName(): string;
  10436. /** @hidden */
  10437. readonly _isLight: boolean;
  10438. /**
  10439. * Converts the light information to a readable string for debug purpose.
  10440. * @param fullDetails Supports for multiple levels of logging within scene loading
  10441. * @returns the human readable light info
  10442. */
  10443. toString(fullDetails?: boolean): string;
  10444. /** @hidden */
  10445. protected _syncParentEnabledState(): void;
  10446. /**
  10447. * Set the enabled state of this node.
  10448. * @param value - the new enabled state
  10449. */
  10450. setEnabled(value: boolean): void;
  10451. /**
  10452. * Returns the Light associated shadow generator if any.
  10453. * @return the associated shadow generator.
  10454. */
  10455. getShadowGenerator(): Nullable<IShadowGenerator>;
  10456. /**
  10457. * Returns a Vector3, the absolute light position in the World.
  10458. * @returns the world space position of the light
  10459. */
  10460. getAbsolutePosition(): Vector3;
  10461. /**
  10462. * Specifies if the light will affect the passed mesh.
  10463. * @param mesh The mesh to test against the light
  10464. * @return true the mesh is affected otherwise, false.
  10465. */
  10466. canAffectMesh(mesh: AbstractMesh): boolean;
  10467. /**
  10468. * Sort function to order lights for rendering.
  10469. * @param a First Light object to compare to second.
  10470. * @param b Second Light object to compare first.
  10471. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10472. */
  10473. static CompareLightsPriority(a: Light, b: Light): number;
  10474. /**
  10475. * Releases resources associated with this node.
  10476. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10477. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10478. */
  10479. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10480. /**
  10481. * Returns the light type ID (integer).
  10482. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10483. */
  10484. getTypeID(): number;
  10485. /**
  10486. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10487. * @returns the scaled intensity in intensity mode unit
  10488. */
  10489. getScaledIntensity(): number;
  10490. /**
  10491. * Returns a new Light object, named "name", from the current one.
  10492. * @param name The name of the cloned light
  10493. * @returns the new created light
  10494. */
  10495. clone(name: string): Nullable<Light>;
  10496. /**
  10497. * Serializes the current light into a Serialization object.
  10498. * @returns the serialized object.
  10499. */
  10500. serialize(): any;
  10501. /**
  10502. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10503. * This new light is named "name" and added to the passed scene.
  10504. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10505. * @param name The friendly name of the light
  10506. * @param scene The scene the new light will belong to
  10507. * @returns the constructor function
  10508. */
  10509. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10510. /**
  10511. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10512. * @param parsedLight The JSON representation of the light
  10513. * @param scene The scene to create the parsed light in
  10514. * @returns the created light after parsing
  10515. */
  10516. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10517. private _hookArrayForExcluded;
  10518. private _hookArrayForIncludedOnly;
  10519. private _resyncMeshes;
  10520. /**
  10521. * Forces the meshes to update their light related information in their rendering used effects
  10522. * @hidden Internal Use Only
  10523. */
  10524. _markMeshesAsLightDirty(): void;
  10525. /**
  10526. * Recomputes the cached photometric scale if needed.
  10527. */
  10528. private _computePhotometricScale;
  10529. /**
  10530. * Returns the Photometric Scale according to the light type and intensity mode.
  10531. */
  10532. private _getPhotometricScale;
  10533. /**
  10534. * Reorder the light in the scene according to their defined priority.
  10535. * @hidden Internal Use Only
  10536. */
  10537. _reorderLightsInScene(): void;
  10538. /**
  10539. * Prepares the list of defines specific to the light type.
  10540. * @param defines the list of defines
  10541. * @param lightIndex defines the index of the light for the effect
  10542. */
  10543. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10544. }
  10545. }
  10546. declare module BABYLON {
  10547. /**
  10548. * Interface used to define Action
  10549. */
  10550. export interface IAction {
  10551. /**
  10552. * Trigger for the action
  10553. */
  10554. trigger: number;
  10555. /** Options of the trigger */
  10556. triggerOptions: any;
  10557. /**
  10558. * Gets the trigger parameters
  10559. * @returns the trigger parameters
  10560. */
  10561. getTriggerParameter(): any;
  10562. /**
  10563. * Internal only - executes current action event
  10564. * @hidden
  10565. */
  10566. _executeCurrent(evt?: ActionEvent): void;
  10567. /**
  10568. * Serialize placeholder for child classes
  10569. * @param parent of child
  10570. * @returns the serialized object
  10571. */
  10572. serialize(parent: any): any;
  10573. /**
  10574. * Internal only
  10575. * @hidden
  10576. */
  10577. _prepare(): void;
  10578. /**
  10579. * Internal only - manager for action
  10580. * @hidden
  10581. */
  10582. _actionManager: AbstractActionManager;
  10583. }
  10584. /**
  10585. * The action to be carried out following a trigger
  10586. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10587. */
  10588. export class Action implements IAction {
  10589. /** the trigger, with or without parameters, for the action */
  10590. triggerOptions: any;
  10591. /**
  10592. * Trigger for the action
  10593. */
  10594. trigger: number;
  10595. /**
  10596. * Internal only - manager for action
  10597. * @hidden
  10598. */
  10599. _actionManager: ActionManager;
  10600. private _nextActiveAction;
  10601. private _child;
  10602. private _condition?;
  10603. private _triggerParameter;
  10604. /**
  10605. * An event triggered prior to action being executed.
  10606. */
  10607. onBeforeExecuteObservable: Observable<Action>;
  10608. /**
  10609. * Creates a new Action
  10610. * @param triggerOptions the trigger, with or without parameters, for the action
  10611. * @param condition an optional determinant of action
  10612. */
  10613. constructor(
  10614. /** the trigger, with or without parameters, for the action */
  10615. triggerOptions: any, condition?: Condition);
  10616. /**
  10617. * Internal only
  10618. * @hidden
  10619. */
  10620. _prepare(): void;
  10621. /**
  10622. * Gets the trigger parameters
  10623. * @returns the trigger parameters
  10624. */
  10625. getTriggerParameter(): any;
  10626. /**
  10627. * Internal only - executes current action event
  10628. * @hidden
  10629. */
  10630. _executeCurrent(evt?: ActionEvent): void;
  10631. /**
  10632. * Execute placeholder for child classes
  10633. * @param evt optional action event
  10634. */
  10635. execute(evt?: ActionEvent): void;
  10636. /**
  10637. * Skips to next active action
  10638. */
  10639. skipToNextActiveAction(): void;
  10640. /**
  10641. * Adds action to chain of actions, may be a DoNothingAction
  10642. * @param action defines the next action to execute
  10643. * @returns The action passed in
  10644. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10645. */
  10646. then(action: Action): Action;
  10647. /**
  10648. * Internal only
  10649. * @hidden
  10650. */
  10651. _getProperty(propertyPath: string): string;
  10652. /**
  10653. * Internal only
  10654. * @hidden
  10655. */
  10656. _getEffectiveTarget(target: any, propertyPath: string): any;
  10657. /**
  10658. * Serialize placeholder for child classes
  10659. * @param parent of child
  10660. * @returns the serialized object
  10661. */
  10662. serialize(parent: any): any;
  10663. /**
  10664. * Internal only called by serialize
  10665. * @hidden
  10666. */
  10667. protected _serialize(serializedAction: any, parent?: any): any;
  10668. /**
  10669. * Internal only
  10670. * @hidden
  10671. */
  10672. static _SerializeValueAsString: (value: any) => string;
  10673. /**
  10674. * Internal only
  10675. * @hidden
  10676. */
  10677. static _GetTargetProperty: (target: Scene | Node) => {
  10678. name: string;
  10679. targetType: string;
  10680. value: string;
  10681. };
  10682. }
  10683. }
  10684. declare module BABYLON {
  10685. /**
  10686. * A Condition applied to an Action
  10687. */
  10688. export class Condition {
  10689. /**
  10690. * Internal only - manager for action
  10691. * @hidden
  10692. */
  10693. _actionManager: ActionManager;
  10694. /**
  10695. * Internal only
  10696. * @hidden
  10697. */
  10698. _evaluationId: number;
  10699. /**
  10700. * Internal only
  10701. * @hidden
  10702. */
  10703. _currentResult: boolean;
  10704. /**
  10705. * Creates a new Condition
  10706. * @param actionManager the manager of the action the condition is applied to
  10707. */
  10708. constructor(actionManager: ActionManager);
  10709. /**
  10710. * Check if the current condition is valid
  10711. * @returns a boolean
  10712. */
  10713. isValid(): boolean;
  10714. /**
  10715. * Internal only
  10716. * @hidden
  10717. */
  10718. _getProperty(propertyPath: string): string;
  10719. /**
  10720. * Internal only
  10721. * @hidden
  10722. */
  10723. _getEffectiveTarget(target: any, propertyPath: string): any;
  10724. /**
  10725. * Serialize placeholder for child classes
  10726. * @returns the serialized object
  10727. */
  10728. serialize(): any;
  10729. /**
  10730. * Internal only
  10731. * @hidden
  10732. */
  10733. protected _serialize(serializedCondition: any): any;
  10734. }
  10735. /**
  10736. * Defines specific conditional operators as extensions of Condition
  10737. */
  10738. export class ValueCondition extends Condition {
  10739. /** path to specify the property of the target the conditional operator uses */
  10740. propertyPath: string;
  10741. /** the value compared by the conditional operator against the current value of the property */
  10742. value: any;
  10743. /** the conditional operator, default ValueCondition.IsEqual */
  10744. operator: number;
  10745. /**
  10746. * Internal only
  10747. * @hidden
  10748. */
  10749. private static _IsEqual;
  10750. /**
  10751. * Internal only
  10752. * @hidden
  10753. */
  10754. private static _IsDifferent;
  10755. /**
  10756. * Internal only
  10757. * @hidden
  10758. */
  10759. private static _IsGreater;
  10760. /**
  10761. * Internal only
  10762. * @hidden
  10763. */
  10764. private static _IsLesser;
  10765. /**
  10766. * returns the number for IsEqual
  10767. */
  10768. static readonly IsEqual: number;
  10769. /**
  10770. * Returns the number for IsDifferent
  10771. */
  10772. static readonly IsDifferent: number;
  10773. /**
  10774. * Returns the number for IsGreater
  10775. */
  10776. static readonly IsGreater: number;
  10777. /**
  10778. * Returns the number for IsLesser
  10779. */
  10780. static readonly IsLesser: number;
  10781. /**
  10782. * Internal only The action manager for the condition
  10783. * @hidden
  10784. */
  10785. _actionManager: ActionManager;
  10786. /**
  10787. * Internal only
  10788. * @hidden
  10789. */
  10790. private _target;
  10791. /**
  10792. * Internal only
  10793. * @hidden
  10794. */
  10795. private _effectiveTarget;
  10796. /**
  10797. * Internal only
  10798. * @hidden
  10799. */
  10800. private _property;
  10801. /**
  10802. * Creates a new ValueCondition
  10803. * @param actionManager manager for the action the condition applies to
  10804. * @param target for the action
  10805. * @param propertyPath path to specify the property of the target the conditional operator uses
  10806. * @param value the value compared by the conditional operator against the current value of the property
  10807. * @param operator the conditional operator, default ValueCondition.IsEqual
  10808. */
  10809. constructor(actionManager: ActionManager, target: any,
  10810. /** path to specify the property of the target the conditional operator uses */
  10811. propertyPath: string,
  10812. /** the value compared by the conditional operator against the current value of the property */
  10813. value: any,
  10814. /** the conditional operator, default ValueCondition.IsEqual */
  10815. operator?: number);
  10816. /**
  10817. * Compares the given value with the property value for the specified conditional operator
  10818. * @returns the result of the comparison
  10819. */
  10820. isValid(): boolean;
  10821. /**
  10822. * Serialize the ValueCondition into a JSON compatible object
  10823. * @returns serialization object
  10824. */
  10825. serialize(): any;
  10826. /**
  10827. * Gets the name of the conditional operator for the ValueCondition
  10828. * @param operator the conditional operator
  10829. * @returns the name
  10830. */
  10831. static GetOperatorName(operator: number): string;
  10832. }
  10833. /**
  10834. * Defines a predicate condition as an extension of Condition
  10835. */
  10836. export class PredicateCondition extends Condition {
  10837. /** defines the predicate function used to validate the condition */
  10838. predicate: () => boolean;
  10839. /**
  10840. * Internal only - manager for action
  10841. * @hidden
  10842. */
  10843. _actionManager: ActionManager;
  10844. /**
  10845. * Creates a new PredicateCondition
  10846. * @param actionManager manager for the action the condition applies to
  10847. * @param predicate defines the predicate function used to validate the condition
  10848. */
  10849. constructor(actionManager: ActionManager,
  10850. /** defines the predicate function used to validate the condition */
  10851. predicate: () => boolean);
  10852. /**
  10853. * @returns the validity of the predicate condition
  10854. */
  10855. isValid(): boolean;
  10856. }
  10857. /**
  10858. * Defines a state condition as an extension of Condition
  10859. */
  10860. export class StateCondition extends Condition {
  10861. /** Value to compare with target state */
  10862. value: string;
  10863. /**
  10864. * Internal only - manager for action
  10865. * @hidden
  10866. */
  10867. _actionManager: ActionManager;
  10868. /**
  10869. * Internal only
  10870. * @hidden
  10871. */
  10872. private _target;
  10873. /**
  10874. * Creates a new StateCondition
  10875. * @param actionManager manager for the action the condition applies to
  10876. * @param target of the condition
  10877. * @param value to compare with target state
  10878. */
  10879. constructor(actionManager: ActionManager, target: any,
  10880. /** Value to compare with target state */
  10881. value: string);
  10882. /**
  10883. * Gets a boolean indicating if the current condition is met
  10884. * @returns the validity of the state
  10885. */
  10886. isValid(): boolean;
  10887. /**
  10888. * Serialize the StateCondition into a JSON compatible object
  10889. * @returns serialization object
  10890. */
  10891. serialize(): any;
  10892. }
  10893. }
  10894. declare module BABYLON {
  10895. /**
  10896. * This defines an action responsible to toggle a boolean once triggered.
  10897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10898. */
  10899. export class SwitchBooleanAction extends Action {
  10900. /**
  10901. * The path to the boolean property in the target object
  10902. */
  10903. propertyPath: string;
  10904. private _target;
  10905. private _effectiveTarget;
  10906. private _property;
  10907. /**
  10908. * Instantiate the action
  10909. * @param triggerOptions defines the trigger options
  10910. * @param target defines the object containing the boolean
  10911. * @param propertyPath defines the path to the boolean property in the target object
  10912. * @param condition defines the trigger related conditions
  10913. */
  10914. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10915. /** @hidden */
  10916. _prepare(): void;
  10917. /**
  10918. * Execute the action toggle the boolean value.
  10919. */
  10920. execute(): void;
  10921. /**
  10922. * Serializes the actions and its related information.
  10923. * @param parent defines the object to serialize in
  10924. * @returns the serialized object
  10925. */
  10926. serialize(parent: any): any;
  10927. }
  10928. /**
  10929. * This defines an action responsible to set a the state field of the target
  10930. * to a desired value once triggered.
  10931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10932. */
  10933. export class SetStateAction extends Action {
  10934. /**
  10935. * The value to store in the state field.
  10936. */
  10937. value: string;
  10938. private _target;
  10939. /**
  10940. * Instantiate the action
  10941. * @param triggerOptions defines the trigger options
  10942. * @param target defines the object containing the state property
  10943. * @param value defines the value to store in the state field
  10944. * @param condition defines the trigger related conditions
  10945. */
  10946. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10947. /**
  10948. * Execute the action and store the value on the target state property.
  10949. */
  10950. execute(): void;
  10951. /**
  10952. * Serializes the actions and its related information.
  10953. * @param parent defines the object to serialize in
  10954. * @returns the serialized object
  10955. */
  10956. serialize(parent: any): any;
  10957. }
  10958. /**
  10959. * This defines an action responsible to set a property of the target
  10960. * to a desired value once triggered.
  10961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10962. */
  10963. export class SetValueAction extends Action {
  10964. /**
  10965. * The path of the property to set in the target.
  10966. */
  10967. propertyPath: string;
  10968. /**
  10969. * The value to set in the property
  10970. */
  10971. value: any;
  10972. private _target;
  10973. private _effectiveTarget;
  10974. private _property;
  10975. /**
  10976. * Instantiate the action
  10977. * @param triggerOptions defines the trigger options
  10978. * @param target defines the object containing the property
  10979. * @param propertyPath defines the path of the property to set in the target
  10980. * @param value defines the value to set in the property
  10981. * @param condition defines the trigger related conditions
  10982. */
  10983. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10984. /** @hidden */
  10985. _prepare(): void;
  10986. /**
  10987. * Execute the action and set the targetted property to the desired value.
  10988. */
  10989. execute(): void;
  10990. /**
  10991. * Serializes the actions and its related information.
  10992. * @param parent defines the object to serialize in
  10993. * @returns the serialized object
  10994. */
  10995. serialize(parent: any): any;
  10996. }
  10997. /**
  10998. * This defines an action responsible to increment the target value
  10999. * to a desired value once triggered.
  11000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11001. */
  11002. export class IncrementValueAction extends Action {
  11003. /**
  11004. * The path of the property to increment in the target.
  11005. */
  11006. propertyPath: string;
  11007. /**
  11008. * The value we should increment the property by.
  11009. */
  11010. value: any;
  11011. private _target;
  11012. private _effectiveTarget;
  11013. private _property;
  11014. /**
  11015. * Instantiate the action
  11016. * @param triggerOptions defines the trigger options
  11017. * @param target defines the object containing the property
  11018. * @param propertyPath defines the path of the property to increment in the target
  11019. * @param value defines the value value we should increment the property by
  11020. * @param condition defines the trigger related conditions
  11021. */
  11022. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11023. /** @hidden */
  11024. _prepare(): void;
  11025. /**
  11026. * Execute the action and increment the target of the value amount.
  11027. */
  11028. execute(): void;
  11029. /**
  11030. * Serializes the actions and its related information.
  11031. * @param parent defines the object to serialize in
  11032. * @returns the serialized object
  11033. */
  11034. serialize(parent: any): any;
  11035. }
  11036. /**
  11037. * This defines an action responsible to start an animation once triggered.
  11038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11039. */
  11040. export class PlayAnimationAction extends Action {
  11041. /**
  11042. * Where the animation should start (animation frame)
  11043. */
  11044. from: number;
  11045. /**
  11046. * Where the animation should stop (animation frame)
  11047. */
  11048. to: number;
  11049. /**
  11050. * Define if the animation should loop or stop after the first play.
  11051. */
  11052. loop?: boolean;
  11053. private _target;
  11054. /**
  11055. * Instantiate the action
  11056. * @param triggerOptions defines the trigger options
  11057. * @param target defines the target animation or animation name
  11058. * @param from defines from where the animation should start (animation frame)
  11059. * @param end defines where the animation should stop (animation frame)
  11060. * @param loop defines if the animation should loop or stop after the first play
  11061. * @param condition defines the trigger related conditions
  11062. */
  11063. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11064. /** @hidden */
  11065. _prepare(): void;
  11066. /**
  11067. * Execute the action and play the animation.
  11068. */
  11069. execute(): void;
  11070. /**
  11071. * Serializes the actions and its related information.
  11072. * @param parent defines the object to serialize in
  11073. * @returns the serialized object
  11074. */
  11075. serialize(parent: any): any;
  11076. }
  11077. /**
  11078. * This defines an action responsible to stop an animation once triggered.
  11079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11080. */
  11081. export class StopAnimationAction extends Action {
  11082. private _target;
  11083. /**
  11084. * Instantiate the action
  11085. * @param triggerOptions defines the trigger options
  11086. * @param target defines the target animation or animation name
  11087. * @param condition defines the trigger related conditions
  11088. */
  11089. constructor(triggerOptions: any, target: any, condition?: Condition);
  11090. /** @hidden */
  11091. _prepare(): void;
  11092. /**
  11093. * Execute the action and stop the animation.
  11094. */
  11095. execute(): void;
  11096. /**
  11097. * Serializes the actions and its related information.
  11098. * @param parent defines the object to serialize in
  11099. * @returns the serialized object
  11100. */
  11101. serialize(parent: any): any;
  11102. }
  11103. /**
  11104. * This defines an action responsible that does nothing once triggered.
  11105. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11106. */
  11107. export class DoNothingAction extends Action {
  11108. /**
  11109. * Instantiate the action
  11110. * @param triggerOptions defines the trigger options
  11111. * @param condition defines the trigger related conditions
  11112. */
  11113. constructor(triggerOptions?: any, condition?: Condition);
  11114. /**
  11115. * Execute the action and do nothing.
  11116. */
  11117. execute(): void;
  11118. /**
  11119. * Serializes the actions and its related information.
  11120. * @param parent defines the object to serialize in
  11121. * @returns the serialized object
  11122. */
  11123. serialize(parent: any): any;
  11124. }
  11125. /**
  11126. * This defines an action responsible to trigger several actions once triggered.
  11127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11128. */
  11129. export class CombineAction extends Action {
  11130. /**
  11131. * The list of aggregated animations to run.
  11132. */
  11133. children: Action[];
  11134. /**
  11135. * Instantiate the action
  11136. * @param triggerOptions defines the trigger options
  11137. * @param children defines the list of aggregated animations to run
  11138. * @param condition defines the trigger related conditions
  11139. */
  11140. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11141. /** @hidden */
  11142. _prepare(): void;
  11143. /**
  11144. * Execute the action and executes all the aggregated actions.
  11145. */
  11146. execute(evt: ActionEvent): void;
  11147. /**
  11148. * Serializes the actions and its related information.
  11149. * @param parent defines the object to serialize in
  11150. * @returns the serialized object
  11151. */
  11152. serialize(parent: any): any;
  11153. }
  11154. /**
  11155. * This defines an action responsible to run code (external event) once triggered.
  11156. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11157. */
  11158. export class ExecuteCodeAction extends Action {
  11159. /**
  11160. * The callback function to run.
  11161. */
  11162. func: (evt: ActionEvent) => void;
  11163. /**
  11164. * Instantiate the action
  11165. * @param triggerOptions defines the trigger options
  11166. * @param func defines the callback function to run
  11167. * @param condition defines the trigger related conditions
  11168. */
  11169. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11170. /**
  11171. * Execute the action and run the attached code.
  11172. */
  11173. execute(evt: ActionEvent): void;
  11174. }
  11175. /**
  11176. * This defines an action responsible to set the parent property of the target once triggered.
  11177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11178. */
  11179. export class SetParentAction extends Action {
  11180. private _parent;
  11181. private _target;
  11182. /**
  11183. * Instantiate the action
  11184. * @param triggerOptions defines the trigger options
  11185. * @param target defines the target containing the parent property
  11186. * @param parent defines from where the animation should start (animation frame)
  11187. * @param condition defines the trigger related conditions
  11188. */
  11189. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11190. /** @hidden */
  11191. _prepare(): void;
  11192. /**
  11193. * Execute the action and set the parent property.
  11194. */
  11195. execute(): void;
  11196. /**
  11197. * Serializes the actions and its related information.
  11198. * @param parent defines the object to serialize in
  11199. * @returns the serialized object
  11200. */
  11201. serialize(parent: any): any;
  11202. }
  11203. }
  11204. declare module BABYLON {
  11205. /**
  11206. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11207. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11209. */
  11210. export class ActionManager extends AbstractActionManager {
  11211. /**
  11212. * Nothing
  11213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11214. */
  11215. static readonly NothingTrigger: number;
  11216. /**
  11217. * On pick
  11218. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11219. */
  11220. static readonly OnPickTrigger: number;
  11221. /**
  11222. * On left pick
  11223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11224. */
  11225. static readonly OnLeftPickTrigger: number;
  11226. /**
  11227. * On right pick
  11228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11229. */
  11230. static readonly OnRightPickTrigger: number;
  11231. /**
  11232. * On center pick
  11233. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11234. */
  11235. static readonly OnCenterPickTrigger: number;
  11236. /**
  11237. * On pick down
  11238. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11239. */
  11240. static readonly OnPickDownTrigger: number;
  11241. /**
  11242. * On double pick
  11243. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11244. */
  11245. static readonly OnDoublePickTrigger: number;
  11246. /**
  11247. * On pick up
  11248. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11249. */
  11250. static readonly OnPickUpTrigger: number;
  11251. /**
  11252. * On pick out.
  11253. * This trigger will only be raised if you also declared a OnPickDown
  11254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11255. */
  11256. static readonly OnPickOutTrigger: number;
  11257. /**
  11258. * On long press
  11259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11260. */
  11261. static readonly OnLongPressTrigger: number;
  11262. /**
  11263. * On pointer over
  11264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11265. */
  11266. static readonly OnPointerOverTrigger: number;
  11267. /**
  11268. * On pointer out
  11269. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11270. */
  11271. static readonly OnPointerOutTrigger: number;
  11272. /**
  11273. * On every frame
  11274. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11275. */
  11276. static readonly OnEveryFrameTrigger: number;
  11277. /**
  11278. * On intersection enter
  11279. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11280. */
  11281. static readonly OnIntersectionEnterTrigger: number;
  11282. /**
  11283. * On intersection exit
  11284. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11285. */
  11286. static readonly OnIntersectionExitTrigger: number;
  11287. /**
  11288. * On key down
  11289. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11290. */
  11291. static readonly OnKeyDownTrigger: number;
  11292. /**
  11293. * On key up
  11294. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11295. */
  11296. static readonly OnKeyUpTrigger: number;
  11297. private _scene;
  11298. /**
  11299. * Creates a new action manager
  11300. * @param scene defines the hosting scene
  11301. */
  11302. constructor(scene: Scene);
  11303. /**
  11304. * Releases all associated resources
  11305. */
  11306. dispose(): void;
  11307. /**
  11308. * Gets hosting scene
  11309. * @returns the hosting scene
  11310. */
  11311. getScene(): Scene;
  11312. /**
  11313. * Does this action manager handles actions of any of the given triggers
  11314. * @param triggers defines the triggers to be tested
  11315. * @return a boolean indicating whether one (or more) of the triggers is handled
  11316. */
  11317. hasSpecificTriggers(triggers: number[]): boolean;
  11318. /**
  11319. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11320. * speed.
  11321. * @param triggerA defines the trigger to be tested
  11322. * @param triggerB defines the trigger to be tested
  11323. * @return a boolean indicating whether one (or more) of the triggers is handled
  11324. */
  11325. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11326. /**
  11327. * Does this action manager handles actions of a given trigger
  11328. * @param trigger defines the trigger to be tested
  11329. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11330. * @return whether the trigger is handled
  11331. */
  11332. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11333. /**
  11334. * Does this action manager has pointer triggers
  11335. */
  11336. readonly hasPointerTriggers: boolean;
  11337. /**
  11338. * Does this action manager has pick triggers
  11339. */
  11340. readonly hasPickTriggers: boolean;
  11341. /**
  11342. * Registers an action to this action manager
  11343. * @param action defines the action to be registered
  11344. * @return the action amended (prepared) after registration
  11345. */
  11346. registerAction(action: IAction): Nullable<IAction>;
  11347. /**
  11348. * Unregisters an action to this action manager
  11349. * @param action defines the action to be unregistered
  11350. * @return a boolean indicating whether the action has been unregistered
  11351. */
  11352. unregisterAction(action: IAction): Boolean;
  11353. /**
  11354. * Process a specific trigger
  11355. * @param trigger defines the trigger to process
  11356. * @param evt defines the event details to be processed
  11357. */
  11358. processTrigger(trigger: number, evt?: IActionEvent): void;
  11359. /** @hidden */
  11360. _getEffectiveTarget(target: any, propertyPath: string): any;
  11361. /** @hidden */
  11362. _getProperty(propertyPath: string): string;
  11363. /**
  11364. * Serialize this manager to a JSON object
  11365. * @param name defines the property name to store this manager
  11366. * @returns a JSON representation of this manager
  11367. */
  11368. serialize(name: string): any;
  11369. /**
  11370. * Creates a new ActionManager from a JSON data
  11371. * @param parsedActions defines the JSON data to read from
  11372. * @param object defines the hosting mesh
  11373. * @param scene defines the hosting scene
  11374. */
  11375. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11376. /**
  11377. * Get a trigger name by index
  11378. * @param trigger defines the trigger index
  11379. * @returns a trigger name
  11380. */
  11381. static GetTriggerName(trigger: number): string;
  11382. }
  11383. }
  11384. declare module BABYLON {
  11385. /**
  11386. * Class representing a ray with position and direction
  11387. */
  11388. export class Ray {
  11389. /** origin point */
  11390. origin: Vector3;
  11391. /** direction */
  11392. direction: Vector3;
  11393. /** length of the ray */
  11394. length: number;
  11395. private static readonly TmpVector3;
  11396. private _tmpRay;
  11397. /**
  11398. * Creates a new ray
  11399. * @param origin origin point
  11400. * @param direction direction
  11401. * @param length length of the ray
  11402. */
  11403. constructor(
  11404. /** origin point */
  11405. origin: Vector3,
  11406. /** direction */
  11407. direction: Vector3,
  11408. /** length of the ray */
  11409. length?: number);
  11410. /**
  11411. * Checks if the ray intersects a box
  11412. * @param minimum bound of the box
  11413. * @param maximum bound of the box
  11414. * @param intersectionTreshold extra extend to be added to the box in all direction
  11415. * @returns if the box was hit
  11416. */
  11417. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11418. /**
  11419. * Checks if the ray intersects a box
  11420. * @param box the bounding box to check
  11421. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11422. * @returns if the box was hit
  11423. */
  11424. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11425. /**
  11426. * If the ray hits a sphere
  11427. * @param sphere the bounding sphere to check
  11428. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11429. * @returns true if it hits the sphere
  11430. */
  11431. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11432. /**
  11433. * If the ray hits a triange
  11434. * @param vertex0 triangle vertex
  11435. * @param vertex1 triangle vertex
  11436. * @param vertex2 triangle vertex
  11437. * @returns intersection information if hit
  11438. */
  11439. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11440. /**
  11441. * Checks if ray intersects a plane
  11442. * @param plane the plane to check
  11443. * @returns the distance away it was hit
  11444. */
  11445. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11446. /**
  11447. * Checks if ray intersects a mesh
  11448. * @param mesh the mesh to check
  11449. * @param fastCheck if only the bounding box should checked
  11450. * @returns picking info of the intersecton
  11451. */
  11452. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11453. /**
  11454. * Checks if ray intersects a mesh
  11455. * @param meshes the meshes to check
  11456. * @param fastCheck if only the bounding box should checked
  11457. * @param results array to store result in
  11458. * @returns Array of picking infos
  11459. */
  11460. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11461. private _comparePickingInfo;
  11462. private static smallnum;
  11463. private static rayl;
  11464. /**
  11465. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11466. * @param sega the first point of the segment to test the intersection against
  11467. * @param segb the second point of the segment to test the intersection against
  11468. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11469. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11470. */
  11471. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11472. /**
  11473. * Update the ray from viewport position
  11474. * @param x position
  11475. * @param y y position
  11476. * @param viewportWidth viewport width
  11477. * @param viewportHeight viewport height
  11478. * @param world world matrix
  11479. * @param view view matrix
  11480. * @param projection projection matrix
  11481. * @returns this ray updated
  11482. */
  11483. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11484. /**
  11485. * Creates a ray with origin and direction of 0,0,0
  11486. * @returns the new ray
  11487. */
  11488. static Zero(): Ray;
  11489. /**
  11490. * Creates a new ray from screen space and viewport
  11491. * @param x position
  11492. * @param y y position
  11493. * @param viewportWidth viewport width
  11494. * @param viewportHeight viewport height
  11495. * @param world world matrix
  11496. * @param view view matrix
  11497. * @param projection projection matrix
  11498. * @returns new ray
  11499. */
  11500. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11501. /**
  11502. * 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
  11503. * transformed to the given world matrix.
  11504. * @param origin The origin point
  11505. * @param end The end point
  11506. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11507. * @returns the new ray
  11508. */
  11509. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11510. /**
  11511. * Transforms a ray by a matrix
  11512. * @param ray ray to transform
  11513. * @param matrix matrix to apply
  11514. * @returns the resulting new ray
  11515. */
  11516. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11517. /**
  11518. * Transforms a ray by a matrix
  11519. * @param ray ray to transform
  11520. * @param matrix matrix to apply
  11521. * @param result ray to store result in
  11522. */
  11523. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11524. /**
  11525. * Unproject a ray from screen space to object space
  11526. * @param sourceX defines the screen space x coordinate to use
  11527. * @param sourceY defines the screen space y coordinate to use
  11528. * @param viewportWidth defines the current width of the viewport
  11529. * @param viewportHeight defines the current height of the viewport
  11530. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11531. * @param view defines the view matrix to use
  11532. * @param projection defines the projection matrix to use
  11533. */
  11534. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11535. }
  11536. /**
  11537. * Type used to define predicate used to select faces when a mesh intersection is detected
  11538. */
  11539. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11540. interface Scene {
  11541. /** @hidden */
  11542. _tempPickingRay: Nullable<Ray>;
  11543. /** @hidden */
  11544. _cachedRayForTransform: Ray;
  11545. /** @hidden */
  11546. _pickWithRayInverseMatrix: Matrix;
  11547. /** @hidden */
  11548. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11549. /** @hidden */
  11550. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11551. }
  11552. }
  11553. declare module BABYLON {
  11554. /**
  11555. * Groups all the scene component constants in one place to ease maintenance.
  11556. * @hidden
  11557. */
  11558. export class SceneComponentConstants {
  11559. static readonly NAME_EFFECTLAYER: string;
  11560. static readonly NAME_LAYER: string;
  11561. static readonly NAME_LENSFLARESYSTEM: string;
  11562. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11563. static readonly NAME_PARTICLESYSTEM: string;
  11564. static readonly NAME_GAMEPAD: string;
  11565. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11566. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11567. static readonly NAME_DEPTHRENDERER: string;
  11568. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11569. static readonly NAME_SPRITE: string;
  11570. static readonly NAME_OUTLINERENDERER: string;
  11571. static readonly NAME_PROCEDURALTEXTURE: string;
  11572. static readonly NAME_SHADOWGENERATOR: string;
  11573. static readonly NAME_OCTREE: string;
  11574. static readonly NAME_PHYSICSENGINE: string;
  11575. static readonly NAME_AUDIO: string;
  11576. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11577. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11578. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11579. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11580. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11581. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11582. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11583. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11584. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11585. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11586. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11587. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11588. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11589. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11590. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11591. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11592. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11593. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11594. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11595. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11596. static readonly STEP_AFTERRENDER_AUDIO: number;
  11597. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11598. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11599. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11600. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11601. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11602. static readonly STEP_POINTERMOVE_SPRITE: number;
  11603. static readonly STEP_POINTERDOWN_SPRITE: number;
  11604. static readonly STEP_POINTERUP_SPRITE: number;
  11605. }
  11606. /**
  11607. * This represents a scene component.
  11608. *
  11609. * This is used to decouple the dependency the scene is having on the different workloads like
  11610. * layers, post processes...
  11611. */
  11612. export interface ISceneComponent {
  11613. /**
  11614. * The name of the component. Each component must have a unique name.
  11615. */
  11616. name: string;
  11617. /**
  11618. * The scene the component belongs to.
  11619. */
  11620. scene: Scene;
  11621. /**
  11622. * Register the component to one instance of a scene.
  11623. */
  11624. register(): void;
  11625. /**
  11626. * Rebuilds the elements related to this component in case of
  11627. * context lost for instance.
  11628. */
  11629. rebuild(): void;
  11630. /**
  11631. * Disposes the component and the associated ressources.
  11632. */
  11633. dispose(): void;
  11634. }
  11635. /**
  11636. * This represents a SERIALIZABLE scene component.
  11637. *
  11638. * This extends Scene Component to add Serialization methods on top.
  11639. */
  11640. export interface ISceneSerializableComponent extends ISceneComponent {
  11641. /**
  11642. * Adds all the element from the container to the scene
  11643. * @param container the container holding the elements
  11644. */
  11645. addFromContainer(container: AbstractScene): void;
  11646. /**
  11647. * Removes all the elements in the container from the scene
  11648. * @param container contains the elements to remove
  11649. * @param dispose if the removed element should be disposed (default: false)
  11650. */
  11651. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11652. /**
  11653. * Serializes the component data to the specified json object
  11654. * @param serializationObject The object to serialize to
  11655. */
  11656. serialize(serializationObject: any): void;
  11657. }
  11658. /**
  11659. * Strong typing of a Mesh related stage step action
  11660. */
  11661. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11662. /**
  11663. * Strong typing of a Evaluate Sub Mesh related stage step action
  11664. */
  11665. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11666. /**
  11667. * Strong typing of a Active Mesh related stage step action
  11668. */
  11669. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11670. /**
  11671. * Strong typing of a Camera related stage step action
  11672. */
  11673. export type CameraStageAction = (camera: Camera) => void;
  11674. /**
  11675. * Strong typing of a Camera Frame buffer related stage step action
  11676. */
  11677. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11678. /**
  11679. * Strong typing of a Render Target related stage step action
  11680. */
  11681. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11682. /**
  11683. * Strong typing of a RenderingGroup related stage step action
  11684. */
  11685. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11686. /**
  11687. * Strong typing of a Mesh Render related stage step action
  11688. */
  11689. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11690. /**
  11691. * Strong typing of a simple stage step action
  11692. */
  11693. export type SimpleStageAction = () => void;
  11694. /**
  11695. * Strong typing of a render target action.
  11696. */
  11697. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11698. /**
  11699. * Strong typing of a pointer move action.
  11700. */
  11701. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11702. /**
  11703. * Strong typing of a pointer up/down action.
  11704. */
  11705. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11706. /**
  11707. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11708. * @hidden
  11709. */
  11710. export class Stage<T extends Function> extends Array<{
  11711. index: number;
  11712. component: ISceneComponent;
  11713. action: T;
  11714. }> {
  11715. /**
  11716. * Hide ctor from the rest of the world.
  11717. * @param items The items to add.
  11718. */
  11719. private constructor();
  11720. /**
  11721. * Creates a new Stage.
  11722. * @returns A new instance of a Stage
  11723. */
  11724. static Create<T extends Function>(): Stage<T>;
  11725. /**
  11726. * Registers a step in an ordered way in the targeted stage.
  11727. * @param index Defines the position to register the step in
  11728. * @param component Defines the component attached to the step
  11729. * @param action Defines the action to launch during the step
  11730. */
  11731. registerStep(index: number, component: ISceneComponent, action: T): void;
  11732. /**
  11733. * Clears all the steps from the stage.
  11734. */
  11735. clear(): void;
  11736. }
  11737. }
  11738. declare module BABYLON {
  11739. interface Scene {
  11740. /** @hidden */
  11741. _pointerOverSprite: Nullable<Sprite>;
  11742. /** @hidden */
  11743. _pickedDownSprite: Nullable<Sprite>;
  11744. /** @hidden */
  11745. _tempSpritePickingRay: Nullable<Ray>;
  11746. /**
  11747. * All of the sprite managers added to this scene
  11748. * @see http://doc.babylonjs.com/babylon101/sprites
  11749. */
  11750. spriteManagers: Array<ISpriteManager>;
  11751. /**
  11752. * An event triggered when sprites rendering is about to start
  11753. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11754. */
  11755. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11756. /**
  11757. * An event triggered when sprites rendering is done
  11758. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11759. */
  11760. onAfterSpritesRenderingObservable: Observable<Scene>;
  11761. /** @hidden */
  11762. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11763. /** Launch a ray to try to pick a sprite in the scene
  11764. * @param x position on screen
  11765. * @param y position on screen
  11766. * @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
  11767. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11768. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11769. * @returns a PickingInfo
  11770. */
  11771. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11772. /** Use the given ray to pick a sprite in the scene
  11773. * @param ray The ray (in world space) to use to pick meshes
  11774. * @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
  11775. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11776. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11777. * @returns a PickingInfo
  11778. */
  11779. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11780. /**
  11781. * Force the sprite under the pointer
  11782. * @param sprite defines the sprite to use
  11783. */
  11784. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11785. /**
  11786. * Gets the sprite under the pointer
  11787. * @returns a Sprite or null if no sprite is under the pointer
  11788. */
  11789. getPointerOverSprite(): Nullable<Sprite>;
  11790. }
  11791. /**
  11792. * Defines the sprite scene component responsible to manage sprites
  11793. * in a given scene.
  11794. */
  11795. export class SpriteSceneComponent implements ISceneComponent {
  11796. /**
  11797. * The component name helpfull to identify the component in the list of scene components.
  11798. */
  11799. readonly name: string;
  11800. /**
  11801. * The scene the component belongs to.
  11802. */
  11803. scene: Scene;
  11804. /** @hidden */
  11805. private _spritePredicate;
  11806. /**
  11807. * Creates a new instance of the component for the given scene
  11808. * @param scene Defines the scene to register the component in
  11809. */
  11810. constructor(scene: Scene);
  11811. /**
  11812. * Registers the component in a given scene
  11813. */
  11814. register(): void;
  11815. /**
  11816. * Rebuilds the elements related to this component in case of
  11817. * context lost for instance.
  11818. */
  11819. rebuild(): void;
  11820. /**
  11821. * Disposes the component and the associated ressources.
  11822. */
  11823. dispose(): void;
  11824. private _pickSpriteButKeepRay;
  11825. private _pointerMove;
  11826. private _pointerDown;
  11827. private _pointerUp;
  11828. }
  11829. }
  11830. declare module BABYLON {
  11831. /** @hidden */
  11832. export var fogFragmentDeclaration: {
  11833. name: string;
  11834. shader: string;
  11835. };
  11836. }
  11837. declare module BABYLON {
  11838. /** @hidden */
  11839. export var fogFragment: {
  11840. name: string;
  11841. shader: string;
  11842. };
  11843. }
  11844. declare module BABYLON {
  11845. /** @hidden */
  11846. export var spritesPixelShader: {
  11847. name: string;
  11848. shader: string;
  11849. };
  11850. }
  11851. declare module BABYLON {
  11852. /** @hidden */
  11853. export var fogVertexDeclaration: {
  11854. name: string;
  11855. shader: string;
  11856. };
  11857. }
  11858. declare module BABYLON {
  11859. /** @hidden */
  11860. export var spritesVertexShader: {
  11861. name: string;
  11862. shader: string;
  11863. };
  11864. }
  11865. declare module BABYLON {
  11866. /**
  11867. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11868. */
  11869. export interface ISpriteManager extends IDisposable {
  11870. /**
  11871. * Restricts the camera to viewing objects with the same layerMask.
  11872. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11873. */
  11874. layerMask: number;
  11875. /**
  11876. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11877. */
  11878. isPickable: boolean;
  11879. /**
  11880. * Specifies the rendering group id for this mesh (0 by default)
  11881. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11882. */
  11883. renderingGroupId: number;
  11884. /**
  11885. * Defines the list of sprites managed by the manager.
  11886. */
  11887. sprites: Array<Sprite>;
  11888. /**
  11889. * Tests the intersection of a sprite with a specific ray.
  11890. * @param ray The ray we are sending to test the collision
  11891. * @param camera The camera space we are sending rays in
  11892. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11893. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11894. * @returns picking info or null.
  11895. */
  11896. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11897. /**
  11898. * Renders the list of sprites on screen.
  11899. */
  11900. render(): void;
  11901. }
  11902. /**
  11903. * Class used to manage multiple sprites on the same spritesheet
  11904. * @see http://doc.babylonjs.com/babylon101/sprites
  11905. */
  11906. export class SpriteManager implements ISpriteManager {
  11907. /** defines the manager's name */
  11908. name: string;
  11909. /** Gets the list of sprites */
  11910. sprites: Sprite[];
  11911. /** Gets or sets the rendering group id (0 by default) */
  11912. renderingGroupId: number;
  11913. /** Gets or sets camera layer mask */
  11914. layerMask: number;
  11915. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11916. fogEnabled: boolean;
  11917. /** Gets or sets a boolean indicating if the sprites are pickable */
  11918. isPickable: boolean;
  11919. /** Defines the default width of a cell in the spritesheet */
  11920. cellWidth: number;
  11921. /** Defines the default height of a cell in the spritesheet */
  11922. cellHeight: number;
  11923. /**
  11924. * An event triggered when the manager is disposed.
  11925. */
  11926. onDisposeObservable: Observable<SpriteManager>;
  11927. private _onDisposeObserver;
  11928. /**
  11929. * Callback called when the manager is disposed
  11930. */
  11931. onDispose: () => void;
  11932. private _capacity;
  11933. private _spriteTexture;
  11934. private _epsilon;
  11935. private _scene;
  11936. private _vertexData;
  11937. private _buffer;
  11938. private _vertexBuffers;
  11939. private _indexBuffer;
  11940. private _effectBase;
  11941. private _effectFog;
  11942. /**
  11943. * Gets or sets the spritesheet texture
  11944. */
  11945. texture: Texture;
  11946. /**
  11947. * Creates a new sprite manager
  11948. * @param name defines the manager's name
  11949. * @param imgUrl defines the sprite sheet url
  11950. * @param capacity defines the maximum allowed number of sprites
  11951. * @param cellSize defines the size of a sprite cell
  11952. * @param scene defines the hosting scene
  11953. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11954. * @param samplingMode defines the smapling mode to use with spritesheet
  11955. */
  11956. constructor(
  11957. /** defines the manager's name */
  11958. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11959. private _appendSpriteVertex;
  11960. /**
  11961. * Intersects the sprites with a ray
  11962. * @param ray defines the ray to intersect with
  11963. * @param camera defines the current active camera
  11964. * @param predicate defines a predicate used to select candidate sprites
  11965. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11966. * @returns null if no hit or a PickingInfo
  11967. */
  11968. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11969. /**
  11970. * Render all child sprites
  11971. */
  11972. render(): void;
  11973. /**
  11974. * Release associated resources
  11975. */
  11976. dispose(): void;
  11977. }
  11978. }
  11979. declare module BABYLON {
  11980. /**
  11981. * Class used to represent a sprite
  11982. * @see http://doc.babylonjs.com/babylon101/sprites
  11983. */
  11984. export class Sprite {
  11985. /** defines the name */
  11986. name: string;
  11987. /** Gets or sets the current world position */
  11988. position: Vector3;
  11989. /** Gets or sets the main color */
  11990. color: Color4;
  11991. /** Gets or sets the width */
  11992. width: number;
  11993. /** Gets or sets the height */
  11994. height: number;
  11995. /** Gets or sets rotation angle */
  11996. angle: number;
  11997. /** Gets or sets the cell index in the sprite sheet */
  11998. cellIndex: number;
  11999. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12000. invertU: number;
  12001. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12002. invertV: number;
  12003. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12004. disposeWhenFinishedAnimating: boolean;
  12005. /** Gets the list of attached animations */
  12006. animations: Animation[];
  12007. /** Gets or sets a boolean indicating if the sprite can be picked */
  12008. isPickable: boolean;
  12009. /**
  12010. * Gets or sets the associated action manager
  12011. */
  12012. actionManager: Nullable<ActionManager>;
  12013. private _animationStarted;
  12014. private _loopAnimation;
  12015. private _fromIndex;
  12016. private _toIndex;
  12017. private _delay;
  12018. private _direction;
  12019. private _manager;
  12020. private _time;
  12021. private _onAnimationEnd;
  12022. /**
  12023. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12024. */
  12025. isVisible: boolean;
  12026. /**
  12027. * Gets or sets the sprite size
  12028. */
  12029. size: number;
  12030. /**
  12031. * Creates a new Sprite
  12032. * @param name defines the name
  12033. * @param manager defines the manager
  12034. */
  12035. constructor(
  12036. /** defines the name */
  12037. name: string, manager: ISpriteManager);
  12038. /**
  12039. * Starts an animation
  12040. * @param from defines the initial key
  12041. * @param to defines the end key
  12042. * @param loop defines if the animation must loop
  12043. * @param delay defines the start delay (in ms)
  12044. * @param onAnimationEnd defines a callback to call when animation ends
  12045. */
  12046. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12047. /** Stops current animation (if any) */
  12048. stopAnimation(): void;
  12049. /** @hidden */
  12050. _animate(deltaTime: number): void;
  12051. /** Release associated resources */
  12052. dispose(): void;
  12053. }
  12054. }
  12055. declare module BABYLON {
  12056. /**
  12057. * Information about the result of picking within a scene
  12058. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12059. */
  12060. export class PickingInfo {
  12061. /** @hidden */
  12062. _pickingUnavailable: boolean;
  12063. /**
  12064. * If the pick collided with an object
  12065. */
  12066. hit: boolean;
  12067. /**
  12068. * Distance away where the pick collided
  12069. */
  12070. distance: number;
  12071. /**
  12072. * The location of pick collision
  12073. */
  12074. pickedPoint: Nullable<Vector3>;
  12075. /**
  12076. * The mesh corresponding the the pick collision
  12077. */
  12078. pickedMesh: Nullable<AbstractMesh>;
  12079. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12080. bu: number;
  12081. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12082. bv: number;
  12083. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12084. faceId: number;
  12085. /** Id of the the submesh that was picked */
  12086. subMeshId: number;
  12087. /** If a sprite was picked, this will be the sprite the pick collided with */
  12088. pickedSprite: Nullable<Sprite>;
  12089. /**
  12090. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12091. */
  12092. originMesh: Nullable<AbstractMesh>;
  12093. /**
  12094. * The ray that was used to perform the picking.
  12095. */
  12096. ray: Nullable<Ray>;
  12097. /**
  12098. * Gets the normal correspodning to the face the pick collided with
  12099. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12100. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12101. * @returns The normal correspodning to the face the pick collided with
  12102. */
  12103. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12104. /**
  12105. * Gets the texture coordinates of where the pick occured
  12106. * @returns the vector containing the coordnates of the texture
  12107. */
  12108. getTextureCoordinates(): Nullable<Vector2>;
  12109. }
  12110. }
  12111. declare module BABYLON {
  12112. /**
  12113. * Gather the list of pointer event types as constants.
  12114. */
  12115. export class PointerEventTypes {
  12116. /**
  12117. * 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.
  12118. */
  12119. static readonly POINTERDOWN: number;
  12120. /**
  12121. * The pointerup event is fired when a pointer is no longer active.
  12122. */
  12123. static readonly POINTERUP: number;
  12124. /**
  12125. * The pointermove event is fired when a pointer changes coordinates.
  12126. */
  12127. static readonly POINTERMOVE: number;
  12128. /**
  12129. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12130. */
  12131. static readonly POINTERWHEEL: number;
  12132. /**
  12133. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12134. */
  12135. static readonly POINTERPICK: number;
  12136. /**
  12137. * The pointertap event is fired when a the object has been touched and released without drag.
  12138. */
  12139. static readonly POINTERTAP: number;
  12140. /**
  12141. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12142. */
  12143. static readonly POINTERDOUBLETAP: number;
  12144. }
  12145. /**
  12146. * Base class of pointer info types.
  12147. */
  12148. export class PointerInfoBase {
  12149. /**
  12150. * Defines the type of event (PointerEventTypes)
  12151. */
  12152. type: number;
  12153. /**
  12154. * Defines the related dom event
  12155. */
  12156. event: PointerEvent | MouseWheelEvent;
  12157. /**
  12158. * Instantiates the base class of pointers info.
  12159. * @param type Defines the type of event (PointerEventTypes)
  12160. * @param event Defines the related dom event
  12161. */
  12162. constructor(
  12163. /**
  12164. * Defines the type of event (PointerEventTypes)
  12165. */
  12166. type: number,
  12167. /**
  12168. * Defines the related dom event
  12169. */
  12170. event: PointerEvent | MouseWheelEvent);
  12171. }
  12172. /**
  12173. * This class is used to store pointer related info for the onPrePointerObservable event.
  12174. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12175. */
  12176. export class PointerInfoPre extends PointerInfoBase {
  12177. /**
  12178. * Ray from a pointer if availible (eg. 6dof controller)
  12179. */
  12180. ray: Nullable<Ray>;
  12181. /**
  12182. * Defines the local position of the pointer on the canvas.
  12183. */
  12184. localPosition: Vector2;
  12185. /**
  12186. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12187. */
  12188. skipOnPointerObservable: boolean;
  12189. /**
  12190. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12191. * @param type Defines the type of event (PointerEventTypes)
  12192. * @param event Defines the related dom event
  12193. * @param localX Defines the local x coordinates of the pointer when the event occured
  12194. * @param localY Defines the local y coordinates of the pointer when the event occured
  12195. */
  12196. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12197. }
  12198. /**
  12199. * This type contains all the data related to a pointer event in Babylon.js.
  12200. * 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.
  12201. */
  12202. export class PointerInfo extends PointerInfoBase {
  12203. /**
  12204. * Defines the picking info associated to the info (if any)\
  12205. */
  12206. pickInfo: Nullable<PickingInfo>;
  12207. /**
  12208. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12209. * @param type Defines the type of event (PointerEventTypes)
  12210. * @param event Defines the related dom event
  12211. * @param pickInfo Defines the picking info associated to the info (if any)\
  12212. */
  12213. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12214. /**
  12215. * Defines the picking info associated to the info (if any)\
  12216. */
  12217. pickInfo: Nullable<PickingInfo>);
  12218. }
  12219. /**
  12220. * Data relating to a touch event on the screen.
  12221. */
  12222. export interface PointerTouch {
  12223. /**
  12224. * X coordinate of touch.
  12225. */
  12226. x: number;
  12227. /**
  12228. * Y coordinate of touch.
  12229. */
  12230. y: number;
  12231. /**
  12232. * Id of touch. Unique for each finger.
  12233. */
  12234. pointerId: number;
  12235. /**
  12236. * Event type passed from DOM.
  12237. */
  12238. type: any;
  12239. }
  12240. }
  12241. declare module BABYLON {
  12242. /**
  12243. * Manage the mouse inputs to control the movement of a free camera.
  12244. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12245. */
  12246. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12247. /**
  12248. * Define if touch is enabled in the mouse input
  12249. */
  12250. touchEnabled: boolean;
  12251. /**
  12252. * Defines the camera the input is attached to.
  12253. */
  12254. camera: FreeCamera;
  12255. /**
  12256. * Defines the buttons associated with the input to handle camera move.
  12257. */
  12258. buttons: number[];
  12259. /**
  12260. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12261. */
  12262. angularSensibility: number;
  12263. private _pointerInput;
  12264. private _onMouseMove;
  12265. private _observer;
  12266. private previousPosition;
  12267. /**
  12268. * Observable for when a pointer move event occurs containing the move offset
  12269. */
  12270. onPointerMovedObservable: Observable<{
  12271. offsetX: number;
  12272. offsetY: number;
  12273. }>;
  12274. /**
  12275. * @hidden
  12276. * If the camera should be rotated automatically based on pointer movement
  12277. */
  12278. _allowCameraRotation: boolean;
  12279. /**
  12280. * Manage the mouse inputs to control the movement of a free camera.
  12281. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12282. * @param touchEnabled Defines if touch is enabled or not
  12283. */
  12284. constructor(
  12285. /**
  12286. * Define if touch is enabled in the mouse input
  12287. */
  12288. touchEnabled?: boolean);
  12289. /**
  12290. * Attach the input controls to a specific dom element to get the input from.
  12291. * @param element Defines the element the controls should be listened from
  12292. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12293. */
  12294. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12295. /**
  12296. * Called on JS contextmenu event.
  12297. * Override this method to provide functionality.
  12298. */
  12299. protected onContextMenu(evt: PointerEvent): void;
  12300. /**
  12301. * Detach the current controls from the specified dom element.
  12302. * @param element Defines the element to stop listening the inputs from
  12303. */
  12304. detachControl(element: Nullable<HTMLElement>): void;
  12305. /**
  12306. * Gets the class name of the current intput.
  12307. * @returns the class name
  12308. */
  12309. getClassName(): string;
  12310. /**
  12311. * Get the friendly name associated with the input class.
  12312. * @returns the input friendly name
  12313. */
  12314. getSimpleName(): string;
  12315. }
  12316. }
  12317. declare module BABYLON {
  12318. /**
  12319. * Manage the touch inputs to control the movement of a free camera.
  12320. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12321. */
  12322. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12323. /**
  12324. * Defines the camera the input is attached to.
  12325. */
  12326. camera: FreeCamera;
  12327. /**
  12328. * Defines the touch sensibility for rotation.
  12329. * The higher the faster.
  12330. */
  12331. touchAngularSensibility: number;
  12332. /**
  12333. * Defines the touch sensibility for move.
  12334. * The higher the faster.
  12335. */
  12336. touchMoveSensibility: number;
  12337. private _offsetX;
  12338. private _offsetY;
  12339. private _pointerPressed;
  12340. private _pointerInput;
  12341. private _observer;
  12342. private _onLostFocus;
  12343. /**
  12344. * Attach the input controls to a specific dom element to get the input from.
  12345. * @param element Defines the element the controls should be listened from
  12346. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12347. */
  12348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12349. /**
  12350. * Detach the current controls from the specified dom element.
  12351. * @param element Defines the element to stop listening the inputs from
  12352. */
  12353. detachControl(element: Nullable<HTMLElement>): void;
  12354. /**
  12355. * Update the current camera state depending on the inputs that have been used this frame.
  12356. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12357. */
  12358. checkInputs(): void;
  12359. /**
  12360. * Gets the class name of the current intput.
  12361. * @returns the class name
  12362. */
  12363. getClassName(): string;
  12364. /**
  12365. * Get the friendly name associated with the input class.
  12366. * @returns the input friendly name
  12367. */
  12368. getSimpleName(): string;
  12369. }
  12370. }
  12371. declare module BABYLON {
  12372. /**
  12373. * Default Inputs manager for the FreeCamera.
  12374. * It groups all the default supported inputs for ease of use.
  12375. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12376. */
  12377. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12378. /**
  12379. * @hidden
  12380. */
  12381. _mouseInput: Nullable<FreeCameraMouseInput>;
  12382. /**
  12383. * Instantiates a new FreeCameraInputsManager.
  12384. * @param camera Defines the camera the inputs belong to
  12385. */
  12386. constructor(camera: FreeCamera);
  12387. /**
  12388. * Add keyboard input support to the input manager.
  12389. * @returns the current input manager
  12390. */
  12391. addKeyboard(): FreeCameraInputsManager;
  12392. /**
  12393. * Add mouse input support to the input manager.
  12394. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12395. * @returns the current input manager
  12396. */
  12397. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12398. /**
  12399. * Removes the mouse input support from the manager
  12400. * @returns the current input manager
  12401. */
  12402. removeMouse(): FreeCameraInputsManager;
  12403. /**
  12404. * Add touch input support to the input manager.
  12405. * @returns the current input manager
  12406. */
  12407. addTouch(): FreeCameraInputsManager;
  12408. /**
  12409. * Remove all attached input methods from a camera
  12410. */
  12411. clear(): void;
  12412. }
  12413. }
  12414. declare module BABYLON {
  12415. /**
  12416. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12417. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12418. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12419. */
  12420. export class FreeCamera extends TargetCamera {
  12421. /**
  12422. * Define the collision ellipsoid of the camera.
  12423. * This is helpful to simulate a camera body like the player body around the camera
  12424. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12425. */
  12426. ellipsoid: Vector3;
  12427. /**
  12428. * Define an offset for the position of the ellipsoid around the camera.
  12429. * This can be helpful to determine the center of the body near the gravity center of the body
  12430. * instead of its head.
  12431. */
  12432. ellipsoidOffset: Vector3;
  12433. /**
  12434. * Enable or disable collisions of the camera with the rest of the scene objects.
  12435. */
  12436. checkCollisions: boolean;
  12437. /**
  12438. * Enable or disable gravity on the camera.
  12439. */
  12440. applyGravity: boolean;
  12441. /**
  12442. * Define the input manager associated to the camera.
  12443. */
  12444. inputs: FreeCameraInputsManager;
  12445. /**
  12446. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12447. * Higher values reduce sensitivity.
  12448. */
  12449. /**
  12450. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12451. * Higher values reduce sensitivity.
  12452. */
  12453. angularSensibility: number;
  12454. /**
  12455. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12456. */
  12457. keysUp: number[];
  12458. /**
  12459. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12460. */
  12461. keysDown: number[];
  12462. /**
  12463. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12464. */
  12465. keysLeft: number[];
  12466. /**
  12467. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12468. */
  12469. keysRight: number[];
  12470. /**
  12471. * Event raised when the camera collide with a mesh in the scene.
  12472. */
  12473. onCollide: (collidedMesh: AbstractMesh) => void;
  12474. private _collider;
  12475. private _needMoveForGravity;
  12476. private _oldPosition;
  12477. private _diffPosition;
  12478. private _newPosition;
  12479. /** @hidden */
  12480. _localDirection: Vector3;
  12481. /** @hidden */
  12482. _transformedDirection: Vector3;
  12483. /**
  12484. * Instantiates a Free Camera.
  12485. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12486. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12487. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12488. * @param name Define the name of the camera in the scene
  12489. * @param position Define the start position of the camera in the scene
  12490. * @param scene Define the scene the camera belongs to
  12491. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12492. */
  12493. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12494. /**
  12495. * Attached controls to the current camera.
  12496. * @param element Defines the element the controls should be listened from
  12497. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12498. */
  12499. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12500. /**
  12501. * Detach the current controls from the camera.
  12502. * The camera will stop reacting to inputs.
  12503. * @param element Defines the element to stop listening the inputs from
  12504. */
  12505. detachControl(element: HTMLElement): void;
  12506. private _collisionMask;
  12507. /**
  12508. * Define a collision mask to limit the list of object the camera can collide with
  12509. */
  12510. collisionMask: number;
  12511. /** @hidden */
  12512. _collideWithWorld(displacement: Vector3): void;
  12513. private _onCollisionPositionChange;
  12514. /** @hidden */
  12515. _checkInputs(): void;
  12516. /** @hidden */
  12517. _decideIfNeedsToMove(): boolean;
  12518. /** @hidden */
  12519. _updatePosition(): void;
  12520. /**
  12521. * Destroy the camera and release the current resources hold by it.
  12522. */
  12523. dispose(): void;
  12524. /**
  12525. * Gets the current object class name.
  12526. * @return the class name
  12527. */
  12528. getClassName(): string;
  12529. }
  12530. }
  12531. declare module BABYLON {
  12532. /**
  12533. * Represents a gamepad control stick position
  12534. */
  12535. export class StickValues {
  12536. /**
  12537. * The x component of the control stick
  12538. */
  12539. x: number;
  12540. /**
  12541. * The y component of the control stick
  12542. */
  12543. y: number;
  12544. /**
  12545. * Initializes the gamepad x and y control stick values
  12546. * @param x The x component of the gamepad control stick value
  12547. * @param y The y component of the gamepad control stick value
  12548. */
  12549. constructor(
  12550. /**
  12551. * The x component of the control stick
  12552. */
  12553. x: number,
  12554. /**
  12555. * The y component of the control stick
  12556. */
  12557. y: number);
  12558. }
  12559. /**
  12560. * An interface which manages callbacks for gamepad button changes
  12561. */
  12562. export interface GamepadButtonChanges {
  12563. /**
  12564. * Called when a gamepad has been changed
  12565. */
  12566. changed: boolean;
  12567. /**
  12568. * Called when a gamepad press event has been triggered
  12569. */
  12570. pressChanged: boolean;
  12571. /**
  12572. * Called when a touch event has been triggered
  12573. */
  12574. touchChanged: boolean;
  12575. /**
  12576. * Called when a value has changed
  12577. */
  12578. valueChanged: boolean;
  12579. }
  12580. /**
  12581. * Represents a gamepad
  12582. */
  12583. export class Gamepad {
  12584. /**
  12585. * The id of the gamepad
  12586. */
  12587. id: string;
  12588. /**
  12589. * The index of the gamepad
  12590. */
  12591. index: number;
  12592. /**
  12593. * The browser gamepad
  12594. */
  12595. browserGamepad: any;
  12596. /**
  12597. * Specifies what type of gamepad this represents
  12598. */
  12599. type: number;
  12600. private _leftStick;
  12601. private _rightStick;
  12602. /** @hidden */
  12603. _isConnected: boolean;
  12604. private _leftStickAxisX;
  12605. private _leftStickAxisY;
  12606. private _rightStickAxisX;
  12607. private _rightStickAxisY;
  12608. /**
  12609. * Triggered when the left control stick has been changed
  12610. */
  12611. private _onleftstickchanged;
  12612. /**
  12613. * Triggered when the right control stick has been changed
  12614. */
  12615. private _onrightstickchanged;
  12616. /**
  12617. * Represents a gamepad controller
  12618. */
  12619. static GAMEPAD: number;
  12620. /**
  12621. * Represents a generic controller
  12622. */
  12623. static GENERIC: number;
  12624. /**
  12625. * Represents an XBox controller
  12626. */
  12627. static XBOX: number;
  12628. /**
  12629. * Represents a pose-enabled controller
  12630. */
  12631. static POSE_ENABLED: number;
  12632. /**
  12633. * Specifies whether the left control stick should be Y-inverted
  12634. */
  12635. protected _invertLeftStickY: boolean;
  12636. /**
  12637. * Specifies if the gamepad has been connected
  12638. */
  12639. readonly isConnected: boolean;
  12640. /**
  12641. * Initializes the gamepad
  12642. * @param id The id of the gamepad
  12643. * @param index The index of the gamepad
  12644. * @param browserGamepad The browser gamepad
  12645. * @param leftStickX The x component of the left joystick
  12646. * @param leftStickY The y component of the left joystick
  12647. * @param rightStickX The x component of the right joystick
  12648. * @param rightStickY The y component of the right joystick
  12649. */
  12650. constructor(
  12651. /**
  12652. * The id of the gamepad
  12653. */
  12654. id: string,
  12655. /**
  12656. * The index of the gamepad
  12657. */
  12658. index: number,
  12659. /**
  12660. * The browser gamepad
  12661. */
  12662. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12663. /**
  12664. * Callback triggered when the left joystick has changed
  12665. * @param callback
  12666. */
  12667. onleftstickchanged(callback: (values: StickValues) => void): void;
  12668. /**
  12669. * Callback triggered when the right joystick has changed
  12670. * @param callback
  12671. */
  12672. onrightstickchanged(callback: (values: StickValues) => void): void;
  12673. /**
  12674. * Gets the left joystick
  12675. */
  12676. /**
  12677. * Sets the left joystick values
  12678. */
  12679. leftStick: StickValues;
  12680. /**
  12681. * Gets the right joystick
  12682. */
  12683. /**
  12684. * Sets the right joystick value
  12685. */
  12686. rightStick: StickValues;
  12687. /**
  12688. * Updates the gamepad joystick positions
  12689. */
  12690. update(): void;
  12691. /**
  12692. * Disposes the gamepad
  12693. */
  12694. dispose(): void;
  12695. }
  12696. /**
  12697. * Represents a generic gamepad
  12698. */
  12699. export class GenericPad extends Gamepad {
  12700. private _buttons;
  12701. private _onbuttondown;
  12702. private _onbuttonup;
  12703. /**
  12704. * Observable triggered when a button has been pressed
  12705. */
  12706. onButtonDownObservable: Observable<number>;
  12707. /**
  12708. * Observable triggered when a button has been released
  12709. */
  12710. onButtonUpObservable: Observable<number>;
  12711. /**
  12712. * Callback triggered when a button has been pressed
  12713. * @param callback Called when a button has been pressed
  12714. */
  12715. onbuttondown(callback: (buttonPressed: number) => void): void;
  12716. /**
  12717. * Callback triggered when a button has been released
  12718. * @param callback Called when a button has been released
  12719. */
  12720. onbuttonup(callback: (buttonReleased: number) => void): void;
  12721. /**
  12722. * Initializes the generic gamepad
  12723. * @param id The id of the generic gamepad
  12724. * @param index The index of the generic gamepad
  12725. * @param browserGamepad The browser gamepad
  12726. */
  12727. constructor(id: string, index: number, browserGamepad: any);
  12728. private _setButtonValue;
  12729. /**
  12730. * Updates the generic gamepad
  12731. */
  12732. update(): void;
  12733. /**
  12734. * Disposes the generic gamepad
  12735. */
  12736. dispose(): void;
  12737. }
  12738. }
  12739. declare module BABYLON {
  12740. /**
  12741. * Defines the types of pose enabled controllers that are supported
  12742. */
  12743. export enum PoseEnabledControllerType {
  12744. /**
  12745. * HTC Vive
  12746. */
  12747. VIVE = 0,
  12748. /**
  12749. * Oculus Rift
  12750. */
  12751. OCULUS = 1,
  12752. /**
  12753. * Windows mixed reality
  12754. */
  12755. WINDOWS = 2,
  12756. /**
  12757. * Samsung gear VR
  12758. */
  12759. GEAR_VR = 3,
  12760. /**
  12761. * Google Daydream
  12762. */
  12763. DAYDREAM = 4,
  12764. /**
  12765. * Generic
  12766. */
  12767. GENERIC = 5
  12768. }
  12769. /**
  12770. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12771. */
  12772. export interface MutableGamepadButton {
  12773. /**
  12774. * Value of the button/trigger
  12775. */
  12776. value: number;
  12777. /**
  12778. * If the button/trigger is currently touched
  12779. */
  12780. touched: boolean;
  12781. /**
  12782. * If the button/trigger is currently pressed
  12783. */
  12784. pressed: boolean;
  12785. }
  12786. /**
  12787. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12788. * @hidden
  12789. */
  12790. export interface ExtendedGamepadButton extends GamepadButton {
  12791. /**
  12792. * If the button/trigger is currently pressed
  12793. */
  12794. readonly pressed: boolean;
  12795. /**
  12796. * If the button/trigger is currently touched
  12797. */
  12798. readonly touched: boolean;
  12799. /**
  12800. * Value of the button/trigger
  12801. */
  12802. readonly value: number;
  12803. }
  12804. /** @hidden */
  12805. export interface _GamePadFactory {
  12806. /**
  12807. * Returns wether or not the current gamepad can be created for this type of controller.
  12808. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12809. * @returns true if it can be created, otherwise false
  12810. */
  12811. canCreate(gamepadInfo: any): boolean;
  12812. /**
  12813. * Creates a new instance of the Gamepad.
  12814. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12815. * @returns the new gamepad instance
  12816. */
  12817. create(gamepadInfo: any): Gamepad;
  12818. }
  12819. /**
  12820. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12821. */
  12822. export class PoseEnabledControllerHelper {
  12823. /** @hidden */
  12824. static _ControllerFactories: _GamePadFactory[];
  12825. /** @hidden */
  12826. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12827. /**
  12828. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12829. * @param vrGamepad the gamepad to initialized
  12830. * @returns a vr controller of the type the gamepad identified as
  12831. */
  12832. static InitiateController(vrGamepad: any): Gamepad;
  12833. }
  12834. /**
  12835. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12836. */
  12837. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12838. private _deviceRoomPosition;
  12839. private _deviceRoomRotationQuaternion;
  12840. /**
  12841. * The device position in babylon space
  12842. */
  12843. devicePosition: Vector3;
  12844. /**
  12845. * The device rotation in babylon space
  12846. */
  12847. deviceRotationQuaternion: Quaternion;
  12848. /**
  12849. * The scale factor of the device in babylon space
  12850. */
  12851. deviceScaleFactor: number;
  12852. /**
  12853. * (Likely devicePosition should be used instead) The device position in its room space
  12854. */
  12855. position: Vector3;
  12856. /**
  12857. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12858. */
  12859. rotationQuaternion: Quaternion;
  12860. /**
  12861. * The type of controller (Eg. Windows mixed reality)
  12862. */
  12863. controllerType: PoseEnabledControllerType;
  12864. protected _calculatedPosition: Vector3;
  12865. private _calculatedRotation;
  12866. /**
  12867. * The raw pose from the device
  12868. */
  12869. rawPose: DevicePose;
  12870. private _trackPosition;
  12871. private _maxRotationDistFromHeadset;
  12872. private _draggedRoomRotation;
  12873. /**
  12874. * @hidden
  12875. */
  12876. _disableTrackPosition(fixedPosition: Vector3): void;
  12877. /**
  12878. * Internal, the mesh attached to the controller
  12879. * @hidden
  12880. */
  12881. _mesh: Nullable<AbstractMesh>;
  12882. private _poseControlledCamera;
  12883. private _leftHandSystemQuaternion;
  12884. /**
  12885. * Internal, matrix used to convert room space to babylon space
  12886. * @hidden
  12887. */
  12888. _deviceToWorld: Matrix;
  12889. /**
  12890. * Node to be used when casting a ray from the controller
  12891. * @hidden
  12892. */
  12893. _pointingPoseNode: Nullable<TransformNode>;
  12894. /**
  12895. * Name of the child mesh that can be used to cast a ray from the controller
  12896. */
  12897. static readonly POINTING_POSE: string;
  12898. /**
  12899. * Creates a new PoseEnabledController from a gamepad
  12900. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12901. */
  12902. constructor(browserGamepad: any);
  12903. private _workingMatrix;
  12904. /**
  12905. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12906. */
  12907. update(): void;
  12908. /**
  12909. * Updates only the pose device and mesh without doing any button event checking
  12910. */
  12911. protected _updatePoseAndMesh(): void;
  12912. /**
  12913. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12914. * @param poseData raw pose fromthe device
  12915. */
  12916. updateFromDevice(poseData: DevicePose): void;
  12917. /**
  12918. * @hidden
  12919. */
  12920. _meshAttachedObservable: Observable<AbstractMesh>;
  12921. /**
  12922. * Attaches a mesh to the controller
  12923. * @param mesh the mesh to be attached
  12924. */
  12925. attachToMesh(mesh: AbstractMesh): void;
  12926. /**
  12927. * Attaches the controllers mesh to a camera
  12928. * @param camera the camera the mesh should be attached to
  12929. */
  12930. attachToPoseControlledCamera(camera: TargetCamera): void;
  12931. /**
  12932. * Disposes of the controller
  12933. */
  12934. dispose(): void;
  12935. /**
  12936. * The mesh that is attached to the controller
  12937. */
  12938. readonly mesh: Nullable<AbstractMesh>;
  12939. /**
  12940. * Gets the ray of the controller in the direction the controller is pointing
  12941. * @param length the length the resulting ray should be
  12942. * @returns a ray in the direction the controller is pointing
  12943. */
  12944. getForwardRay(length?: number): Ray;
  12945. }
  12946. }
  12947. declare module BABYLON {
  12948. /**
  12949. * Defines the WebVRController object that represents controllers tracked in 3D space
  12950. */
  12951. export abstract class WebVRController extends PoseEnabledController {
  12952. /**
  12953. * Internal, the default controller model for the controller
  12954. */
  12955. protected _defaultModel: AbstractMesh;
  12956. /**
  12957. * Fired when the trigger state has changed
  12958. */
  12959. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12960. /**
  12961. * Fired when the main button state has changed
  12962. */
  12963. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12964. /**
  12965. * Fired when the secondary button state has changed
  12966. */
  12967. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12968. /**
  12969. * Fired when the pad state has changed
  12970. */
  12971. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12972. /**
  12973. * Fired when controllers stick values have changed
  12974. */
  12975. onPadValuesChangedObservable: Observable<StickValues>;
  12976. /**
  12977. * Array of button availible on the controller
  12978. */
  12979. protected _buttons: Array<MutableGamepadButton>;
  12980. private _onButtonStateChange;
  12981. /**
  12982. * Fired when a controller button's state has changed
  12983. * @param callback the callback containing the button that was modified
  12984. */
  12985. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12986. /**
  12987. * X and Y axis corrisponding to the controllers joystick
  12988. */
  12989. pad: StickValues;
  12990. /**
  12991. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12992. */
  12993. hand: string;
  12994. /**
  12995. * The default controller model for the controller
  12996. */
  12997. readonly defaultModel: AbstractMesh;
  12998. /**
  12999. * Creates a new WebVRController from a gamepad
  13000. * @param vrGamepad the gamepad that the WebVRController should be created from
  13001. */
  13002. constructor(vrGamepad: any);
  13003. /**
  13004. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13005. */
  13006. update(): void;
  13007. /**
  13008. * Function to be called when a button is modified
  13009. */
  13010. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13011. /**
  13012. * Loads a mesh and attaches it to the controller
  13013. * @param scene the scene the mesh should be added to
  13014. * @param meshLoaded callback for when the mesh has been loaded
  13015. */
  13016. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13017. private _setButtonValue;
  13018. private _changes;
  13019. private _checkChanges;
  13020. /**
  13021. * Disposes of th webVRCOntroller
  13022. */
  13023. dispose(): void;
  13024. }
  13025. }
  13026. declare module BABYLON {
  13027. /**
  13028. * The HemisphericLight simulates the ambient environment light,
  13029. * so the passed direction is the light reflection direction, not the incoming direction.
  13030. */
  13031. export class HemisphericLight extends Light {
  13032. /**
  13033. * The groundColor is the light in the opposite direction to the one specified during creation.
  13034. * 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.
  13035. */
  13036. groundColor: Color3;
  13037. /**
  13038. * The light reflection direction, not the incoming direction.
  13039. */
  13040. direction: Vector3;
  13041. /**
  13042. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13043. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13044. * The HemisphericLight can't cast shadows.
  13045. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13046. * @param name The friendly name of the light
  13047. * @param direction The direction of the light reflection
  13048. * @param scene The scene the light belongs to
  13049. */
  13050. constructor(name: string, direction: Vector3, scene: Scene);
  13051. protected _buildUniformLayout(): void;
  13052. /**
  13053. * Returns the string "HemisphericLight".
  13054. * @return The class name
  13055. */
  13056. getClassName(): string;
  13057. /**
  13058. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13059. * Returns the updated direction.
  13060. * @param target The target the direction should point to
  13061. * @return The computed direction
  13062. */
  13063. setDirectionToTarget(target: Vector3): Vector3;
  13064. /**
  13065. * Returns the shadow generator associated to the light.
  13066. * @returns Always null for hemispheric lights because it does not support shadows.
  13067. */
  13068. getShadowGenerator(): Nullable<IShadowGenerator>;
  13069. /**
  13070. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13071. * @param effect The effect to update
  13072. * @param lightIndex The index of the light in the effect to update
  13073. * @returns The hemispheric light
  13074. */
  13075. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13076. /**
  13077. * Computes the world matrix of the node
  13078. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13079. * @param useWasUpdatedFlag defines a reserved property
  13080. * @returns the world matrix
  13081. */
  13082. computeWorldMatrix(): Matrix;
  13083. /**
  13084. * Returns the integer 3.
  13085. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13086. */
  13087. getTypeID(): number;
  13088. /**
  13089. * Prepares the list of defines specific to the light type.
  13090. * @param defines the list of defines
  13091. * @param lightIndex defines the index of the light for the effect
  13092. */
  13093. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13094. }
  13095. }
  13096. declare module BABYLON {
  13097. /** @hidden */
  13098. export var vrMultiviewToSingleviewPixelShader: {
  13099. name: string;
  13100. shader: string;
  13101. };
  13102. }
  13103. declare module BABYLON {
  13104. /**
  13105. * Renders to multiple views with a single draw call
  13106. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13107. */
  13108. export class MultiviewRenderTarget extends RenderTargetTexture {
  13109. /**
  13110. * Creates a multiview render target
  13111. * @param scene scene used with the render target
  13112. * @param size the size of the render target (used for each view)
  13113. */
  13114. constructor(scene: Scene, size?: number | {
  13115. width: number;
  13116. height: number;
  13117. } | {
  13118. ratio: number;
  13119. });
  13120. /**
  13121. * @hidden
  13122. * @param faceIndex the face index, if its a cube texture
  13123. */
  13124. _bindFrameBuffer(faceIndex?: number): void;
  13125. /**
  13126. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13127. * @returns the view count
  13128. */
  13129. getViewCount(): number;
  13130. }
  13131. }
  13132. declare module BABYLON {
  13133. interface Engine {
  13134. /**
  13135. * Creates a new multiview render target
  13136. * @param width defines the width of the texture
  13137. * @param height defines the height of the texture
  13138. * @returns the created multiview texture
  13139. */
  13140. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13141. /**
  13142. * Binds a multiview framebuffer to be drawn to
  13143. * @param multiviewTexture texture to bind
  13144. */
  13145. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13146. }
  13147. interface Camera {
  13148. /**
  13149. * @hidden
  13150. * 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)
  13151. */
  13152. _useMultiviewToSingleView: boolean;
  13153. /**
  13154. * @hidden
  13155. * 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)
  13156. */
  13157. _multiviewTexture: Nullable<RenderTargetTexture>;
  13158. /**
  13159. * @hidden
  13160. * ensures the multiview texture of the camera exists and has the specified width/height
  13161. * @param width height to set on the multiview texture
  13162. * @param height width to set on the multiview texture
  13163. */
  13164. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13165. }
  13166. interface Scene {
  13167. /** @hidden */
  13168. _transformMatrixR: Matrix;
  13169. /** @hidden */
  13170. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13171. /** @hidden */
  13172. _createMultiviewUbo(): void;
  13173. /** @hidden */
  13174. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13175. /** @hidden */
  13176. _renderMultiviewToSingleView(camera: Camera): void;
  13177. }
  13178. }
  13179. declare module BABYLON {
  13180. /**
  13181. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13182. * This will not be used for webXR as it supports displaying texture arrays directly
  13183. */
  13184. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13185. /**
  13186. * Initializes a VRMultiviewToSingleview
  13187. * @param name name of the post process
  13188. * @param camera camera to be applied to
  13189. * @param scaleFactor scaling factor to the size of the output texture
  13190. */
  13191. constructor(name: string, camera: Camera, scaleFactor: number);
  13192. }
  13193. }
  13194. declare module BABYLON {
  13195. /**
  13196. * Defines the interface used by display changed events
  13197. */
  13198. interface IDisplayChangedEventArgs {
  13199. /** Gets the vrDisplay object (if any) */
  13200. vrDisplay: Nullable<any>;
  13201. /** Gets a boolean indicating if webVR is supported */
  13202. vrSupported: boolean;
  13203. }
  13204. interface Engine {
  13205. /** @hidden */
  13206. _vrDisplay: any;
  13207. /** @hidden */
  13208. _vrSupported: boolean;
  13209. /** @hidden */
  13210. _oldSize: Size;
  13211. /** @hidden */
  13212. _oldHardwareScaleFactor: number;
  13213. /** @hidden */
  13214. _vrExclusivePointerMode: boolean;
  13215. /** @hidden */
  13216. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13217. /** @hidden */
  13218. _onVRDisplayPointerRestricted: () => void;
  13219. /** @hidden */
  13220. _onVRDisplayPointerUnrestricted: () => void;
  13221. /** @hidden */
  13222. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13223. /** @hidden */
  13224. _onVrDisplayDisconnect: Nullable<() => void>;
  13225. /** @hidden */
  13226. _onVrDisplayPresentChange: Nullable<() => void>;
  13227. /**
  13228. * Observable signaled when VR display mode changes
  13229. */
  13230. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13231. /**
  13232. * Observable signaled when VR request present is complete
  13233. */
  13234. onVRRequestPresentComplete: Observable<boolean>;
  13235. /**
  13236. * Observable signaled when VR request present starts
  13237. */
  13238. onVRRequestPresentStart: Observable<Engine>;
  13239. /**
  13240. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13241. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13242. */
  13243. isInVRExclusivePointerMode: boolean;
  13244. /**
  13245. * Gets a boolean indicating if a webVR device was detected
  13246. * @returns true if a webVR device was detected
  13247. */
  13248. isVRDevicePresent(): boolean;
  13249. /**
  13250. * Gets the current webVR device
  13251. * @returns the current webVR device (or null)
  13252. */
  13253. getVRDevice(): any;
  13254. /**
  13255. * Initializes a webVR display and starts listening to display change events
  13256. * The onVRDisplayChangedObservable will be notified upon these changes
  13257. * @returns A promise containing a VRDisplay and if vr is supported
  13258. */
  13259. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13260. /** @hidden */
  13261. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13262. /**
  13263. * Call this function to switch to webVR mode
  13264. * Will do nothing if webVR is not supported or if there is no webVR device
  13265. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13266. */
  13267. enableVR(): void;
  13268. /** @hidden */
  13269. _onVRFullScreenTriggered(): void;
  13270. }
  13271. }
  13272. declare module BABYLON {
  13273. /**
  13274. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13275. * IMPORTANT!! The data is right-hand data.
  13276. * @export
  13277. * @interface DevicePose
  13278. */
  13279. export interface DevicePose {
  13280. /**
  13281. * The position of the device, values in array are [x,y,z].
  13282. */
  13283. readonly position: Nullable<Float32Array>;
  13284. /**
  13285. * The linearVelocity of the device, values in array are [x,y,z].
  13286. */
  13287. readonly linearVelocity: Nullable<Float32Array>;
  13288. /**
  13289. * The linearAcceleration of the device, values in array are [x,y,z].
  13290. */
  13291. readonly linearAcceleration: Nullable<Float32Array>;
  13292. /**
  13293. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13294. */
  13295. readonly orientation: Nullable<Float32Array>;
  13296. /**
  13297. * The angularVelocity of the device, values in array are [x,y,z].
  13298. */
  13299. readonly angularVelocity: Nullable<Float32Array>;
  13300. /**
  13301. * The angularAcceleration of the device, values in array are [x,y,z].
  13302. */
  13303. readonly angularAcceleration: Nullable<Float32Array>;
  13304. }
  13305. /**
  13306. * Interface representing a pose controlled object in Babylon.
  13307. * A pose controlled object has both regular pose values as well as pose values
  13308. * from an external device such as a VR head mounted display
  13309. */
  13310. export interface PoseControlled {
  13311. /**
  13312. * The position of the object in babylon space.
  13313. */
  13314. position: Vector3;
  13315. /**
  13316. * The rotation quaternion of the object in babylon space.
  13317. */
  13318. rotationQuaternion: Quaternion;
  13319. /**
  13320. * The position of the device in babylon space.
  13321. */
  13322. devicePosition?: Vector3;
  13323. /**
  13324. * The rotation quaternion of the device in babylon space.
  13325. */
  13326. deviceRotationQuaternion: Quaternion;
  13327. /**
  13328. * The raw pose coming from the device.
  13329. */
  13330. rawPose: Nullable<DevicePose>;
  13331. /**
  13332. * The scale of the device to be used when translating from device space to babylon space.
  13333. */
  13334. deviceScaleFactor: number;
  13335. /**
  13336. * Updates the poseControlled values based on the input device pose.
  13337. * @param poseData the pose data to update the object with
  13338. */
  13339. updateFromDevice(poseData: DevicePose): void;
  13340. }
  13341. /**
  13342. * Set of options to customize the webVRCamera
  13343. */
  13344. export interface WebVROptions {
  13345. /**
  13346. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13347. */
  13348. trackPosition?: boolean;
  13349. /**
  13350. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13351. */
  13352. positionScale?: number;
  13353. /**
  13354. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13355. */
  13356. displayName?: string;
  13357. /**
  13358. * Should the native controller meshes be initialized. (default: true)
  13359. */
  13360. controllerMeshes?: boolean;
  13361. /**
  13362. * Creating a default HemiLight only on controllers. (default: true)
  13363. */
  13364. defaultLightingOnControllers?: boolean;
  13365. /**
  13366. * If you don't want to use the default VR button of the helper. (default: false)
  13367. */
  13368. useCustomVRButton?: boolean;
  13369. /**
  13370. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13371. */
  13372. customVRButton?: HTMLButtonElement;
  13373. /**
  13374. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13375. */
  13376. rayLength?: number;
  13377. /**
  13378. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13379. */
  13380. defaultHeight?: number;
  13381. /**
  13382. * If multiview should be used if availible (default: false)
  13383. */
  13384. useMultiview?: boolean;
  13385. }
  13386. /**
  13387. * This represents a WebVR camera.
  13388. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13389. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13390. */
  13391. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13392. private webVROptions;
  13393. /**
  13394. * @hidden
  13395. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13396. */
  13397. _vrDevice: any;
  13398. /**
  13399. * The rawPose of the vrDevice.
  13400. */
  13401. rawPose: Nullable<DevicePose>;
  13402. private _onVREnabled;
  13403. private _specsVersion;
  13404. private _attached;
  13405. private _frameData;
  13406. protected _descendants: Array<Node>;
  13407. private _deviceRoomPosition;
  13408. /** @hidden */
  13409. _deviceRoomRotationQuaternion: Quaternion;
  13410. private _standingMatrix;
  13411. /**
  13412. * Represents device position in babylon space.
  13413. */
  13414. devicePosition: Vector3;
  13415. /**
  13416. * Represents device rotation in babylon space.
  13417. */
  13418. deviceRotationQuaternion: Quaternion;
  13419. /**
  13420. * The scale of the device to be used when translating from device space to babylon space.
  13421. */
  13422. deviceScaleFactor: number;
  13423. private _deviceToWorld;
  13424. private _worldToDevice;
  13425. /**
  13426. * References to the webVR controllers for the vrDevice.
  13427. */
  13428. controllers: Array<WebVRController>;
  13429. /**
  13430. * Emits an event when a controller is attached.
  13431. */
  13432. onControllersAttachedObservable: Observable<WebVRController[]>;
  13433. /**
  13434. * Emits an event when a controller's mesh has been loaded;
  13435. */
  13436. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13437. /**
  13438. * Emits an event when the HMD's pose has been updated.
  13439. */
  13440. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13441. private _poseSet;
  13442. /**
  13443. * If the rig cameras be used as parent instead of this camera.
  13444. */
  13445. rigParenting: boolean;
  13446. private _lightOnControllers;
  13447. private _defaultHeight?;
  13448. /**
  13449. * Instantiates a WebVRFreeCamera.
  13450. * @param name The name of the WebVRFreeCamera
  13451. * @param position The starting anchor position for the camera
  13452. * @param scene The scene the camera belongs to
  13453. * @param webVROptions a set of customizable options for the webVRCamera
  13454. */
  13455. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13456. /**
  13457. * Gets the device distance from the ground in meters.
  13458. * @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.
  13459. */
  13460. deviceDistanceToRoomGround(): number;
  13461. /**
  13462. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13463. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13464. */
  13465. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13466. /**
  13467. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13468. * @returns A promise with a boolean set to if the standing matrix is supported.
  13469. */
  13470. useStandingMatrixAsync(): Promise<boolean>;
  13471. /**
  13472. * Disposes the camera
  13473. */
  13474. dispose(): void;
  13475. /**
  13476. * Gets a vrController by name.
  13477. * @param name The name of the controller to retreive
  13478. * @returns the controller matching the name specified or null if not found
  13479. */
  13480. getControllerByName(name: string): Nullable<WebVRController>;
  13481. private _leftController;
  13482. /**
  13483. * The controller corrisponding to the users left hand.
  13484. */
  13485. readonly leftController: Nullable<WebVRController>;
  13486. private _rightController;
  13487. /**
  13488. * The controller corrisponding to the users right hand.
  13489. */
  13490. readonly rightController: Nullable<WebVRController>;
  13491. /**
  13492. * Casts a ray forward from the vrCamera's gaze.
  13493. * @param length Length of the ray (default: 100)
  13494. * @returns the ray corrisponding to the gaze
  13495. */
  13496. getForwardRay(length?: number): Ray;
  13497. /**
  13498. * @hidden
  13499. * Updates the camera based on device's frame data
  13500. */
  13501. _checkInputs(): void;
  13502. /**
  13503. * Updates the poseControlled values based on the input device pose.
  13504. * @param poseData Pose coming from the device
  13505. */
  13506. updateFromDevice(poseData: DevicePose): void;
  13507. private _htmlElementAttached;
  13508. private _detachIfAttached;
  13509. /**
  13510. * WebVR's attach control will start broadcasting frames to the device.
  13511. * Note that in certain browsers (chrome for example) this function must be called
  13512. * within a user-interaction callback. Example:
  13513. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13514. *
  13515. * @param element html element to attach the vrDevice to
  13516. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13517. */
  13518. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13519. /**
  13520. * Detaches the camera from the html element and disables VR
  13521. *
  13522. * @param element html element to detach from
  13523. */
  13524. detachControl(element: HTMLElement): void;
  13525. /**
  13526. * @returns the name of this class
  13527. */
  13528. getClassName(): string;
  13529. /**
  13530. * Calls resetPose on the vrDisplay
  13531. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13532. */
  13533. resetToCurrentRotation(): void;
  13534. /**
  13535. * @hidden
  13536. * Updates the rig cameras (left and right eye)
  13537. */
  13538. _updateRigCameras(): void;
  13539. private _workingVector;
  13540. private _oneVector;
  13541. private _workingMatrix;
  13542. private updateCacheCalled;
  13543. private _correctPositionIfNotTrackPosition;
  13544. /**
  13545. * @hidden
  13546. * Updates the cached values of the camera
  13547. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13548. */
  13549. _updateCache(ignoreParentClass?: boolean): void;
  13550. /**
  13551. * @hidden
  13552. * Get current device position in babylon world
  13553. */
  13554. _computeDevicePosition(): void;
  13555. /**
  13556. * Updates the current device position and rotation in the babylon world
  13557. */
  13558. update(): void;
  13559. /**
  13560. * @hidden
  13561. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13562. * @returns an identity matrix
  13563. */
  13564. _getViewMatrix(): Matrix;
  13565. private _tmpMatrix;
  13566. /**
  13567. * This function is called by the two RIG cameras.
  13568. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13569. * @hidden
  13570. */
  13571. _getWebVRViewMatrix(): Matrix;
  13572. /** @hidden */
  13573. _getWebVRProjectionMatrix(): Matrix;
  13574. private _onGamepadConnectedObserver;
  13575. private _onGamepadDisconnectedObserver;
  13576. private _updateCacheWhenTrackingDisabledObserver;
  13577. /**
  13578. * Initializes the controllers and their meshes
  13579. */
  13580. initControllers(): void;
  13581. }
  13582. }
  13583. declare module BABYLON {
  13584. /**
  13585. * Size options for a post process
  13586. */
  13587. export type PostProcessOptions = {
  13588. width: number;
  13589. height: number;
  13590. };
  13591. /**
  13592. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13593. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13594. */
  13595. export class PostProcess {
  13596. /** Name of the PostProcess. */
  13597. name: string;
  13598. /**
  13599. * Gets or sets the unique id of the post process
  13600. */
  13601. uniqueId: number;
  13602. /**
  13603. * Width of the texture to apply the post process on
  13604. */
  13605. width: number;
  13606. /**
  13607. * Height of the texture to apply the post process on
  13608. */
  13609. height: number;
  13610. /**
  13611. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13612. * @hidden
  13613. */
  13614. _outputTexture: Nullable<InternalTexture>;
  13615. /**
  13616. * Sampling mode used by the shader
  13617. * See https://doc.babylonjs.com/classes/3.1/texture
  13618. */
  13619. renderTargetSamplingMode: number;
  13620. /**
  13621. * Clear color to use when screen clearing
  13622. */
  13623. clearColor: Color4;
  13624. /**
  13625. * If the buffer needs to be cleared before applying the post process. (default: true)
  13626. * Should be set to false if shader will overwrite all previous pixels.
  13627. */
  13628. autoClear: boolean;
  13629. /**
  13630. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13631. */
  13632. alphaMode: number;
  13633. /**
  13634. * Sets the setAlphaBlendConstants of the babylon engine
  13635. */
  13636. alphaConstants: Color4;
  13637. /**
  13638. * Animations to be used for the post processing
  13639. */
  13640. animations: Animation[];
  13641. /**
  13642. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13643. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13644. */
  13645. enablePixelPerfectMode: boolean;
  13646. /**
  13647. * Force the postprocess to be applied without taking in account viewport
  13648. */
  13649. forceFullscreenViewport: boolean;
  13650. /**
  13651. * List of inspectable custom properties (used by the Inspector)
  13652. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13653. */
  13654. inspectableCustomProperties: IInspectable[];
  13655. /**
  13656. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13657. *
  13658. * | Value | Type | Description |
  13659. * | ----- | ----------------------------------- | ----------- |
  13660. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13661. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13662. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13663. *
  13664. */
  13665. scaleMode: number;
  13666. /**
  13667. * Force textures to be a power of two (default: false)
  13668. */
  13669. alwaysForcePOT: boolean;
  13670. private _samples;
  13671. /**
  13672. * Number of sample textures (default: 1)
  13673. */
  13674. samples: number;
  13675. /**
  13676. * Modify the scale of the post process to be the same as the viewport (default: false)
  13677. */
  13678. adaptScaleToCurrentViewport: boolean;
  13679. private _camera;
  13680. private _scene;
  13681. private _engine;
  13682. private _options;
  13683. private _reusable;
  13684. private _textureType;
  13685. /**
  13686. * Smart array of input and output textures for the post process.
  13687. * @hidden
  13688. */
  13689. _textures: SmartArray<InternalTexture>;
  13690. /**
  13691. * The index in _textures that corresponds to the output texture.
  13692. * @hidden
  13693. */
  13694. _currentRenderTextureInd: number;
  13695. private _effect;
  13696. private _samplers;
  13697. private _fragmentUrl;
  13698. private _vertexUrl;
  13699. private _parameters;
  13700. private _scaleRatio;
  13701. protected _indexParameters: any;
  13702. private _shareOutputWithPostProcess;
  13703. private _texelSize;
  13704. private _forcedOutputTexture;
  13705. /**
  13706. * Returns the fragment url or shader name used in the post process.
  13707. * @returns the fragment url or name in the shader store.
  13708. */
  13709. getEffectName(): string;
  13710. /**
  13711. * An event triggered when the postprocess is activated.
  13712. */
  13713. onActivateObservable: Observable<Camera>;
  13714. private _onActivateObserver;
  13715. /**
  13716. * A function that is added to the onActivateObservable
  13717. */
  13718. onActivate: Nullable<(camera: Camera) => void>;
  13719. /**
  13720. * An event triggered when the postprocess changes its size.
  13721. */
  13722. onSizeChangedObservable: Observable<PostProcess>;
  13723. private _onSizeChangedObserver;
  13724. /**
  13725. * A function that is added to the onSizeChangedObservable
  13726. */
  13727. onSizeChanged: (postProcess: PostProcess) => void;
  13728. /**
  13729. * An event triggered when the postprocess applies its effect.
  13730. */
  13731. onApplyObservable: Observable<Effect>;
  13732. private _onApplyObserver;
  13733. /**
  13734. * A function that is added to the onApplyObservable
  13735. */
  13736. onApply: (effect: Effect) => void;
  13737. /**
  13738. * An event triggered before rendering the postprocess
  13739. */
  13740. onBeforeRenderObservable: Observable<Effect>;
  13741. private _onBeforeRenderObserver;
  13742. /**
  13743. * A function that is added to the onBeforeRenderObservable
  13744. */
  13745. onBeforeRender: (effect: Effect) => void;
  13746. /**
  13747. * An event triggered after rendering the postprocess
  13748. */
  13749. onAfterRenderObservable: Observable<Effect>;
  13750. private _onAfterRenderObserver;
  13751. /**
  13752. * A function that is added to the onAfterRenderObservable
  13753. */
  13754. onAfterRender: (efect: Effect) => void;
  13755. /**
  13756. * 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
  13757. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13758. */
  13759. inputTexture: InternalTexture;
  13760. /**
  13761. * Gets the camera which post process is applied to.
  13762. * @returns The camera the post process is applied to.
  13763. */
  13764. getCamera(): Camera;
  13765. /**
  13766. * Gets the texel size of the postprocess.
  13767. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13768. */
  13769. readonly texelSize: Vector2;
  13770. /**
  13771. * Creates a new instance PostProcess
  13772. * @param name The name of the PostProcess.
  13773. * @param fragmentUrl The url of the fragment shader to be used.
  13774. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13775. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13776. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13777. * @param camera The camera to apply the render pass to.
  13778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13779. * @param engine The engine which the post process will be applied. (default: current engine)
  13780. * @param reusable If the post process can be reused on the same frame. (default: false)
  13781. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13782. * @param textureType Type of textures used when performing the post process. (default: 0)
  13783. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13784. * @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
  13785. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13786. */
  13787. constructor(
  13788. /** Name of the PostProcess. */
  13789. 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);
  13790. /**
  13791. * Gets a string idenfifying the name of the class
  13792. * @returns "PostProcess" string
  13793. */
  13794. getClassName(): string;
  13795. /**
  13796. * Gets the engine which this post process belongs to.
  13797. * @returns The engine the post process was enabled with.
  13798. */
  13799. getEngine(): Engine;
  13800. /**
  13801. * The effect that is created when initializing the post process.
  13802. * @returns The created effect corrisponding the the postprocess.
  13803. */
  13804. getEffect(): Effect;
  13805. /**
  13806. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13807. * @param postProcess The post process to share the output with.
  13808. * @returns This post process.
  13809. */
  13810. shareOutputWith(postProcess: PostProcess): PostProcess;
  13811. /**
  13812. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13813. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13814. */
  13815. useOwnOutput(): void;
  13816. /**
  13817. * Updates the effect with the current post process compile time values and recompiles the shader.
  13818. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13819. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13820. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13821. * @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
  13822. * @param onCompiled Called when the shader has been compiled.
  13823. * @param onError Called if there is an error when compiling a shader.
  13824. */
  13825. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13826. /**
  13827. * The post process is reusable if it can be used multiple times within one frame.
  13828. * @returns If the post process is reusable
  13829. */
  13830. isReusable(): boolean;
  13831. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13832. markTextureDirty(): void;
  13833. /**
  13834. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13835. * 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.
  13836. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13837. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13838. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13839. * @returns The target texture that was bound to be written to.
  13840. */
  13841. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13842. /**
  13843. * If the post process is supported.
  13844. */
  13845. readonly isSupported: boolean;
  13846. /**
  13847. * The aspect ratio of the output texture.
  13848. */
  13849. readonly aspectRatio: number;
  13850. /**
  13851. * Get a value indicating if the post-process is ready to be used
  13852. * @returns true if the post-process is ready (shader is compiled)
  13853. */
  13854. isReady(): boolean;
  13855. /**
  13856. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13857. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13858. */
  13859. apply(): Nullable<Effect>;
  13860. private _disposeTextures;
  13861. /**
  13862. * Disposes the post process.
  13863. * @param camera The camera to dispose the post process on.
  13864. */
  13865. dispose(camera?: Camera): void;
  13866. }
  13867. }
  13868. declare module BABYLON {
  13869. /**
  13870. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13871. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13872. */
  13873. export class PostProcessManager {
  13874. private _scene;
  13875. private _indexBuffer;
  13876. private _vertexBuffers;
  13877. /**
  13878. * Creates a new instance PostProcess
  13879. * @param scene The scene that the post process is associated with.
  13880. */
  13881. constructor(scene: Scene);
  13882. private _prepareBuffers;
  13883. private _buildIndexBuffer;
  13884. /**
  13885. * Rebuilds the vertex buffers of the manager.
  13886. * @hidden
  13887. */
  13888. _rebuild(): void;
  13889. /**
  13890. * Prepares a frame to be run through a post process.
  13891. * @param sourceTexture The input texture to the post procesess. (default: null)
  13892. * @param postProcesses An array of post processes to be run. (default: null)
  13893. * @returns True if the post processes were able to be run.
  13894. * @hidden
  13895. */
  13896. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13897. /**
  13898. * Manually render a set of post processes to a texture.
  13899. * @param postProcesses An array of post processes to be run.
  13900. * @param targetTexture The target texture to render to.
  13901. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13902. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13903. * @param lodLevel defines which lod of the texture to render to
  13904. */
  13905. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13906. /**
  13907. * Finalize the result of the output of the postprocesses.
  13908. * @param doNotPresent If true the result will not be displayed to the screen.
  13909. * @param targetTexture The target texture to render to.
  13910. * @param faceIndex The index of the face to bind the target texture to.
  13911. * @param postProcesses The array of post processes to render.
  13912. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13913. * @hidden
  13914. */
  13915. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13916. /**
  13917. * Disposes of the post process manager.
  13918. */
  13919. dispose(): void;
  13920. }
  13921. }
  13922. declare module BABYLON {
  13923. interface AbstractScene {
  13924. /**
  13925. * The list of layers (background and foreground) of the scene
  13926. */
  13927. layers: Array<Layer>;
  13928. }
  13929. /**
  13930. * Defines the layer scene component responsible to manage any layers
  13931. * in a given scene.
  13932. */
  13933. export class LayerSceneComponent implements ISceneComponent {
  13934. /**
  13935. * The component name helpfull to identify the component in the list of scene components.
  13936. */
  13937. readonly name: string;
  13938. /**
  13939. * The scene the component belongs to.
  13940. */
  13941. scene: Scene;
  13942. private _engine;
  13943. /**
  13944. * Creates a new instance of the component for the given scene
  13945. * @param scene Defines the scene to register the component in
  13946. */
  13947. constructor(scene: Scene);
  13948. /**
  13949. * Registers the component in a given scene
  13950. */
  13951. register(): void;
  13952. /**
  13953. * Rebuilds the elements related to this component in case of
  13954. * context lost for instance.
  13955. */
  13956. rebuild(): void;
  13957. /**
  13958. * Disposes the component and the associated ressources.
  13959. */
  13960. dispose(): void;
  13961. private _draw;
  13962. private _drawCameraPredicate;
  13963. private _drawCameraBackground;
  13964. private _drawCameraForeground;
  13965. private _drawRenderTargetPredicate;
  13966. private _drawRenderTargetBackground;
  13967. private _drawRenderTargetForeground;
  13968. }
  13969. }
  13970. declare module BABYLON {
  13971. /** @hidden */
  13972. export var layerPixelShader: {
  13973. name: string;
  13974. shader: string;
  13975. };
  13976. }
  13977. declare module BABYLON {
  13978. /** @hidden */
  13979. export var layerVertexShader: {
  13980. name: string;
  13981. shader: string;
  13982. };
  13983. }
  13984. declare module BABYLON {
  13985. /**
  13986. * This represents a full screen 2d layer.
  13987. * This can be useful to display a picture in the background of your scene for instance.
  13988. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13989. */
  13990. export class Layer {
  13991. /**
  13992. * Define the name of the layer.
  13993. */
  13994. name: string;
  13995. /**
  13996. * Define the texture the layer should display.
  13997. */
  13998. texture: Nullable<Texture>;
  13999. /**
  14000. * Is the layer in background or foreground.
  14001. */
  14002. isBackground: boolean;
  14003. /**
  14004. * Define the color of the layer (instead of texture).
  14005. */
  14006. color: Color4;
  14007. /**
  14008. * Define the scale of the layer in order to zoom in out of the texture.
  14009. */
  14010. scale: Vector2;
  14011. /**
  14012. * Define an offset for the layer in order to shift the texture.
  14013. */
  14014. offset: Vector2;
  14015. /**
  14016. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14017. */
  14018. alphaBlendingMode: number;
  14019. /**
  14020. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14021. * Alpha test will not mix with the background color in case of transparency.
  14022. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14023. */
  14024. alphaTest: boolean;
  14025. /**
  14026. * Define a mask to restrict the layer to only some of the scene cameras.
  14027. */
  14028. layerMask: number;
  14029. /**
  14030. * Define the list of render target the layer is visible into.
  14031. */
  14032. renderTargetTextures: RenderTargetTexture[];
  14033. /**
  14034. * Define if the layer is only used in renderTarget or if it also
  14035. * renders in the main frame buffer of the canvas.
  14036. */
  14037. renderOnlyInRenderTargetTextures: boolean;
  14038. private _scene;
  14039. private _vertexBuffers;
  14040. private _indexBuffer;
  14041. private _effect;
  14042. private _alphaTestEffect;
  14043. /**
  14044. * An event triggered when the layer is disposed.
  14045. */
  14046. onDisposeObservable: Observable<Layer>;
  14047. private _onDisposeObserver;
  14048. /**
  14049. * Back compatibility with callback before the onDisposeObservable existed.
  14050. * The set callback will be triggered when the layer has been disposed.
  14051. */
  14052. onDispose: () => void;
  14053. /**
  14054. * An event triggered before rendering the scene
  14055. */
  14056. onBeforeRenderObservable: Observable<Layer>;
  14057. private _onBeforeRenderObserver;
  14058. /**
  14059. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14060. * The set callback will be triggered just before rendering the layer.
  14061. */
  14062. onBeforeRender: () => void;
  14063. /**
  14064. * An event triggered after rendering the scene
  14065. */
  14066. onAfterRenderObservable: Observable<Layer>;
  14067. private _onAfterRenderObserver;
  14068. /**
  14069. * Back compatibility with callback before the onAfterRenderObservable existed.
  14070. * The set callback will be triggered just after rendering the layer.
  14071. */
  14072. onAfterRender: () => void;
  14073. /**
  14074. * Instantiates a new layer.
  14075. * This represents a full screen 2d layer.
  14076. * This can be useful to display a picture in the background of your scene for instance.
  14077. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14078. * @param name Define the name of the layer in the scene
  14079. * @param imgUrl Define the url of the texture to display in the layer
  14080. * @param scene Define the scene the layer belongs to
  14081. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14082. * @param color Defines a color for the layer
  14083. */
  14084. constructor(
  14085. /**
  14086. * Define the name of the layer.
  14087. */
  14088. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14089. private _createIndexBuffer;
  14090. /** @hidden */
  14091. _rebuild(): void;
  14092. /**
  14093. * Renders the layer in the scene.
  14094. */
  14095. render(): void;
  14096. /**
  14097. * Disposes and releases the associated ressources.
  14098. */
  14099. dispose(): void;
  14100. }
  14101. }
  14102. declare module BABYLON {
  14103. interface AbstractScene {
  14104. /**
  14105. * The list of procedural textures added to the scene
  14106. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14107. */
  14108. proceduralTextures: Array<ProceduralTexture>;
  14109. }
  14110. /**
  14111. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14112. * in a given scene.
  14113. */
  14114. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14115. /**
  14116. * The component name helpfull to identify the component in the list of scene components.
  14117. */
  14118. readonly name: string;
  14119. /**
  14120. * The scene the component belongs to.
  14121. */
  14122. scene: Scene;
  14123. /**
  14124. * Creates a new instance of the component for the given scene
  14125. * @param scene Defines the scene to register the component in
  14126. */
  14127. constructor(scene: Scene);
  14128. /**
  14129. * Registers the component in a given scene
  14130. */
  14131. register(): void;
  14132. /**
  14133. * Rebuilds the elements related to this component in case of
  14134. * context lost for instance.
  14135. */
  14136. rebuild(): void;
  14137. /**
  14138. * Disposes the component and the associated ressources.
  14139. */
  14140. dispose(): void;
  14141. private _beforeClear;
  14142. }
  14143. }
  14144. declare module BABYLON {
  14145. interface Engine {
  14146. /**
  14147. * Creates a new render target cube texture
  14148. * @param size defines the size of the texture
  14149. * @param options defines the options used to create the texture
  14150. * @returns a new render target cube texture stored in an InternalTexture
  14151. */
  14152. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14153. }
  14154. }
  14155. declare module BABYLON {
  14156. /** @hidden */
  14157. export var proceduralVertexShader: {
  14158. name: string;
  14159. shader: string;
  14160. };
  14161. }
  14162. declare module BABYLON {
  14163. /**
  14164. * 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.
  14165. * This is the base class of any Procedural texture and contains most of the shareable code.
  14166. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14167. */
  14168. export class ProceduralTexture extends Texture {
  14169. isCube: boolean;
  14170. /**
  14171. * Define if the texture is enabled or not (disabled texture will not render)
  14172. */
  14173. isEnabled: boolean;
  14174. /**
  14175. * Define if the texture must be cleared before rendering (default is true)
  14176. */
  14177. autoClear: boolean;
  14178. /**
  14179. * Callback called when the texture is generated
  14180. */
  14181. onGenerated: () => void;
  14182. /**
  14183. * Event raised when the texture is generated
  14184. */
  14185. onGeneratedObservable: Observable<ProceduralTexture>;
  14186. /** @hidden */
  14187. _generateMipMaps: boolean;
  14188. /** @hidden **/
  14189. _effect: Effect;
  14190. /** @hidden */
  14191. _textures: {
  14192. [key: string]: Texture;
  14193. };
  14194. private _size;
  14195. private _currentRefreshId;
  14196. private _refreshRate;
  14197. private _vertexBuffers;
  14198. private _indexBuffer;
  14199. private _uniforms;
  14200. private _samplers;
  14201. private _fragment;
  14202. private _floats;
  14203. private _ints;
  14204. private _floatsArrays;
  14205. private _colors3;
  14206. private _colors4;
  14207. private _vectors2;
  14208. private _vectors3;
  14209. private _matrices;
  14210. private _fallbackTexture;
  14211. private _fallbackTextureUsed;
  14212. private _engine;
  14213. private _cachedDefines;
  14214. private _contentUpdateId;
  14215. private _contentData;
  14216. /**
  14217. * Instantiates a new procedural texture.
  14218. * 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.
  14219. * This is the base class of any Procedural texture and contains most of the shareable code.
  14220. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14221. * @param name Define the name of the texture
  14222. * @param size Define the size of the texture to create
  14223. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14224. * @param scene Define the scene the texture belongs to
  14225. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14226. * @param generateMipMaps Define if the texture should creates mip maps or not
  14227. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14228. */
  14229. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14230. /**
  14231. * The effect that is created when initializing the post process.
  14232. * @returns The created effect corrisponding the the postprocess.
  14233. */
  14234. getEffect(): Effect;
  14235. /**
  14236. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14237. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14238. */
  14239. getContent(): Nullable<ArrayBufferView>;
  14240. private _createIndexBuffer;
  14241. /** @hidden */
  14242. _rebuild(): void;
  14243. /**
  14244. * Resets the texture in order to recreate its associated resources.
  14245. * This can be called in case of context loss
  14246. */
  14247. reset(): void;
  14248. protected _getDefines(): string;
  14249. /**
  14250. * Is the texture ready to be used ? (rendered at least once)
  14251. * @returns true if ready, otherwise, false.
  14252. */
  14253. isReady(): boolean;
  14254. /**
  14255. * Resets the refresh counter of the texture and start bak from scratch.
  14256. * Could be useful to regenerate the texture if it is setup to render only once.
  14257. */
  14258. resetRefreshCounter(): void;
  14259. /**
  14260. * Set the fragment shader to use in order to render the texture.
  14261. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14262. */
  14263. setFragment(fragment: any): void;
  14264. /**
  14265. * Define the refresh rate of the texture or the rendering frequency.
  14266. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14267. */
  14268. refreshRate: number;
  14269. /** @hidden */
  14270. _shouldRender(): boolean;
  14271. /**
  14272. * Get the size the texture is rendering at.
  14273. * @returns the size (texture is always squared)
  14274. */
  14275. getRenderSize(): number;
  14276. /**
  14277. * Resize the texture to new value.
  14278. * @param size Define the new size the texture should have
  14279. * @param generateMipMaps Define whether the new texture should create mip maps
  14280. */
  14281. resize(size: number, generateMipMaps: boolean): void;
  14282. private _checkUniform;
  14283. /**
  14284. * Set a texture in the shader program used to render.
  14285. * @param name Define the name of the uniform samplers as defined in the shader
  14286. * @param texture Define the texture to bind to this sampler
  14287. * @return the texture itself allowing "fluent" like uniform updates
  14288. */
  14289. setTexture(name: string, texture: Texture): ProceduralTexture;
  14290. /**
  14291. * Set a float in the shader.
  14292. * @param name Define the name of the uniform as defined in the shader
  14293. * @param value Define the value to give to the uniform
  14294. * @return the texture itself allowing "fluent" like uniform updates
  14295. */
  14296. setFloat(name: string, value: number): ProceduralTexture;
  14297. /**
  14298. * Set a int in the shader.
  14299. * @param name Define the name of the uniform as defined in the shader
  14300. * @param value Define the value to give to the uniform
  14301. * @return the texture itself allowing "fluent" like uniform updates
  14302. */
  14303. setInt(name: string, value: number): ProceduralTexture;
  14304. /**
  14305. * Set an array of floats in the shader.
  14306. * @param name Define the name of the uniform as defined in the shader
  14307. * @param value Define the value to give to the uniform
  14308. * @return the texture itself allowing "fluent" like uniform updates
  14309. */
  14310. setFloats(name: string, value: number[]): ProceduralTexture;
  14311. /**
  14312. * Set a vec3 in the shader from a Color3.
  14313. * @param name Define the name of the uniform as defined in the shader
  14314. * @param value Define the value to give to the uniform
  14315. * @return the texture itself allowing "fluent" like uniform updates
  14316. */
  14317. setColor3(name: string, value: Color3): ProceduralTexture;
  14318. /**
  14319. * Set a vec4 in the shader from a Color4.
  14320. * @param name Define the name of the uniform as defined in the shader
  14321. * @param value Define the value to give to the uniform
  14322. * @return the texture itself allowing "fluent" like uniform updates
  14323. */
  14324. setColor4(name: string, value: Color4): ProceduralTexture;
  14325. /**
  14326. * Set a vec2 in the shader from a Vector2.
  14327. * @param name Define the name of the uniform as defined in the shader
  14328. * @param value Define the value to give to the uniform
  14329. * @return the texture itself allowing "fluent" like uniform updates
  14330. */
  14331. setVector2(name: string, value: Vector2): ProceduralTexture;
  14332. /**
  14333. * Set a vec3 in the shader from a Vector3.
  14334. * @param name Define the name of the uniform as defined in the shader
  14335. * @param value Define the value to give to the uniform
  14336. * @return the texture itself allowing "fluent" like uniform updates
  14337. */
  14338. setVector3(name: string, value: Vector3): ProceduralTexture;
  14339. /**
  14340. * Set a mat4 in the shader from a MAtrix.
  14341. * @param name Define the name of the uniform as defined in the shader
  14342. * @param value Define the value to give to the uniform
  14343. * @return the texture itself allowing "fluent" like uniform updates
  14344. */
  14345. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14346. /**
  14347. * Render the texture to its associated render target.
  14348. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14349. */
  14350. render(useCameraPostProcess?: boolean): void;
  14351. /**
  14352. * Clone the texture.
  14353. * @returns the cloned texture
  14354. */
  14355. clone(): ProceduralTexture;
  14356. /**
  14357. * Dispose the texture and release its asoociated resources.
  14358. */
  14359. dispose(): void;
  14360. }
  14361. }
  14362. declare module BABYLON {
  14363. /**
  14364. * This represents the base class for particle system in Babylon.
  14365. * 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.
  14366. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14367. * @example https://doc.babylonjs.com/babylon101/particles
  14368. */
  14369. export class BaseParticleSystem {
  14370. /**
  14371. * Source color is added to the destination color without alpha affecting the result
  14372. */
  14373. static BLENDMODE_ONEONE: number;
  14374. /**
  14375. * Blend current color and particle color using particle’s alpha
  14376. */
  14377. static BLENDMODE_STANDARD: number;
  14378. /**
  14379. * Add current color and particle color multiplied by particle’s alpha
  14380. */
  14381. static BLENDMODE_ADD: number;
  14382. /**
  14383. * Multiply current color with particle color
  14384. */
  14385. static BLENDMODE_MULTIPLY: number;
  14386. /**
  14387. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14388. */
  14389. static BLENDMODE_MULTIPLYADD: number;
  14390. /**
  14391. * List of animations used by the particle system.
  14392. */
  14393. animations: Animation[];
  14394. /**
  14395. * The id of the Particle system.
  14396. */
  14397. id: string;
  14398. /**
  14399. * The friendly name of the Particle system.
  14400. */
  14401. name: string;
  14402. /**
  14403. * The rendering group used by the Particle system to chose when to render.
  14404. */
  14405. renderingGroupId: number;
  14406. /**
  14407. * The emitter represents the Mesh or position we are attaching the particle system to.
  14408. */
  14409. emitter: Nullable<AbstractMesh | Vector3>;
  14410. /**
  14411. * The maximum number of particles to emit per frame
  14412. */
  14413. emitRate: number;
  14414. /**
  14415. * If you want to launch only a few particles at once, that can be done, as well.
  14416. */
  14417. manualEmitCount: number;
  14418. /**
  14419. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14420. */
  14421. updateSpeed: number;
  14422. /**
  14423. * The amount of time the particle system is running (depends of the overall update speed).
  14424. */
  14425. targetStopDuration: number;
  14426. /**
  14427. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14428. */
  14429. disposeOnStop: boolean;
  14430. /**
  14431. * Minimum power of emitting particles.
  14432. */
  14433. minEmitPower: number;
  14434. /**
  14435. * Maximum power of emitting particles.
  14436. */
  14437. maxEmitPower: number;
  14438. /**
  14439. * Minimum life time of emitting particles.
  14440. */
  14441. minLifeTime: number;
  14442. /**
  14443. * Maximum life time of emitting particles.
  14444. */
  14445. maxLifeTime: number;
  14446. /**
  14447. * Minimum Size of emitting particles.
  14448. */
  14449. minSize: number;
  14450. /**
  14451. * Maximum Size of emitting particles.
  14452. */
  14453. maxSize: number;
  14454. /**
  14455. * Minimum scale of emitting particles on X axis.
  14456. */
  14457. minScaleX: number;
  14458. /**
  14459. * Maximum scale of emitting particles on X axis.
  14460. */
  14461. maxScaleX: number;
  14462. /**
  14463. * Minimum scale of emitting particles on Y axis.
  14464. */
  14465. minScaleY: number;
  14466. /**
  14467. * Maximum scale of emitting particles on Y axis.
  14468. */
  14469. maxScaleY: number;
  14470. /**
  14471. * Gets or sets the minimal initial rotation in radians.
  14472. */
  14473. minInitialRotation: number;
  14474. /**
  14475. * Gets or sets the maximal initial rotation in radians.
  14476. */
  14477. maxInitialRotation: number;
  14478. /**
  14479. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14480. */
  14481. minAngularSpeed: number;
  14482. /**
  14483. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14484. */
  14485. maxAngularSpeed: number;
  14486. /**
  14487. * The texture used to render each particle. (this can be a spritesheet)
  14488. */
  14489. particleTexture: Nullable<Texture>;
  14490. /**
  14491. * The layer mask we are rendering the particles through.
  14492. */
  14493. layerMask: number;
  14494. /**
  14495. * This can help using your own shader to render the particle system.
  14496. * The according effect will be created
  14497. */
  14498. customShader: any;
  14499. /**
  14500. * By default particle system starts as soon as they are created. This prevents the
  14501. * automatic start to happen and let you decide when to start emitting particles.
  14502. */
  14503. preventAutoStart: boolean;
  14504. private _noiseTexture;
  14505. /**
  14506. * Gets or sets a texture used to add random noise to particle positions
  14507. */
  14508. noiseTexture: Nullable<ProceduralTexture>;
  14509. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14510. noiseStrength: Vector3;
  14511. /**
  14512. * Callback triggered when the particle animation is ending.
  14513. */
  14514. onAnimationEnd: Nullable<() => void>;
  14515. /**
  14516. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14517. */
  14518. blendMode: number;
  14519. /**
  14520. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14521. * to override the particles.
  14522. */
  14523. forceDepthWrite: boolean;
  14524. /** 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 */
  14525. preWarmCycles: number;
  14526. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14527. preWarmStepOffset: number;
  14528. /**
  14529. * 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)
  14530. */
  14531. spriteCellChangeSpeed: number;
  14532. /**
  14533. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14534. */
  14535. startSpriteCellID: number;
  14536. /**
  14537. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14538. */
  14539. endSpriteCellID: number;
  14540. /**
  14541. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14542. */
  14543. spriteCellWidth: number;
  14544. /**
  14545. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14546. */
  14547. spriteCellHeight: number;
  14548. /**
  14549. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14550. */
  14551. spriteRandomStartCell: boolean;
  14552. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14553. translationPivot: Vector2;
  14554. /** @hidden */
  14555. protected _isAnimationSheetEnabled: boolean;
  14556. /**
  14557. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14558. */
  14559. beginAnimationOnStart: boolean;
  14560. /**
  14561. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14562. */
  14563. beginAnimationFrom: number;
  14564. /**
  14565. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14566. */
  14567. beginAnimationTo: number;
  14568. /**
  14569. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14570. */
  14571. beginAnimationLoop: boolean;
  14572. /**
  14573. * Gets or sets a world offset applied to all particles
  14574. */
  14575. worldOffset: Vector3;
  14576. /**
  14577. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14578. */
  14579. isAnimationSheetEnabled: boolean;
  14580. /**
  14581. * Get hosting scene
  14582. * @returns the scene
  14583. */
  14584. getScene(): Scene;
  14585. /**
  14586. * You can use gravity if you want to give an orientation to your particles.
  14587. */
  14588. gravity: Vector3;
  14589. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14590. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14591. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14592. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14593. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14594. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14595. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14596. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14597. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14598. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14599. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14600. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14601. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14602. /**
  14603. * Defines the delay in milliseconds before starting the system (0 by default)
  14604. */
  14605. startDelay: number;
  14606. /**
  14607. * Gets the current list of drag gradients.
  14608. * You must use addDragGradient and removeDragGradient to udpate this list
  14609. * @returns the list of drag gradients
  14610. */
  14611. getDragGradients(): Nullable<Array<FactorGradient>>;
  14612. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14613. limitVelocityDamping: number;
  14614. /**
  14615. * Gets the current list of limit velocity gradients.
  14616. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14617. * @returns the list of limit velocity gradients
  14618. */
  14619. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14620. /**
  14621. * Gets the current list of color gradients.
  14622. * You must use addColorGradient and removeColorGradient to udpate this list
  14623. * @returns the list of color gradients
  14624. */
  14625. getColorGradients(): Nullable<Array<ColorGradient>>;
  14626. /**
  14627. * Gets the current list of size gradients.
  14628. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14629. * @returns the list of size gradients
  14630. */
  14631. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14632. /**
  14633. * Gets the current list of color remap gradients.
  14634. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14635. * @returns the list of color remap gradients
  14636. */
  14637. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14638. /**
  14639. * Gets the current list of alpha remap gradients.
  14640. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14641. * @returns the list of alpha remap gradients
  14642. */
  14643. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14644. /**
  14645. * Gets the current list of life time gradients.
  14646. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14647. * @returns the list of life time gradients
  14648. */
  14649. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14650. /**
  14651. * Gets the current list of angular speed gradients.
  14652. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14653. * @returns the list of angular speed gradients
  14654. */
  14655. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14656. /**
  14657. * Gets the current list of velocity gradients.
  14658. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14659. * @returns the list of velocity gradients
  14660. */
  14661. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14662. /**
  14663. * Gets the current list of start size gradients.
  14664. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14665. * @returns the list of start size gradients
  14666. */
  14667. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14668. /**
  14669. * Gets the current list of emit rate gradients.
  14670. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14671. * @returns the list of emit rate gradients
  14672. */
  14673. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14674. /**
  14675. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14676. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14677. */
  14678. direction1: Vector3;
  14679. /**
  14680. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14681. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14682. */
  14683. direction2: Vector3;
  14684. /**
  14685. * 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.
  14686. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14687. */
  14688. minEmitBox: Vector3;
  14689. /**
  14690. * 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.
  14691. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14692. */
  14693. maxEmitBox: Vector3;
  14694. /**
  14695. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14696. */
  14697. color1: Color4;
  14698. /**
  14699. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14700. */
  14701. color2: Color4;
  14702. /**
  14703. * Color the particle will have at the end of its lifetime
  14704. */
  14705. colorDead: Color4;
  14706. /**
  14707. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14708. */
  14709. textureMask: Color4;
  14710. /**
  14711. * The particle emitter type defines the emitter used by the particle system.
  14712. * It can be for example box, sphere, or cone...
  14713. */
  14714. particleEmitterType: IParticleEmitterType;
  14715. /** @hidden */
  14716. _isSubEmitter: boolean;
  14717. /**
  14718. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14719. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14720. */
  14721. billboardMode: number;
  14722. protected _isBillboardBased: boolean;
  14723. /**
  14724. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14725. */
  14726. isBillboardBased: boolean;
  14727. /**
  14728. * The scene the particle system belongs to.
  14729. */
  14730. protected _scene: Scene;
  14731. /**
  14732. * Local cache of defines for image processing.
  14733. */
  14734. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14735. /**
  14736. * Default configuration related to image processing available in the standard Material.
  14737. */
  14738. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14739. /**
  14740. * Gets the image processing configuration used either in this material.
  14741. */
  14742. /**
  14743. * Sets the Default image processing configuration used either in the this material.
  14744. *
  14745. * If sets to null, the scene one is in use.
  14746. */
  14747. imageProcessingConfiguration: ImageProcessingConfiguration;
  14748. /**
  14749. * Attaches a new image processing configuration to the Standard Material.
  14750. * @param configuration
  14751. */
  14752. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14753. /** @hidden */
  14754. protected _reset(): void;
  14755. /** @hidden */
  14756. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14757. /**
  14758. * Instantiates a particle system.
  14759. * 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.
  14760. * @param name The name of the particle system
  14761. */
  14762. constructor(name: string);
  14763. /**
  14764. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14765. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14766. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14767. * @returns the emitter
  14768. */
  14769. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14770. /**
  14771. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14772. * @param radius The radius of the hemisphere to emit from
  14773. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14774. * @returns the emitter
  14775. */
  14776. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14777. /**
  14778. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14779. * @param radius The radius of the sphere to emit from
  14780. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14781. * @returns the emitter
  14782. */
  14783. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14784. /**
  14785. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14786. * @param radius The radius of the sphere to emit from
  14787. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14788. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14789. * @returns the emitter
  14790. */
  14791. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14792. /**
  14793. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14794. * @param radius The radius of the emission cylinder
  14795. * @param height The height of the emission cylinder
  14796. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14797. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14798. * @returns the emitter
  14799. */
  14800. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14801. /**
  14802. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14803. * @param radius The radius of the cylinder to emit from
  14804. * @param height The height of the emission cylinder
  14805. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14806. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14807. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14808. * @returns the emitter
  14809. */
  14810. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14811. /**
  14812. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14813. * @param radius The radius of the cone to emit from
  14814. * @param angle The base angle of the cone
  14815. * @returns the emitter
  14816. */
  14817. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14818. /**
  14819. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14820. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14821. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14822. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14823. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14824. * @returns the emitter
  14825. */
  14826. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14827. }
  14828. }
  14829. declare module BABYLON {
  14830. /**
  14831. * Type of sub emitter
  14832. */
  14833. export enum SubEmitterType {
  14834. /**
  14835. * Attached to the particle over it's lifetime
  14836. */
  14837. ATTACHED = 0,
  14838. /**
  14839. * Created when the particle dies
  14840. */
  14841. END = 1
  14842. }
  14843. /**
  14844. * Sub emitter class used to emit particles from an existing particle
  14845. */
  14846. export class SubEmitter {
  14847. /**
  14848. * the particle system to be used by the sub emitter
  14849. */
  14850. particleSystem: ParticleSystem;
  14851. /**
  14852. * Type of the submitter (Default: END)
  14853. */
  14854. type: SubEmitterType;
  14855. /**
  14856. * 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)
  14857. * Note: This only is supported when using an emitter of type Mesh
  14858. */
  14859. inheritDirection: boolean;
  14860. /**
  14861. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14862. */
  14863. inheritedVelocityAmount: number;
  14864. /**
  14865. * Creates a sub emitter
  14866. * @param particleSystem the particle system to be used by the sub emitter
  14867. */
  14868. constructor(
  14869. /**
  14870. * the particle system to be used by the sub emitter
  14871. */
  14872. particleSystem: ParticleSystem);
  14873. /**
  14874. * Clones the sub emitter
  14875. * @returns the cloned sub emitter
  14876. */
  14877. clone(): SubEmitter;
  14878. /**
  14879. * Serialize current object to a JSON object
  14880. * @returns the serialized object
  14881. */
  14882. serialize(): any;
  14883. /** @hidden */
  14884. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14885. /**
  14886. * Creates a new SubEmitter from a serialized JSON version
  14887. * @param serializationObject defines the JSON object to read from
  14888. * @param scene defines the hosting scene
  14889. * @param rootUrl defines the rootUrl for data loading
  14890. * @returns a new SubEmitter
  14891. */
  14892. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14893. /** Release associated resources */
  14894. dispose(): void;
  14895. }
  14896. }
  14897. declare module BABYLON {
  14898. /** @hidden */
  14899. export var clipPlaneFragmentDeclaration: {
  14900. name: string;
  14901. shader: string;
  14902. };
  14903. }
  14904. declare module BABYLON {
  14905. /** @hidden */
  14906. export var imageProcessingDeclaration: {
  14907. name: string;
  14908. shader: string;
  14909. };
  14910. }
  14911. declare module BABYLON {
  14912. /** @hidden */
  14913. export var imageProcessingFunctions: {
  14914. name: string;
  14915. shader: string;
  14916. };
  14917. }
  14918. declare module BABYLON {
  14919. /** @hidden */
  14920. export var clipPlaneFragment: {
  14921. name: string;
  14922. shader: string;
  14923. };
  14924. }
  14925. declare module BABYLON {
  14926. /** @hidden */
  14927. export var particlesPixelShader: {
  14928. name: string;
  14929. shader: string;
  14930. };
  14931. }
  14932. declare module BABYLON {
  14933. /** @hidden */
  14934. export var clipPlaneVertexDeclaration: {
  14935. name: string;
  14936. shader: string;
  14937. };
  14938. }
  14939. declare module BABYLON {
  14940. /** @hidden */
  14941. export var clipPlaneVertex: {
  14942. name: string;
  14943. shader: string;
  14944. };
  14945. }
  14946. declare module BABYLON {
  14947. /** @hidden */
  14948. export var particlesVertexShader: {
  14949. name: string;
  14950. shader: string;
  14951. };
  14952. }
  14953. declare module BABYLON {
  14954. /**
  14955. * This represents a particle system in Babylon.
  14956. * 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.
  14957. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14958. * @example https://doc.babylonjs.com/babylon101/particles
  14959. */
  14960. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14961. /**
  14962. * Billboard mode will only apply to Y axis
  14963. */
  14964. static readonly BILLBOARDMODE_Y: number;
  14965. /**
  14966. * Billboard mode will apply to all axes
  14967. */
  14968. static readonly BILLBOARDMODE_ALL: number;
  14969. /**
  14970. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14971. */
  14972. static readonly BILLBOARDMODE_STRETCHED: number;
  14973. /**
  14974. * This function can be defined to provide custom update for active particles.
  14975. * This function will be called instead of regular update (age, position, color, etc.).
  14976. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14977. */
  14978. updateFunction: (particles: Particle[]) => void;
  14979. private _emitterWorldMatrix;
  14980. /**
  14981. * This function can be defined to specify initial direction for every new particle.
  14982. * It by default use the emitterType defined function
  14983. */
  14984. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14985. /**
  14986. * This function can be defined to specify initial position for every new particle.
  14987. * It by default use the emitterType defined function
  14988. */
  14989. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14990. /**
  14991. * @hidden
  14992. */
  14993. _inheritedVelocityOffset: Vector3;
  14994. /**
  14995. * An event triggered when the system is disposed
  14996. */
  14997. onDisposeObservable: Observable<ParticleSystem>;
  14998. private _onDisposeObserver;
  14999. /**
  15000. * Sets a callback that will be triggered when the system is disposed
  15001. */
  15002. onDispose: () => void;
  15003. private _particles;
  15004. private _epsilon;
  15005. private _capacity;
  15006. private _stockParticles;
  15007. private _newPartsExcess;
  15008. private _vertexData;
  15009. private _vertexBuffer;
  15010. private _vertexBuffers;
  15011. private _spriteBuffer;
  15012. private _indexBuffer;
  15013. private _effect;
  15014. private _customEffect;
  15015. private _cachedDefines;
  15016. private _scaledColorStep;
  15017. private _colorDiff;
  15018. private _scaledDirection;
  15019. private _scaledGravity;
  15020. private _currentRenderId;
  15021. private _alive;
  15022. private _useInstancing;
  15023. private _started;
  15024. private _stopped;
  15025. private _actualFrame;
  15026. private _scaledUpdateSpeed;
  15027. private _vertexBufferSize;
  15028. /** @hidden */
  15029. _currentEmitRateGradient: Nullable<FactorGradient>;
  15030. /** @hidden */
  15031. _currentEmitRate1: number;
  15032. /** @hidden */
  15033. _currentEmitRate2: number;
  15034. /** @hidden */
  15035. _currentStartSizeGradient: Nullable<FactorGradient>;
  15036. /** @hidden */
  15037. _currentStartSize1: number;
  15038. /** @hidden */
  15039. _currentStartSize2: number;
  15040. private readonly _rawTextureWidth;
  15041. private _rampGradientsTexture;
  15042. private _useRampGradients;
  15043. /** Gets or sets a boolean indicating that ramp gradients must be used
  15044. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15045. */
  15046. useRampGradients: boolean;
  15047. /**
  15048. * 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.
  15049. * 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: [])
  15050. */
  15051. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15052. private _subEmitters;
  15053. /**
  15054. * @hidden
  15055. * If the particle systems emitter should be disposed when the particle system is disposed
  15056. */
  15057. _disposeEmitterOnDispose: boolean;
  15058. /**
  15059. * The current active Sub-systems, this property is used by the root particle system only.
  15060. */
  15061. activeSubSystems: Array<ParticleSystem>;
  15062. private _rootParticleSystem;
  15063. /**
  15064. * Gets the current list of active particles
  15065. */
  15066. readonly particles: Particle[];
  15067. /**
  15068. * Returns the string "ParticleSystem"
  15069. * @returns a string containing the class name
  15070. */
  15071. getClassName(): string;
  15072. /**
  15073. * Instantiates a particle system.
  15074. * 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.
  15075. * @param name The name of the particle system
  15076. * @param capacity The max number of particles alive at the same time
  15077. * @param scene The scene the particle system belongs to
  15078. * @param customEffect a custom effect used to change the way particles are rendered by default
  15079. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15080. * @param epsilon Offset used to render the particles
  15081. */
  15082. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15083. private _addFactorGradient;
  15084. private _removeFactorGradient;
  15085. /**
  15086. * Adds a new life time gradient
  15087. * @param gradient defines the gradient to use (between 0 and 1)
  15088. * @param factor defines the life time factor to affect to the specified gradient
  15089. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15090. * @returns the current particle system
  15091. */
  15092. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15093. /**
  15094. * Remove a specific life time gradient
  15095. * @param gradient defines the gradient to remove
  15096. * @returns the current particle system
  15097. */
  15098. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15099. /**
  15100. * Adds a new size gradient
  15101. * @param gradient defines the gradient to use (between 0 and 1)
  15102. * @param factor defines the size factor to affect to the specified gradient
  15103. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15104. * @returns the current particle system
  15105. */
  15106. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15107. /**
  15108. * Remove a specific size gradient
  15109. * @param gradient defines the gradient to remove
  15110. * @returns the current particle system
  15111. */
  15112. removeSizeGradient(gradient: number): IParticleSystem;
  15113. /**
  15114. * Adds a new color remap gradient
  15115. * @param gradient defines the gradient to use (between 0 and 1)
  15116. * @param min defines the color remap minimal range
  15117. * @param max defines the color remap maximal range
  15118. * @returns the current particle system
  15119. */
  15120. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15121. /**
  15122. * Remove a specific color remap gradient
  15123. * @param gradient defines the gradient to remove
  15124. * @returns the current particle system
  15125. */
  15126. removeColorRemapGradient(gradient: number): IParticleSystem;
  15127. /**
  15128. * Adds a new alpha remap gradient
  15129. * @param gradient defines the gradient to use (between 0 and 1)
  15130. * @param min defines the alpha remap minimal range
  15131. * @param max defines the alpha remap maximal range
  15132. * @returns the current particle system
  15133. */
  15134. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15135. /**
  15136. * Remove a specific alpha remap gradient
  15137. * @param gradient defines the gradient to remove
  15138. * @returns the current particle system
  15139. */
  15140. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15141. /**
  15142. * Adds a new angular speed gradient
  15143. * @param gradient defines the gradient to use (between 0 and 1)
  15144. * @param factor defines the angular speed to affect to the specified gradient
  15145. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15146. * @returns the current particle system
  15147. */
  15148. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15149. /**
  15150. * Remove a specific angular speed gradient
  15151. * @param gradient defines the gradient to remove
  15152. * @returns the current particle system
  15153. */
  15154. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15155. /**
  15156. * Adds a new velocity gradient
  15157. * @param gradient defines the gradient to use (between 0 and 1)
  15158. * @param factor defines the velocity to affect to the specified gradient
  15159. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15160. * @returns the current particle system
  15161. */
  15162. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15163. /**
  15164. * Remove a specific velocity gradient
  15165. * @param gradient defines the gradient to remove
  15166. * @returns the current particle system
  15167. */
  15168. removeVelocityGradient(gradient: number): IParticleSystem;
  15169. /**
  15170. * Adds a new limit velocity gradient
  15171. * @param gradient defines the gradient to use (between 0 and 1)
  15172. * @param factor defines the limit velocity value to affect to the specified gradient
  15173. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15174. * @returns the current particle system
  15175. */
  15176. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15177. /**
  15178. * Remove a specific limit velocity gradient
  15179. * @param gradient defines the gradient to remove
  15180. * @returns the current particle system
  15181. */
  15182. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15183. /**
  15184. * Adds a new drag gradient
  15185. * @param gradient defines the gradient to use (between 0 and 1)
  15186. * @param factor defines the drag value to affect to the specified gradient
  15187. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15188. * @returns the current particle system
  15189. */
  15190. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15191. /**
  15192. * Remove a specific drag gradient
  15193. * @param gradient defines the gradient to remove
  15194. * @returns the current particle system
  15195. */
  15196. removeDragGradient(gradient: number): IParticleSystem;
  15197. /**
  15198. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15199. * @param gradient defines the gradient to use (between 0 and 1)
  15200. * @param factor defines the emit rate value to affect to the specified gradient
  15201. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15202. * @returns the current particle system
  15203. */
  15204. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15205. /**
  15206. * Remove a specific emit rate gradient
  15207. * @param gradient defines the gradient to remove
  15208. * @returns the current particle system
  15209. */
  15210. removeEmitRateGradient(gradient: number): IParticleSystem;
  15211. /**
  15212. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15213. * @param gradient defines the gradient to use (between 0 and 1)
  15214. * @param factor defines the start size value to affect to the specified gradient
  15215. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15216. * @returns the current particle system
  15217. */
  15218. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15219. /**
  15220. * Remove a specific start size gradient
  15221. * @param gradient defines the gradient to remove
  15222. * @returns the current particle system
  15223. */
  15224. removeStartSizeGradient(gradient: number): IParticleSystem;
  15225. private _createRampGradientTexture;
  15226. /**
  15227. * Gets the current list of ramp gradients.
  15228. * You must use addRampGradient and removeRampGradient to udpate this list
  15229. * @returns the list of ramp gradients
  15230. */
  15231. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15232. /**
  15233. * Adds a new ramp gradient used to remap particle colors
  15234. * @param gradient defines the gradient to use (between 0 and 1)
  15235. * @param color defines the color to affect to the specified gradient
  15236. * @returns the current particle system
  15237. */
  15238. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15239. /**
  15240. * Remove a specific ramp gradient
  15241. * @param gradient defines the gradient to remove
  15242. * @returns the current particle system
  15243. */
  15244. removeRampGradient(gradient: number): ParticleSystem;
  15245. /**
  15246. * Adds a new color gradient
  15247. * @param gradient defines the gradient to use (between 0 and 1)
  15248. * @param color1 defines the color to affect to the specified gradient
  15249. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15250. * @returns this particle system
  15251. */
  15252. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15253. /**
  15254. * Remove a specific color gradient
  15255. * @param gradient defines the gradient to remove
  15256. * @returns this particle system
  15257. */
  15258. removeColorGradient(gradient: number): IParticleSystem;
  15259. private _fetchR;
  15260. protected _reset(): void;
  15261. private _resetEffect;
  15262. private _createVertexBuffers;
  15263. private _createIndexBuffer;
  15264. /**
  15265. * Gets the maximum number of particles active at the same time.
  15266. * @returns The max number of active particles.
  15267. */
  15268. getCapacity(): number;
  15269. /**
  15270. * Gets whether there are still active particles in the system.
  15271. * @returns True if it is alive, otherwise false.
  15272. */
  15273. isAlive(): boolean;
  15274. /**
  15275. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15276. * @returns True if it has been started, otherwise false.
  15277. */
  15278. isStarted(): boolean;
  15279. private _prepareSubEmitterInternalArray;
  15280. /**
  15281. * Starts the particle system and begins to emit
  15282. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15283. */
  15284. start(delay?: number): void;
  15285. /**
  15286. * Stops the particle system.
  15287. * @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.
  15288. */
  15289. stop(stopSubEmitters?: boolean): void;
  15290. /**
  15291. * Remove all active particles
  15292. */
  15293. reset(): void;
  15294. /**
  15295. * @hidden (for internal use only)
  15296. */
  15297. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15298. /**
  15299. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15300. * Its lifetime will start back at 0.
  15301. */
  15302. recycleParticle: (particle: Particle) => void;
  15303. private _stopSubEmitters;
  15304. private _createParticle;
  15305. private _removeFromRoot;
  15306. private _emitFromParticle;
  15307. private _update;
  15308. /** @hidden */
  15309. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15310. /** @hidden */
  15311. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15312. /** @hidden */
  15313. private _getEffect;
  15314. /**
  15315. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15316. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15317. */
  15318. animate(preWarmOnly?: boolean): void;
  15319. private _appendParticleVertices;
  15320. /**
  15321. * Rebuilds the particle system.
  15322. */
  15323. rebuild(): void;
  15324. /**
  15325. * Is this system ready to be used/rendered
  15326. * @return true if the system is ready
  15327. */
  15328. isReady(): boolean;
  15329. private _render;
  15330. /**
  15331. * Renders the particle system in its current state.
  15332. * @returns the current number of particles
  15333. */
  15334. render(): number;
  15335. /**
  15336. * Disposes the particle system and free the associated resources
  15337. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15338. */
  15339. dispose(disposeTexture?: boolean): void;
  15340. /**
  15341. * Clones the particle system.
  15342. * @param name The name of the cloned object
  15343. * @param newEmitter The new emitter to use
  15344. * @returns the cloned particle system
  15345. */
  15346. clone(name: string, newEmitter: any): ParticleSystem;
  15347. /**
  15348. * Serializes the particle system to a JSON object.
  15349. * @returns the JSON object
  15350. */
  15351. serialize(): any;
  15352. /** @hidden */
  15353. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15354. /** @hidden */
  15355. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15356. /**
  15357. * Parses a JSON object to create a particle system.
  15358. * @param parsedParticleSystem The JSON object to parse
  15359. * @param scene The scene to create the particle system in
  15360. * @param rootUrl The root url to use to load external dependencies like texture
  15361. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15362. * @returns the Parsed particle system
  15363. */
  15364. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15365. }
  15366. }
  15367. declare module BABYLON {
  15368. /**
  15369. * A particle represents one of the element emitted by a particle system.
  15370. * This is mainly define by its coordinates, direction, velocity and age.
  15371. */
  15372. export class Particle {
  15373. /**
  15374. * The particle system the particle belongs to.
  15375. */
  15376. particleSystem: ParticleSystem;
  15377. private static _Count;
  15378. /**
  15379. * Unique ID of the particle
  15380. */
  15381. id: number;
  15382. /**
  15383. * The world position of the particle in the scene.
  15384. */
  15385. position: Vector3;
  15386. /**
  15387. * The world direction of the particle in the scene.
  15388. */
  15389. direction: Vector3;
  15390. /**
  15391. * The color of the particle.
  15392. */
  15393. color: Color4;
  15394. /**
  15395. * The color change of the particle per step.
  15396. */
  15397. colorStep: Color4;
  15398. /**
  15399. * Defines how long will the life of the particle be.
  15400. */
  15401. lifeTime: number;
  15402. /**
  15403. * The current age of the particle.
  15404. */
  15405. age: number;
  15406. /**
  15407. * The current size of the particle.
  15408. */
  15409. size: number;
  15410. /**
  15411. * The current scale of the particle.
  15412. */
  15413. scale: Vector2;
  15414. /**
  15415. * The current angle of the particle.
  15416. */
  15417. angle: number;
  15418. /**
  15419. * Defines how fast is the angle changing.
  15420. */
  15421. angularSpeed: number;
  15422. /**
  15423. * Defines the cell index used by the particle to be rendered from a sprite.
  15424. */
  15425. cellIndex: number;
  15426. /**
  15427. * The information required to support color remapping
  15428. */
  15429. remapData: Vector4;
  15430. /** @hidden */
  15431. _randomCellOffset?: number;
  15432. /** @hidden */
  15433. _initialDirection: Nullable<Vector3>;
  15434. /** @hidden */
  15435. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15436. /** @hidden */
  15437. _initialStartSpriteCellID: number;
  15438. /** @hidden */
  15439. _initialEndSpriteCellID: number;
  15440. /** @hidden */
  15441. _currentColorGradient: Nullable<ColorGradient>;
  15442. /** @hidden */
  15443. _currentColor1: Color4;
  15444. /** @hidden */
  15445. _currentColor2: Color4;
  15446. /** @hidden */
  15447. _currentSizeGradient: Nullable<FactorGradient>;
  15448. /** @hidden */
  15449. _currentSize1: number;
  15450. /** @hidden */
  15451. _currentSize2: number;
  15452. /** @hidden */
  15453. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15454. /** @hidden */
  15455. _currentAngularSpeed1: number;
  15456. /** @hidden */
  15457. _currentAngularSpeed2: number;
  15458. /** @hidden */
  15459. _currentVelocityGradient: Nullable<FactorGradient>;
  15460. /** @hidden */
  15461. _currentVelocity1: number;
  15462. /** @hidden */
  15463. _currentVelocity2: number;
  15464. /** @hidden */
  15465. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15466. /** @hidden */
  15467. _currentLimitVelocity1: number;
  15468. /** @hidden */
  15469. _currentLimitVelocity2: number;
  15470. /** @hidden */
  15471. _currentDragGradient: Nullable<FactorGradient>;
  15472. /** @hidden */
  15473. _currentDrag1: number;
  15474. /** @hidden */
  15475. _currentDrag2: number;
  15476. /** @hidden */
  15477. _randomNoiseCoordinates1: Vector3;
  15478. /** @hidden */
  15479. _randomNoiseCoordinates2: Vector3;
  15480. /**
  15481. * Creates a new instance Particle
  15482. * @param particleSystem the particle system the particle belongs to
  15483. */
  15484. constructor(
  15485. /**
  15486. * The particle system the particle belongs to.
  15487. */
  15488. particleSystem: ParticleSystem);
  15489. private updateCellInfoFromSystem;
  15490. /**
  15491. * Defines how the sprite cell index is updated for the particle
  15492. */
  15493. updateCellIndex(): void;
  15494. /** @hidden */
  15495. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15496. /** @hidden */
  15497. _inheritParticleInfoToSubEmitters(): void;
  15498. /** @hidden */
  15499. _reset(): void;
  15500. /**
  15501. * Copy the properties of particle to another one.
  15502. * @param other the particle to copy the information to.
  15503. */
  15504. copyTo(other: Particle): void;
  15505. }
  15506. }
  15507. declare module BABYLON {
  15508. /**
  15509. * Particle emitter represents a volume emitting particles.
  15510. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15511. */
  15512. export interface IParticleEmitterType {
  15513. /**
  15514. * Called by the particle System when the direction is computed for the created particle.
  15515. * @param worldMatrix is the world matrix of the particle system
  15516. * @param directionToUpdate is the direction vector to update with the result
  15517. * @param particle is the particle we are computed the direction for
  15518. */
  15519. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15520. /**
  15521. * Called by the particle System when the position is computed for the created particle.
  15522. * @param worldMatrix is the world matrix of the particle system
  15523. * @param positionToUpdate is the position vector to update with the result
  15524. * @param particle is the particle we are computed the position for
  15525. */
  15526. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15527. /**
  15528. * Clones the current emitter and returns a copy of it
  15529. * @returns the new emitter
  15530. */
  15531. clone(): IParticleEmitterType;
  15532. /**
  15533. * Called by the GPUParticleSystem to setup the update shader
  15534. * @param effect defines the update shader
  15535. */
  15536. applyToShader(effect: Effect): void;
  15537. /**
  15538. * Returns a string to use to update the GPU particles update shader
  15539. * @returns the effect defines string
  15540. */
  15541. getEffectDefines(): string;
  15542. /**
  15543. * Returns a string representing the class name
  15544. * @returns a string containing the class name
  15545. */
  15546. getClassName(): string;
  15547. /**
  15548. * Serializes the particle system to a JSON object.
  15549. * @returns the JSON object
  15550. */
  15551. serialize(): any;
  15552. /**
  15553. * Parse properties from a JSON object
  15554. * @param serializationObject defines the JSON object
  15555. */
  15556. parse(serializationObject: any): void;
  15557. }
  15558. }
  15559. declare module BABYLON {
  15560. /**
  15561. * Particle emitter emitting particles from the inside of a box.
  15562. * It emits the particles randomly between 2 given directions.
  15563. */
  15564. export class BoxParticleEmitter implements IParticleEmitterType {
  15565. /**
  15566. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15567. */
  15568. direction1: Vector3;
  15569. /**
  15570. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15571. */
  15572. direction2: Vector3;
  15573. /**
  15574. * 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.
  15575. */
  15576. minEmitBox: Vector3;
  15577. /**
  15578. * 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.
  15579. */
  15580. maxEmitBox: Vector3;
  15581. /**
  15582. * Creates a new instance BoxParticleEmitter
  15583. */
  15584. constructor();
  15585. /**
  15586. * Called by the particle System when the direction is computed for the created particle.
  15587. * @param worldMatrix is the world matrix of the particle system
  15588. * @param directionToUpdate is the direction vector to update with the result
  15589. * @param particle is the particle we are computed the direction for
  15590. */
  15591. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15592. /**
  15593. * Called by the particle System when the position is computed for the created particle.
  15594. * @param worldMatrix is the world matrix of the particle system
  15595. * @param positionToUpdate is the position vector to update with the result
  15596. * @param particle is the particle we are computed the position for
  15597. */
  15598. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15599. /**
  15600. * Clones the current emitter and returns a copy of it
  15601. * @returns the new emitter
  15602. */
  15603. clone(): BoxParticleEmitter;
  15604. /**
  15605. * Called by the GPUParticleSystem to setup the update shader
  15606. * @param effect defines the update shader
  15607. */
  15608. applyToShader(effect: Effect): void;
  15609. /**
  15610. * Returns a string to use to update the GPU particles update shader
  15611. * @returns a string containng the defines string
  15612. */
  15613. getEffectDefines(): string;
  15614. /**
  15615. * Returns the string "BoxParticleEmitter"
  15616. * @returns a string containing the class name
  15617. */
  15618. getClassName(): string;
  15619. /**
  15620. * Serializes the particle system to a JSON object.
  15621. * @returns the JSON object
  15622. */
  15623. serialize(): any;
  15624. /**
  15625. * Parse properties from a JSON object
  15626. * @param serializationObject defines the JSON object
  15627. */
  15628. parse(serializationObject: any): void;
  15629. }
  15630. }
  15631. declare module BABYLON {
  15632. /**
  15633. * Particle emitter emitting particles from the inside of a cone.
  15634. * It emits the particles alongside the cone volume from the base to the particle.
  15635. * The emission direction might be randomized.
  15636. */
  15637. export class ConeParticleEmitter implements IParticleEmitterType {
  15638. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15639. directionRandomizer: number;
  15640. private _radius;
  15641. private _angle;
  15642. private _height;
  15643. /**
  15644. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15645. */
  15646. radiusRange: number;
  15647. /**
  15648. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15649. */
  15650. heightRange: number;
  15651. /**
  15652. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15653. */
  15654. emitFromSpawnPointOnly: boolean;
  15655. /**
  15656. * Gets or sets the radius of the emission cone
  15657. */
  15658. radius: number;
  15659. /**
  15660. * Gets or sets the angle of the emission cone
  15661. */
  15662. angle: number;
  15663. private _buildHeight;
  15664. /**
  15665. * Creates a new instance ConeParticleEmitter
  15666. * @param radius the radius of the emission cone (1 by default)
  15667. * @param angle the cone base angle (PI by default)
  15668. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15669. */
  15670. constructor(radius?: number, angle?: number,
  15671. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15672. directionRandomizer?: number);
  15673. /**
  15674. * Called by the particle System when the direction is computed for the created particle.
  15675. * @param worldMatrix is the world matrix of the particle system
  15676. * @param directionToUpdate is the direction vector to update with the result
  15677. * @param particle is the particle we are computed the direction for
  15678. */
  15679. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15680. /**
  15681. * Called by the particle System when the position is computed for the created particle.
  15682. * @param worldMatrix is the world matrix of the particle system
  15683. * @param positionToUpdate is the position vector to update with the result
  15684. * @param particle is the particle we are computed the position for
  15685. */
  15686. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15687. /**
  15688. * Clones the current emitter and returns a copy of it
  15689. * @returns the new emitter
  15690. */
  15691. clone(): ConeParticleEmitter;
  15692. /**
  15693. * Called by the GPUParticleSystem to setup the update shader
  15694. * @param effect defines the update shader
  15695. */
  15696. applyToShader(effect: Effect): void;
  15697. /**
  15698. * Returns a string to use to update the GPU particles update shader
  15699. * @returns a string containng the defines string
  15700. */
  15701. getEffectDefines(): string;
  15702. /**
  15703. * Returns the string "ConeParticleEmitter"
  15704. * @returns a string containing the class name
  15705. */
  15706. getClassName(): string;
  15707. /**
  15708. * Serializes the particle system to a JSON object.
  15709. * @returns the JSON object
  15710. */
  15711. serialize(): any;
  15712. /**
  15713. * Parse properties from a JSON object
  15714. * @param serializationObject defines the JSON object
  15715. */
  15716. parse(serializationObject: any): void;
  15717. }
  15718. }
  15719. declare module BABYLON {
  15720. /**
  15721. * Particle emitter emitting particles from the inside of a cylinder.
  15722. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15723. */
  15724. export class CylinderParticleEmitter implements IParticleEmitterType {
  15725. /**
  15726. * The radius of the emission cylinder.
  15727. */
  15728. radius: number;
  15729. /**
  15730. * The height of the emission cylinder.
  15731. */
  15732. height: number;
  15733. /**
  15734. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15735. */
  15736. radiusRange: number;
  15737. /**
  15738. * How much to randomize the particle direction [0-1].
  15739. */
  15740. directionRandomizer: number;
  15741. /**
  15742. * Creates a new instance CylinderParticleEmitter
  15743. * @param radius the radius of the emission cylinder (1 by default)
  15744. * @param height the height of the emission cylinder (1 by default)
  15745. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15746. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15747. */
  15748. constructor(
  15749. /**
  15750. * The radius of the emission cylinder.
  15751. */
  15752. radius?: number,
  15753. /**
  15754. * The height of the emission cylinder.
  15755. */
  15756. height?: number,
  15757. /**
  15758. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15759. */
  15760. radiusRange?: number,
  15761. /**
  15762. * How much to randomize the particle direction [0-1].
  15763. */
  15764. directionRandomizer?: number);
  15765. /**
  15766. * Called by the particle System when the direction is computed for the created particle.
  15767. * @param worldMatrix is the world matrix of the particle system
  15768. * @param directionToUpdate is the direction vector to update with the result
  15769. * @param particle is the particle we are computed the direction for
  15770. */
  15771. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15772. /**
  15773. * Called by the particle System when the position is computed for the created particle.
  15774. * @param worldMatrix is the world matrix of the particle system
  15775. * @param positionToUpdate is the position vector to update with the result
  15776. * @param particle is the particle we are computed the position for
  15777. */
  15778. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15779. /**
  15780. * Clones the current emitter and returns a copy of it
  15781. * @returns the new emitter
  15782. */
  15783. clone(): CylinderParticleEmitter;
  15784. /**
  15785. * Called by the GPUParticleSystem to setup the update shader
  15786. * @param effect defines the update shader
  15787. */
  15788. applyToShader(effect: Effect): void;
  15789. /**
  15790. * Returns a string to use to update the GPU particles update shader
  15791. * @returns a string containng the defines string
  15792. */
  15793. getEffectDefines(): string;
  15794. /**
  15795. * Returns the string "CylinderParticleEmitter"
  15796. * @returns a string containing the class name
  15797. */
  15798. getClassName(): string;
  15799. /**
  15800. * Serializes the particle system to a JSON object.
  15801. * @returns the JSON object
  15802. */
  15803. serialize(): any;
  15804. /**
  15805. * Parse properties from a JSON object
  15806. * @param serializationObject defines the JSON object
  15807. */
  15808. parse(serializationObject: any): void;
  15809. }
  15810. /**
  15811. * Particle emitter emitting particles from the inside of a cylinder.
  15812. * It emits the particles randomly between two vectors.
  15813. */
  15814. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15815. /**
  15816. * The min limit of the emission direction.
  15817. */
  15818. direction1: Vector3;
  15819. /**
  15820. * The max limit of the emission direction.
  15821. */
  15822. direction2: Vector3;
  15823. /**
  15824. * Creates a new instance CylinderDirectedParticleEmitter
  15825. * @param radius the radius of the emission cylinder (1 by default)
  15826. * @param height the height of the emission cylinder (1 by default)
  15827. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15828. * @param direction1 the min limit of the emission direction (up vector by default)
  15829. * @param direction2 the max limit of the emission direction (up vector by default)
  15830. */
  15831. constructor(radius?: number, height?: number, radiusRange?: number,
  15832. /**
  15833. * The min limit of the emission direction.
  15834. */
  15835. direction1?: Vector3,
  15836. /**
  15837. * The max limit of the emission direction.
  15838. */
  15839. direction2?: Vector3);
  15840. /**
  15841. * Called by the particle System when the direction is computed for the created particle.
  15842. * @param worldMatrix is the world matrix of the particle system
  15843. * @param directionToUpdate is the direction vector to update with the result
  15844. * @param particle is the particle we are computed the direction for
  15845. */
  15846. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15847. /**
  15848. * Clones the current emitter and returns a copy of it
  15849. * @returns the new emitter
  15850. */
  15851. clone(): CylinderDirectedParticleEmitter;
  15852. /**
  15853. * Called by the GPUParticleSystem to setup the update shader
  15854. * @param effect defines the update shader
  15855. */
  15856. applyToShader(effect: Effect): void;
  15857. /**
  15858. * Returns a string to use to update the GPU particles update shader
  15859. * @returns a string containng the defines string
  15860. */
  15861. getEffectDefines(): string;
  15862. /**
  15863. * Returns the string "CylinderDirectedParticleEmitter"
  15864. * @returns a string containing the class name
  15865. */
  15866. getClassName(): string;
  15867. /**
  15868. * Serializes the particle system to a JSON object.
  15869. * @returns the JSON object
  15870. */
  15871. serialize(): any;
  15872. /**
  15873. * Parse properties from a JSON object
  15874. * @param serializationObject defines the JSON object
  15875. */
  15876. parse(serializationObject: any): void;
  15877. }
  15878. }
  15879. declare module BABYLON {
  15880. /**
  15881. * Particle emitter emitting particles from the inside of a hemisphere.
  15882. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15883. */
  15884. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15885. /**
  15886. * The radius of the emission hemisphere.
  15887. */
  15888. radius: number;
  15889. /**
  15890. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15891. */
  15892. radiusRange: number;
  15893. /**
  15894. * How much to randomize the particle direction [0-1].
  15895. */
  15896. directionRandomizer: number;
  15897. /**
  15898. * Creates a new instance HemisphericParticleEmitter
  15899. * @param radius the radius of the emission hemisphere (1 by default)
  15900. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15901. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15902. */
  15903. constructor(
  15904. /**
  15905. * The radius of the emission hemisphere.
  15906. */
  15907. radius?: number,
  15908. /**
  15909. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15910. */
  15911. radiusRange?: number,
  15912. /**
  15913. * How much to randomize the particle direction [0-1].
  15914. */
  15915. directionRandomizer?: number);
  15916. /**
  15917. * Called by the particle System when the direction is computed for the created particle.
  15918. * @param worldMatrix is the world matrix of the particle system
  15919. * @param directionToUpdate is the direction vector to update with the result
  15920. * @param particle is the particle we are computed the direction for
  15921. */
  15922. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15923. /**
  15924. * Called by the particle System when the position is computed for the created particle.
  15925. * @param worldMatrix is the world matrix of the particle system
  15926. * @param positionToUpdate is the position vector to update with the result
  15927. * @param particle is the particle we are computed the position for
  15928. */
  15929. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15930. /**
  15931. * Clones the current emitter and returns a copy of it
  15932. * @returns the new emitter
  15933. */
  15934. clone(): HemisphericParticleEmitter;
  15935. /**
  15936. * Called by the GPUParticleSystem to setup the update shader
  15937. * @param effect defines the update shader
  15938. */
  15939. applyToShader(effect: Effect): void;
  15940. /**
  15941. * Returns a string to use to update the GPU particles update shader
  15942. * @returns a string containng the defines string
  15943. */
  15944. getEffectDefines(): string;
  15945. /**
  15946. * Returns the string "HemisphericParticleEmitter"
  15947. * @returns a string containing the class name
  15948. */
  15949. getClassName(): string;
  15950. /**
  15951. * Serializes the particle system to a JSON object.
  15952. * @returns the JSON object
  15953. */
  15954. serialize(): any;
  15955. /**
  15956. * Parse properties from a JSON object
  15957. * @param serializationObject defines the JSON object
  15958. */
  15959. parse(serializationObject: any): void;
  15960. }
  15961. }
  15962. declare module BABYLON {
  15963. /**
  15964. * Particle emitter emitting particles from a point.
  15965. * It emits the particles randomly between 2 given directions.
  15966. */
  15967. export class PointParticleEmitter implements IParticleEmitterType {
  15968. /**
  15969. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15970. */
  15971. direction1: Vector3;
  15972. /**
  15973. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15974. */
  15975. direction2: Vector3;
  15976. /**
  15977. * Creates a new instance PointParticleEmitter
  15978. */
  15979. constructor();
  15980. /**
  15981. * Called by the particle System when the direction is computed for the created particle.
  15982. * @param worldMatrix is the world matrix of the particle system
  15983. * @param directionToUpdate is the direction vector to update with the result
  15984. * @param particle is the particle we are computed the direction for
  15985. */
  15986. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15987. /**
  15988. * Called by the particle System when the position is computed for the created particle.
  15989. * @param worldMatrix is the world matrix of the particle system
  15990. * @param positionToUpdate is the position vector to update with the result
  15991. * @param particle is the particle we are computed the position for
  15992. */
  15993. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15994. /**
  15995. * Clones the current emitter and returns a copy of it
  15996. * @returns the new emitter
  15997. */
  15998. clone(): PointParticleEmitter;
  15999. /**
  16000. * Called by the GPUParticleSystem to setup the update shader
  16001. * @param effect defines the update shader
  16002. */
  16003. applyToShader(effect: Effect): void;
  16004. /**
  16005. * Returns a string to use to update the GPU particles update shader
  16006. * @returns a string containng the defines string
  16007. */
  16008. getEffectDefines(): string;
  16009. /**
  16010. * Returns the string "PointParticleEmitter"
  16011. * @returns a string containing the class name
  16012. */
  16013. getClassName(): string;
  16014. /**
  16015. * Serializes the particle system to a JSON object.
  16016. * @returns the JSON object
  16017. */
  16018. serialize(): any;
  16019. /**
  16020. * Parse properties from a JSON object
  16021. * @param serializationObject defines the JSON object
  16022. */
  16023. parse(serializationObject: any): void;
  16024. }
  16025. }
  16026. declare module BABYLON {
  16027. /**
  16028. * Particle emitter emitting particles from the inside of a sphere.
  16029. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16030. */
  16031. export class SphereParticleEmitter implements IParticleEmitterType {
  16032. /**
  16033. * The radius of the emission sphere.
  16034. */
  16035. radius: number;
  16036. /**
  16037. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16038. */
  16039. radiusRange: number;
  16040. /**
  16041. * How much to randomize the particle direction [0-1].
  16042. */
  16043. directionRandomizer: number;
  16044. /**
  16045. * Creates a new instance SphereParticleEmitter
  16046. * @param radius the radius of the emission sphere (1 by default)
  16047. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16048. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16049. */
  16050. constructor(
  16051. /**
  16052. * The radius of the emission sphere.
  16053. */
  16054. radius?: number,
  16055. /**
  16056. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16057. */
  16058. radiusRange?: number,
  16059. /**
  16060. * How much to randomize the particle direction [0-1].
  16061. */
  16062. directionRandomizer?: number);
  16063. /**
  16064. * Called by the particle System when the direction is computed for the created particle.
  16065. * @param worldMatrix is the world matrix of the particle system
  16066. * @param directionToUpdate is the direction vector to update with the result
  16067. * @param particle is the particle we are computed the direction for
  16068. */
  16069. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16070. /**
  16071. * Called by the particle System when the position is computed for the created particle.
  16072. * @param worldMatrix is the world matrix of the particle system
  16073. * @param positionToUpdate is the position vector to update with the result
  16074. * @param particle is the particle we are computed the position for
  16075. */
  16076. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16077. /**
  16078. * Clones the current emitter and returns a copy of it
  16079. * @returns the new emitter
  16080. */
  16081. clone(): SphereParticleEmitter;
  16082. /**
  16083. * Called by the GPUParticleSystem to setup the update shader
  16084. * @param effect defines the update shader
  16085. */
  16086. applyToShader(effect: Effect): void;
  16087. /**
  16088. * Returns a string to use to update the GPU particles update shader
  16089. * @returns a string containng the defines string
  16090. */
  16091. getEffectDefines(): string;
  16092. /**
  16093. * Returns the string "SphereParticleEmitter"
  16094. * @returns a string containing the class name
  16095. */
  16096. getClassName(): string;
  16097. /**
  16098. * Serializes the particle system to a JSON object.
  16099. * @returns the JSON object
  16100. */
  16101. serialize(): any;
  16102. /**
  16103. * Parse properties from a JSON object
  16104. * @param serializationObject defines the JSON object
  16105. */
  16106. parse(serializationObject: any): void;
  16107. }
  16108. /**
  16109. * Particle emitter emitting particles from the inside of a sphere.
  16110. * It emits the particles randomly between two vectors.
  16111. */
  16112. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16113. /**
  16114. * The min limit of the emission direction.
  16115. */
  16116. direction1: Vector3;
  16117. /**
  16118. * The max limit of the emission direction.
  16119. */
  16120. direction2: Vector3;
  16121. /**
  16122. * Creates a new instance SphereDirectedParticleEmitter
  16123. * @param radius the radius of the emission sphere (1 by default)
  16124. * @param direction1 the min limit of the emission direction (up vector by default)
  16125. * @param direction2 the max limit of the emission direction (up vector by default)
  16126. */
  16127. constructor(radius?: number,
  16128. /**
  16129. * The min limit of the emission direction.
  16130. */
  16131. direction1?: Vector3,
  16132. /**
  16133. * The max limit of the emission direction.
  16134. */
  16135. direction2?: Vector3);
  16136. /**
  16137. * Called by the particle System when the direction is computed for the created particle.
  16138. * @param worldMatrix is the world matrix of the particle system
  16139. * @param directionToUpdate is the direction vector to update with the result
  16140. * @param particle is the particle we are computed the direction for
  16141. */
  16142. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16143. /**
  16144. * Clones the current emitter and returns a copy of it
  16145. * @returns the new emitter
  16146. */
  16147. clone(): SphereDirectedParticleEmitter;
  16148. /**
  16149. * Called by the GPUParticleSystem to setup the update shader
  16150. * @param effect defines the update shader
  16151. */
  16152. applyToShader(effect: Effect): void;
  16153. /**
  16154. * Returns a string to use to update the GPU particles update shader
  16155. * @returns a string containng the defines string
  16156. */
  16157. getEffectDefines(): string;
  16158. /**
  16159. * Returns the string "SphereDirectedParticleEmitter"
  16160. * @returns a string containing the class name
  16161. */
  16162. getClassName(): string;
  16163. /**
  16164. * Serializes the particle system to a JSON object.
  16165. * @returns the JSON object
  16166. */
  16167. serialize(): any;
  16168. /**
  16169. * Parse properties from a JSON object
  16170. * @param serializationObject defines the JSON object
  16171. */
  16172. parse(serializationObject: any): void;
  16173. }
  16174. }
  16175. declare module BABYLON {
  16176. /**
  16177. * Interface representing a particle system in Babylon.js.
  16178. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16179. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16180. */
  16181. export interface IParticleSystem {
  16182. /**
  16183. * List of animations used by the particle system.
  16184. */
  16185. animations: Animation[];
  16186. /**
  16187. * The id of the Particle system.
  16188. */
  16189. id: string;
  16190. /**
  16191. * The name of the Particle system.
  16192. */
  16193. name: string;
  16194. /**
  16195. * The emitter represents the Mesh or position we are attaching the particle system to.
  16196. */
  16197. emitter: Nullable<AbstractMesh | Vector3>;
  16198. /**
  16199. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16200. */
  16201. isBillboardBased: boolean;
  16202. /**
  16203. * The rendering group used by the Particle system to chose when to render.
  16204. */
  16205. renderingGroupId: number;
  16206. /**
  16207. * The layer mask we are rendering the particles through.
  16208. */
  16209. layerMask: number;
  16210. /**
  16211. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16212. */
  16213. updateSpeed: number;
  16214. /**
  16215. * The amount of time the particle system is running (depends of the overall update speed).
  16216. */
  16217. targetStopDuration: number;
  16218. /**
  16219. * The texture used to render each particle. (this can be a spritesheet)
  16220. */
  16221. particleTexture: Nullable<Texture>;
  16222. /**
  16223. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16224. */
  16225. blendMode: number;
  16226. /**
  16227. * Minimum life time of emitting particles.
  16228. */
  16229. minLifeTime: number;
  16230. /**
  16231. * Maximum life time of emitting particles.
  16232. */
  16233. maxLifeTime: number;
  16234. /**
  16235. * Minimum Size of emitting particles.
  16236. */
  16237. minSize: number;
  16238. /**
  16239. * Maximum Size of emitting particles.
  16240. */
  16241. maxSize: number;
  16242. /**
  16243. * Minimum scale of emitting particles on X axis.
  16244. */
  16245. minScaleX: number;
  16246. /**
  16247. * Maximum scale of emitting particles on X axis.
  16248. */
  16249. maxScaleX: number;
  16250. /**
  16251. * Minimum scale of emitting particles on Y axis.
  16252. */
  16253. minScaleY: number;
  16254. /**
  16255. * Maximum scale of emitting particles on Y axis.
  16256. */
  16257. maxScaleY: number;
  16258. /**
  16259. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16260. */
  16261. color1: Color4;
  16262. /**
  16263. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16264. */
  16265. color2: Color4;
  16266. /**
  16267. * Color the particle will have at the end of its lifetime.
  16268. */
  16269. colorDead: Color4;
  16270. /**
  16271. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16272. */
  16273. emitRate: number;
  16274. /**
  16275. * You can use gravity if you want to give an orientation to your particles.
  16276. */
  16277. gravity: Vector3;
  16278. /**
  16279. * Minimum power of emitting particles.
  16280. */
  16281. minEmitPower: number;
  16282. /**
  16283. * Maximum power of emitting particles.
  16284. */
  16285. maxEmitPower: number;
  16286. /**
  16287. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16288. */
  16289. minAngularSpeed: number;
  16290. /**
  16291. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16292. */
  16293. maxAngularSpeed: number;
  16294. /**
  16295. * Gets or sets the minimal initial rotation in radians.
  16296. */
  16297. minInitialRotation: number;
  16298. /**
  16299. * Gets or sets the maximal initial rotation in radians.
  16300. */
  16301. maxInitialRotation: number;
  16302. /**
  16303. * The particle emitter type defines the emitter used by the particle system.
  16304. * It can be for example box, sphere, or cone...
  16305. */
  16306. particleEmitterType: Nullable<IParticleEmitterType>;
  16307. /**
  16308. * Defines the delay in milliseconds before starting the system (0 by default)
  16309. */
  16310. startDelay: number;
  16311. /**
  16312. * 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
  16313. */
  16314. preWarmCycles: number;
  16315. /**
  16316. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16317. */
  16318. preWarmStepOffset: number;
  16319. /**
  16320. * 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)
  16321. */
  16322. spriteCellChangeSpeed: number;
  16323. /**
  16324. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16325. */
  16326. startSpriteCellID: number;
  16327. /**
  16328. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16329. */
  16330. endSpriteCellID: number;
  16331. /**
  16332. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16333. */
  16334. spriteCellWidth: number;
  16335. /**
  16336. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16337. */
  16338. spriteCellHeight: number;
  16339. /**
  16340. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16341. */
  16342. spriteRandomStartCell: boolean;
  16343. /**
  16344. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16345. */
  16346. isAnimationSheetEnabled: boolean;
  16347. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16348. translationPivot: Vector2;
  16349. /**
  16350. * Gets or sets a texture used to add random noise to particle positions
  16351. */
  16352. noiseTexture: Nullable<BaseTexture>;
  16353. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16354. noiseStrength: Vector3;
  16355. /**
  16356. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16357. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16358. */
  16359. billboardMode: number;
  16360. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16361. limitVelocityDamping: number;
  16362. /**
  16363. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16364. */
  16365. beginAnimationOnStart: boolean;
  16366. /**
  16367. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16368. */
  16369. beginAnimationFrom: number;
  16370. /**
  16371. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16372. */
  16373. beginAnimationTo: number;
  16374. /**
  16375. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16376. */
  16377. beginAnimationLoop: boolean;
  16378. /**
  16379. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16380. */
  16381. disposeOnStop: boolean;
  16382. /**
  16383. * Gets the maximum number of particles active at the same time.
  16384. * @returns The max number of active particles.
  16385. */
  16386. getCapacity(): number;
  16387. /**
  16388. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16389. * @returns True if it has been started, otherwise false.
  16390. */
  16391. isStarted(): boolean;
  16392. /**
  16393. * Animates the particle system for this frame.
  16394. */
  16395. animate(): void;
  16396. /**
  16397. * Renders the particle system in its current state.
  16398. * @returns the current number of particles
  16399. */
  16400. render(): number;
  16401. /**
  16402. * Dispose the particle system and frees its associated resources.
  16403. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16404. */
  16405. dispose(disposeTexture?: boolean): void;
  16406. /**
  16407. * Clones the particle system.
  16408. * @param name The name of the cloned object
  16409. * @param newEmitter The new emitter to use
  16410. * @returns the cloned particle system
  16411. */
  16412. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16413. /**
  16414. * Serializes the particle system to a JSON object.
  16415. * @returns the JSON object
  16416. */
  16417. serialize(): any;
  16418. /**
  16419. * Rebuild the particle system
  16420. */
  16421. rebuild(): void;
  16422. /**
  16423. * Starts the particle system and begins to emit
  16424. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16425. */
  16426. start(delay?: number): void;
  16427. /**
  16428. * Stops the particle system.
  16429. */
  16430. stop(): void;
  16431. /**
  16432. * Remove all active particles
  16433. */
  16434. reset(): void;
  16435. /**
  16436. * Is this system ready to be used/rendered
  16437. * @return true if the system is ready
  16438. */
  16439. isReady(): boolean;
  16440. /**
  16441. * Adds a new color gradient
  16442. * @param gradient defines the gradient to use (between 0 and 1)
  16443. * @param color1 defines the color to affect to the specified gradient
  16444. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16445. * @returns the current particle system
  16446. */
  16447. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16448. /**
  16449. * Remove a specific color gradient
  16450. * @param gradient defines the gradient to remove
  16451. * @returns the current particle system
  16452. */
  16453. removeColorGradient(gradient: number): IParticleSystem;
  16454. /**
  16455. * Adds a new size gradient
  16456. * @param gradient defines the gradient to use (between 0 and 1)
  16457. * @param factor defines the size factor to affect to the specified gradient
  16458. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16459. * @returns the current particle system
  16460. */
  16461. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16462. /**
  16463. * Remove a specific size gradient
  16464. * @param gradient defines the gradient to remove
  16465. * @returns the current particle system
  16466. */
  16467. removeSizeGradient(gradient: number): IParticleSystem;
  16468. /**
  16469. * Gets the current list of color gradients.
  16470. * You must use addColorGradient and removeColorGradient to udpate this list
  16471. * @returns the list of color gradients
  16472. */
  16473. getColorGradients(): Nullable<Array<ColorGradient>>;
  16474. /**
  16475. * Gets the current list of size gradients.
  16476. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16477. * @returns the list of size gradients
  16478. */
  16479. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16480. /**
  16481. * Gets the current list of angular speed gradients.
  16482. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16483. * @returns the list of angular speed gradients
  16484. */
  16485. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16486. /**
  16487. * Adds a new angular speed gradient
  16488. * @param gradient defines the gradient to use (between 0 and 1)
  16489. * @param factor defines the angular speed to affect to the specified gradient
  16490. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16491. * @returns the current particle system
  16492. */
  16493. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16494. /**
  16495. * Remove a specific angular speed gradient
  16496. * @param gradient defines the gradient to remove
  16497. * @returns the current particle system
  16498. */
  16499. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16500. /**
  16501. * Gets the current list of velocity gradients.
  16502. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16503. * @returns the list of velocity gradients
  16504. */
  16505. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16506. /**
  16507. * Adds a new velocity gradient
  16508. * @param gradient defines the gradient to use (between 0 and 1)
  16509. * @param factor defines the velocity to affect to the specified gradient
  16510. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16511. * @returns the current particle system
  16512. */
  16513. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16514. /**
  16515. * Remove a specific velocity gradient
  16516. * @param gradient defines the gradient to remove
  16517. * @returns the current particle system
  16518. */
  16519. removeVelocityGradient(gradient: number): IParticleSystem;
  16520. /**
  16521. * Gets the current list of limit velocity gradients.
  16522. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16523. * @returns the list of limit velocity gradients
  16524. */
  16525. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16526. /**
  16527. * Adds a new limit velocity gradient
  16528. * @param gradient defines the gradient to use (between 0 and 1)
  16529. * @param factor defines the limit velocity to affect to the specified gradient
  16530. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16531. * @returns the current particle system
  16532. */
  16533. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16534. /**
  16535. * Remove a specific limit velocity gradient
  16536. * @param gradient defines the gradient to remove
  16537. * @returns the current particle system
  16538. */
  16539. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16540. /**
  16541. * Adds a new drag gradient
  16542. * @param gradient defines the gradient to use (between 0 and 1)
  16543. * @param factor defines the drag to affect to the specified gradient
  16544. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16545. * @returns the current particle system
  16546. */
  16547. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16548. /**
  16549. * Remove a specific drag gradient
  16550. * @param gradient defines the gradient to remove
  16551. * @returns the current particle system
  16552. */
  16553. removeDragGradient(gradient: number): IParticleSystem;
  16554. /**
  16555. * Gets the current list of drag gradients.
  16556. * You must use addDragGradient and removeDragGradient to udpate this list
  16557. * @returns the list of drag gradients
  16558. */
  16559. getDragGradients(): Nullable<Array<FactorGradient>>;
  16560. /**
  16561. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16562. * @param gradient defines the gradient to use (between 0 and 1)
  16563. * @param factor defines the emit rate to affect to the specified gradient
  16564. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16565. * @returns the current particle system
  16566. */
  16567. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16568. /**
  16569. * Remove a specific emit rate gradient
  16570. * @param gradient defines the gradient to remove
  16571. * @returns the current particle system
  16572. */
  16573. removeEmitRateGradient(gradient: number): IParticleSystem;
  16574. /**
  16575. * Gets the current list of emit rate gradients.
  16576. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16577. * @returns the list of emit rate gradients
  16578. */
  16579. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16580. /**
  16581. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16582. * @param gradient defines the gradient to use (between 0 and 1)
  16583. * @param factor defines the start size to affect to the specified gradient
  16584. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16585. * @returns the current particle system
  16586. */
  16587. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16588. /**
  16589. * Remove a specific start size gradient
  16590. * @param gradient defines the gradient to remove
  16591. * @returns the current particle system
  16592. */
  16593. removeStartSizeGradient(gradient: number): IParticleSystem;
  16594. /**
  16595. * Gets the current list of start size gradients.
  16596. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16597. * @returns the list of start size gradients
  16598. */
  16599. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16600. /**
  16601. * Adds a new life time gradient
  16602. * @param gradient defines the gradient to use (between 0 and 1)
  16603. * @param factor defines the life time factor to affect to the specified gradient
  16604. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16605. * @returns the current particle system
  16606. */
  16607. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16608. /**
  16609. * Remove a specific life time gradient
  16610. * @param gradient defines the gradient to remove
  16611. * @returns the current particle system
  16612. */
  16613. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16614. /**
  16615. * Gets the current list of life time gradients.
  16616. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16617. * @returns the list of life time gradients
  16618. */
  16619. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16620. /**
  16621. * Gets the current list of color gradients.
  16622. * You must use addColorGradient and removeColorGradient to udpate this list
  16623. * @returns the list of color gradients
  16624. */
  16625. getColorGradients(): Nullable<Array<ColorGradient>>;
  16626. /**
  16627. * Adds a new ramp gradient used to remap particle colors
  16628. * @param gradient defines the gradient to use (between 0 and 1)
  16629. * @param color defines the color to affect to the specified gradient
  16630. * @returns the current particle system
  16631. */
  16632. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16633. /**
  16634. * Gets the current list of ramp gradients.
  16635. * You must use addRampGradient and removeRampGradient to udpate this list
  16636. * @returns the list of ramp gradients
  16637. */
  16638. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16639. /** Gets or sets a boolean indicating that ramp gradients must be used
  16640. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16641. */
  16642. useRampGradients: boolean;
  16643. /**
  16644. * Adds a new color remap gradient
  16645. * @param gradient defines the gradient to use (between 0 and 1)
  16646. * @param min defines the color remap minimal range
  16647. * @param max defines the color remap maximal range
  16648. * @returns the current particle system
  16649. */
  16650. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16651. /**
  16652. * Gets the current list of color remap gradients.
  16653. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16654. * @returns the list of color remap gradients
  16655. */
  16656. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16657. /**
  16658. * Adds a new alpha remap gradient
  16659. * @param gradient defines the gradient to use (between 0 and 1)
  16660. * @param min defines the alpha remap minimal range
  16661. * @param max defines the alpha remap maximal range
  16662. * @returns the current particle system
  16663. */
  16664. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16665. /**
  16666. * Gets the current list of alpha remap gradients.
  16667. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16668. * @returns the list of alpha remap gradients
  16669. */
  16670. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16671. /**
  16672. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16673. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16674. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16675. * @returns the emitter
  16676. */
  16677. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16678. /**
  16679. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16680. * @param radius The radius of the hemisphere to emit from
  16681. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16682. * @returns the emitter
  16683. */
  16684. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16685. /**
  16686. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16687. * @param radius The radius of the sphere to emit from
  16688. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16689. * @returns the emitter
  16690. */
  16691. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16692. /**
  16693. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16694. * @param radius The radius of the sphere to emit from
  16695. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16696. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16697. * @returns the emitter
  16698. */
  16699. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16700. /**
  16701. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16702. * @param radius The radius of the emission cylinder
  16703. * @param height The height of the emission cylinder
  16704. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16705. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16706. * @returns the emitter
  16707. */
  16708. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16709. /**
  16710. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16711. * @param radius The radius of the cylinder to emit from
  16712. * @param height The height of the emission cylinder
  16713. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16714. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16715. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16716. * @returns the emitter
  16717. */
  16718. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16719. /**
  16720. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16721. * @param radius The radius of the cone to emit from
  16722. * @param angle The base angle of the cone
  16723. * @returns the emitter
  16724. */
  16725. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16726. /**
  16727. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16728. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16729. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16730. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16731. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16732. * @returns the emitter
  16733. */
  16734. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16735. /**
  16736. * Get hosting scene
  16737. * @returns the scene
  16738. */
  16739. getScene(): Scene;
  16740. }
  16741. }
  16742. declare module BABYLON {
  16743. /**
  16744. * Creates an instance based on a source mesh.
  16745. */
  16746. export class InstancedMesh extends AbstractMesh {
  16747. private _sourceMesh;
  16748. private _currentLOD;
  16749. /** @hidden */
  16750. _indexInSourceMeshInstanceArray: number;
  16751. constructor(name: string, source: Mesh);
  16752. /**
  16753. * Returns the string "InstancedMesh".
  16754. */
  16755. getClassName(): string;
  16756. /** Gets the list of lights affecting that mesh */
  16757. readonly lightSources: Light[];
  16758. _resyncLightSources(): void;
  16759. _resyncLighSource(light: Light): void;
  16760. _removeLightSource(light: Light): void;
  16761. /**
  16762. * If the source mesh receives shadows
  16763. */
  16764. readonly receiveShadows: boolean;
  16765. /**
  16766. * The material of the source mesh
  16767. */
  16768. readonly material: Nullable<Material>;
  16769. /**
  16770. * Visibility of the source mesh
  16771. */
  16772. readonly visibility: number;
  16773. /**
  16774. * Skeleton of the source mesh
  16775. */
  16776. readonly skeleton: Nullable<Skeleton>;
  16777. /**
  16778. * Rendering ground id of the source mesh
  16779. */
  16780. renderingGroupId: number;
  16781. /**
  16782. * Returns the total number of vertices (integer).
  16783. */
  16784. getTotalVertices(): number;
  16785. /**
  16786. * Returns a positive integer : the total number of indices in this mesh geometry.
  16787. * @returns the numner of indices or zero if the mesh has no geometry.
  16788. */
  16789. getTotalIndices(): number;
  16790. /**
  16791. * The source mesh of the instance
  16792. */
  16793. readonly sourceMesh: Mesh;
  16794. /**
  16795. * Is this node ready to be used/rendered
  16796. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16797. * @return {boolean} is it ready
  16798. */
  16799. isReady(completeCheck?: boolean): boolean;
  16800. /**
  16801. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16802. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16803. * @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.
  16804. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16805. */
  16806. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16807. /**
  16808. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16809. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16810. * The `data` are either a numeric array either a Float32Array.
  16811. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16812. * 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).
  16813. * Note that a new underlying VertexBuffer object is created each call.
  16814. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16815. *
  16816. * Possible `kind` values :
  16817. * - VertexBuffer.PositionKind
  16818. * - VertexBuffer.UVKind
  16819. * - VertexBuffer.UV2Kind
  16820. * - VertexBuffer.UV3Kind
  16821. * - VertexBuffer.UV4Kind
  16822. * - VertexBuffer.UV5Kind
  16823. * - VertexBuffer.UV6Kind
  16824. * - VertexBuffer.ColorKind
  16825. * - VertexBuffer.MatricesIndicesKind
  16826. * - VertexBuffer.MatricesIndicesExtraKind
  16827. * - VertexBuffer.MatricesWeightsKind
  16828. * - VertexBuffer.MatricesWeightsExtraKind
  16829. *
  16830. * Returns the Mesh.
  16831. */
  16832. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16833. /**
  16834. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16835. * If the mesh has no geometry, it is simply returned as it is.
  16836. * The `data` are either a numeric array either a Float32Array.
  16837. * No new underlying VertexBuffer object is created.
  16838. * 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.
  16839. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16840. *
  16841. * Possible `kind` values :
  16842. * - VertexBuffer.PositionKind
  16843. * - VertexBuffer.UVKind
  16844. * - VertexBuffer.UV2Kind
  16845. * - VertexBuffer.UV3Kind
  16846. * - VertexBuffer.UV4Kind
  16847. * - VertexBuffer.UV5Kind
  16848. * - VertexBuffer.UV6Kind
  16849. * - VertexBuffer.ColorKind
  16850. * - VertexBuffer.MatricesIndicesKind
  16851. * - VertexBuffer.MatricesIndicesExtraKind
  16852. * - VertexBuffer.MatricesWeightsKind
  16853. * - VertexBuffer.MatricesWeightsExtraKind
  16854. *
  16855. * Returns the Mesh.
  16856. */
  16857. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16858. /**
  16859. * Sets the mesh indices.
  16860. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16861. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16862. * This method creates a new index buffer each call.
  16863. * Returns the Mesh.
  16864. */
  16865. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16866. /**
  16867. * Boolean : True if the mesh owns the requested kind of data.
  16868. */
  16869. isVerticesDataPresent(kind: string): boolean;
  16870. /**
  16871. * Returns an array of indices (IndicesArray).
  16872. */
  16873. getIndices(): Nullable<IndicesArray>;
  16874. readonly _positions: Nullable<Vector3[]>;
  16875. /**
  16876. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16877. * This means the mesh underlying bounding box and sphere are recomputed.
  16878. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16879. * @returns the current mesh
  16880. */
  16881. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16882. /** @hidden */
  16883. _preActivate(): InstancedMesh;
  16884. /** @hidden */
  16885. _activate(renderId: number): boolean;
  16886. /** @hidden */
  16887. _postActivate(): void;
  16888. getWorldMatrix(): Matrix;
  16889. readonly isAnInstance: boolean;
  16890. /**
  16891. * Returns the current associated LOD AbstractMesh.
  16892. */
  16893. getLOD(camera: Camera): AbstractMesh;
  16894. /** @hidden */
  16895. _syncSubMeshes(): InstancedMesh;
  16896. /** @hidden */
  16897. _generatePointsArray(): boolean;
  16898. /**
  16899. * Creates a new InstancedMesh from the current mesh.
  16900. * - name (string) : the cloned mesh name
  16901. * - newParent (optional Node) : the optional Node to parent the clone to.
  16902. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16903. *
  16904. * Returns the clone.
  16905. */
  16906. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16907. /**
  16908. * Disposes the InstancedMesh.
  16909. * Returns nothing.
  16910. */
  16911. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16912. }
  16913. }
  16914. declare module BABYLON {
  16915. /**
  16916. * Defines the options associated with the creation of a shader material.
  16917. */
  16918. export interface IShaderMaterialOptions {
  16919. /**
  16920. * Does the material work in alpha blend mode
  16921. */
  16922. needAlphaBlending: boolean;
  16923. /**
  16924. * Does the material work in alpha test mode
  16925. */
  16926. needAlphaTesting: boolean;
  16927. /**
  16928. * The list of attribute names used in the shader
  16929. */
  16930. attributes: string[];
  16931. /**
  16932. * The list of unifrom names used in the shader
  16933. */
  16934. uniforms: string[];
  16935. /**
  16936. * The list of UBO names used in the shader
  16937. */
  16938. uniformBuffers: string[];
  16939. /**
  16940. * The list of sampler names used in the shader
  16941. */
  16942. samplers: string[];
  16943. /**
  16944. * The list of defines used in the shader
  16945. */
  16946. defines: string[];
  16947. }
  16948. /**
  16949. * 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.
  16950. *
  16951. * This returned material effects how the mesh will look based on the code in the shaders.
  16952. *
  16953. * @see http://doc.babylonjs.com/how_to/shader_material
  16954. */
  16955. export class ShaderMaterial extends Material {
  16956. private _shaderPath;
  16957. private _options;
  16958. private _textures;
  16959. private _textureArrays;
  16960. private _floats;
  16961. private _ints;
  16962. private _floatsArrays;
  16963. private _colors3;
  16964. private _colors3Arrays;
  16965. private _colors4;
  16966. private _vectors2;
  16967. private _vectors3;
  16968. private _vectors4;
  16969. private _matrices;
  16970. private _matrices3x3;
  16971. private _matrices2x2;
  16972. private _vectors2Arrays;
  16973. private _vectors3Arrays;
  16974. private _cachedWorldViewMatrix;
  16975. private _renderId;
  16976. /**
  16977. * Instantiate a new shader material.
  16978. * 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.
  16979. * This returned material effects how the mesh will look based on the code in the shaders.
  16980. * @see http://doc.babylonjs.com/how_to/shader_material
  16981. * @param name Define the name of the material in the scene
  16982. * @param scene Define the scene the material belongs to
  16983. * @param shaderPath Defines the route to the shader code in one of three ways:
  16984. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16985. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16986. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16987. * @param options Define the options used to create the shader
  16988. */
  16989. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16990. /**
  16991. * Gets the options used to compile the shader.
  16992. * They can be modified to trigger a new compilation
  16993. */
  16994. readonly options: IShaderMaterialOptions;
  16995. /**
  16996. * Gets the current class name of the material e.g. "ShaderMaterial"
  16997. * Mainly use in serialization.
  16998. * @returns the class name
  16999. */
  17000. getClassName(): string;
  17001. /**
  17002. * Specifies if the material will require alpha blending
  17003. * @returns a boolean specifying if alpha blending is needed
  17004. */
  17005. needAlphaBlending(): boolean;
  17006. /**
  17007. * Specifies if this material should be rendered in alpha test mode
  17008. * @returns a boolean specifying if an alpha test is needed.
  17009. */
  17010. needAlphaTesting(): boolean;
  17011. private _checkUniform;
  17012. /**
  17013. * Set a texture in the shader.
  17014. * @param name Define the name of the uniform samplers as defined in the shader
  17015. * @param texture Define the texture to bind to this sampler
  17016. * @return the material itself allowing "fluent" like uniform updates
  17017. */
  17018. setTexture(name: string, texture: Texture): ShaderMaterial;
  17019. /**
  17020. * Set a texture array in the shader.
  17021. * @param name Define the name of the uniform sampler array as defined in the shader
  17022. * @param textures Define the list of textures to bind to this sampler
  17023. * @return the material itself allowing "fluent" like uniform updates
  17024. */
  17025. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17026. /**
  17027. * Set a float in the shader.
  17028. * @param name Define the name of the uniform as defined in the shader
  17029. * @param value Define the value to give to the uniform
  17030. * @return the material itself allowing "fluent" like uniform updates
  17031. */
  17032. setFloat(name: string, value: number): ShaderMaterial;
  17033. /**
  17034. * Set a int in the shader.
  17035. * @param name Define the name of the uniform as defined in the shader
  17036. * @param value Define the value to give to the uniform
  17037. * @return the material itself allowing "fluent" like uniform updates
  17038. */
  17039. setInt(name: string, value: number): ShaderMaterial;
  17040. /**
  17041. * Set an array of floats in the shader.
  17042. * @param name Define the name of the uniform as defined in the shader
  17043. * @param value Define the value to give to the uniform
  17044. * @return the material itself allowing "fluent" like uniform updates
  17045. */
  17046. setFloats(name: string, value: number[]): ShaderMaterial;
  17047. /**
  17048. * Set a vec3 in the shader from a Color3.
  17049. * @param name Define the name of the uniform as defined in the shader
  17050. * @param value Define the value to give to the uniform
  17051. * @return the material itself allowing "fluent" like uniform updates
  17052. */
  17053. setColor3(name: string, value: Color3): ShaderMaterial;
  17054. /**
  17055. * Set a vec3 array in the shader from a Color3 array.
  17056. * @param name Define the name of the uniform as defined in the shader
  17057. * @param value Define the value to give to the uniform
  17058. * @return the material itself allowing "fluent" like uniform updates
  17059. */
  17060. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17061. /**
  17062. * Set a vec4 in the shader from a Color4.
  17063. * @param name Define the name of the uniform as defined in the shader
  17064. * @param value Define the value to give to the uniform
  17065. * @return the material itself allowing "fluent" like uniform updates
  17066. */
  17067. setColor4(name: string, value: Color4): ShaderMaterial;
  17068. /**
  17069. * Set a vec2 in the shader from a Vector2.
  17070. * @param name Define the name of the uniform as defined in the shader
  17071. * @param value Define the value to give to the uniform
  17072. * @return the material itself allowing "fluent" like uniform updates
  17073. */
  17074. setVector2(name: string, value: Vector2): ShaderMaterial;
  17075. /**
  17076. * Set a vec3 in the shader from a Vector3.
  17077. * @param name Define the name of the uniform as defined in the shader
  17078. * @param value Define the value to give to the uniform
  17079. * @return the material itself allowing "fluent" like uniform updates
  17080. */
  17081. setVector3(name: string, value: Vector3): ShaderMaterial;
  17082. /**
  17083. * Set a vec4 in the shader from a Vector4.
  17084. * @param name Define the name of the uniform as defined in the shader
  17085. * @param value Define the value to give to the uniform
  17086. * @return the material itself allowing "fluent" like uniform updates
  17087. */
  17088. setVector4(name: string, value: Vector4): ShaderMaterial;
  17089. /**
  17090. * Set a mat4 in the shader from a Matrix.
  17091. * @param name Define the name of the uniform as defined in the shader
  17092. * @param value Define the value to give to the uniform
  17093. * @return the material itself allowing "fluent" like uniform updates
  17094. */
  17095. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17096. /**
  17097. * Set a mat3 in the shader from a Float32Array.
  17098. * @param name Define the name of the uniform as defined in the shader
  17099. * @param value Define the value to give to the uniform
  17100. * @return the material itself allowing "fluent" like uniform updates
  17101. */
  17102. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17103. /**
  17104. * Set a mat2 in the shader from a Float32Array.
  17105. * @param name Define the name of the uniform as defined in the shader
  17106. * @param value Define the value to give to the uniform
  17107. * @return the material itself allowing "fluent" like uniform updates
  17108. */
  17109. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17110. /**
  17111. * Set a vec2 array in the shader from a number array.
  17112. * @param name Define the name of the uniform as defined in the shader
  17113. * @param value Define the value to give to the uniform
  17114. * @return the material itself allowing "fluent" like uniform updates
  17115. */
  17116. setArray2(name: string, value: number[]): ShaderMaterial;
  17117. /**
  17118. * Set a vec3 array in the shader from a number array.
  17119. * @param name Define the name of the uniform as defined in the shader
  17120. * @param value Define the value to give to the uniform
  17121. * @return the material itself allowing "fluent" like uniform updates
  17122. */
  17123. setArray3(name: string, value: number[]): ShaderMaterial;
  17124. private _checkCache;
  17125. /**
  17126. * Specifies that the submesh is ready to be used
  17127. * @param mesh defines the mesh to check
  17128. * @param subMesh defines which submesh to check
  17129. * @param useInstances specifies that instances should be used
  17130. * @returns a boolean indicating that the submesh is ready or not
  17131. */
  17132. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17133. /**
  17134. * Checks if the material is ready to render the requested mesh
  17135. * @param mesh Define the mesh to render
  17136. * @param useInstances Define whether or not the material is used with instances
  17137. * @returns true if ready, otherwise false
  17138. */
  17139. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17140. /**
  17141. * Binds the world matrix to the material
  17142. * @param world defines the world transformation matrix
  17143. */
  17144. bindOnlyWorldMatrix(world: Matrix): void;
  17145. /**
  17146. * Binds the material to the mesh
  17147. * @param world defines the world transformation matrix
  17148. * @param mesh defines the mesh to bind the material to
  17149. */
  17150. bind(world: Matrix, mesh?: Mesh): void;
  17151. /**
  17152. * Gets the active textures from the material
  17153. * @returns an array of textures
  17154. */
  17155. getActiveTextures(): BaseTexture[];
  17156. /**
  17157. * Specifies if the material uses a texture
  17158. * @param texture defines the texture to check against the material
  17159. * @returns a boolean specifying if the material uses the texture
  17160. */
  17161. hasTexture(texture: BaseTexture): boolean;
  17162. /**
  17163. * Makes a duplicate of the material, and gives it a new name
  17164. * @param name defines the new name for the duplicated material
  17165. * @returns the cloned material
  17166. */
  17167. clone(name: string): ShaderMaterial;
  17168. /**
  17169. * Disposes the material
  17170. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17171. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17172. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17173. */
  17174. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17175. /**
  17176. * Serializes this material in a JSON representation
  17177. * @returns the serialized material object
  17178. */
  17179. serialize(): any;
  17180. /**
  17181. * Creates a shader material from parsed shader material data
  17182. * @param source defines the JSON represnetation of the material
  17183. * @param scene defines the hosting scene
  17184. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17185. * @returns a new material
  17186. */
  17187. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17188. }
  17189. }
  17190. declare module BABYLON {
  17191. /** @hidden */
  17192. export var colorPixelShader: {
  17193. name: string;
  17194. shader: string;
  17195. };
  17196. }
  17197. declare module BABYLON {
  17198. /** @hidden */
  17199. export var colorVertexShader: {
  17200. name: string;
  17201. shader: string;
  17202. };
  17203. }
  17204. declare module BABYLON {
  17205. /**
  17206. * Line mesh
  17207. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17208. */
  17209. export class LinesMesh extends Mesh {
  17210. /**
  17211. * If vertex color should be applied to the mesh
  17212. */
  17213. useVertexColor?: boolean | undefined;
  17214. /**
  17215. * If vertex alpha should be applied to the mesh
  17216. */
  17217. useVertexAlpha?: boolean | undefined;
  17218. /**
  17219. * Color of the line (Default: White)
  17220. */
  17221. color: Color3;
  17222. /**
  17223. * Alpha of the line (Default: 1)
  17224. */
  17225. alpha: number;
  17226. /**
  17227. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17228. * This margin is expressed in world space coordinates, so its value may vary.
  17229. * Default value is 0.1
  17230. */
  17231. intersectionThreshold: number;
  17232. private _colorShader;
  17233. /**
  17234. * Creates a new LinesMesh
  17235. * @param name defines the name
  17236. * @param scene defines the hosting scene
  17237. * @param parent defines the parent mesh if any
  17238. * @param source defines the optional source LinesMesh used to clone data from
  17239. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17240. * When false, achieved by calling a clone(), also passing False.
  17241. * This will make creation of children, recursive.
  17242. * @param useVertexColor defines if this LinesMesh supports vertex color
  17243. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17244. */
  17245. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17246. /**
  17247. * If vertex color should be applied to the mesh
  17248. */
  17249. useVertexColor?: boolean | undefined,
  17250. /**
  17251. * If vertex alpha should be applied to the mesh
  17252. */
  17253. useVertexAlpha?: boolean | undefined);
  17254. private _addClipPlaneDefine;
  17255. private _removeClipPlaneDefine;
  17256. isReady(): boolean;
  17257. /**
  17258. * Returns the string "LineMesh"
  17259. */
  17260. getClassName(): string;
  17261. /**
  17262. * @hidden
  17263. */
  17264. /**
  17265. * @hidden
  17266. */
  17267. material: Material;
  17268. /**
  17269. * @hidden
  17270. */
  17271. readonly checkCollisions: boolean;
  17272. /** @hidden */
  17273. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17274. /** @hidden */
  17275. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17276. /**
  17277. * Disposes of the line mesh
  17278. * @param doNotRecurse If children should be disposed
  17279. */
  17280. dispose(doNotRecurse?: boolean): void;
  17281. /**
  17282. * Returns a new LineMesh object cloned from the current one.
  17283. */
  17284. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17285. /**
  17286. * Creates a new InstancedLinesMesh object from the mesh model.
  17287. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17288. * @param name defines the name of the new instance
  17289. * @returns a new InstancedLinesMesh
  17290. */
  17291. createInstance(name: string): InstancedLinesMesh;
  17292. }
  17293. /**
  17294. * Creates an instance based on a source LinesMesh
  17295. */
  17296. export class InstancedLinesMesh extends InstancedMesh {
  17297. /**
  17298. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17299. * This margin is expressed in world space coordinates, so its value may vary.
  17300. * Initilized with the intersectionThreshold value of the source LinesMesh
  17301. */
  17302. intersectionThreshold: number;
  17303. constructor(name: string, source: LinesMesh);
  17304. /**
  17305. * Returns the string "InstancedLinesMesh".
  17306. */
  17307. getClassName(): string;
  17308. }
  17309. }
  17310. declare module BABYLON {
  17311. /** @hidden */
  17312. export var linePixelShader: {
  17313. name: string;
  17314. shader: string;
  17315. };
  17316. }
  17317. declare module BABYLON {
  17318. /** @hidden */
  17319. export var lineVertexShader: {
  17320. name: string;
  17321. shader: string;
  17322. };
  17323. }
  17324. declare module BABYLON {
  17325. interface AbstractMesh {
  17326. /**
  17327. * Disables the mesh edge rendering mode
  17328. * @returns the currentAbstractMesh
  17329. */
  17330. disableEdgesRendering(): AbstractMesh;
  17331. /**
  17332. * Enables the edge rendering mode on the mesh.
  17333. * This mode makes the mesh edges visible
  17334. * @param epsilon defines the maximal distance between two angles to detect a face
  17335. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17336. * @returns the currentAbstractMesh
  17337. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17338. */
  17339. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17340. /**
  17341. * Gets the edgesRenderer associated with the mesh
  17342. */
  17343. edgesRenderer: Nullable<EdgesRenderer>;
  17344. }
  17345. interface LinesMesh {
  17346. /**
  17347. * Enables the edge rendering mode on the mesh.
  17348. * This mode makes the mesh edges visible
  17349. * @param epsilon defines the maximal distance between two angles to detect a face
  17350. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17351. * @returns the currentAbstractMesh
  17352. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17353. */
  17354. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17355. }
  17356. interface InstancedLinesMesh {
  17357. /**
  17358. * Enables the edge rendering mode on the mesh.
  17359. * This mode makes the mesh edges visible
  17360. * @param epsilon defines the maximal distance between two angles to detect a face
  17361. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17362. * @returns the current InstancedLinesMesh
  17363. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17364. */
  17365. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17366. }
  17367. /**
  17368. * Defines the minimum contract an Edges renderer should follow.
  17369. */
  17370. export interface IEdgesRenderer extends IDisposable {
  17371. /**
  17372. * Gets or sets a boolean indicating if the edgesRenderer is active
  17373. */
  17374. isEnabled: boolean;
  17375. /**
  17376. * Renders the edges of the attached mesh,
  17377. */
  17378. render(): void;
  17379. /**
  17380. * Checks wether or not the edges renderer is ready to render.
  17381. * @return true if ready, otherwise false.
  17382. */
  17383. isReady(): boolean;
  17384. }
  17385. /**
  17386. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17387. */
  17388. export class EdgesRenderer implements IEdgesRenderer {
  17389. /**
  17390. * Define the size of the edges with an orthographic camera
  17391. */
  17392. edgesWidthScalerForOrthographic: number;
  17393. /**
  17394. * Define the size of the edges with a perspective camera
  17395. */
  17396. edgesWidthScalerForPerspective: number;
  17397. protected _source: AbstractMesh;
  17398. protected _linesPositions: number[];
  17399. protected _linesNormals: number[];
  17400. protected _linesIndices: number[];
  17401. protected _epsilon: number;
  17402. protected _indicesCount: number;
  17403. protected _lineShader: ShaderMaterial;
  17404. protected _ib: DataBuffer;
  17405. protected _buffers: {
  17406. [key: string]: Nullable<VertexBuffer>;
  17407. };
  17408. protected _checkVerticesInsteadOfIndices: boolean;
  17409. private _meshRebuildObserver;
  17410. private _meshDisposeObserver;
  17411. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17412. isEnabled: boolean;
  17413. /**
  17414. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17415. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17416. * @param source Mesh used to create edges
  17417. * @param epsilon sum of angles in adjacency to check for edge
  17418. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17419. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17420. */
  17421. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17422. protected _prepareRessources(): void;
  17423. /** @hidden */
  17424. _rebuild(): void;
  17425. /**
  17426. * Releases the required resources for the edges renderer
  17427. */
  17428. dispose(): void;
  17429. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17430. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17431. /**
  17432. * Checks if the pair of p0 and p1 is en edge
  17433. * @param faceIndex
  17434. * @param edge
  17435. * @param faceNormals
  17436. * @param p0
  17437. * @param p1
  17438. * @private
  17439. */
  17440. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17441. /**
  17442. * push line into the position, normal and index buffer
  17443. * @protected
  17444. */
  17445. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17446. /**
  17447. * Generates lines edges from adjacencjes
  17448. * @private
  17449. */
  17450. _generateEdgesLines(): void;
  17451. /**
  17452. * Checks wether or not the edges renderer is ready to render.
  17453. * @return true if ready, otherwise false.
  17454. */
  17455. isReady(): boolean;
  17456. /**
  17457. * Renders the edges of the attached mesh,
  17458. */
  17459. render(): void;
  17460. }
  17461. /**
  17462. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17463. */
  17464. export class LineEdgesRenderer extends EdgesRenderer {
  17465. /**
  17466. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17467. * @param source LineMesh used to generate edges
  17468. * @param epsilon not important (specified angle for edge detection)
  17469. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17470. */
  17471. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17472. /**
  17473. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17474. */
  17475. _generateEdgesLines(): void;
  17476. }
  17477. }
  17478. declare module BABYLON {
  17479. /**
  17480. * This represents the object necessary to create a rendering group.
  17481. * This is exclusively used and created by the rendering manager.
  17482. * To modify the behavior, you use the available helpers in your scene or meshes.
  17483. * @hidden
  17484. */
  17485. export class RenderingGroup {
  17486. index: number;
  17487. private _scene;
  17488. private _opaqueSubMeshes;
  17489. private _transparentSubMeshes;
  17490. private _alphaTestSubMeshes;
  17491. private _depthOnlySubMeshes;
  17492. private _particleSystems;
  17493. private _spriteManagers;
  17494. private _opaqueSortCompareFn;
  17495. private _alphaTestSortCompareFn;
  17496. private _transparentSortCompareFn;
  17497. private _renderOpaque;
  17498. private _renderAlphaTest;
  17499. private _renderTransparent;
  17500. /** @hidden */
  17501. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17502. onBeforeTransparentRendering: () => void;
  17503. /**
  17504. * Set the opaque sort comparison function.
  17505. * If null the sub meshes will be render in the order they were created
  17506. */
  17507. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17508. /**
  17509. * Set the alpha test sort comparison function.
  17510. * If null the sub meshes will be render in the order they were created
  17511. */
  17512. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17513. /**
  17514. * Set the transparent sort comparison function.
  17515. * If null the sub meshes will be render in the order they were created
  17516. */
  17517. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17518. /**
  17519. * Creates a new rendering group.
  17520. * @param index The rendering group index
  17521. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17522. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17523. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17524. */
  17525. 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>);
  17526. /**
  17527. * Render all the sub meshes contained in the group.
  17528. * @param customRenderFunction Used to override the default render behaviour of the group.
  17529. * @returns true if rendered some submeshes.
  17530. */
  17531. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17532. /**
  17533. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17534. * @param subMeshes The submeshes to render
  17535. */
  17536. private renderOpaqueSorted;
  17537. /**
  17538. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17539. * @param subMeshes The submeshes to render
  17540. */
  17541. private renderAlphaTestSorted;
  17542. /**
  17543. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17544. * @param subMeshes The submeshes to render
  17545. */
  17546. private renderTransparentSorted;
  17547. /**
  17548. * Renders the submeshes in a specified order.
  17549. * @param subMeshes The submeshes to sort before render
  17550. * @param sortCompareFn The comparison function use to sort
  17551. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17552. * @param transparent Specifies to activate blending if true
  17553. */
  17554. private static renderSorted;
  17555. /**
  17556. * Renders the submeshes in the order they were dispatched (no sort applied).
  17557. * @param subMeshes The submeshes to render
  17558. */
  17559. private static renderUnsorted;
  17560. /**
  17561. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17562. * are rendered back to front if in the same alpha index.
  17563. *
  17564. * @param a The first submesh
  17565. * @param b The second submesh
  17566. * @returns The result of the comparison
  17567. */
  17568. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17569. /**
  17570. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17571. * are rendered back to front.
  17572. *
  17573. * @param a The first submesh
  17574. * @param b The second submesh
  17575. * @returns The result of the comparison
  17576. */
  17577. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17578. /**
  17579. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17580. * are rendered front to back (prevent overdraw).
  17581. *
  17582. * @param a The first submesh
  17583. * @param b The second submesh
  17584. * @returns The result of the comparison
  17585. */
  17586. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17587. /**
  17588. * Resets the different lists of submeshes to prepare a new frame.
  17589. */
  17590. prepare(): void;
  17591. dispose(): void;
  17592. /**
  17593. * Inserts the submesh in its correct queue depending on its material.
  17594. * @param subMesh The submesh to dispatch
  17595. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17596. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17597. */
  17598. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17599. dispatchSprites(spriteManager: ISpriteManager): void;
  17600. dispatchParticles(particleSystem: IParticleSystem): void;
  17601. private _renderParticles;
  17602. private _renderSprites;
  17603. }
  17604. }
  17605. declare module BABYLON {
  17606. /**
  17607. * Interface describing the different options available in the rendering manager
  17608. * regarding Auto Clear between groups.
  17609. */
  17610. export interface IRenderingManagerAutoClearSetup {
  17611. /**
  17612. * Defines whether or not autoclear is enable.
  17613. */
  17614. autoClear: boolean;
  17615. /**
  17616. * Defines whether or not to autoclear the depth buffer.
  17617. */
  17618. depth: boolean;
  17619. /**
  17620. * Defines whether or not to autoclear the stencil buffer.
  17621. */
  17622. stencil: boolean;
  17623. }
  17624. /**
  17625. * This class is used by the onRenderingGroupObservable
  17626. */
  17627. export class RenderingGroupInfo {
  17628. /**
  17629. * The Scene that being rendered
  17630. */
  17631. scene: Scene;
  17632. /**
  17633. * The camera currently used for the rendering pass
  17634. */
  17635. camera: Nullable<Camera>;
  17636. /**
  17637. * The ID of the renderingGroup being processed
  17638. */
  17639. renderingGroupId: number;
  17640. }
  17641. /**
  17642. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17643. * It is enable to manage the different groups as well as the different necessary sort functions.
  17644. * This should not be used directly aside of the few static configurations
  17645. */
  17646. export class RenderingManager {
  17647. /**
  17648. * The max id used for rendering groups (not included)
  17649. */
  17650. static MAX_RENDERINGGROUPS: number;
  17651. /**
  17652. * The min id used for rendering groups (included)
  17653. */
  17654. static MIN_RENDERINGGROUPS: number;
  17655. /**
  17656. * Used to globally prevent autoclearing scenes.
  17657. */
  17658. static AUTOCLEAR: boolean;
  17659. /**
  17660. * @hidden
  17661. */
  17662. _useSceneAutoClearSetup: boolean;
  17663. private _scene;
  17664. private _renderingGroups;
  17665. private _depthStencilBufferAlreadyCleaned;
  17666. private _autoClearDepthStencil;
  17667. private _customOpaqueSortCompareFn;
  17668. private _customAlphaTestSortCompareFn;
  17669. private _customTransparentSortCompareFn;
  17670. private _renderingGroupInfo;
  17671. /**
  17672. * Instantiates a new rendering group for a particular scene
  17673. * @param scene Defines the scene the groups belongs to
  17674. */
  17675. constructor(scene: Scene);
  17676. private _clearDepthStencilBuffer;
  17677. /**
  17678. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17679. * @hidden
  17680. */
  17681. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17682. /**
  17683. * Resets the different information of the group to prepare a new frame
  17684. * @hidden
  17685. */
  17686. reset(): void;
  17687. /**
  17688. * Dispose and release the group and its associated resources.
  17689. * @hidden
  17690. */
  17691. dispose(): void;
  17692. /**
  17693. * Clear the info related to rendering groups preventing retention points during dispose.
  17694. */
  17695. freeRenderingGroups(): void;
  17696. private _prepareRenderingGroup;
  17697. /**
  17698. * Add a sprite manager to the rendering manager in order to render it this frame.
  17699. * @param spriteManager Define the sprite manager to render
  17700. */
  17701. dispatchSprites(spriteManager: ISpriteManager): void;
  17702. /**
  17703. * Add a particle system to the rendering manager in order to render it this frame.
  17704. * @param particleSystem Define the particle system to render
  17705. */
  17706. dispatchParticles(particleSystem: IParticleSystem): void;
  17707. /**
  17708. * Add a submesh to the manager in order to render it this frame
  17709. * @param subMesh The submesh to dispatch
  17710. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17711. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17712. */
  17713. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17714. /**
  17715. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17716. * This allowed control for front to back rendering or reversly depending of the special needs.
  17717. *
  17718. * @param renderingGroupId The rendering group id corresponding to its index
  17719. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17720. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17721. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17722. */
  17723. 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;
  17724. /**
  17725. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17726. *
  17727. * @param renderingGroupId The rendering group id corresponding to its index
  17728. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17729. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17730. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17731. */
  17732. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17733. /**
  17734. * Gets the current auto clear configuration for one rendering group of the rendering
  17735. * manager.
  17736. * @param index the rendering group index to get the information for
  17737. * @returns The auto clear setup for the requested rendering group
  17738. */
  17739. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17740. }
  17741. }
  17742. declare module BABYLON {
  17743. /**
  17744. * This Helps creating a texture that will be created from a camera in your scene.
  17745. * It is basically a dynamic texture that could be used to create special effects for instance.
  17746. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17747. */
  17748. export class RenderTargetTexture extends Texture {
  17749. isCube: boolean;
  17750. /**
  17751. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17752. */
  17753. static readonly REFRESHRATE_RENDER_ONCE: number;
  17754. /**
  17755. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17756. */
  17757. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17758. /**
  17759. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17760. * the central point of your effect and can save a lot of performances.
  17761. */
  17762. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17763. /**
  17764. * Use this predicate to dynamically define the list of mesh you want to render.
  17765. * If set, the renderList property will be overwritten.
  17766. */
  17767. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17768. private _renderList;
  17769. /**
  17770. * Use this list to define the list of mesh you want to render.
  17771. */
  17772. renderList: Nullable<Array<AbstractMesh>>;
  17773. private _hookArray;
  17774. /**
  17775. * Define if particles should be rendered in your texture.
  17776. */
  17777. renderParticles: boolean;
  17778. /**
  17779. * Define if sprites should be rendered in your texture.
  17780. */
  17781. renderSprites: boolean;
  17782. /**
  17783. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17784. */
  17785. coordinatesMode: number;
  17786. /**
  17787. * Define the camera used to render the texture.
  17788. */
  17789. activeCamera: Nullable<Camera>;
  17790. /**
  17791. * Override the render function of the texture with your own one.
  17792. */
  17793. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17794. /**
  17795. * Define if camera post processes should be use while rendering the texture.
  17796. */
  17797. useCameraPostProcesses: boolean;
  17798. /**
  17799. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17800. */
  17801. ignoreCameraViewport: boolean;
  17802. private _postProcessManager;
  17803. private _postProcesses;
  17804. private _resizeObserver;
  17805. /**
  17806. * An event triggered when the texture is unbind.
  17807. */
  17808. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17809. /**
  17810. * An event triggered when the texture is unbind.
  17811. */
  17812. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17813. private _onAfterUnbindObserver;
  17814. /**
  17815. * Set a after unbind callback in the texture.
  17816. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17817. */
  17818. onAfterUnbind: () => void;
  17819. /**
  17820. * An event triggered before rendering the texture
  17821. */
  17822. onBeforeRenderObservable: Observable<number>;
  17823. private _onBeforeRenderObserver;
  17824. /**
  17825. * Set a before render callback in the texture.
  17826. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17827. */
  17828. onBeforeRender: (faceIndex: number) => void;
  17829. /**
  17830. * An event triggered after rendering the texture
  17831. */
  17832. onAfterRenderObservable: Observable<number>;
  17833. private _onAfterRenderObserver;
  17834. /**
  17835. * Set a after render callback in the texture.
  17836. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17837. */
  17838. onAfterRender: (faceIndex: number) => void;
  17839. /**
  17840. * An event triggered after the texture clear
  17841. */
  17842. onClearObservable: Observable<Engine>;
  17843. private _onClearObserver;
  17844. /**
  17845. * Set a clear callback in the texture.
  17846. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17847. */
  17848. onClear: (Engine: Engine) => void;
  17849. /**
  17850. * Define the clear color of the Render Target if it should be different from the scene.
  17851. */
  17852. clearColor: Color4;
  17853. protected _size: number | {
  17854. width: number;
  17855. height: number;
  17856. };
  17857. protected _initialSizeParameter: number | {
  17858. width: number;
  17859. height: number;
  17860. } | {
  17861. ratio: number;
  17862. };
  17863. protected _sizeRatio: Nullable<number>;
  17864. /** @hidden */
  17865. _generateMipMaps: boolean;
  17866. protected _renderingManager: RenderingManager;
  17867. /** @hidden */
  17868. _waitingRenderList: string[];
  17869. protected _doNotChangeAspectRatio: boolean;
  17870. protected _currentRefreshId: number;
  17871. protected _refreshRate: number;
  17872. protected _textureMatrix: Matrix;
  17873. protected _samples: number;
  17874. protected _renderTargetOptions: RenderTargetCreationOptions;
  17875. /**
  17876. * Gets render target creation options that were used.
  17877. */
  17878. readonly renderTargetOptions: RenderTargetCreationOptions;
  17879. protected _engine: Engine;
  17880. protected _onRatioRescale(): void;
  17881. /**
  17882. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17883. * It must define where the camera used to render the texture is set
  17884. */
  17885. boundingBoxPosition: Vector3;
  17886. private _boundingBoxSize;
  17887. /**
  17888. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17889. * When defined, the cubemap will switch to local mode
  17890. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17891. * @example https://www.babylonjs-playground.com/#RNASML
  17892. */
  17893. boundingBoxSize: Vector3;
  17894. /**
  17895. * In case the RTT has been created with a depth texture, get the associated
  17896. * depth texture.
  17897. * Otherwise, return null.
  17898. */
  17899. depthStencilTexture: Nullable<InternalTexture>;
  17900. /**
  17901. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17902. * or used a shadow, depth texture...
  17903. * @param name The friendly name of the texture
  17904. * @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)
  17905. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17906. * @param generateMipMaps True if mip maps need to be generated after render.
  17907. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17908. * @param type The type of the buffer in the RTT (int, half float, float...)
  17909. * @param isCube True if a cube texture needs to be created
  17910. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17911. * @param generateDepthBuffer True to generate a depth buffer
  17912. * @param generateStencilBuffer True to generate a stencil buffer
  17913. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17914. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17915. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17916. */
  17917. constructor(name: string, size: number | {
  17918. width: number;
  17919. height: number;
  17920. } | {
  17921. ratio: number;
  17922. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17923. /**
  17924. * Creates a depth stencil texture.
  17925. * This is only available in WebGL 2 or with the depth texture extension available.
  17926. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17927. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17928. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17929. */
  17930. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17931. private _processSizeParameter;
  17932. /**
  17933. * Define the number of samples to use in case of MSAA.
  17934. * It defaults to one meaning no MSAA has been enabled.
  17935. */
  17936. samples: number;
  17937. /**
  17938. * Resets the refresh counter of the texture and start bak from scratch.
  17939. * Could be useful to regenerate the texture if it is setup to render only once.
  17940. */
  17941. resetRefreshCounter(): void;
  17942. /**
  17943. * Define the refresh rate of the texture or the rendering frequency.
  17944. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17945. */
  17946. refreshRate: number;
  17947. /**
  17948. * Adds a post process to the render target rendering passes.
  17949. * @param postProcess define the post process to add
  17950. */
  17951. addPostProcess(postProcess: PostProcess): void;
  17952. /**
  17953. * Clear all the post processes attached to the render target
  17954. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17955. */
  17956. clearPostProcesses(dispose?: boolean): void;
  17957. /**
  17958. * Remove one of the post process from the list of attached post processes to the texture
  17959. * @param postProcess define the post process to remove from the list
  17960. */
  17961. removePostProcess(postProcess: PostProcess): void;
  17962. /** @hidden */
  17963. _shouldRender(): boolean;
  17964. /**
  17965. * Gets the actual render size of the texture.
  17966. * @returns the width of the render size
  17967. */
  17968. getRenderSize(): number;
  17969. /**
  17970. * Gets the actual render width of the texture.
  17971. * @returns the width of the render size
  17972. */
  17973. getRenderWidth(): number;
  17974. /**
  17975. * Gets the actual render height of the texture.
  17976. * @returns the height of the render size
  17977. */
  17978. getRenderHeight(): number;
  17979. /**
  17980. * Get if the texture can be rescaled or not.
  17981. */
  17982. readonly canRescale: boolean;
  17983. /**
  17984. * Resize the texture using a ratio.
  17985. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17986. */
  17987. scale(ratio: number): void;
  17988. /**
  17989. * Get the texture reflection matrix used to rotate/transform the reflection.
  17990. * @returns the reflection matrix
  17991. */
  17992. getReflectionTextureMatrix(): Matrix;
  17993. /**
  17994. * Resize the texture to a new desired size.
  17995. * Be carrefull as it will recreate all the data in the new texture.
  17996. * @param size Define the new size. It can be:
  17997. * - a number for squared texture,
  17998. * - an object containing { width: number, height: number }
  17999. * - or an object containing a ratio { ratio: number }
  18000. */
  18001. resize(size: number | {
  18002. width: number;
  18003. height: number;
  18004. } | {
  18005. ratio: number;
  18006. }): void;
  18007. /**
  18008. * Renders all the objects from the render list into the texture.
  18009. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18010. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18011. */
  18012. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18013. private _bestReflectionRenderTargetDimension;
  18014. /**
  18015. * @hidden
  18016. * @param faceIndex face index to bind to if this is a cubetexture
  18017. */
  18018. _bindFrameBuffer(faceIndex?: number): void;
  18019. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18020. private renderToTarget;
  18021. /**
  18022. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18023. * This allowed control for front to back rendering or reversly depending of the special needs.
  18024. *
  18025. * @param renderingGroupId The rendering group id corresponding to its index
  18026. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18027. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18028. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18029. */
  18030. 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;
  18031. /**
  18032. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18033. *
  18034. * @param renderingGroupId The rendering group id corresponding to its index
  18035. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18036. */
  18037. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18038. /**
  18039. * Clones the texture.
  18040. * @returns the cloned texture
  18041. */
  18042. clone(): RenderTargetTexture;
  18043. /**
  18044. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18045. * @returns The JSON representation of the texture
  18046. */
  18047. serialize(): any;
  18048. /**
  18049. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18050. */
  18051. disposeFramebufferObjects(): void;
  18052. /**
  18053. * Dispose the texture and release its associated resources.
  18054. */
  18055. dispose(): void;
  18056. /** @hidden */
  18057. _rebuild(): void;
  18058. /**
  18059. * Clear the info related to rendering groups preventing retention point in material dispose.
  18060. */
  18061. freeRenderingGroups(): void;
  18062. /**
  18063. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18064. * @returns the view count
  18065. */
  18066. getViewCount(): number;
  18067. }
  18068. }
  18069. declare module BABYLON {
  18070. /**
  18071. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18072. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18073. * You can then easily use it as a reflectionTexture on a flat surface.
  18074. * In case the surface is not a plane, please consider relying on reflection probes.
  18075. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18076. */
  18077. export class MirrorTexture extends RenderTargetTexture {
  18078. private scene;
  18079. /**
  18080. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18081. * 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.
  18082. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18083. */
  18084. mirrorPlane: Plane;
  18085. /**
  18086. * Define the blur ratio used to blur the reflection if needed.
  18087. */
  18088. blurRatio: number;
  18089. /**
  18090. * Define the adaptive blur kernel used to blur the reflection if needed.
  18091. * This will autocompute the closest best match for the `blurKernel`
  18092. */
  18093. adaptiveBlurKernel: number;
  18094. /**
  18095. * Define the blur kernel used to blur the reflection if needed.
  18096. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18097. */
  18098. blurKernel: number;
  18099. /**
  18100. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18101. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18102. */
  18103. blurKernelX: number;
  18104. /**
  18105. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18106. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18107. */
  18108. blurKernelY: number;
  18109. private _autoComputeBlurKernel;
  18110. protected _onRatioRescale(): void;
  18111. private _updateGammaSpace;
  18112. private _imageProcessingConfigChangeObserver;
  18113. private _transformMatrix;
  18114. private _mirrorMatrix;
  18115. private _savedViewMatrix;
  18116. private _blurX;
  18117. private _blurY;
  18118. private _adaptiveBlurKernel;
  18119. private _blurKernelX;
  18120. private _blurKernelY;
  18121. private _blurRatio;
  18122. /**
  18123. * Instantiates a Mirror Texture.
  18124. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18125. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18126. * You can then easily use it as a reflectionTexture on a flat surface.
  18127. * In case the surface is not a plane, please consider relying on reflection probes.
  18128. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18129. * @param name
  18130. * @param size
  18131. * @param scene
  18132. * @param generateMipMaps
  18133. * @param type
  18134. * @param samplingMode
  18135. * @param generateDepthBuffer
  18136. */
  18137. constructor(name: string, size: number | {
  18138. width: number;
  18139. height: number;
  18140. } | {
  18141. ratio: number;
  18142. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18143. private _preparePostProcesses;
  18144. /**
  18145. * Clone the mirror texture.
  18146. * @returns the cloned texture
  18147. */
  18148. clone(): MirrorTexture;
  18149. /**
  18150. * Serialize the texture to a JSON representation you could use in Parse later on
  18151. * @returns the serialized JSON representation
  18152. */
  18153. serialize(): any;
  18154. /**
  18155. * Dispose the texture and release its associated resources.
  18156. */
  18157. dispose(): void;
  18158. }
  18159. }
  18160. declare module BABYLON {
  18161. /**
  18162. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18163. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18164. */
  18165. export class Texture extends BaseTexture {
  18166. /** @hidden */
  18167. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  18168. /** @hidden */
  18169. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  18170. /** @hidden */
  18171. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  18172. /** nearest is mag = nearest and min = nearest and mip = linear */
  18173. static readonly NEAREST_SAMPLINGMODE: number;
  18174. /** nearest is mag = nearest and min = nearest and mip = linear */
  18175. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18176. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18177. static readonly BILINEAR_SAMPLINGMODE: number;
  18178. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18179. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18180. /** Trilinear is mag = linear and min = linear and mip = linear */
  18181. static readonly TRILINEAR_SAMPLINGMODE: number;
  18182. /** Trilinear is mag = linear and min = linear and mip = linear */
  18183. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18184. /** mag = nearest and min = nearest and mip = nearest */
  18185. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18186. /** mag = nearest and min = linear and mip = nearest */
  18187. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18188. /** mag = nearest and min = linear and mip = linear */
  18189. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18190. /** mag = nearest and min = linear and mip = none */
  18191. static readonly NEAREST_LINEAR: number;
  18192. /** mag = nearest and min = nearest and mip = none */
  18193. static readonly NEAREST_NEAREST: number;
  18194. /** mag = linear and min = nearest and mip = nearest */
  18195. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18196. /** mag = linear and min = nearest and mip = linear */
  18197. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18198. /** mag = linear and min = linear and mip = none */
  18199. static readonly LINEAR_LINEAR: number;
  18200. /** mag = linear and min = nearest and mip = none */
  18201. static readonly LINEAR_NEAREST: number;
  18202. /** Explicit coordinates mode */
  18203. static readonly EXPLICIT_MODE: number;
  18204. /** Spherical coordinates mode */
  18205. static readonly SPHERICAL_MODE: number;
  18206. /** Planar coordinates mode */
  18207. static readonly PLANAR_MODE: number;
  18208. /** Cubic coordinates mode */
  18209. static readonly CUBIC_MODE: number;
  18210. /** Projection coordinates mode */
  18211. static readonly PROJECTION_MODE: number;
  18212. /** Inverse Cubic coordinates mode */
  18213. static readonly SKYBOX_MODE: number;
  18214. /** Inverse Cubic coordinates mode */
  18215. static readonly INVCUBIC_MODE: number;
  18216. /** Equirectangular coordinates mode */
  18217. static readonly EQUIRECTANGULAR_MODE: number;
  18218. /** Equirectangular Fixed coordinates mode */
  18219. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18220. /** Equirectangular Fixed Mirrored coordinates mode */
  18221. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18222. /** Texture is not repeating outside of 0..1 UVs */
  18223. static readonly CLAMP_ADDRESSMODE: number;
  18224. /** Texture is repeating outside of 0..1 UVs */
  18225. static readonly WRAP_ADDRESSMODE: number;
  18226. /** Texture is repeating and mirrored */
  18227. static readonly MIRROR_ADDRESSMODE: number;
  18228. /**
  18229. * 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
  18230. */
  18231. static UseSerializedUrlIfAny: boolean;
  18232. /**
  18233. * Define the url of the texture.
  18234. */
  18235. url: Nullable<string>;
  18236. /**
  18237. * Define an offset on the texture to offset the u coordinates of the UVs
  18238. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18239. */
  18240. uOffset: number;
  18241. /**
  18242. * Define an offset on the texture to offset the v coordinates of the UVs
  18243. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18244. */
  18245. vOffset: number;
  18246. /**
  18247. * Define an offset on the texture to scale the u coordinates of the UVs
  18248. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18249. */
  18250. uScale: number;
  18251. /**
  18252. * Define an offset on the texture to scale the v coordinates of the UVs
  18253. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18254. */
  18255. vScale: number;
  18256. /**
  18257. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18258. * @see http://doc.babylonjs.com/how_to/more_materials
  18259. */
  18260. uAng: number;
  18261. /**
  18262. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18263. * @see http://doc.babylonjs.com/how_to/more_materials
  18264. */
  18265. vAng: number;
  18266. /**
  18267. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18268. * @see http://doc.babylonjs.com/how_to/more_materials
  18269. */
  18270. wAng: number;
  18271. /**
  18272. * Defines the center of rotation (U)
  18273. */
  18274. uRotationCenter: number;
  18275. /**
  18276. * Defines the center of rotation (V)
  18277. */
  18278. vRotationCenter: number;
  18279. /**
  18280. * Defines the center of rotation (W)
  18281. */
  18282. wRotationCenter: number;
  18283. /**
  18284. * Are mip maps generated for this texture or not.
  18285. */
  18286. readonly noMipmap: boolean;
  18287. /**
  18288. * List of inspectable custom properties (used by the Inspector)
  18289. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18290. */
  18291. inspectableCustomProperties: Nullable<IInspectable[]>;
  18292. private _noMipmap;
  18293. /** @hidden */
  18294. _invertY: boolean;
  18295. private _rowGenerationMatrix;
  18296. private _cachedTextureMatrix;
  18297. private _projectionModeMatrix;
  18298. private _t0;
  18299. private _t1;
  18300. private _t2;
  18301. private _cachedUOffset;
  18302. private _cachedVOffset;
  18303. private _cachedUScale;
  18304. private _cachedVScale;
  18305. private _cachedUAng;
  18306. private _cachedVAng;
  18307. private _cachedWAng;
  18308. private _cachedProjectionMatrixId;
  18309. private _cachedCoordinatesMode;
  18310. /** @hidden */
  18311. protected _initialSamplingMode: number;
  18312. /** @hidden */
  18313. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18314. private _deleteBuffer;
  18315. protected _format: Nullable<number>;
  18316. private _delayedOnLoad;
  18317. private _delayedOnError;
  18318. /**
  18319. * Observable triggered once the texture has been loaded.
  18320. */
  18321. onLoadObservable: Observable<Texture>;
  18322. protected _isBlocking: boolean;
  18323. /**
  18324. * Is the texture preventing material to render while loading.
  18325. * If false, a default texture will be used instead of the loading one during the preparation step.
  18326. */
  18327. isBlocking: boolean;
  18328. /**
  18329. * Get the current sampling mode associated with the texture.
  18330. */
  18331. readonly samplingMode: number;
  18332. /**
  18333. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18334. */
  18335. readonly invertY: boolean;
  18336. /**
  18337. * Instantiates a new texture.
  18338. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18339. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18340. * @param url define the url of the picture to load as a texture
  18341. * @param scene define the scene the texture will belong to
  18342. * @param noMipmap define if the texture will require mip maps or not
  18343. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18344. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18345. * @param onLoad define a callback triggered when the texture has been loaded
  18346. * @param onError define a callback triggered when an error occurred during the loading session
  18347. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18348. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18349. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18350. */
  18351. 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);
  18352. /**
  18353. * Update the url (and optional buffer) of this texture if url was null during construction.
  18354. * @param url the url of the texture
  18355. * @param buffer the buffer of the texture (defaults to null)
  18356. * @param onLoad callback called when the texture is loaded (defaults to null)
  18357. */
  18358. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18359. /**
  18360. * Finish the loading sequence of a texture flagged as delayed load.
  18361. * @hidden
  18362. */
  18363. delayLoad(): void;
  18364. private _prepareRowForTextureGeneration;
  18365. /**
  18366. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18367. * @returns the transform matrix of the texture.
  18368. */
  18369. getTextureMatrix(): Matrix;
  18370. /**
  18371. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18372. * @returns The reflection texture transform
  18373. */
  18374. getReflectionTextureMatrix(): Matrix;
  18375. /**
  18376. * Clones the texture.
  18377. * @returns the cloned texture
  18378. */
  18379. clone(): Texture;
  18380. /**
  18381. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18382. * @returns The JSON representation of the texture
  18383. */
  18384. serialize(): any;
  18385. /**
  18386. * Get the current class name of the texture useful for serialization or dynamic coding.
  18387. * @returns "Texture"
  18388. */
  18389. getClassName(): string;
  18390. /**
  18391. * Dispose the texture and release its associated resources.
  18392. */
  18393. dispose(): void;
  18394. /**
  18395. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18396. * @param parsedTexture Define the JSON representation of the texture
  18397. * @param scene Define the scene the parsed texture should be instantiated in
  18398. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18399. * @returns The parsed texture if successful
  18400. */
  18401. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18402. /**
  18403. * Creates a texture from its base 64 representation.
  18404. * @param data Define the base64 payload without the data: prefix
  18405. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18406. * @param scene Define the scene the texture should belong to
  18407. * @param noMipmap Forces the texture to not create mip map information if true
  18408. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18409. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18410. * @param onLoad define a callback triggered when the texture has been loaded
  18411. * @param onError define a callback triggered when an error occurred during the loading session
  18412. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18413. * @returns the created texture
  18414. */
  18415. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18416. /**
  18417. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18418. * @param data Define the base64 payload without the data: prefix
  18419. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18420. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18421. * @param scene Define the scene the texture should belong to
  18422. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18423. * @param noMipmap Forces the texture to not create mip map information if true
  18424. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18425. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18426. * @param onLoad define a callback triggered when the texture has been loaded
  18427. * @param onError define a callback triggered when an error occurred during the loading session
  18428. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18429. * @returns the created texture
  18430. */
  18431. 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;
  18432. }
  18433. }
  18434. declare module BABYLON {
  18435. interface Engine {
  18436. /**
  18437. * Creates a raw texture
  18438. * @param data defines the data to store in the texture
  18439. * @param width defines the width of the texture
  18440. * @param height defines the height of the texture
  18441. * @param format defines the format of the data
  18442. * @param generateMipMaps defines if the engine should generate the mip levels
  18443. * @param invertY defines if data must be stored with Y axis inverted
  18444. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18445. * @param compression defines the compression used (null by default)
  18446. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18447. * @returns the raw texture inside an InternalTexture
  18448. */
  18449. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18450. /**
  18451. * Update a raw texture
  18452. * @param texture defines the texture to update
  18453. * @param data defines the data to store in the texture
  18454. * @param format defines the format of the data
  18455. * @param invertY defines if data must be stored with Y axis inverted
  18456. */
  18457. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18458. /**
  18459. * Update a raw texture
  18460. * @param texture defines the texture to update
  18461. * @param data defines the data to store in the texture
  18462. * @param format defines the format of the data
  18463. * @param invertY defines if data must be stored with Y axis inverted
  18464. * @param compression defines the compression used (null by default)
  18465. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18466. */
  18467. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18468. /**
  18469. * Creates a new raw cube texture
  18470. * @param data defines the array of data to use to create each face
  18471. * @param size defines the size of the textures
  18472. * @param format defines the format of the data
  18473. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18474. * @param generateMipMaps defines if the engine should generate the mip levels
  18475. * @param invertY defines if data must be stored with Y axis inverted
  18476. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18477. * @param compression defines the compression used (null by default)
  18478. * @returns the cube texture as an InternalTexture
  18479. */
  18480. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18481. /**
  18482. * Update a raw cube texture
  18483. * @param texture defines the texture to udpdate
  18484. * @param data defines the data to store
  18485. * @param format defines the data format
  18486. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18487. * @param invertY defines if data must be stored with Y axis inverted
  18488. */
  18489. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18490. /**
  18491. * Update a raw cube texture
  18492. * @param texture defines the texture to udpdate
  18493. * @param data defines the data to store
  18494. * @param format defines the data format
  18495. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18496. * @param invertY defines if data must be stored with Y axis inverted
  18497. * @param compression defines the compression used (null by default)
  18498. */
  18499. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18500. /**
  18501. * Update a raw cube texture
  18502. * @param texture defines the texture to udpdate
  18503. * @param data defines the data to store
  18504. * @param format defines the data format
  18505. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18506. * @param invertY defines if data must be stored with Y axis inverted
  18507. * @param compression defines the compression used (null by default)
  18508. * @param level defines which level of the texture to update
  18509. */
  18510. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18511. /**
  18512. * Creates a new raw cube texture from a specified url
  18513. * @param url defines the url where the data is located
  18514. * @param scene defines the current scene
  18515. * @param size defines the size of the textures
  18516. * @param format defines the format of the data
  18517. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18518. * @param noMipmap defines if the engine should avoid generating the mip levels
  18519. * @param callback defines a callback used to extract texture data from loaded data
  18520. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18521. * @param onLoad defines a callback called when texture is loaded
  18522. * @param onError defines a callback called if there is an error
  18523. * @returns the cube texture as an InternalTexture
  18524. */
  18525. 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;
  18526. /**
  18527. * Creates a new raw cube texture from a specified url
  18528. * @param url defines the url where the data is located
  18529. * @param scene defines the current scene
  18530. * @param size defines the size of the textures
  18531. * @param format defines the format of the data
  18532. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18533. * @param noMipmap defines if the engine should avoid generating the mip levels
  18534. * @param callback defines a callback used to extract texture data from loaded data
  18535. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18536. * @param onLoad defines a callback called when texture is loaded
  18537. * @param onError defines a callback called if there is an error
  18538. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18539. * @param invertY defines if data must be stored with Y axis inverted
  18540. * @returns the cube texture as an InternalTexture
  18541. */
  18542. 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;
  18543. /**
  18544. * Creates a new raw 3D texture
  18545. * @param data defines the data used to create the texture
  18546. * @param width defines the width of the texture
  18547. * @param height defines the height of the texture
  18548. * @param depth defines the depth of the texture
  18549. * @param format defines the format of the texture
  18550. * @param generateMipMaps defines if the engine must generate mip levels
  18551. * @param invertY defines if data must be stored with Y axis inverted
  18552. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18553. * @param compression defines the compressed used (can be null)
  18554. * @param textureType defines the compressed used (can be null)
  18555. * @returns a new raw 3D texture (stored in an InternalTexture)
  18556. */
  18557. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18558. /**
  18559. * Update a raw 3D texture
  18560. * @param texture defines the texture to update
  18561. * @param data defines the data to store
  18562. * @param format defines the data format
  18563. * @param invertY defines if data must be stored with Y axis inverted
  18564. */
  18565. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18566. /**
  18567. * Update a raw 3D texture
  18568. * @param texture defines the texture to update
  18569. * @param data defines the data to store
  18570. * @param format defines the data format
  18571. * @param invertY defines if data must be stored with Y axis inverted
  18572. * @param compression defines the used compression (can be null)
  18573. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18574. */
  18575. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18576. }
  18577. }
  18578. declare module BABYLON {
  18579. /**
  18580. * Raw texture can help creating a texture directly from an array of data.
  18581. * This can be super useful if you either get the data from an uncompressed source or
  18582. * if you wish to create your texture pixel by pixel.
  18583. */
  18584. export class RawTexture extends Texture {
  18585. /**
  18586. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18587. */
  18588. format: number;
  18589. private _engine;
  18590. /**
  18591. * Instantiates a new RawTexture.
  18592. * Raw texture can help creating a texture directly from an array of data.
  18593. * This can be super useful if you either get the data from an uncompressed source or
  18594. * if you wish to create your texture pixel by pixel.
  18595. * @param data define the array of data to use to create the texture
  18596. * @param width define the width of the texture
  18597. * @param height define the height of the texture
  18598. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18599. * @param scene define the scene the texture belongs to
  18600. * @param generateMipMaps define whether mip maps should be generated or not
  18601. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18602. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18603. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18604. */
  18605. constructor(data: ArrayBufferView, width: number, height: number,
  18606. /**
  18607. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18608. */
  18609. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18610. /**
  18611. * Updates the texture underlying data.
  18612. * @param data Define the new data of the texture
  18613. */
  18614. update(data: ArrayBufferView): void;
  18615. /**
  18616. * Creates a luminance texture from some data.
  18617. * @param data Define the texture data
  18618. * @param width Define the width of the texture
  18619. * @param height Define the height of the texture
  18620. * @param scene Define the scene the texture belongs to
  18621. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18622. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18623. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18624. * @returns the luminance texture
  18625. */
  18626. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18627. /**
  18628. * Creates a luminance alpha texture from some data.
  18629. * @param data Define the texture data
  18630. * @param width Define the width of the texture
  18631. * @param height Define the height of the texture
  18632. * @param scene Define the scene the texture belongs to
  18633. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18634. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18635. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18636. * @returns the luminance alpha texture
  18637. */
  18638. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18639. /**
  18640. * Creates an alpha texture from some data.
  18641. * @param data Define the texture data
  18642. * @param width Define the width of the texture
  18643. * @param height Define the height of the texture
  18644. * @param scene Define the scene the texture belongs to
  18645. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18646. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18647. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18648. * @returns the alpha texture
  18649. */
  18650. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18651. /**
  18652. * Creates a RGB texture from some data.
  18653. * @param data Define the texture data
  18654. * @param width Define the width of the texture
  18655. * @param height Define the height of the texture
  18656. * @param scene Define the scene the texture belongs to
  18657. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18658. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18659. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18660. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18661. * @returns the RGB alpha texture
  18662. */
  18663. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18664. /**
  18665. * Creates a RGBA texture from some data.
  18666. * @param data Define the texture data
  18667. * @param width Define the width of the texture
  18668. * @param height Define the height of the texture
  18669. * @param scene Define the scene the texture belongs to
  18670. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18671. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18672. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18673. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18674. * @returns the RGBA texture
  18675. */
  18676. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18677. /**
  18678. * Creates a R texture from some data.
  18679. * @param data Define the texture data
  18680. * @param width Define the width of the texture
  18681. * @param height Define the height of the texture
  18682. * @param scene Define the scene the texture belongs to
  18683. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18684. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18685. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18686. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18687. * @returns the R texture
  18688. */
  18689. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18690. }
  18691. }
  18692. declare module BABYLON {
  18693. /**
  18694. * Defines a runtime animation
  18695. */
  18696. export class RuntimeAnimation {
  18697. private _events;
  18698. /**
  18699. * The current frame of the runtime animation
  18700. */
  18701. private _currentFrame;
  18702. /**
  18703. * The animation used by the runtime animation
  18704. */
  18705. private _animation;
  18706. /**
  18707. * The target of the runtime animation
  18708. */
  18709. private _target;
  18710. /**
  18711. * The initiating animatable
  18712. */
  18713. private _host;
  18714. /**
  18715. * The original value of the runtime animation
  18716. */
  18717. private _originalValue;
  18718. /**
  18719. * The original blend value of the runtime animation
  18720. */
  18721. private _originalBlendValue;
  18722. /**
  18723. * The offsets cache of the runtime animation
  18724. */
  18725. private _offsetsCache;
  18726. /**
  18727. * The high limits cache of the runtime animation
  18728. */
  18729. private _highLimitsCache;
  18730. /**
  18731. * Specifies if the runtime animation has been stopped
  18732. */
  18733. private _stopped;
  18734. /**
  18735. * The blending factor of the runtime animation
  18736. */
  18737. private _blendingFactor;
  18738. /**
  18739. * The BabylonJS scene
  18740. */
  18741. private _scene;
  18742. /**
  18743. * The current value of the runtime animation
  18744. */
  18745. private _currentValue;
  18746. /** @hidden */
  18747. _animationState: _IAnimationState;
  18748. /**
  18749. * The active target of the runtime animation
  18750. */
  18751. private _activeTargets;
  18752. private _currentActiveTarget;
  18753. private _directTarget;
  18754. /**
  18755. * The target path of the runtime animation
  18756. */
  18757. private _targetPath;
  18758. /**
  18759. * The weight of the runtime animation
  18760. */
  18761. private _weight;
  18762. /**
  18763. * The ratio offset of the runtime animation
  18764. */
  18765. private _ratioOffset;
  18766. /**
  18767. * The previous delay of the runtime animation
  18768. */
  18769. private _previousDelay;
  18770. /**
  18771. * The previous ratio of the runtime animation
  18772. */
  18773. private _previousRatio;
  18774. private _enableBlending;
  18775. private _keys;
  18776. private _minFrame;
  18777. private _maxFrame;
  18778. private _minValue;
  18779. private _maxValue;
  18780. private _targetIsArray;
  18781. /**
  18782. * Gets the current frame of the runtime animation
  18783. */
  18784. readonly currentFrame: number;
  18785. /**
  18786. * Gets the weight of the runtime animation
  18787. */
  18788. readonly weight: number;
  18789. /**
  18790. * Gets the current value of the runtime animation
  18791. */
  18792. readonly currentValue: any;
  18793. /**
  18794. * Gets the target path of the runtime animation
  18795. */
  18796. readonly targetPath: string;
  18797. /**
  18798. * Gets the actual target of the runtime animation
  18799. */
  18800. readonly target: any;
  18801. /** @hidden */
  18802. _onLoop: () => void;
  18803. /**
  18804. * Create a new RuntimeAnimation object
  18805. * @param target defines the target of the animation
  18806. * @param animation defines the source animation object
  18807. * @param scene defines the hosting scene
  18808. * @param host defines the initiating Animatable
  18809. */
  18810. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18811. private _preparePath;
  18812. /**
  18813. * Gets the animation from the runtime animation
  18814. */
  18815. readonly animation: Animation;
  18816. /**
  18817. * Resets the runtime animation to the beginning
  18818. * @param restoreOriginal defines whether to restore the target property to the original value
  18819. */
  18820. reset(restoreOriginal?: boolean): void;
  18821. /**
  18822. * Specifies if the runtime animation is stopped
  18823. * @returns Boolean specifying if the runtime animation is stopped
  18824. */
  18825. isStopped(): boolean;
  18826. /**
  18827. * Disposes of the runtime animation
  18828. */
  18829. dispose(): void;
  18830. /**
  18831. * Apply the interpolated value to the target
  18832. * @param currentValue defines the value computed by the animation
  18833. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18834. */
  18835. setValue(currentValue: any, weight: number): void;
  18836. private _getOriginalValues;
  18837. private _setValue;
  18838. /**
  18839. * Gets the loop pmode of the runtime animation
  18840. * @returns Loop Mode
  18841. */
  18842. private _getCorrectLoopMode;
  18843. /**
  18844. * Move the current animation to a given frame
  18845. * @param frame defines the frame to move to
  18846. */
  18847. goToFrame(frame: number): void;
  18848. /**
  18849. * @hidden Internal use only
  18850. */
  18851. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18852. /**
  18853. * Execute the current animation
  18854. * @param delay defines the delay to add to the current frame
  18855. * @param from defines the lower bound of the animation range
  18856. * @param to defines the upper bound of the animation range
  18857. * @param loop defines if the current animation must loop
  18858. * @param speedRatio defines the current speed ratio
  18859. * @param weight defines the weight of the animation (default is -1 so no weight)
  18860. * @param onLoop optional callback called when animation loops
  18861. * @returns a boolean indicating if the animation is running
  18862. */
  18863. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  18864. }
  18865. }
  18866. declare module BABYLON {
  18867. /**
  18868. * Class used to store an actual running animation
  18869. */
  18870. export class Animatable {
  18871. /** defines the target object */
  18872. target: any;
  18873. /** defines the starting frame number (default is 0) */
  18874. fromFrame: number;
  18875. /** defines the ending frame number (default is 100) */
  18876. toFrame: number;
  18877. /** defines if the animation must loop (default is false) */
  18878. loopAnimation: boolean;
  18879. /** defines a callback to call when animation ends if it is not looping */
  18880. onAnimationEnd?: (() => void) | null | undefined;
  18881. /** defines a callback to call when animation loops */
  18882. onAnimationLoop?: (() => void) | null | undefined;
  18883. private _localDelayOffset;
  18884. private _pausedDelay;
  18885. private _runtimeAnimations;
  18886. private _paused;
  18887. private _scene;
  18888. private _speedRatio;
  18889. private _weight;
  18890. private _syncRoot;
  18891. /**
  18892. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18893. * This will only apply for non looping animation (default is true)
  18894. */
  18895. disposeOnEnd: boolean;
  18896. /**
  18897. * Gets a boolean indicating if the animation has started
  18898. */
  18899. animationStarted: boolean;
  18900. /**
  18901. * Observer raised when the animation ends
  18902. */
  18903. onAnimationEndObservable: Observable<Animatable>;
  18904. /**
  18905. * Observer raised when the animation loops
  18906. */
  18907. onAnimationLoopObservable: Observable<Animatable>;
  18908. /**
  18909. * Gets the root Animatable used to synchronize and normalize animations
  18910. */
  18911. readonly syncRoot: Nullable<Animatable>;
  18912. /**
  18913. * Gets the current frame of the first RuntimeAnimation
  18914. * Used to synchronize Animatables
  18915. */
  18916. readonly masterFrame: number;
  18917. /**
  18918. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18919. */
  18920. weight: number;
  18921. /**
  18922. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18923. */
  18924. speedRatio: number;
  18925. /**
  18926. * Creates a new Animatable
  18927. * @param scene defines the hosting scene
  18928. * @param target defines the target object
  18929. * @param fromFrame defines the starting frame number (default is 0)
  18930. * @param toFrame defines the ending frame number (default is 100)
  18931. * @param loopAnimation defines if the animation must loop (default is false)
  18932. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18933. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18934. * @param animations defines a group of animation to add to the new Animatable
  18935. * @param onAnimationLoop defines a callback to call when animation loops
  18936. */
  18937. constructor(scene: Scene,
  18938. /** defines the target object */
  18939. target: any,
  18940. /** defines the starting frame number (default is 0) */
  18941. fromFrame?: number,
  18942. /** defines the ending frame number (default is 100) */
  18943. toFrame?: number,
  18944. /** defines if the animation must loop (default is false) */
  18945. loopAnimation?: boolean, speedRatio?: number,
  18946. /** defines a callback to call when animation ends if it is not looping */
  18947. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18948. /** defines a callback to call when animation loops */
  18949. onAnimationLoop?: (() => void) | null | undefined);
  18950. /**
  18951. * Synchronize and normalize current Animatable with a source Animatable
  18952. * This is useful when using animation weights and when animations are not of the same length
  18953. * @param root defines the root Animatable to synchronize with
  18954. * @returns the current Animatable
  18955. */
  18956. syncWith(root: Animatable): Animatable;
  18957. /**
  18958. * Gets the list of runtime animations
  18959. * @returns an array of RuntimeAnimation
  18960. */
  18961. getAnimations(): RuntimeAnimation[];
  18962. /**
  18963. * Adds more animations to the current animatable
  18964. * @param target defines the target of the animations
  18965. * @param animations defines the new animations to add
  18966. */
  18967. appendAnimations(target: any, animations: Animation[]): void;
  18968. /**
  18969. * Gets the source animation for a specific property
  18970. * @param property defines the propertyu to look for
  18971. * @returns null or the source animation for the given property
  18972. */
  18973. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18974. /**
  18975. * Gets the runtime animation for a specific property
  18976. * @param property defines the propertyu to look for
  18977. * @returns null or the runtime animation for the given property
  18978. */
  18979. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18980. /**
  18981. * Resets the animatable to its original state
  18982. */
  18983. reset(): void;
  18984. /**
  18985. * Allows the animatable to blend with current running animations
  18986. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18987. * @param blendingSpeed defines the blending speed to use
  18988. */
  18989. enableBlending(blendingSpeed: number): void;
  18990. /**
  18991. * Disable animation blending
  18992. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18993. */
  18994. disableBlending(): void;
  18995. /**
  18996. * Jump directly to a given frame
  18997. * @param frame defines the frame to jump to
  18998. */
  18999. goToFrame(frame: number): void;
  19000. /**
  19001. * Pause the animation
  19002. */
  19003. pause(): void;
  19004. /**
  19005. * Restart the animation
  19006. */
  19007. restart(): void;
  19008. private _raiseOnAnimationEnd;
  19009. /**
  19010. * Stop and delete the current animation
  19011. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19012. * @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)
  19013. */
  19014. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19015. /**
  19016. * Wait asynchronously for the animation to end
  19017. * @returns a promise which will be fullfilled when the animation ends
  19018. */
  19019. waitAsync(): Promise<Animatable>;
  19020. /** @hidden */
  19021. _animate(delay: number): boolean;
  19022. }
  19023. interface Scene {
  19024. /** @hidden */
  19025. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19026. /** @hidden */
  19027. _processLateAnimationBindingsForMatrices(holder: {
  19028. totalWeight: number;
  19029. animations: RuntimeAnimation[];
  19030. originalValue: Matrix;
  19031. }): any;
  19032. /** @hidden */
  19033. _processLateAnimationBindingsForQuaternions(holder: {
  19034. totalWeight: number;
  19035. animations: RuntimeAnimation[];
  19036. originalValue: Quaternion;
  19037. }, refQuaternion: Quaternion): Quaternion;
  19038. /** @hidden */
  19039. _processLateAnimationBindings(): void;
  19040. /**
  19041. * Will start the animation sequence of a given target
  19042. * @param target defines the target
  19043. * @param from defines from which frame should animation start
  19044. * @param to defines until which frame should animation run.
  19045. * @param weight defines the weight to apply to the animation (1.0 by default)
  19046. * @param loop defines if the animation loops
  19047. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19048. * @param onAnimationEnd defines the function to be executed when the animation ends
  19049. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19050. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19051. * @param onAnimationLoop defines the callback to call when an animation loops
  19052. * @returns the animatable object created for this animation
  19053. */
  19054. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19055. /**
  19056. * Will start the animation sequence of a given target
  19057. * @param target defines the target
  19058. * @param from defines from which frame should animation start
  19059. * @param to defines until which frame should animation run.
  19060. * @param loop defines if the animation loops
  19061. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19062. * @param onAnimationEnd defines the function to be executed when the animation ends
  19063. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19064. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19065. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19066. * @param onAnimationLoop defines the callback to call when an animation loops
  19067. * @returns the animatable object created for this animation
  19068. */
  19069. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19070. /**
  19071. * Will start the animation sequence of a given target and its hierarchy
  19072. * @param target defines the target
  19073. * @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.
  19074. * @param from defines from which frame should animation start
  19075. * @param to defines until which frame should animation run.
  19076. * @param loop defines if the animation loops
  19077. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19078. * @param onAnimationEnd defines the function to be executed when the animation ends
  19079. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19080. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19081. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19082. * @param onAnimationLoop defines the callback to call when an animation loops
  19083. * @returns the list of created animatables
  19084. */
  19085. 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[];
  19086. /**
  19087. * Begin a new animation on a given node
  19088. * @param target defines the target where the animation will take place
  19089. * @param animations defines the list of animations to start
  19090. * @param from defines the initial value
  19091. * @param to defines the final value
  19092. * @param loop defines if you want animation to loop (off by default)
  19093. * @param speedRatio defines the speed ratio to apply to all animations
  19094. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19095. * @param onAnimationLoop defines the callback to call when an animation loops
  19096. * @returns the list of created animatables
  19097. */
  19098. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19099. /**
  19100. * Begin a new animation on a given node and its hierarchy
  19101. * @param target defines the root node where the animation will take place
  19102. * @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.
  19103. * @param animations defines the list of animations to start
  19104. * @param from defines the initial value
  19105. * @param to defines the final value
  19106. * @param loop defines if you want animation to loop (off by default)
  19107. * @param speedRatio defines the speed ratio to apply to all animations
  19108. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19109. * @param onAnimationLoop defines the callback to call when an animation loops
  19110. * @returns the list of animatables created for all nodes
  19111. */
  19112. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19113. /**
  19114. * Gets the animatable associated with a specific target
  19115. * @param target defines the target of the animatable
  19116. * @returns the required animatable if found
  19117. */
  19118. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19119. /**
  19120. * Gets all animatables associated with a given target
  19121. * @param target defines the target to look animatables for
  19122. * @returns an array of Animatables
  19123. */
  19124. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19125. /**
  19126. * Stops and removes all animations that have been applied to the scene
  19127. */
  19128. stopAllAnimations(): void;
  19129. }
  19130. interface Bone {
  19131. /**
  19132. * Copy an animation range from another bone
  19133. * @param source defines the source bone
  19134. * @param rangeName defines the range name to copy
  19135. * @param frameOffset defines the frame offset
  19136. * @param rescaleAsRequired defines if rescaling must be applied if required
  19137. * @param skelDimensionsRatio defines the scaling ratio
  19138. * @returns true if operation was successful
  19139. */
  19140. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19141. }
  19142. }
  19143. declare module BABYLON {
  19144. /**
  19145. * Class used to handle skinning animations
  19146. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19147. */
  19148. export class Skeleton implements IAnimatable {
  19149. /** defines the skeleton name */
  19150. name: string;
  19151. /** defines the skeleton Id */
  19152. id: string;
  19153. /**
  19154. * Defines the list of child bones
  19155. */
  19156. bones: Bone[];
  19157. /**
  19158. * Defines an estimate of the dimension of the skeleton at rest
  19159. */
  19160. dimensionsAtRest: Vector3;
  19161. /**
  19162. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19163. */
  19164. needInitialSkinMatrix: boolean;
  19165. /**
  19166. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19167. */
  19168. overrideMesh: Nullable<AbstractMesh>;
  19169. /**
  19170. * Gets the list of animations attached to this skeleton
  19171. */
  19172. animations: Array<Animation>;
  19173. private _scene;
  19174. private _isDirty;
  19175. private _transformMatrices;
  19176. private _transformMatrixTexture;
  19177. private _meshesWithPoseMatrix;
  19178. private _animatables;
  19179. private _identity;
  19180. private _synchronizedWithMesh;
  19181. private _ranges;
  19182. private _lastAbsoluteTransformsUpdateId;
  19183. private _canUseTextureForBones;
  19184. private _uniqueId;
  19185. /** @hidden */
  19186. _numBonesWithLinkedTransformNode: number;
  19187. /** @hidden */
  19188. _hasWaitingData: Nullable<boolean>;
  19189. /**
  19190. * Specifies if the skeleton should be serialized
  19191. */
  19192. doNotSerialize: boolean;
  19193. private _useTextureToStoreBoneMatrices;
  19194. /**
  19195. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19196. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19197. */
  19198. useTextureToStoreBoneMatrices: boolean;
  19199. private _animationPropertiesOverride;
  19200. /**
  19201. * Gets or sets the animation properties override
  19202. */
  19203. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19204. /**
  19205. * List of inspectable custom properties (used by the Inspector)
  19206. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19207. */
  19208. inspectableCustomProperties: IInspectable[];
  19209. /**
  19210. * An observable triggered before computing the skeleton's matrices
  19211. */
  19212. onBeforeComputeObservable: Observable<Skeleton>;
  19213. /**
  19214. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19215. */
  19216. readonly isUsingTextureForMatrices: boolean;
  19217. /**
  19218. * Gets the unique ID of this skeleton
  19219. */
  19220. readonly uniqueId: number;
  19221. /**
  19222. * Creates a new skeleton
  19223. * @param name defines the skeleton name
  19224. * @param id defines the skeleton Id
  19225. * @param scene defines the hosting scene
  19226. */
  19227. constructor(
  19228. /** defines the skeleton name */
  19229. name: string,
  19230. /** defines the skeleton Id */
  19231. id: string, scene: Scene);
  19232. /**
  19233. * Gets the current object class name.
  19234. * @return the class name
  19235. */
  19236. getClassName(): string;
  19237. /**
  19238. * Returns an array containing the root bones
  19239. * @returns an array containing the root bones
  19240. */
  19241. getChildren(): Array<Bone>;
  19242. /**
  19243. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19244. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19245. * @returns a Float32Array containing matrices data
  19246. */
  19247. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19248. /**
  19249. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19250. * @returns a raw texture containing the data
  19251. */
  19252. getTransformMatrixTexture(): Nullable<RawTexture>;
  19253. /**
  19254. * Gets the current hosting scene
  19255. * @returns a scene object
  19256. */
  19257. getScene(): Scene;
  19258. /**
  19259. * Gets a string representing the current skeleton data
  19260. * @param fullDetails defines a boolean indicating if we want a verbose version
  19261. * @returns a string representing the current skeleton data
  19262. */
  19263. toString(fullDetails?: boolean): string;
  19264. /**
  19265. * Get bone's index searching by name
  19266. * @param name defines bone's name to search for
  19267. * @return the indice of the bone. Returns -1 if not found
  19268. */
  19269. getBoneIndexByName(name: string): number;
  19270. /**
  19271. * Creater a new animation range
  19272. * @param name defines the name of the range
  19273. * @param from defines the start key
  19274. * @param to defines the end key
  19275. */
  19276. createAnimationRange(name: string, from: number, to: number): void;
  19277. /**
  19278. * Delete a specific animation range
  19279. * @param name defines the name of the range
  19280. * @param deleteFrames defines if frames must be removed as well
  19281. */
  19282. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19283. /**
  19284. * Gets a specific animation range
  19285. * @param name defines the name of the range to look for
  19286. * @returns the requested animation range or null if not found
  19287. */
  19288. getAnimationRange(name: string): Nullable<AnimationRange>;
  19289. /**
  19290. * Gets the list of all animation ranges defined on this skeleton
  19291. * @returns an array
  19292. */
  19293. getAnimationRanges(): Nullable<AnimationRange>[];
  19294. /**
  19295. * Copy animation range from a source skeleton.
  19296. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19297. * @param source defines the source skeleton
  19298. * @param name defines the name of the range to copy
  19299. * @param rescaleAsRequired defines if rescaling must be applied if required
  19300. * @returns true if operation was successful
  19301. */
  19302. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19303. /**
  19304. * Forces the skeleton to go to rest pose
  19305. */
  19306. returnToRest(): void;
  19307. private _getHighestAnimationFrame;
  19308. /**
  19309. * Begin a specific animation range
  19310. * @param name defines the name of the range to start
  19311. * @param loop defines if looping must be turned on (false by default)
  19312. * @param speedRatio defines the speed ratio to apply (1 by default)
  19313. * @param onAnimationEnd defines a callback which will be called when animation will end
  19314. * @returns a new animatable
  19315. */
  19316. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19317. /** @hidden */
  19318. _markAsDirty(): void;
  19319. /** @hidden */
  19320. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19321. /** @hidden */
  19322. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19323. private _computeTransformMatrices;
  19324. /**
  19325. * Build all resources required to render a skeleton
  19326. */
  19327. prepare(): void;
  19328. /**
  19329. * Gets the list of animatables currently running for this skeleton
  19330. * @returns an array of animatables
  19331. */
  19332. getAnimatables(): IAnimatable[];
  19333. /**
  19334. * Clone the current skeleton
  19335. * @param name defines the name of the new skeleton
  19336. * @param id defines the id of the new skeleton
  19337. * @returns the new skeleton
  19338. */
  19339. clone(name: string, id: string): Skeleton;
  19340. /**
  19341. * Enable animation blending for this skeleton
  19342. * @param blendingSpeed defines the blending speed to apply
  19343. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19344. */
  19345. enableBlending(blendingSpeed?: number): void;
  19346. /**
  19347. * Releases all resources associated with the current skeleton
  19348. */
  19349. dispose(): void;
  19350. /**
  19351. * Serialize the skeleton in a JSON object
  19352. * @returns a JSON object
  19353. */
  19354. serialize(): any;
  19355. /**
  19356. * Creates a new skeleton from serialized data
  19357. * @param parsedSkeleton defines the serialized data
  19358. * @param scene defines the hosting scene
  19359. * @returns a new skeleton
  19360. */
  19361. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19362. /**
  19363. * Compute all node absolute transforms
  19364. * @param forceUpdate defines if computation must be done even if cache is up to date
  19365. */
  19366. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19367. /**
  19368. * Gets the root pose matrix
  19369. * @returns a matrix
  19370. */
  19371. getPoseMatrix(): Nullable<Matrix>;
  19372. /**
  19373. * Sorts bones per internal index
  19374. */
  19375. sortBones(): void;
  19376. private _sortBones;
  19377. }
  19378. }
  19379. declare module BABYLON {
  19380. /**
  19381. * Defines a target to use with MorphTargetManager
  19382. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19383. */
  19384. export class MorphTarget implements IAnimatable {
  19385. /** defines the name of the target */
  19386. name: string;
  19387. /**
  19388. * Gets or sets the list of animations
  19389. */
  19390. animations: Animation[];
  19391. private _scene;
  19392. private _positions;
  19393. private _normals;
  19394. private _tangents;
  19395. private _influence;
  19396. /**
  19397. * Observable raised when the influence changes
  19398. */
  19399. onInfluenceChanged: Observable<boolean>;
  19400. /** @hidden */
  19401. _onDataLayoutChanged: Observable<void>;
  19402. /**
  19403. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19404. */
  19405. influence: number;
  19406. /**
  19407. * Gets or sets the id of the morph Target
  19408. */
  19409. id: string;
  19410. private _animationPropertiesOverride;
  19411. /**
  19412. * Gets or sets the animation properties override
  19413. */
  19414. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19415. /**
  19416. * Creates a new MorphTarget
  19417. * @param name defines the name of the target
  19418. * @param influence defines the influence to use
  19419. * @param scene defines the scene the morphtarget belongs to
  19420. */
  19421. constructor(
  19422. /** defines the name of the target */
  19423. name: string, influence?: number, scene?: Nullable<Scene>);
  19424. /**
  19425. * Gets a boolean defining if the target contains position data
  19426. */
  19427. readonly hasPositions: boolean;
  19428. /**
  19429. * Gets a boolean defining if the target contains normal data
  19430. */
  19431. readonly hasNormals: boolean;
  19432. /**
  19433. * Gets a boolean defining if the target contains tangent data
  19434. */
  19435. readonly hasTangents: boolean;
  19436. /**
  19437. * Affects position data to this target
  19438. * @param data defines the position data to use
  19439. */
  19440. setPositions(data: Nullable<FloatArray>): void;
  19441. /**
  19442. * Gets the position data stored in this target
  19443. * @returns a FloatArray containing the position data (or null if not present)
  19444. */
  19445. getPositions(): Nullable<FloatArray>;
  19446. /**
  19447. * Affects normal data to this target
  19448. * @param data defines the normal data to use
  19449. */
  19450. setNormals(data: Nullable<FloatArray>): void;
  19451. /**
  19452. * Gets the normal data stored in this target
  19453. * @returns a FloatArray containing the normal data (or null if not present)
  19454. */
  19455. getNormals(): Nullable<FloatArray>;
  19456. /**
  19457. * Affects tangent data to this target
  19458. * @param data defines the tangent data to use
  19459. */
  19460. setTangents(data: Nullable<FloatArray>): void;
  19461. /**
  19462. * Gets the tangent data stored in this target
  19463. * @returns a FloatArray containing the tangent data (or null if not present)
  19464. */
  19465. getTangents(): Nullable<FloatArray>;
  19466. /**
  19467. * Serializes the current target into a Serialization object
  19468. * @returns the serialized object
  19469. */
  19470. serialize(): any;
  19471. /**
  19472. * Returns the string "MorphTarget"
  19473. * @returns "MorphTarget"
  19474. */
  19475. getClassName(): string;
  19476. /**
  19477. * Creates a new target from serialized data
  19478. * @param serializationObject defines the serialized data to use
  19479. * @returns a new MorphTarget
  19480. */
  19481. static Parse(serializationObject: any): MorphTarget;
  19482. /**
  19483. * Creates a MorphTarget from mesh data
  19484. * @param mesh defines the source mesh
  19485. * @param name defines the name to use for the new target
  19486. * @param influence defines the influence to attach to the target
  19487. * @returns a new MorphTarget
  19488. */
  19489. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19490. }
  19491. }
  19492. declare module BABYLON {
  19493. /**
  19494. * This class is used to deform meshes using morphing between different targets
  19495. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19496. */
  19497. export class MorphTargetManager {
  19498. private _targets;
  19499. private _targetInfluenceChangedObservers;
  19500. private _targetDataLayoutChangedObservers;
  19501. private _activeTargets;
  19502. private _scene;
  19503. private _influences;
  19504. private _supportsNormals;
  19505. private _supportsTangents;
  19506. private _vertexCount;
  19507. private _uniqueId;
  19508. private _tempInfluences;
  19509. /**
  19510. * Creates a new MorphTargetManager
  19511. * @param scene defines the current scene
  19512. */
  19513. constructor(scene?: Nullable<Scene>);
  19514. /**
  19515. * Gets the unique ID of this manager
  19516. */
  19517. readonly uniqueId: number;
  19518. /**
  19519. * Gets the number of vertices handled by this manager
  19520. */
  19521. readonly vertexCount: number;
  19522. /**
  19523. * Gets a boolean indicating if this manager supports morphing of normals
  19524. */
  19525. readonly supportsNormals: boolean;
  19526. /**
  19527. * Gets a boolean indicating if this manager supports morphing of tangents
  19528. */
  19529. readonly supportsTangents: boolean;
  19530. /**
  19531. * Gets the number of targets stored in this manager
  19532. */
  19533. readonly numTargets: number;
  19534. /**
  19535. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19536. */
  19537. readonly numInfluencers: number;
  19538. /**
  19539. * Gets the list of influences (one per target)
  19540. */
  19541. readonly influences: Float32Array;
  19542. /**
  19543. * Gets the active target at specified index. An active target is a target with an influence > 0
  19544. * @param index defines the index to check
  19545. * @returns the requested target
  19546. */
  19547. getActiveTarget(index: number): MorphTarget;
  19548. /**
  19549. * Gets the target at specified index
  19550. * @param index defines the index to check
  19551. * @returns the requested target
  19552. */
  19553. getTarget(index: number): MorphTarget;
  19554. /**
  19555. * Add a new target to this manager
  19556. * @param target defines the target to add
  19557. */
  19558. addTarget(target: MorphTarget): void;
  19559. /**
  19560. * Removes a target from the manager
  19561. * @param target defines the target to remove
  19562. */
  19563. removeTarget(target: MorphTarget): void;
  19564. /**
  19565. * Serializes the current manager into a Serialization object
  19566. * @returns the serialized object
  19567. */
  19568. serialize(): any;
  19569. private _syncActiveTargets;
  19570. /**
  19571. * Syncrhonize the targets with all the meshes using this morph target manager
  19572. */
  19573. synchronize(): void;
  19574. /**
  19575. * Creates a new MorphTargetManager from serialized data
  19576. * @param serializationObject defines the serialized data
  19577. * @param scene defines the hosting scene
  19578. * @returns the new MorphTargetManager
  19579. */
  19580. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19581. }
  19582. }
  19583. declare module BABYLON {
  19584. /**
  19585. * Class used to represent a specific level of detail of a mesh
  19586. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19587. */
  19588. export class MeshLODLevel {
  19589. /** Defines the distance where this level should star being displayed */
  19590. distance: number;
  19591. /** Defines the mesh to use to render this level */
  19592. mesh: Nullable<Mesh>;
  19593. /**
  19594. * Creates a new LOD level
  19595. * @param distance defines the distance where this level should star being displayed
  19596. * @param mesh defines the mesh to use to render this level
  19597. */
  19598. constructor(
  19599. /** Defines the distance where this level should star being displayed */
  19600. distance: number,
  19601. /** Defines the mesh to use to render this level */
  19602. mesh: Nullable<Mesh>);
  19603. }
  19604. }
  19605. declare module BABYLON {
  19606. /**
  19607. * Mesh representing the gorund
  19608. */
  19609. export class GroundMesh extends Mesh {
  19610. /** If octree should be generated */
  19611. generateOctree: boolean;
  19612. private _heightQuads;
  19613. /** @hidden */
  19614. _subdivisionsX: number;
  19615. /** @hidden */
  19616. _subdivisionsY: number;
  19617. /** @hidden */
  19618. _width: number;
  19619. /** @hidden */
  19620. _height: number;
  19621. /** @hidden */
  19622. _minX: number;
  19623. /** @hidden */
  19624. _maxX: number;
  19625. /** @hidden */
  19626. _minZ: number;
  19627. /** @hidden */
  19628. _maxZ: number;
  19629. constructor(name: string, scene: Scene);
  19630. /**
  19631. * "GroundMesh"
  19632. * @returns "GroundMesh"
  19633. */
  19634. getClassName(): string;
  19635. /**
  19636. * The minimum of x and y subdivisions
  19637. */
  19638. readonly subdivisions: number;
  19639. /**
  19640. * X subdivisions
  19641. */
  19642. readonly subdivisionsX: number;
  19643. /**
  19644. * Y subdivisions
  19645. */
  19646. readonly subdivisionsY: number;
  19647. /**
  19648. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19649. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19650. * @param chunksCount the number of subdivisions for x and y
  19651. * @param octreeBlocksSize (Default: 32)
  19652. */
  19653. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19654. /**
  19655. * Returns a height (y) value in the Worl system :
  19656. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19657. * @param x x coordinate
  19658. * @param z z coordinate
  19659. * @returns the ground y position if (x, z) are outside the ground surface.
  19660. */
  19661. getHeightAtCoordinates(x: number, z: number): number;
  19662. /**
  19663. * Returns a normalized vector (Vector3) orthogonal to the ground
  19664. * at the ground coordinates (x, z) expressed in the World system.
  19665. * @param x x coordinate
  19666. * @param z z coordinate
  19667. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19668. */
  19669. getNormalAtCoordinates(x: number, z: number): Vector3;
  19670. /**
  19671. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19672. * at the ground coordinates (x, z) expressed in the World system.
  19673. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19674. * @param x x coordinate
  19675. * @param z z coordinate
  19676. * @param ref vector to store the result
  19677. * @returns the GroundMesh.
  19678. */
  19679. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19680. /**
  19681. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19682. * if the ground has been updated.
  19683. * This can be used in the render loop.
  19684. * @returns the GroundMesh.
  19685. */
  19686. updateCoordinateHeights(): GroundMesh;
  19687. private _getFacetAt;
  19688. private _initHeightQuads;
  19689. private _computeHeightQuads;
  19690. /**
  19691. * Serializes this ground mesh
  19692. * @param serializationObject object to write serialization to
  19693. */
  19694. serialize(serializationObject: any): void;
  19695. /**
  19696. * Parses a serialized ground mesh
  19697. * @param parsedMesh the serialized mesh
  19698. * @param scene the scene to create the ground mesh in
  19699. * @returns the created ground mesh
  19700. */
  19701. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19702. }
  19703. }
  19704. declare module BABYLON {
  19705. /**
  19706. * Interface for Physics-Joint data
  19707. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19708. */
  19709. export interface PhysicsJointData {
  19710. /**
  19711. * The main pivot of the joint
  19712. */
  19713. mainPivot?: Vector3;
  19714. /**
  19715. * The connected pivot of the joint
  19716. */
  19717. connectedPivot?: Vector3;
  19718. /**
  19719. * The main axis of the joint
  19720. */
  19721. mainAxis?: Vector3;
  19722. /**
  19723. * The connected axis of the joint
  19724. */
  19725. connectedAxis?: Vector3;
  19726. /**
  19727. * The collision of the joint
  19728. */
  19729. collision?: boolean;
  19730. /**
  19731. * Native Oimo/Cannon/Energy data
  19732. */
  19733. nativeParams?: any;
  19734. }
  19735. /**
  19736. * This is a holder class for the physics joint created by the physics plugin
  19737. * It holds a set of functions to control the underlying joint
  19738. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19739. */
  19740. export class PhysicsJoint {
  19741. /**
  19742. * The type of the physics joint
  19743. */
  19744. type: number;
  19745. /**
  19746. * The data for the physics joint
  19747. */
  19748. jointData: PhysicsJointData;
  19749. private _physicsJoint;
  19750. protected _physicsPlugin: IPhysicsEnginePlugin;
  19751. /**
  19752. * Initializes the physics joint
  19753. * @param type The type of the physics joint
  19754. * @param jointData The data for the physics joint
  19755. */
  19756. constructor(
  19757. /**
  19758. * The type of the physics joint
  19759. */
  19760. type: number,
  19761. /**
  19762. * The data for the physics joint
  19763. */
  19764. jointData: PhysicsJointData);
  19765. /**
  19766. * Gets the physics joint
  19767. */
  19768. /**
  19769. * Sets the physics joint
  19770. */
  19771. physicsJoint: any;
  19772. /**
  19773. * Sets the physics plugin
  19774. */
  19775. physicsPlugin: IPhysicsEnginePlugin;
  19776. /**
  19777. * Execute a function that is physics-plugin specific.
  19778. * @param {Function} func the function that will be executed.
  19779. * It accepts two parameters: the physics world and the physics joint
  19780. */
  19781. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19782. /**
  19783. * Distance-Joint type
  19784. */
  19785. static DistanceJoint: number;
  19786. /**
  19787. * Hinge-Joint type
  19788. */
  19789. static HingeJoint: number;
  19790. /**
  19791. * Ball-and-Socket joint type
  19792. */
  19793. static BallAndSocketJoint: number;
  19794. /**
  19795. * Wheel-Joint type
  19796. */
  19797. static WheelJoint: number;
  19798. /**
  19799. * Slider-Joint type
  19800. */
  19801. static SliderJoint: number;
  19802. /**
  19803. * Prismatic-Joint type
  19804. */
  19805. static PrismaticJoint: number;
  19806. /**
  19807. * Universal-Joint type
  19808. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19809. */
  19810. static UniversalJoint: number;
  19811. /**
  19812. * Hinge-Joint 2 type
  19813. */
  19814. static Hinge2Joint: number;
  19815. /**
  19816. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19817. */
  19818. static PointToPointJoint: number;
  19819. /**
  19820. * Spring-Joint type
  19821. */
  19822. static SpringJoint: number;
  19823. /**
  19824. * Lock-Joint type
  19825. */
  19826. static LockJoint: number;
  19827. }
  19828. /**
  19829. * A class representing a physics distance joint
  19830. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19831. */
  19832. export class DistanceJoint extends PhysicsJoint {
  19833. /**
  19834. *
  19835. * @param jointData The data for the Distance-Joint
  19836. */
  19837. constructor(jointData: DistanceJointData);
  19838. /**
  19839. * Update the predefined distance.
  19840. * @param maxDistance The maximum preferred distance
  19841. * @param minDistance The minimum preferred distance
  19842. */
  19843. updateDistance(maxDistance: number, minDistance?: number): void;
  19844. }
  19845. /**
  19846. * Represents a Motor-Enabled Joint
  19847. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19848. */
  19849. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19850. /**
  19851. * Initializes the Motor-Enabled Joint
  19852. * @param type The type of the joint
  19853. * @param jointData The physica joint data for the joint
  19854. */
  19855. constructor(type: number, jointData: PhysicsJointData);
  19856. /**
  19857. * Set the motor values.
  19858. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19859. * @param force the force to apply
  19860. * @param maxForce max force for this motor.
  19861. */
  19862. setMotor(force?: number, maxForce?: number): void;
  19863. /**
  19864. * Set the motor's limits.
  19865. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19866. * @param upperLimit The upper limit of the motor
  19867. * @param lowerLimit The lower limit of the motor
  19868. */
  19869. setLimit(upperLimit: number, lowerLimit?: number): void;
  19870. }
  19871. /**
  19872. * This class represents a single physics Hinge-Joint
  19873. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19874. */
  19875. export class HingeJoint extends MotorEnabledJoint {
  19876. /**
  19877. * Initializes the Hinge-Joint
  19878. * @param jointData The joint data for the Hinge-Joint
  19879. */
  19880. constructor(jointData: PhysicsJointData);
  19881. /**
  19882. * Set the motor values.
  19883. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19884. * @param {number} force the force to apply
  19885. * @param {number} maxForce max force for this motor.
  19886. */
  19887. setMotor(force?: number, maxForce?: number): void;
  19888. /**
  19889. * Set the motor's limits.
  19890. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19891. * @param upperLimit The upper limit of the motor
  19892. * @param lowerLimit The lower limit of the motor
  19893. */
  19894. setLimit(upperLimit: number, lowerLimit?: number): void;
  19895. }
  19896. /**
  19897. * This class represents a dual hinge physics joint (same as wheel joint)
  19898. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19899. */
  19900. export class Hinge2Joint extends MotorEnabledJoint {
  19901. /**
  19902. * Initializes the Hinge2-Joint
  19903. * @param jointData The joint data for the Hinge2-Joint
  19904. */
  19905. constructor(jointData: PhysicsJointData);
  19906. /**
  19907. * Set the motor values.
  19908. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19909. * @param {number} targetSpeed the speed the motor is to reach
  19910. * @param {number} maxForce max force for this motor.
  19911. * @param {motorIndex} the motor's index, 0 or 1.
  19912. */
  19913. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19914. /**
  19915. * Set the motor limits.
  19916. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19917. * @param {number} upperLimit the upper limit
  19918. * @param {number} lowerLimit lower limit
  19919. * @param {motorIndex} the motor's index, 0 or 1.
  19920. */
  19921. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19922. }
  19923. /**
  19924. * Interface for a motor enabled joint
  19925. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19926. */
  19927. export interface IMotorEnabledJoint {
  19928. /**
  19929. * Physics joint
  19930. */
  19931. physicsJoint: any;
  19932. /**
  19933. * Sets the motor of the motor-enabled joint
  19934. * @param force The force of the motor
  19935. * @param maxForce The maximum force of the motor
  19936. * @param motorIndex The index of the motor
  19937. */
  19938. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19939. /**
  19940. * Sets the limit of the motor
  19941. * @param upperLimit The upper limit of the motor
  19942. * @param lowerLimit The lower limit of the motor
  19943. * @param motorIndex The index of the motor
  19944. */
  19945. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19946. }
  19947. /**
  19948. * Joint data for a Distance-Joint
  19949. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19950. */
  19951. export interface DistanceJointData extends PhysicsJointData {
  19952. /**
  19953. * Max distance the 2 joint objects can be apart
  19954. */
  19955. maxDistance: number;
  19956. }
  19957. /**
  19958. * Joint data from a spring joint
  19959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19960. */
  19961. export interface SpringJointData extends PhysicsJointData {
  19962. /**
  19963. * Length of the spring
  19964. */
  19965. length: number;
  19966. /**
  19967. * Stiffness of the spring
  19968. */
  19969. stiffness: number;
  19970. /**
  19971. * Damping of the spring
  19972. */
  19973. damping: number;
  19974. /** this callback will be called when applying the force to the impostors. */
  19975. forceApplicationCallback: () => void;
  19976. }
  19977. }
  19978. declare module BABYLON {
  19979. /**
  19980. * Holds the data for the raycast result
  19981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19982. */
  19983. export class PhysicsRaycastResult {
  19984. private _hasHit;
  19985. private _hitDistance;
  19986. private _hitNormalWorld;
  19987. private _hitPointWorld;
  19988. private _rayFromWorld;
  19989. private _rayToWorld;
  19990. /**
  19991. * Gets if there was a hit
  19992. */
  19993. readonly hasHit: boolean;
  19994. /**
  19995. * Gets the distance from the hit
  19996. */
  19997. readonly hitDistance: number;
  19998. /**
  19999. * Gets the hit normal/direction in the world
  20000. */
  20001. readonly hitNormalWorld: Vector3;
  20002. /**
  20003. * Gets the hit point in the world
  20004. */
  20005. readonly hitPointWorld: Vector3;
  20006. /**
  20007. * Gets the ray "start point" of the ray in the world
  20008. */
  20009. readonly rayFromWorld: Vector3;
  20010. /**
  20011. * Gets the ray "end point" of the ray in the world
  20012. */
  20013. readonly rayToWorld: Vector3;
  20014. /**
  20015. * Sets the hit data (normal & point in world space)
  20016. * @param hitNormalWorld defines the normal in world space
  20017. * @param hitPointWorld defines the point in world space
  20018. */
  20019. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20020. /**
  20021. * Sets the distance from the start point to the hit point
  20022. * @param distance
  20023. */
  20024. setHitDistance(distance: number): void;
  20025. /**
  20026. * Calculates the distance manually
  20027. */
  20028. calculateHitDistance(): void;
  20029. /**
  20030. * Resets all the values to default
  20031. * @param from The from point on world space
  20032. * @param to The to point on world space
  20033. */
  20034. reset(from?: Vector3, to?: Vector3): void;
  20035. }
  20036. /**
  20037. * Interface for the size containing width and height
  20038. */
  20039. interface IXYZ {
  20040. /**
  20041. * X
  20042. */
  20043. x: number;
  20044. /**
  20045. * Y
  20046. */
  20047. y: number;
  20048. /**
  20049. * Z
  20050. */
  20051. z: number;
  20052. }
  20053. }
  20054. declare module BABYLON {
  20055. /**
  20056. * Interface used to describe a physics joint
  20057. */
  20058. export interface PhysicsImpostorJoint {
  20059. /** Defines the main impostor to which the joint is linked */
  20060. mainImpostor: PhysicsImpostor;
  20061. /** Defines the impostor that is connected to the main impostor using this joint */
  20062. connectedImpostor: PhysicsImpostor;
  20063. /** Defines the joint itself */
  20064. joint: PhysicsJoint;
  20065. }
  20066. /** @hidden */
  20067. export interface IPhysicsEnginePlugin {
  20068. world: any;
  20069. name: string;
  20070. setGravity(gravity: Vector3): void;
  20071. setTimeStep(timeStep: number): void;
  20072. getTimeStep(): number;
  20073. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20074. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20075. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20076. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20077. removePhysicsBody(impostor: PhysicsImpostor): void;
  20078. generateJoint(joint: PhysicsImpostorJoint): void;
  20079. removeJoint(joint: PhysicsImpostorJoint): void;
  20080. isSupported(): boolean;
  20081. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20082. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20083. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20084. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20085. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20086. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20087. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20088. getBodyMass(impostor: PhysicsImpostor): number;
  20089. getBodyFriction(impostor: PhysicsImpostor): number;
  20090. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20091. getBodyRestitution(impostor: PhysicsImpostor): number;
  20092. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20093. getBodyPressure?(impostor: PhysicsImpostor): number;
  20094. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20095. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20096. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20097. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20098. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20099. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20100. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20101. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20102. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20103. sleepBody(impostor: PhysicsImpostor): void;
  20104. wakeUpBody(impostor: PhysicsImpostor): void;
  20105. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20106. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20107. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20108. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20109. getRadius(impostor: PhysicsImpostor): number;
  20110. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20111. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20112. dispose(): void;
  20113. }
  20114. /**
  20115. * Interface used to define a physics engine
  20116. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20117. */
  20118. export interface IPhysicsEngine {
  20119. /**
  20120. * Gets the gravity vector used by the simulation
  20121. */
  20122. gravity: Vector3;
  20123. /**
  20124. * Sets the gravity vector used by the simulation
  20125. * @param gravity defines the gravity vector to use
  20126. */
  20127. setGravity(gravity: Vector3): void;
  20128. /**
  20129. * Set the time step of the physics engine.
  20130. * Default is 1/60.
  20131. * To slow it down, enter 1/600 for example.
  20132. * To speed it up, 1/30
  20133. * @param newTimeStep the new timestep to apply to this world.
  20134. */
  20135. setTimeStep(newTimeStep: number): void;
  20136. /**
  20137. * Get the time step of the physics engine.
  20138. * @returns the current time step
  20139. */
  20140. getTimeStep(): number;
  20141. /**
  20142. * Release all resources
  20143. */
  20144. dispose(): void;
  20145. /**
  20146. * Gets the name of the current physics plugin
  20147. * @returns the name of the plugin
  20148. */
  20149. getPhysicsPluginName(): string;
  20150. /**
  20151. * Adding a new impostor for the impostor tracking.
  20152. * This will be done by the impostor itself.
  20153. * @param impostor the impostor to add
  20154. */
  20155. addImpostor(impostor: PhysicsImpostor): void;
  20156. /**
  20157. * Remove an impostor from the engine.
  20158. * This impostor and its mesh will not longer be updated by the physics engine.
  20159. * @param impostor the impostor to remove
  20160. */
  20161. removeImpostor(impostor: PhysicsImpostor): void;
  20162. /**
  20163. * Add a joint to the physics engine
  20164. * @param mainImpostor defines the main impostor to which the joint is added.
  20165. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20166. * @param joint defines the joint that will connect both impostors.
  20167. */
  20168. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20169. /**
  20170. * Removes a joint from the simulation
  20171. * @param mainImpostor defines the impostor used with the joint
  20172. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20173. * @param joint defines the joint to remove
  20174. */
  20175. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20176. /**
  20177. * Gets the current plugin used to run the simulation
  20178. * @returns current plugin
  20179. */
  20180. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20181. /**
  20182. * Gets the list of physic impostors
  20183. * @returns an array of PhysicsImpostor
  20184. */
  20185. getImpostors(): Array<PhysicsImpostor>;
  20186. /**
  20187. * Gets the impostor for a physics enabled object
  20188. * @param object defines the object impersonated by the impostor
  20189. * @returns the PhysicsImpostor or null if not found
  20190. */
  20191. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20192. /**
  20193. * Gets the impostor for a physics body object
  20194. * @param body defines physics body used by the impostor
  20195. * @returns the PhysicsImpostor or null if not found
  20196. */
  20197. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20198. /**
  20199. * Does a raycast in the physics world
  20200. * @param from when should the ray start?
  20201. * @param to when should the ray end?
  20202. * @returns PhysicsRaycastResult
  20203. */
  20204. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20205. /**
  20206. * Called by the scene. No need to call it.
  20207. * @param delta defines the timespam between frames
  20208. */
  20209. _step(delta: number): void;
  20210. }
  20211. }
  20212. declare module BABYLON {
  20213. /**
  20214. * The interface for the physics imposter parameters
  20215. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20216. */
  20217. export interface PhysicsImpostorParameters {
  20218. /**
  20219. * The mass of the physics imposter
  20220. */
  20221. mass: number;
  20222. /**
  20223. * The friction of the physics imposter
  20224. */
  20225. friction?: number;
  20226. /**
  20227. * The coefficient of restitution of the physics imposter
  20228. */
  20229. restitution?: number;
  20230. /**
  20231. * The native options of the physics imposter
  20232. */
  20233. nativeOptions?: any;
  20234. /**
  20235. * Specifies if the parent should be ignored
  20236. */
  20237. ignoreParent?: boolean;
  20238. /**
  20239. * Specifies if bi-directional transformations should be disabled
  20240. */
  20241. disableBidirectionalTransformation?: boolean;
  20242. /**
  20243. * The pressure inside the physics imposter, soft object only
  20244. */
  20245. pressure?: number;
  20246. /**
  20247. * The stiffness the physics imposter, soft object only
  20248. */
  20249. stiffness?: number;
  20250. /**
  20251. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20252. */
  20253. velocityIterations?: number;
  20254. /**
  20255. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20256. */
  20257. positionIterations?: number;
  20258. /**
  20259. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20260. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20261. * Add to fix multiple points
  20262. */
  20263. fixedPoints?: number;
  20264. /**
  20265. * The collision margin around a soft object
  20266. */
  20267. margin?: number;
  20268. /**
  20269. * The collision margin around a soft object
  20270. */
  20271. damping?: number;
  20272. /**
  20273. * The path for a rope based on an extrusion
  20274. */
  20275. path?: any;
  20276. /**
  20277. * The shape of an extrusion used for a rope based on an extrusion
  20278. */
  20279. shape?: any;
  20280. }
  20281. /**
  20282. * Interface for a physics-enabled object
  20283. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20284. */
  20285. export interface IPhysicsEnabledObject {
  20286. /**
  20287. * The position of the physics-enabled object
  20288. */
  20289. position: Vector3;
  20290. /**
  20291. * The rotation of the physics-enabled object
  20292. */
  20293. rotationQuaternion: Nullable<Quaternion>;
  20294. /**
  20295. * The scale of the physics-enabled object
  20296. */
  20297. scaling: Vector3;
  20298. /**
  20299. * The rotation of the physics-enabled object
  20300. */
  20301. rotation?: Vector3;
  20302. /**
  20303. * The parent of the physics-enabled object
  20304. */
  20305. parent?: any;
  20306. /**
  20307. * The bounding info of the physics-enabled object
  20308. * @returns The bounding info of the physics-enabled object
  20309. */
  20310. getBoundingInfo(): BoundingInfo;
  20311. /**
  20312. * Computes the world matrix
  20313. * @param force Specifies if the world matrix should be computed by force
  20314. * @returns A world matrix
  20315. */
  20316. computeWorldMatrix(force: boolean): Matrix;
  20317. /**
  20318. * Gets the world matrix
  20319. * @returns A world matrix
  20320. */
  20321. getWorldMatrix?(): Matrix;
  20322. /**
  20323. * Gets the child meshes
  20324. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20325. * @returns An array of abstract meshes
  20326. */
  20327. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20328. /**
  20329. * Gets the vertex data
  20330. * @param kind The type of vertex data
  20331. * @returns A nullable array of numbers, or a float32 array
  20332. */
  20333. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20334. /**
  20335. * Gets the indices from the mesh
  20336. * @returns A nullable array of index arrays
  20337. */
  20338. getIndices?(): Nullable<IndicesArray>;
  20339. /**
  20340. * Gets the scene from the mesh
  20341. * @returns the indices array or null
  20342. */
  20343. getScene?(): Scene;
  20344. /**
  20345. * Gets the absolute position from the mesh
  20346. * @returns the absolute position
  20347. */
  20348. getAbsolutePosition(): Vector3;
  20349. /**
  20350. * Gets the absolute pivot point from the mesh
  20351. * @returns the absolute pivot point
  20352. */
  20353. getAbsolutePivotPoint(): Vector3;
  20354. /**
  20355. * Rotates the mesh
  20356. * @param axis The axis of rotation
  20357. * @param amount The amount of rotation
  20358. * @param space The space of the rotation
  20359. * @returns The rotation transform node
  20360. */
  20361. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20362. /**
  20363. * Translates the mesh
  20364. * @param axis The axis of translation
  20365. * @param distance The distance of translation
  20366. * @param space The space of the translation
  20367. * @returns The transform node
  20368. */
  20369. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20370. /**
  20371. * Sets the absolute position of the mesh
  20372. * @param absolutePosition The absolute position of the mesh
  20373. * @returns The transform node
  20374. */
  20375. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20376. /**
  20377. * Gets the class name of the mesh
  20378. * @returns The class name
  20379. */
  20380. getClassName(): string;
  20381. }
  20382. /**
  20383. * Represents a physics imposter
  20384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20385. */
  20386. export class PhysicsImpostor {
  20387. /**
  20388. * The physics-enabled object used as the physics imposter
  20389. */
  20390. object: IPhysicsEnabledObject;
  20391. /**
  20392. * The type of the physics imposter
  20393. */
  20394. type: number;
  20395. private _options;
  20396. private _scene?;
  20397. /**
  20398. * The default object size of the imposter
  20399. */
  20400. static DEFAULT_OBJECT_SIZE: Vector3;
  20401. /**
  20402. * The identity quaternion of the imposter
  20403. */
  20404. static IDENTITY_QUATERNION: Quaternion;
  20405. /** @hidden */
  20406. _pluginData: any;
  20407. private _physicsEngine;
  20408. private _physicsBody;
  20409. private _bodyUpdateRequired;
  20410. private _onBeforePhysicsStepCallbacks;
  20411. private _onAfterPhysicsStepCallbacks;
  20412. /** @hidden */
  20413. _onPhysicsCollideCallbacks: Array<{
  20414. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20415. otherImpostors: Array<PhysicsImpostor>;
  20416. }>;
  20417. private _deltaPosition;
  20418. private _deltaRotation;
  20419. private _deltaRotationConjugated;
  20420. /** hidden */
  20421. _isFromLine: boolean;
  20422. private _parent;
  20423. private _isDisposed;
  20424. private static _tmpVecs;
  20425. private static _tmpQuat;
  20426. /**
  20427. * Specifies if the physics imposter is disposed
  20428. */
  20429. readonly isDisposed: boolean;
  20430. /**
  20431. * Gets the mass of the physics imposter
  20432. */
  20433. mass: number;
  20434. /**
  20435. * Gets the coefficient of friction
  20436. */
  20437. /**
  20438. * Sets the coefficient of friction
  20439. */
  20440. friction: number;
  20441. /**
  20442. * Gets the coefficient of restitution
  20443. */
  20444. /**
  20445. * Sets the coefficient of restitution
  20446. */
  20447. restitution: number;
  20448. /**
  20449. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20450. */
  20451. /**
  20452. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20453. */
  20454. pressure: number;
  20455. /**
  20456. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20457. */
  20458. /**
  20459. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20460. */
  20461. stiffness: number;
  20462. /**
  20463. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20464. */
  20465. /**
  20466. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20467. */
  20468. velocityIterations: number;
  20469. /**
  20470. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20471. */
  20472. /**
  20473. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20474. */
  20475. positionIterations: number;
  20476. /**
  20477. * The unique id of the physics imposter
  20478. * set by the physics engine when adding this impostor to the array
  20479. */
  20480. uniqueId: number;
  20481. /**
  20482. * @hidden
  20483. */
  20484. soft: boolean;
  20485. /**
  20486. * @hidden
  20487. */
  20488. segments: number;
  20489. private _joints;
  20490. /**
  20491. * Initializes the physics imposter
  20492. * @param object The physics-enabled object used as the physics imposter
  20493. * @param type The type of the physics imposter
  20494. * @param _options The options for the physics imposter
  20495. * @param _scene The Babylon scene
  20496. */
  20497. constructor(
  20498. /**
  20499. * The physics-enabled object used as the physics imposter
  20500. */
  20501. object: IPhysicsEnabledObject,
  20502. /**
  20503. * The type of the physics imposter
  20504. */
  20505. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20506. /**
  20507. * This function will completly initialize this impostor.
  20508. * It will create a new body - but only if this mesh has no parent.
  20509. * If it has, this impostor will not be used other than to define the impostor
  20510. * of the child mesh.
  20511. * @hidden
  20512. */
  20513. _init(): void;
  20514. private _getPhysicsParent;
  20515. /**
  20516. * Should a new body be generated.
  20517. * @returns boolean specifying if body initialization is required
  20518. */
  20519. isBodyInitRequired(): boolean;
  20520. /**
  20521. * Sets the updated scaling
  20522. * @param updated Specifies if the scaling is updated
  20523. */
  20524. setScalingUpdated(): void;
  20525. /**
  20526. * Force a regeneration of this or the parent's impostor's body.
  20527. * Use under cautious - This will remove all joints already implemented.
  20528. */
  20529. forceUpdate(): void;
  20530. /**
  20531. * Gets the body that holds this impostor. Either its own, or its parent.
  20532. */
  20533. /**
  20534. * Set the physics body. Used mainly by the physics engine/plugin
  20535. */
  20536. physicsBody: any;
  20537. /**
  20538. * Get the parent of the physics imposter
  20539. * @returns Physics imposter or null
  20540. */
  20541. /**
  20542. * Sets the parent of the physics imposter
  20543. */
  20544. parent: Nullable<PhysicsImpostor>;
  20545. /**
  20546. * Resets the update flags
  20547. */
  20548. resetUpdateFlags(): void;
  20549. /**
  20550. * Gets the object extend size
  20551. * @returns the object extend size
  20552. */
  20553. getObjectExtendSize(): Vector3;
  20554. /**
  20555. * Gets the object center
  20556. * @returns The object center
  20557. */
  20558. getObjectCenter(): Vector3;
  20559. /**
  20560. * Get a specific parametes from the options parameter
  20561. * @param paramName The object parameter name
  20562. * @returns The object parameter
  20563. */
  20564. getParam(paramName: string): any;
  20565. /**
  20566. * Sets a specific parameter in the options given to the physics plugin
  20567. * @param paramName The parameter name
  20568. * @param value The value of the parameter
  20569. */
  20570. setParam(paramName: string, value: number): void;
  20571. /**
  20572. * Specifically change the body's mass option. Won't recreate the physics body object
  20573. * @param mass The mass of the physics imposter
  20574. */
  20575. setMass(mass: number): void;
  20576. /**
  20577. * Gets the linear velocity
  20578. * @returns linear velocity or null
  20579. */
  20580. getLinearVelocity(): Nullable<Vector3>;
  20581. /**
  20582. * Sets the linear velocity
  20583. * @param velocity linear velocity or null
  20584. */
  20585. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20586. /**
  20587. * Gets the angular velocity
  20588. * @returns angular velocity or null
  20589. */
  20590. getAngularVelocity(): Nullable<Vector3>;
  20591. /**
  20592. * Sets the angular velocity
  20593. * @param velocity The velocity or null
  20594. */
  20595. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20596. /**
  20597. * Execute a function with the physics plugin native code
  20598. * Provide a function the will have two variables - the world object and the physics body object
  20599. * @param func The function to execute with the physics plugin native code
  20600. */
  20601. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20602. /**
  20603. * Register a function that will be executed before the physics world is stepping forward
  20604. * @param func The function to execute before the physics world is stepped forward
  20605. */
  20606. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20607. /**
  20608. * Unregister a function that will be executed before the physics world is stepping forward
  20609. * @param func The function to execute before the physics world is stepped forward
  20610. */
  20611. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20612. /**
  20613. * Register a function that will be executed after the physics step
  20614. * @param func The function to execute after physics step
  20615. */
  20616. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20617. /**
  20618. * Unregisters a function that will be executed after the physics step
  20619. * @param func The function to execute after physics step
  20620. */
  20621. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20622. /**
  20623. * register a function that will be executed when this impostor collides against a different body
  20624. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20625. * @param func Callback that is executed on collision
  20626. */
  20627. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20628. /**
  20629. * Unregisters the physics imposter on contact
  20630. * @param collideAgainst The physics object to collide against
  20631. * @param func Callback to execute on collision
  20632. */
  20633. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20634. private _tmpQuat;
  20635. private _tmpQuat2;
  20636. /**
  20637. * Get the parent rotation
  20638. * @returns The parent rotation
  20639. */
  20640. getParentsRotation(): Quaternion;
  20641. /**
  20642. * this function is executed by the physics engine.
  20643. */
  20644. beforeStep: () => void;
  20645. /**
  20646. * this function is executed by the physics engine
  20647. */
  20648. afterStep: () => void;
  20649. /**
  20650. * Legacy collision detection event support
  20651. */
  20652. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20653. /**
  20654. * event and body object due to cannon's event-based architecture.
  20655. */
  20656. onCollide: (e: {
  20657. body: any;
  20658. }) => void;
  20659. /**
  20660. * Apply a force
  20661. * @param force The force to apply
  20662. * @param contactPoint The contact point for the force
  20663. * @returns The physics imposter
  20664. */
  20665. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20666. /**
  20667. * Apply an impulse
  20668. * @param force The impulse force
  20669. * @param contactPoint The contact point for the impulse force
  20670. * @returns The physics imposter
  20671. */
  20672. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20673. /**
  20674. * A help function to create a joint
  20675. * @param otherImpostor A physics imposter used to create a joint
  20676. * @param jointType The type of joint
  20677. * @param jointData The data for the joint
  20678. * @returns The physics imposter
  20679. */
  20680. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20681. /**
  20682. * Add a joint to this impostor with a different impostor
  20683. * @param otherImpostor A physics imposter used to add a joint
  20684. * @param joint The joint to add
  20685. * @returns The physics imposter
  20686. */
  20687. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20688. /**
  20689. * Add an anchor to a cloth impostor
  20690. * @param otherImpostor rigid impostor to anchor to
  20691. * @param width ratio across width from 0 to 1
  20692. * @param height ratio up height from 0 to 1
  20693. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20694. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20695. * @returns impostor the soft imposter
  20696. */
  20697. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20698. /**
  20699. * Add a hook to a rope impostor
  20700. * @param otherImpostor rigid impostor to anchor to
  20701. * @param length ratio across rope from 0 to 1
  20702. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20703. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20704. * @returns impostor the rope imposter
  20705. */
  20706. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20707. /**
  20708. * Will keep this body still, in a sleep mode.
  20709. * @returns the physics imposter
  20710. */
  20711. sleep(): PhysicsImpostor;
  20712. /**
  20713. * Wake the body up.
  20714. * @returns The physics imposter
  20715. */
  20716. wakeUp(): PhysicsImpostor;
  20717. /**
  20718. * Clones the physics imposter
  20719. * @param newObject The physics imposter clones to this physics-enabled object
  20720. * @returns A nullable physics imposter
  20721. */
  20722. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20723. /**
  20724. * Disposes the physics imposter
  20725. */
  20726. dispose(): void;
  20727. /**
  20728. * Sets the delta position
  20729. * @param position The delta position amount
  20730. */
  20731. setDeltaPosition(position: Vector3): void;
  20732. /**
  20733. * Sets the delta rotation
  20734. * @param rotation The delta rotation amount
  20735. */
  20736. setDeltaRotation(rotation: Quaternion): void;
  20737. /**
  20738. * Gets the box size of the physics imposter and stores the result in the input parameter
  20739. * @param result Stores the box size
  20740. * @returns The physics imposter
  20741. */
  20742. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20743. /**
  20744. * Gets the radius of the physics imposter
  20745. * @returns Radius of the physics imposter
  20746. */
  20747. getRadius(): number;
  20748. /**
  20749. * Sync a bone with this impostor
  20750. * @param bone The bone to sync to the impostor.
  20751. * @param boneMesh The mesh that the bone is influencing.
  20752. * @param jointPivot The pivot of the joint / bone in local space.
  20753. * @param distToJoint Optional distance from the impostor to the joint.
  20754. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20755. */
  20756. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20757. /**
  20758. * Sync impostor to a bone
  20759. * @param bone The bone that the impostor will be synced to.
  20760. * @param boneMesh The mesh that the bone is influencing.
  20761. * @param jointPivot The pivot of the joint / bone in local space.
  20762. * @param distToJoint Optional distance from the impostor to the joint.
  20763. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20764. * @param boneAxis Optional vector3 axis the bone is aligned with
  20765. */
  20766. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20767. /**
  20768. * No-Imposter type
  20769. */
  20770. static NoImpostor: number;
  20771. /**
  20772. * Sphere-Imposter type
  20773. */
  20774. static SphereImpostor: number;
  20775. /**
  20776. * Box-Imposter type
  20777. */
  20778. static BoxImpostor: number;
  20779. /**
  20780. * Plane-Imposter type
  20781. */
  20782. static PlaneImpostor: number;
  20783. /**
  20784. * Mesh-imposter type
  20785. */
  20786. static MeshImpostor: number;
  20787. /**
  20788. * Cylinder-Imposter type
  20789. */
  20790. static CylinderImpostor: number;
  20791. /**
  20792. * Particle-Imposter type
  20793. */
  20794. static ParticleImpostor: number;
  20795. /**
  20796. * Heightmap-Imposter type
  20797. */
  20798. static HeightmapImpostor: number;
  20799. /**
  20800. * ConvexHull-Impostor type (Ammo.js plugin only)
  20801. */
  20802. static ConvexHullImpostor: number;
  20803. /**
  20804. * Rope-Imposter type
  20805. */
  20806. static RopeImpostor: number;
  20807. /**
  20808. * Cloth-Imposter type
  20809. */
  20810. static ClothImpostor: number;
  20811. /**
  20812. * Softbody-Imposter type
  20813. */
  20814. static SoftbodyImpostor: number;
  20815. }
  20816. }
  20817. declare module BABYLON {
  20818. /**
  20819. * @hidden
  20820. **/
  20821. export class _CreationDataStorage {
  20822. closePath?: boolean;
  20823. closeArray?: boolean;
  20824. idx: number[];
  20825. dashSize: number;
  20826. gapSize: number;
  20827. path3D: Path3D;
  20828. pathArray: Vector3[][];
  20829. arc: number;
  20830. radius: number;
  20831. cap: number;
  20832. tessellation: number;
  20833. }
  20834. /**
  20835. * @hidden
  20836. **/
  20837. class _InstanceDataStorage {
  20838. visibleInstances: any;
  20839. batchCache: _InstancesBatch;
  20840. instancesBufferSize: number;
  20841. instancesBuffer: Nullable<Buffer>;
  20842. instancesData: Float32Array;
  20843. overridenInstanceCount: number;
  20844. isFrozen: boolean;
  20845. previousBatch: _InstancesBatch;
  20846. hardwareInstancedRendering: boolean;
  20847. sideOrientation: number;
  20848. }
  20849. /**
  20850. * @hidden
  20851. **/
  20852. export class _InstancesBatch {
  20853. mustReturn: boolean;
  20854. visibleInstances: Nullable<InstancedMesh[]>[];
  20855. renderSelf: boolean[];
  20856. hardwareInstancedRendering: boolean[];
  20857. }
  20858. /**
  20859. * Class used to represent renderable models
  20860. */
  20861. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20862. /**
  20863. * Mesh side orientation : usually the external or front surface
  20864. */
  20865. static readonly FRONTSIDE: number;
  20866. /**
  20867. * Mesh side orientation : usually the internal or back surface
  20868. */
  20869. static readonly BACKSIDE: number;
  20870. /**
  20871. * Mesh side orientation : both internal and external or front and back surfaces
  20872. */
  20873. static readonly DOUBLESIDE: number;
  20874. /**
  20875. * Mesh side orientation : by default, `FRONTSIDE`
  20876. */
  20877. static readonly DEFAULTSIDE: number;
  20878. /**
  20879. * Mesh cap setting : no cap
  20880. */
  20881. static readonly NO_CAP: number;
  20882. /**
  20883. * Mesh cap setting : one cap at the beginning of the mesh
  20884. */
  20885. static readonly CAP_START: number;
  20886. /**
  20887. * Mesh cap setting : one cap at the end of the mesh
  20888. */
  20889. static readonly CAP_END: number;
  20890. /**
  20891. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20892. */
  20893. static readonly CAP_ALL: number;
  20894. /**
  20895. * Gets the default side orientation.
  20896. * @param orientation the orientation to value to attempt to get
  20897. * @returns the default orientation
  20898. * @hidden
  20899. */
  20900. static _GetDefaultSideOrientation(orientation?: number): number;
  20901. private _internalMeshDataInfo;
  20902. /**
  20903. * An event triggered before rendering the mesh
  20904. */
  20905. readonly onBeforeRenderObservable: Observable<Mesh>;
  20906. /**
  20907. * An event triggered before binding the mesh
  20908. */
  20909. readonly onBeforeBindObservable: Observable<Mesh>;
  20910. /**
  20911. * An event triggered after rendering the mesh
  20912. */
  20913. readonly onAfterRenderObservable: Observable<Mesh>;
  20914. /**
  20915. * An event triggered before drawing the mesh
  20916. */
  20917. readonly onBeforeDrawObservable: Observable<Mesh>;
  20918. private _onBeforeDrawObserver;
  20919. /**
  20920. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20921. */
  20922. onBeforeDraw: () => void;
  20923. /**
  20924. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20925. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20926. */
  20927. delayLoadState: number;
  20928. /**
  20929. * Gets the list of instances created from this mesh
  20930. * it is not supposed to be modified manually.
  20931. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20932. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20933. */
  20934. instances: InstancedMesh[];
  20935. /**
  20936. * Gets the file containing delay loading data for this mesh
  20937. */
  20938. delayLoadingFile: string;
  20939. /** @hidden */
  20940. _binaryInfo: any;
  20941. /**
  20942. * User defined function used to change how LOD level selection is done
  20943. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20944. */
  20945. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20946. /**
  20947. * Gets or sets the morph target manager
  20948. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20949. */
  20950. morphTargetManager: Nullable<MorphTargetManager>;
  20951. /** @hidden */
  20952. _creationDataStorage: Nullable<_CreationDataStorage>;
  20953. /** @hidden */
  20954. _geometry: Nullable<Geometry>;
  20955. /** @hidden */
  20956. _delayInfo: Array<string>;
  20957. /** @hidden */
  20958. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20959. /** @hidden */
  20960. _instanceDataStorage: _InstanceDataStorage;
  20961. private _effectiveMaterial;
  20962. /** @hidden */
  20963. _shouldGenerateFlatShading: boolean;
  20964. /** @hidden */
  20965. _originalBuilderSideOrientation: number;
  20966. /**
  20967. * Use this property to change the original side orientation defined at construction time
  20968. */
  20969. overrideMaterialSideOrientation: Nullable<number>;
  20970. /**
  20971. * Gets the source mesh (the one used to clone this one from)
  20972. */
  20973. readonly source: Nullable<Mesh>;
  20974. /**
  20975. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20976. */
  20977. isUnIndexed: boolean;
  20978. /**
  20979. * @constructor
  20980. * @param name The value used by scene.getMeshByName() to do a lookup.
  20981. * @param scene The scene to add this mesh to.
  20982. * @param parent The parent of this mesh, if it has one
  20983. * @param source An optional Mesh from which geometry is shared, cloned.
  20984. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20985. * When false, achieved by calling a clone(), also passing False.
  20986. * This will make creation of children, recursive.
  20987. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20988. */
  20989. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20990. /**
  20991. * Gets the class name
  20992. * @returns the string "Mesh".
  20993. */
  20994. getClassName(): string;
  20995. /** @hidden */
  20996. readonly _isMesh: boolean;
  20997. /**
  20998. * Returns a description of this mesh
  20999. * @param fullDetails define if full details about this mesh must be used
  21000. * @returns a descriptive string representing this mesh
  21001. */
  21002. toString(fullDetails?: boolean): string;
  21003. /** @hidden */
  21004. _unBindEffect(): void;
  21005. /**
  21006. * Gets a boolean indicating if this mesh has LOD
  21007. */
  21008. readonly hasLODLevels: boolean;
  21009. /**
  21010. * Gets the list of MeshLODLevel associated with the current mesh
  21011. * @returns an array of MeshLODLevel
  21012. */
  21013. getLODLevels(): MeshLODLevel[];
  21014. private _sortLODLevels;
  21015. /**
  21016. * Add a mesh as LOD level triggered at the given distance.
  21017. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21018. * @param distance The distance from the center of the object to show this level
  21019. * @param mesh The mesh to be added as LOD level (can be null)
  21020. * @return This mesh (for chaining)
  21021. */
  21022. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21023. /**
  21024. * Returns the LOD level mesh at the passed distance or null if not found.
  21025. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21026. * @param distance The distance from the center of the object to show this level
  21027. * @returns a Mesh or `null`
  21028. */
  21029. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21030. /**
  21031. * Remove a mesh from the LOD array
  21032. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21033. * @param mesh defines the mesh to be removed
  21034. * @return This mesh (for chaining)
  21035. */
  21036. removeLODLevel(mesh: Mesh): Mesh;
  21037. /**
  21038. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21039. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21040. * @param camera defines the camera to use to compute distance
  21041. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21042. * @return This mesh (for chaining)
  21043. */
  21044. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21045. /**
  21046. * Gets the mesh internal Geometry object
  21047. */
  21048. readonly geometry: Nullable<Geometry>;
  21049. /**
  21050. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21051. * @returns the total number of vertices
  21052. */
  21053. getTotalVertices(): number;
  21054. /**
  21055. * Returns the content of an associated vertex buffer
  21056. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21057. * - VertexBuffer.PositionKind
  21058. * - VertexBuffer.UVKind
  21059. * - VertexBuffer.UV2Kind
  21060. * - VertexBuffer.UV3Kind
  21061. * - VertexBuffer.UV4Kind
  21062. * - VertexBuffer.UV5Kind
  21063. * - VertexBuffer.UV6Kind
  21064. * - VertexBuffer.ColorKind
  21065. * - VertexBuffer.MatricesIndicesKind
  21066. * - VertexBuffer.MatricesIndicesExtraKind
  21067. * - VertexBuffer.MatricesWeightsKind
  21068. * - VertexBuffer.MatricesWeightsExtraKind
  21069. * @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
  21070. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21071. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21072. */
  21073. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21074. /**
  21075. * Returns the mesh VertexBuffer object from the requested `kind`
  21076. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21077. * - VertexBuffer.PositionKind
  21078. * - VertexBuffer.UVKind
  21079. * - VertexBuffer.UV2Kind
  21080. * - VertexBuffer.UV3Kind
  21081. * - VertexBuffer.UV4Kind
  21082. * - VertexBuffer.UV5Kind
  21083. * - VertexBuffer.UV6Kind
  21084. * - VertexBuffer.ColorKind
  21085. * - VertexBuffer.MatricesIndicesKind
  21086. * - VertexBuffer.MatricesIndicesExtraKind
  21087. * - VertexBuffer.MatricesWeightsKind
  21088. * - VertexBuffer.MatricesWeightsExtraKind
  21089. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21090. */
  21091. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21092. /**
  21093. * Tests if a specific vertex buffer is associated with this mesh
  21094. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21095. * - VertexBuffer.PositionKind
  21096. * - VertexBuffer.UVKind
  21097. * - VertexBuffer.UV2Kind
  21098. * - VertexBuffer.UV3Kind
  21099. * - VertexBuffer.UV4Kind
  21100. * - VertexBuffer.UV5Kind
  21101. * - VertexBuffer.UV6Kind
  21102. * - VertexBuffer.ColorKind
  21103. * - VertexBuffer.MatricesIndicesKind
  21104. * - VertexBuffer.MatricesIndicesExtraKind
  21105. * - VertexBuffer.MatricesWeightsKind
  21106. * - VertexBuffer.MatricesWeightsExtraKind
  21107. * @returns a boolean
  21108. */
  21109. isVerticesDataPresent(kind: string): boolean;
  21110. /**
  21111. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21112. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21113. * - VertexBuffer.PositionKind
  21114. * - VertexBuffer.UVKind
  21115. * - VertexBuffer.UV2Kind
  21116. * - VertexBuffer.UV3Kind
  21117. * - VertexBuffer.UV4Kind
  21118. * - VertexBuffer.UV5Kind
  21119. * - VertexBuffer.UV6Kind
  21120. * - VertexBuffer.ColorKind
  21121. * - VertexBuffer.MatricesIndicesKind
  21122. * - VertexBuffer.MatricesIndicesExtraKind
  21123. * - VertexBuffer.MatricesWeightsKind
  21124. * - VertexBuffer.MatricesWeightsExtraKind
  21125. * @returns a boolean
  21126. */
  21127. isVertexBufferUpdatable(kind: string): boolean;
  21128. /**
  21129. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21130. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21131. * - VertexBuffer.PositionKind
  21132. * - VertexBuffer.UVKind
  21133. * - VertexBuffer.UV2Kind
  21134. * - VertexBuffer.UV3Kind
  21135. * - VertexBuffer.UV4Kind
  21136. * - VertexBuffer.UV5Kind
  21137. * - VertexBuffer.UV6Kind
  21138. * - VertexBuffer.ColorKind
  21139. * - VertexBuffer.MatricesIndicesKind
  21140. * - VertexBuffer.MatricesIndicesExtraKind
  21141. * - VertexBuffer.MatricesWeightsKind
  21142. * - VertexBuffer.MatricesWeightsExtraKind
  21143. * @returns an array of strings
  21144. */
  21145. getVerticesDataKinds(): string[];
  21146. /**
  21147. * Returns a positive integer : the total number of indices in this mesh geometry.
  21148. * @returns the numner of indices or zero if the mesh has no geometry.
  21149. */
  21150. getTotalIndices(): number;
  21151. /**
  21152. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21153. * @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.
  21154. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21155. * @returns the indices array or an empty array if the mesh has no geometry
  21156. */
  21157. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21158. readonly isBlocked: boolean;
  21159. /**
  21160. * Determine if the current mesh is ready to be rendered
  21161. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21162. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21163. * @returns true if all associated assets are ready (material, textures, shaders)
  21164. */
  21165. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21166. /**
  21167. * 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.
  21168. */
  21169. readonly areNormalsFrozen: boolean;
  21170. /**
  21171. * 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.
  21172. * @returns the current mesh
  21173. */
  21174. freezeNormals(): Mesh;
  21175. /**
  21176. * 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
  21177. * @returns the current mesh
  21178. */
  21179. unfreezeNormals(): Mesh;
  21180. /**
  21181. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21182. */
  21183. overridenInstanceCount: number;
  21184. /** @hidden */
  21185. _preActivate(): Mesh;
  21186. /** @hidden */
  21187. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21188. /** @hidden */
  21189. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21190. /**
  21191. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21192. * This means the mesh underlying bounding box and sphere are recomputed.
  21193. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21194. * @returns the current mesh
  21195. */
  21196. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21197. /** @hidden */
  21198. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21199. /**
  21200. * This function will subdivide the mesh into multiple submeshes
  21201. * @param count defines the expected number of submeshes
  21202. */
  21203. subdivide(count: number): void;
  21204. /**
  21205. * Copy a FloatArray into a specific associated vertex buffer
  21206. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21207. * - VertexBuffer.PositionKind
  21208. * - VertexBuffer.UVKind
  21209. * - VertexBuffer.UV2Kind
  21210. * - VertexBuffer.UV3Kind
  21211. * - VertexBuffer.UV4Kind
  21212. * - VertexBuffer.UV5Kind
  21213. * - VertexBuffer.UV6Kind
  21214. * - VertexBuffer.ColorKind
  21215. * - VertexBuffer.MatricesIndicesKind
  21216. * - VertexBuffer.MatricesIndicesExtraKind
  21217. * - VertexBuffer.MatricesWeightsKind
  21218. * - VertexBuffer.MatricesWeightsExtraKind
  21219. * @param data defines the data source
  21220. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21221. * @param stride defines the data stride size (can be null)
  21222. * @returns the current mesh
  21223. */
  21224. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21225. /**
  21226. * Flags an associated vertex buffer as updatable
  21227. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21228. * - VertexBuffer.PositionKind
  21229. * - VertexBuffer.UVKind
  21230. * - VertexBuffer.UV2Kind
  21231. * - VertexBuffer.UV3Kind
  21232. * - VertexBuffer.UV4Kind
  21233. * - VertexBuffer.UV5Kind
  21234. * - VertexBuffer.UV6Kind
  21235. * - VertexBuffer.ColorKind
  21236. * - VertexBuffer.MatricesIndicesKind
  21237. * - VertexBuffer.MatricesIndicesExtraKind
  21238. * - VertexBuffer.MatricesWeightsKind
  21239. * - VertexBuffer.MatricesWeightsExtraKind
  21240. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21241. */
  21242. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21243. /**
  21244. * Sets the mesh global Vertex Buffer
  21245. * @param buffer defines the buffer to use
  21246. * @returns the current mesh
  21247. */
  21248. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21249. /**
  21250. * Update a specific associated vertex buffer
  21251. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21252. * - VertexBuffer.PositionKind
  21253. * - VertexBuffer.UVKind
  21254. * - VertexBuffer.UV2Kind
  21255. * - VertexBuffer.UV3Kind
  21256. * - VertexBuffer.UV4Kind
  21257. * - VertexBuffer.UV5Kind
  21258. * - VertexBuffer.UV6Kind
  21259. * - VertexBuffer.ColorKind
  21260. * - VertexBuffer.MatricesIndicesKind
  21261. * - VertexBuffer.MatricesIndicesExtraKind
  21262. * - VertexBuffer.MatricesWeightsKind
  21263. * - VertexBuffer.MatricesWeightsExtraKind
  21264. * @param data defines the data source
  21265. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21266. * @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)
  21267. * @returns the current mesh
  21268. */
  21269. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21270. /**
  21271. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21272. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21273. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21274. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21275. * @returns the current mesh
  21276. */
  21277. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21278. /**
  21279. * Creates a un-shared specific occurence of the geometry for the mesh.
  21280. * @returns the current mesh
  21281. */
  21282. makeGeometryUnique(): Mesh;
  21283. /**
  21284. * Set the index buffer of this mesh
  21285. * @param indices defines the source data
  21286. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21287. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21288. * @returns the current mesh
  21289. */
  21290. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21291. /**
  21292. * Update the current index buffer
  21293. * @param indices defines the source data
  21294. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21295. * @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)
  21296. * @returns the current mesh
  21297. */
  21298. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21299. /**
  21300. * Invert the geometry to move from a right handed system to a left handed one.
  21301. * @returns the current mesh
  21302. */
  21303. toLeftHanded(): Mesh;
  21304. /** @hidden */
  21305. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21306. /** @hidden */
  21307. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21308. /**
  21309. * Registers for this mesh a javascript function called just before the rendering process
  21310. * @param func defines the function to call before rendering this mesh
  21311. * @returns the current mesh
  21312. */
  21313. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21314. /**
  21315. * Disposes a previously registered javascript function called before the rendering
  21316. * @param func defines the function to remove
  21317. * @returns the current mesh
  21318. */
  21319. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21320. /**
  21321. * Registers for this mesh a javascript function called just after the rendering is complete
  21322. * @param func defines the function to call after rendering this mesh
  21323. * @returns the current mesh
  21324. */
  21325. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21326. /**
  21327. * Disposes a previously registered javascript function called after the rendering.
  21328. * @param func defines the function to remove
  21329. * @returns the current mesh
  21330. */
  21331. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21332. /** @hidden */
  21333. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21334. /** @hidden */
  21335. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21336. /** @hidden */
  21337. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21338. /** @hidden */
  21339. _freeze(): void;
  21340. /** @hidden */
  21341. _unFreeze(): void;
  21342. /**
  21343. * 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
  21344. * @param subMesh defines the subMesh to render
  21345. * @param enableAlphaMode defines if alpha mode can be changed
  21346. * @returns the current mesh
  21347. */
  21348. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21349. private _onBeforeDraw;
  21350. /**
  21351. * Renormalize the mesh and patch it up if there are no weights
  21352. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21353. * However in the case of zero weights then we set just a single influence to 1.
  21354. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21355. */
  21356. cleanMatrixWeights(): void;
  21357. private normalizeSkinFourWeights;
  21358. private normalizeSkinWeightsAndExtra;
  21359. /**
  21360. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21361. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21362. * the user know there was an issue with importing the mesh
  21363. * @returns a validation object with skinned, valid and report string
  21364. */
  21365. validateSkinning(): {
  21366. skinned: boolean;
  21367. valid: boolean;
  21368. report: string;
  21369. };
  21370. /** @hidden */
  21371. _checkDelayState(): Mesh;
  21372. private _queueLoad;
  21373. /**
  21374. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21375. * A mesh is in the frustum if its bounding box intersects the frustum
  21376. * @param frustumPlanes defines the frustum to test
  21377. * @returns true if the mesh is in the frustum planes
  21378. */
  21379. isInFrustum(frustumPlanes: Plane[]): boolean;
  21380. /**
  21381. * Sets the mesh material by the material or multiMaterial `id` property
  21382. * @param id is a string identifying the material or the multiMaterial
  21383. * @returns the current mesh
  21384. */
  21385. setMaterialByID(id: string): Mesh;
  21386. /**
  21387. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21388. * @returns an array of IAnimatable
  21389. */
  21390. getAnimatables(): IAnimatable[];
  21391. /**
  21392. * Modifies the mesh geometry according to the passed transformation matrix.
  21393. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21394. * The mesh normals are modified using the same transformation.
  21395. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21396. * @param transform defines the transform matrix to use
  21397. * @see http://doc.babylonjs.com/resources/baking_transformations
  21398. * @returns the current mesh
  21399. */
  21400. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21401. /**
  21402. * Modifies the mesh geometry according to its own current World Matrix.
  21403. * The mesh World Matrix is then reset.
  21404. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21405. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21406. * @see http://doc.babylonjs.com/resources/baking_transformations
  21407. * @returns the current mesh
  21408. */
  21409. bakeCurrentTransformIntoVertices(): Mesh;
  21410. /** @hidden */
  21411. readonly _positions: Nullable<Vector3[]>;
  21412. /** @hidden */
  21413. _resetPointsArrayCache(): Mesh;
  21414. /** @hidden */
  21415. _generatePointsArray(): boolean;
  21416. /**
  21417. * Returns a new Mesh object generated from the current mesh properties.
  21418. * This method must not get confused with createInstance()
  21419. * @param name is a string, the name given to the new mesh
  21420. * @param newParent can be any Node object (default `null`)
  21421. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21422. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21423. * @returns a new mesh
  21424. */
  21425. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21426. /**
  21427. * Releases resources associated with this mesh.
  21428. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21429. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21430. */
  21431. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21432. /**
  21433. * Modifies the mesh geometry according to a displacement map.
  21434. * 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.
  21435. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21436. * @param url is a string, the URL from the image file is to be downloaded.
  21437. * @param minHeight is the lower limit of the displacement.
  21438. * @param maxHeight is the upper limit of the displacement.
  21439. * @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.
  21440. * @param uvOffset is an optional vector2 used to offset UV.
  21441. * @param uvScale is an optional vector2 used to scale UV.
  21442. * @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.
  21443. * @returns the Mesh.
  21444. */
  21445. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21446. /**
  21447. * Modifies the mesh geometry according to a displacementMap buffer.
  21448. * 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.
  21449. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21450. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21451. * @param heightMapWidth is the width of the buffer image.
  21452. * @param heightMapHeight is the height of the buffer image.
  21453. * @param minHeight is the lower limit of the displacement.
  21454. * @param maxHeight is the upper limit of the displacement.
  21455. * @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.
  21456. * @param uvOffset is an optional vector2 used to offset UV.
  21457. * @param uvScale is an optional vector2 used to scale UV.
  21458. * @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.
  21459. * @returns the Mesh.
  21460. */
  21461. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21462. /**
  21463. * Modify the mesh to get a flat shading rendering.
  21464. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21465. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21466. * @returns current mesh
  21467. */
  21468. convertToFlatShadedMesh(): Mesh;
  21469. /**
  21470. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21471. * In other words, more vertices, no more indices and a single bigger VBO.
  21472. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21473. * @returns current mesh
  21474. */
  21475. convertToUnIndexedMesh(): Mesh;
  21476. /**
  21477. * Inverses facet orientations.
  21478. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21479. * @param flipNormals will also inverts the normals
  21480. * @returns current mesh
  21481. */
  21482. flipFaces(flipNormals?: boolean): Mesh;
  21483. /**
  21484. * Increase the number of facets and hence vertices in a mesh
  21485. * Vertex normals are interpolated from existing vertex normals
  21486. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21487. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21488. */
  21489. increaseVertices(numberPerEdge: number): void;
  21490. /**
  21491. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21492. * This will undo any application of covertToFlatShadedMesh
  21493. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21494. */
  21495. forceSharedVertices(): void;
  21496. /** @hidden */
  21497. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21498. /** @hidden */
  21499. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21500. /**
  21501. * Creates a new InstancedMesh object from the mesh model.
  21502. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21503. * @param name defines the name of the new instance
  21504. * @returns a new InstancedMesh
  21505. */
  21506. createInstance(name: string): InstancedMesh;
  21507. /**
  21508. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21509. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21510. * @returns the current mesh
  21511. */
  21512. synchronizeInstances(): Mesh;
  21513. /**
  21514. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21515. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21516. * This should be used together with the simplification to avoid disappearing triangles.
  21517. * @param successCallback an optional success callback to be called after the optimization finished.
  21518. * @returns the current mesh
  21519. */
  21520. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21521. /**
  21522. * Serialize current mesh
  21523. * @param serializationObject defines the object which will receive the serialization data
  21524. */
  21525. serialize(serializationObject: any): void;
  21526. /** @hidden */
  21527. _syncGeometryWithMorphTargetManager(): void;
  21528. /** @hidden */
  21529. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21530. /**
  21531. * Returns a new Mesh object parsed from the source provided.
  21532. * @param parsedMesh is the source
  21533. * @param scene defines the hosting scene
  21534. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21535. * @returns a new Mesh
  21536. */
  21537. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21538. /**
  21539. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21540. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21541. * @param name defines the name of the mesh to create
  21542. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21543. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21544. * @param closePath creates a seam between the first and the last points of each path of the path array
  21545. * @param offset is taken in account only if the `pathArray` is containing a single path
  21546. * @param scene defines the hosting scene
  21547. * @param updatable defines if the mesh must be flagged as updatable
  21548. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21549. * @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)
  21550. * @returns a new Mesh
  21551. */
  21552. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21553. /**
  21554. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21555. * @param name defines the name of the mesh to create
  21556. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21557. * @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
  21558. * @param scene defines the hosting scene
  21559. * @param updatable defines if the mesh must be flagged as updatable
  21560. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21561. * @returns a new Mesh
  21562. */
  21563. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21564. /**
  21565. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21566. * @param name defines the name of the mesh to create
  21567. * @param size sets the size (float) of each box side (default 1)
  21568. * @param scene defines the hosting scene
  21569. * @param updatable defines if the mesh must be flagged as updatable
  21570. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21571. * @returns a new Mesh
  21572. */
  21573. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21574. /**
  21575. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21576. * @param name defines the name of the mesh to create
  21577. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21578. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21579. * @param scene defines the hosting scene
  21580. * @param updatable defines if the mesh must be flagged as updatable
  21581. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21582. * @returns a new Mesh
  21583. */
  21584. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21585. /**
  21586. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21587. * @param name defines the name of the mesh to create
  21588. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21589. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21590. * @param scene defines the hosting scene
  21591. * @returns a new Mesh
  21592. */
  21593. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21594. /**
  21595. * Creates a cylinder or a cone 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 height sets the height size (float) of the cylinder/cone (float, default 2)
  21598. * @param diameterTop set the top cap diameter (floats, default 1)
  21599. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21600. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21601. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21602. * @param scene defines the hosting scene
  21603. * @param updatable defines if the mesh must be flagged as updatable
  21604. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21605. * @returns a new Mesh
  21606. */
  21607. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21608. /**
  21609. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21610. * @param name defines the name of the mesh to create
  21611. * @param diameter sets the diameter size (float) of the torus (default 1)
  21612. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21613. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21614. * @param scene defines the hosting scene
  21615. * @param updatable defines if the mesh must be flagged as updatable
  21616. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21617. * @returns a new Mesh
  21618. */
  21619. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21620. /**
  21621. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21622. * @param name defines the name of the mesh to create
  21623. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21624. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21625. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21626. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21627. * @param p the number of windings on X axis (positive integers, default 2)
  21628. * @param q the number of windings on Y axis (positive integers, default 3)
  21629. * @param scene defines the hosting scene
  21630. * @param updatable defines if the mesh must be flagged as updatable
  21631. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21632. * @returns a new Mesh
  21633. */
  21634. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21635. /**
  21636. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21637. * @param name defines the name of the mesh to create
  21638. * @param points is an array successive Vector3
  21639. * @param scene defines the hosting scene
  21640. * @param updatable defines if the mesh must be flagged as updatable
  21641. * @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).
  21642. * @returns a new Mesh
  21643. */
  21644. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21645. /**
  21646. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21647. * @param name defines the name of the mesh to create
  21648. * @param points is an array successive Vector3
  21649. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21650. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21651. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21652. * @param scene defines the hosting scene
  21653. * @param updatable defines if the mesh must be flagged as updatable
  21654. * @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)
  21655. * @returns a new Mesh
  21656. */
  21657. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21658. /**
  21659. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21660. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21661. * 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.
  21662. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21663. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21664. * Remember you can only change the shape positions, not their number when updating a polygon.
  21665. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21666. * @param name defines the name of the mesh to create
  21667. * @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
  21668. * @param scene defines the hosting scene
  21669. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21670. * @param updatable defines if the mesh must be flagged as updatable
  21671. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21672. * @param earcutInjection can be used to inject your own earcut reference
  21673. * @returns a new Mesh
  21674. */
  21675. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21676. /**
  21677. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21678. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21679. * @param name defines the name of the mesh to create
  21680. * @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
  21681. * @param depth defines the height of extrusion
  21682. * @param scene defines the hosting scene
  21683. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21684. * @param updatable defines if the mesh must be flagged as updatable
  21685. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21686. * @param earcutInjection can be used to inject your own earcut reference
  21687. * @returns a new Mesh
  21688. */
  21689. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21690. /**
  21691. * Creates an extruded shape mesh.
  21692. * 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
  21693. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21694. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21695. * @param name defines the name of the mesh to create
  21696. * @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
  21697. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21698. * @param scale is the value to scale the shape
  21699. * @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
  21700. * @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
  21701. * @param scene defines the hosting scene
  21702. * @param updatable defines if the mesh must be flagged as updatable
  21703. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21704. * @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)
  21705. * @returns a new Mesh
  21706. */
  21707. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21708. /**
  21709. * Creates an custom extruded shape mesh.
  21710. * The custom extrusion is a parametric shape.
  21711. * It has no predefined shape. Its final shape will depend on the input parameters.
  21712. * Please consider using the same method from the MeshBuilder class instead
  21713. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21714. * @param name defines the name of the mesh to create
  21715. * @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
  21716. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21717. * @param scaleFunction is a custom Javascript function called on each path point
  21718. * @param rotationFunction is a custom Javascript function called on each path point
  21719. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21720. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21721. * @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
  21722. * @param scene defines the hosting scene
  21723. * @param updatable defines if the mesh must be flagged as updatable
  21724. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21725. * @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)
  21726. * @returns a new Mesh
  21727. */
  21728. 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;
  21729. /**
  21730. * Creates lathe mesh.
  21731. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21732. * Please consider using the same method from the MeshBuilder class instead
  21733. * @param name defines the name of the mesh to create
  21734. * @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
  21735. * @param radius is the radius value of the lathe
  21736. * @param tessellation is the side number of the lathe.
  21737. * @param scene defines the hosting scene
  21738. * @param updatable defines if the mesh must be flagged as updatable
  21739. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21740. * @returns a new Mesh
  21741. */
  21742. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21743. /**
  21744. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21745. * @param name defines the name of the mesh to create
  21746. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21747. * @param scene defines the hosting scene
  21748. * @param updatable defines if the mesh must be flagged as updatable
  21749. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21750. * @returns a new Mesh
  21751. */
  21752. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21753. /**
  21754. * Creates a ground mesh.
  21755. * Please consider using the same method from the MeshBuilder class instead
  21756. * @param name defines the name of the mesh to create
  21757. * @param width set the width of the ground
  21758. * @param height set the height of the ground
  21759. * @param subdivisions sets the number of subdivisions per side
  21760. * @param scene defines the hosting scene
  21761. * @param updatable defines if the mesh must be flagged as updatable
  21762. * @returns a new Mesh
  21763. */
  21764. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21765. /**
  21766. * Creates a tiled ground mesh.
  21767. * Please consider using the same method from the MeshBuilder class instead
  21768. * @param name defines the name of the mesh to create
  21769. * @param xmin set the ground minimum X coordinate
  21770. * @param zmin set the ground minimum Y coordinate
  21771. * @param xmax set the ground maximum X coordinate
  21772. * @param zmax set the ground maximum Z coordinate
  21773. * @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
  21774. * @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
  21775. * @param scene defines the hosting scene
  21776. * @param updatable defines if the mesh must be flagged as updatable
  21777. * @returns a new Mesh
  21778. */
  21779. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21780. w: number;
  21781. h: number;
  21782. }, precision: {
  21783. w: number;
  21784. h: number;
  21785. }, scene: Scene, updatable?: boolean): Mesh;
  21786. /**
  21787. * Creates a ground mesh from a height map.
  21788. * Please consider using the same method from the MeshBuilder class instead
  21789. * @see http://doc.babylonjs.com/babylon101/height_map
  21790. * @param name defines the name of the mesh to create
  21791. * @param url sets the URL of the height map image resource
  21792. * @param width set the ground width size
  21793. * @param height set the ground height size
  21794. * @param subdivisions sets the number of subdivision per side
  21795. * @param minHeight is the minimum altitude on the ground
  21796. * @param maxHeight is the maximum altitude on the ground
  21797. * @param scene defines the hosting scene
  21798. * @param updatable defines if the mesh must be flagged as updatable
  21799. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21800. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21801. * @returns a new Mesh
  21802. */
  21803. 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;
  21804. /**
  21805. * Creates a tube mesh.
  21806. * The tube is a parametric shape.
  21807. * It has no predefined shape. Its final shape will depend on the input parameters.
  21808. * Please consider using the same method from the MeshBuilder class instead
  21809. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21810. * @param name defines the name of the mesh to create
  21811. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21812. * @param radius sets the tube radius size
  21813. * @param tessellation is the number of sides on the tubular surface
  21814. * @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
  21815. * @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
  21816. * @param scene defines the hosting scene
  21817. * @param updatable defines if the mesh must be flagged as updatable
  21818. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21819. * @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)
  21820. * @returns a new Mesh
  21821. */
  21822. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21823. (i: number, distance: number): number;
  21824. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21825. /**
  21826. * Creates a polyhedron mesh.
  21827. * Please consider using the same method from the MeshBuilder class instead.
  21828. * * 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
  21829. * * The parameter `size` (positive float, default 1) sets the polygon size
  21830. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21831. * * 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`
  21832. * * 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
  21833. * * 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)`)
  21834. * * 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
  21835. * * 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
  21836. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21837. * * 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
  21838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21839. * @param name defines the name of the mesh to create
  21840. * @param options defines the options used to create the mesh
  21841. * @param scene defines the hosting scene
  21842. * @returns a new Mesh
  21843. */
  21844. static CreatePolyhedron(name: string, options: {
  21845. type?: number;
  21846. size?: number;
  21847. sizeX?: number;
  21848. sizeY?: number;
  21849. sizeZ?: number;
  21850. custom?: any;
  21851. faceUV?: Vector4[];
  21852. faceColors?: Color4[];
  21853. updatable?: boolean;
  21854. sideOrientation?: number;
  21855. }, scene: Scene): Mesh;
  21856. /**
  21857. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21858. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21859. * * 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`)
  21860. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21861. * * 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
  21862. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21863. * * 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
  21864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21865. * @param name defines the name of the mesh
  21866. * @param options defines the options used to create the mesh
  21867. * @param scene defines the hosting scene
  21868. * @returns a new Mesh
  21869. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21870. */
  21871. static CreateIcoSphere(name: string, options: {
  21872. radius?: number;
  21873. flat?: boolean;
  21874. subdivisions?: number;
  21875. sideOrientation?: number;
  21876. updatable?: boolean;
  21877. }, scene: Scene): Mesh;
  21878. /**
  21879. * Creates a decal mesh.
  21880. * Please consider using the same method from the MeshBuilder class instead.
  21881. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21882. * @param name defines the name of the mesh
  21883. * @param sourceMesh defines the mesh receiving the decal
  21884. * @param position sets the position of the decal in world coordinates
  21885. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21886. * @param size sets the decal scaling
  21887. * @param angle sets the angle to rotate the decal
  21888. * @returns a new Mesh
  21889. */
  21890. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21891. /**
  21892. * Prepare internal position array for software CPU skinning
  21893. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21894. */
  21895. setPositionsForCPUSkinning(): Float32Array;
  21896. /**
  21897. * Prepare internal normal array for software CPU skinning
  21898. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21899. */
  21900. setNormalsForCPUSkinning(): Float32Array;
  21901. /**
  21902. * Updates the vertex buffer by applying transformation from the bones
  21903. * @param skeleton defines the skeleton to apply to current mesh
  21904. * @returns the current mesh
  21905. */
  21906. applySkeleton(skeleton: Skeleton): Mesh;
  21907. /**
  21908. * 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
  21909. * @param meshes defines the list of meshes to scan
  21910. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21911. */
  21912. static MinMax(meshes: AbstractMesh[]): {
  21913. min: Vector3;
  21914. max: Vector3;
  21915. };
  21916. /**
  21917. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21918. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21919. * @returns a vector3
  21920. */
  21921. static Center(meshesOrMinMaxVector: {
  21922. min: Vector3;
  21923. max: Vector3;
  21924. } | AbstractMesh[]): Vector3;
  21925. /**
  21926. * Merge the array of meshes into a single mesh for performance reasons.
  21927. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21928. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21929. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21930. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21931. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21932. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21933. * @returns a new mesh
  21934. */
  21935. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21936. /** @hidden */
  21937. addInstance(instance: InstancedMesh): void;
  21938. /** @hidden */
  21939. removeInstance(instance: InstancedMesh): void;
  21940. }
  21941. }
  21942. declare module BABYLON {
  21943. /**
  21944. * Base class for the main features of a material in Babylon.js
  21945. */
  21946. export class Material implements IAnimatable {
  21947. /**
  21948. * Returns the triangle fill mode
  21949. */
  21950. static readonly TriangleFillMode: number;
  21951. /**
  21952. * Returns the wireframe mode
  21953. */
  21954. static readonly WireFrameFillMode: number;
  21955. /**
  21956. * Returns the point fill mode
  21957. */
  21958. static readonly PointFillMode: number;
  21959. /**
  21960. * Returns the point list draw mode
  21961. */
  21962. static readonly PointListDrawMode: number;
  21963. /**
  21964. * Returns the line list draw mode
  21965. */
  21966. static readonly LineListDrawMode: number;
  21967. /**
  21968. * Returns the line loop draw mode
  21969. */
  21970. static readonly LineLoopDrawMode: number;
  21971. /**
  21972. * Returns the line strip draw mode
  21973. */
  21974. static readonly LineStripDrawMode: number;
  21975. /**
  21976. * Returns the triangle strip draw mode
  21977. */
  21978. static readonly TriangleStripDrawMode: number;
  21979. /**
  21980. * Returns the triangle fan draw mode
  21981. */
  21982. static readonly TriangleFanDrawMode: number;
  21983. /**
  21984. * Stores the clock-wise side orientation
  21985. */
  21986. static readonly ClockWiseSideOrientation: number;
  21987. /**
  21988. * Stores the counter clock-wise side orientation
  21989. */
  21990. static readonly CounterClockWiseSideOrientation: number;
  21991. /**
  21992. * The dirty texture flag value
  21993. */
  21994. static readonly TextureDirtyFlag: number;
  21995. /**
  21996. * The dirty light flag value
  21997. */
  21998. static readonly LightDirtyFlag: number;
  21999. /**
  22000. * The dirty fresnel flag value
  22001. */
  22002. static readonly FresnelDirtyFlag: number;
  22003. /**
  22004. * The dirty attribute flag value
  22005. */
  22006. static readonly AttributesDirtyFlag: number;
  22007. /**
  22008. * The dirty misc flag value
  22009. */
  22010. static readonly MiscDirtyFlag: number;
  22011. /**
  22012. * The all dirty flag value
  22013. */
  22014. static readonly AllDirtyFlag: number;
  22015. /**
  22016. * The ID of the material
  22017. */
  22018. id: string;
  22019. /**
  22020. * Gets or sets the unique id of the material
  22021. */
  22022. uniqueId: number;
  22023. /**
  22024. * The name of the material
  22025. */
  22026. name: string;
  22027. /**
  22028. * Gets or sets user defined metadata
  22029. */
  22030. metadata: any;
  22031. /**
  22032. * For internal use only. Please do not use.
  22033. */
  22034. reservedDataStore: any;
  22035. /**
  22036. * Specifies if the ready state should be checked on each call
  22037. */
  22038. checkReadyOnEveryCall: boolean;
  22039. /**
  22040. * Specifies if the ready state should be checked once
  22041. */
  22042. checkReadyOnlyOnce: boolean;
  22043. /**
  22044. * The state of the material
  22045. */
  22046. state: string;
  22047. /**
  22048. * The alpha value of the material
  22049. */
  22050. protected _alpha: number;
  22051. /**
  22052. * List of inspectable custom properties (used by the Inspector)
  22053. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22054. */
  22055. inspectableCustomProperties: IInspectable[];
  22056. /**
  22057. * Sets the alpha value of the material
  22058. */
  22059. /**
  22060. * Gets the alpha value of the material
  22061. */
  22062. alpha: number;
  22063. /**
  22064. * Specifies if back face culling is enabled
  22065. */
  22066. protected _backFaceCulling: boolean;
  22067. /**
  22068. * Sets the back-face culling state
  22069. */
  22070. /**
  22071. * Gets the back-face culling state
  22072. */
  22073. backFaceCulling: boolean;
  22074. /**
  22075. * Stores the value for side orientation
  22076. */
  22077. sideOrientation: number;
  22078. /**
  22079. * Callback triggered when the material is compiled
  22080. */
  22081. onCompiled: Nullable<(effect: Effect) => void>;
  22082. /**
  22083. * Callback triggered when an error occurs
  22084. */
  22085. onError: Nullable<(effect: Effect, errors: string) => void>;
  22086. /**
  22087. * Callback triggered to get the render target textures
  22088. */
  22089. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22090. /**
  22091. * Gets a boolean indicating that current material needs to register RTT
  22092. */
  22093. readonly hasRenderTargetTextures: boolean;
  22094. /**
  22095. * Specifies if the material should be serialized
  22096. */
  22097. doNotSerialize: boolean;
  22098. /**
  22099. * @hidden
  22100. */
  22101. _storeEffectOnSubMeshes: boolean;
  22102. /**
  22103. * Stores the animations for the material
  22104. */
  22105. animations: Nullable<Array<Animation>>;
  22106. /**
  22107. * An event triggered when the material is disposed
  22108. */
  22109. onDisposeObservable: Observable<Material>;
  22110. /**
  22111. * An observer which watches for dispose events
  22112. */
  22113. private _onDisposeObserver;
  22114. private _onUnBindObservable;
  22115. /**
  22116. * Called during a dispose event
  22117. */
  22118. onDispose: () => void;
  22119. private _onBindObservable;
  22120. /**
  22121. * An event triggered when the material is bound
  22122. */
  22123. readonly onBindObservable: Observable<AbstractMesh>;
  22124. /**
  22125. * An observer which watches for bind events
  22126. */
  22127. private _onBindObserver;
  22128. /**
  22129. * Called during a bind event
  22130. */
  22131. onBind: (Mesh: AbstractMesh) => void;
  22132. /**
  22133. * An event triggered when the material is unbound
  22134. */
  22135. readonly onUnBindObservable: Observable<Material>;
  22136. /**
  22137. * Stores the value of the alpha mode
  22138. */
  22139. private _alphaMode;
  22140. /**
  22141. * Sets the value of the alpha mode.
  22142. *
  22143. * | Value | Type | Description |
  22144. * | --- | --- | --- |
  22145. * | 0 | ALPHA_DISABLE | |
  22146. * | 1 | ALPHA_ADD | |
  22147. * | 2 | ALPHA_COMBINE | |
  22148. * | 3 | ALPHA_SUBTRACT | |
  22149. * | 4 | ALPHA_MULTIPLY | |
  22150. * | 5 | ALPHA_MAXIMIZED | |
  22151. * | 6 | ALPHA_ONEONE | |
  22152. * | 7 | ALPHA_PREMULTIPLIED | |
  22153. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22154. * | 9 | ALPHA_INTERPOLATE | |
  22155. * | 10 | ALPHA_SCREENMODE | |
  22156. *
  22157. */
  22158. /**
  22159. * Gets the value of the alpha mode
  22160. */
  22161. alphaMode: number;
  22162. /**
  22163. * Stores the state of the need depth pre-pass value
  22164. */
  22165. private _needDepthPrePass;
  22166. /**
  22167. * Sets the need depth pre-pass value
  22168. */
  22169. /**
  22170. * Gets the depth pre-pass value
  22171. */
  22172. needDepthPrePass: boolean;
  22173. /**
  22174. * Specifies if depth writing should be disabled
  22175. */
  22176. disableDepthWrite: boolean;
  22177. /**
  22178. * Specifies if depth writing should be forced
  22179. */
  22180. forceDepthWrite: boolean;
  22181. /**
  22182. * Specifies if there should be a separate pass for culling
  22183. */
  22184. separateCullingPass: boolean;
  22185. /**
  22186. * Stores the state specifing if fog should be enabled
  22187. */
  22188. private _fogEnabled;
  22189. /**
  22190. * Sets the state for enabling fog
  22191. */
  22192. /**
  22193. * Gets the value of the fog enabled state
  22194. */
  22195. fogEnabled: boolean;
  22196. /**
  22197. * Stores the size of points
  22198. */
  22199. pointSize: number;
  22200. /**
  22201. * Stores the z offset value
  22202. */
  22203. zOffset: number;
  22204. /**
  22205. * Gets a value specifying if wireframe mode is enabled
  22206. */
  22207. /**
  22208. * Sets the state of wireframe mode
  22209. */
  22210. wireframe: boolean;
  22211. /**
  22212. * Gets the value specifying if point clouds are enabled
  22213. */
  22214. /**
  22215. * Sets the state of point cloud mode
  22216. */
  22217. pointsCloud: boolean;
  22218. /**
  22219. * Gets the material fill mode
  22220. */
  22221. /**
  22222. * Sets the material fill mode
  22223. */
  22224. fillMode: number;
  22225. /**
  22226. * @hidden
  22227. * Stores the effects for the material
  22228. */
  22229. _effect: Nullable<Effect>;
  22230. /**
  22231. * @hidden
  22232. * Specifies if the material was previously ready
  22233. */
  22234. _wasPreviouslyReady: boolean;
  22235. /**
  22236. * Specifies if uniform buffers should be used
  22237. */
  22238. private _useUBO;
  22239. /**
  22240. * Stores a reference to the scene
  22241. */
  22242. private _scene;
  22243. /**
  22244. * Stores the fill mode state
  22245. */
  22246. private _fillMode;
  22247. /**
  22248. * Specifies if the depth write state should be cached
  22249. */
  22250. private _cachedDepthWriteState;
  22251. /**
  22252. * Stores the uniform buffer
  22253. */
  22254. protected _uniformBuffer: UniformBuffer;
  22255. /** @hidden */
  22256. _indexInSceneMaterialArray: number;
  22257. /** @hidden */
  22258. meshMap: Nullable<{
  22259. [id: string]: AbstractMesh | undefined;
  22260. }>;
  22261. /**
  22262. * Creates a material instance
  22263. * @param name defines the name of the material
  22264. * @param scene defines the scene to reference
  22265. * @param doNotAdd specifies if the material should be added to the scene
  22266. */
  22267. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22268. /**
  22269. * Returns a string representation of the current material
  22270. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22271. * @returns a string with material information
  22272. */
  22273. toString(fullDetails?: boolean): string;
  22274. /**
  22275. * Gets the class name of the material
  22276. * @returns a string with the class name of the material
  22277. */
  22278. getClassName(): string;
  22279. /**
  22280. * Specifies if updates for the material been locked
  22281. */
  22282. readonly isFrozen: boolean;
  22283. /**
  22284. * Locks updates for the material
  22285. */
  22286. freeze(): void;
  22287. /**
  22288. * Unlocks updates for the material
  22289. */
  22290. unfreeze(): void;
  22291. /**
  22292. * Specifies if the material is ready to be used
  22293. * @param mesh defines the mesh to check
  22294. * @param useInstances specifies if instances should be used
  22295. * @returns a boolean indicating if the material is ready to be used
  22296. */
  22297. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22298. /**
  22299. * Specifies that the submesh is ready to be used
  22300. * @param mesh defines the mesh to check
  22301. * @param subMesh defines which submesh to check
  22302. * @param useInstances specifies that instances should be used
  22303. * @returns a boolean indicating that the submesh is ready or not
  22304. */
  22305. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22306. /**
  22307. * Returns the material effect
  22308. * @returns the effect associated with the material
  22309. */
  22310. getEffect(): Nullable<Effect>;
  22311. /**
  22312. * Returns the current scene
  22313. * @returns a Scene
  22314. */
  22315. getScene(): Scene;
  22316. /**
  22317. * Specifies if the material will require alpha blending
  22318. * @returns a boolean specifying if alpha blending is needed
  22319. */
  22320. needAlphaBlending(): boolean;
  22321. /**
  22322. * Specifies if the mesh will require alpha blending
  22323. * @param mesh defines the mesh to check
  22324. * @returns a boolean specifying if alpha blending is needed for the mesh
  22325. */
  22326. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22327. /**
  22328. * Specifies if this material should be rendered in alpha test mode
  22329. * @returns a boolean specifying if an alpha test is needed.
  22330. */
  22331. needAlphaTesting(): boolean;
  22332. /**
  22333. * Gets the texture used for the alpha test
  22334. * @returns the texture to use for alpha testing
  22335. */
  22336. getAlphaTestTexture(): Nullable<BaseTexture>;
  22337. /**
  22338. * Marks the material to indicate that it needs to be re-calculated
  22339. */
  22340. markDirty(): void;
  22341. /** @hidden */
  22342. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22343. /**
  22344. * Binds the material to the mesh
  22345. * @param world defines the world transformation matrix
  22346. * @param mesh defines the mesh to bind the material to
  22347. */
  22348. bind(world: Matrix, mesh?: Mesh): void;
  22349. /**
  22350. * Binds the submesh to the material
  22351. * @param world defines the world transformation matrix
  22352. * @param mesh defines the mesh containing the submesh
  22353. * @param subMesh defines the submesh to bind the material to
  22354. */
  22355. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22356. /**
  22357. * Binds the world matrix to the material
  22358. * @param world defines the world transformation matrix
  22359. */
  22360. bindOnlyWorldMatrix(world: Matrix): void;
  22361. /**
  22362. * Binds the scene's uniform buffer to the effect.
  22363. * @param effect defines the effect to bind to the scene uniform buffer
  22364. * @param sceneUbo defines the uniform buffer storing scene data
  22365. */
  22366. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22367. /**
  22368. * Binds the view matrix to the effect
  22369. * @param effect defines the effect to bind the view matrix to
  22370. */
  22371. bindView(effect: Effect): void;
  22372. /**
  22373. * Binds the view projection matrix to the effect
  22374. * @param effect defines the effect to bind the view projection matrix to
  22375. */
  22376. bindViewProjection(effect: Effect): void;
  22377. /**
  22378. * Specifies if material alpha testing should be turned on for the mesh
  22379. * @param mesh defines the mesh to check
  22380. */
  22381. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22382. /**
  22383. * Processes to execute after binding the material to a mesh
  22384. * @param mesh defines the rendered mesh
  22385. */
  22386. protected _afterBind(mesh?: Mesh): void;
  22387. /**
  22388. * Unbinds the material from the mesh
  22389. */
  22390. unbind(): void;
  22391. /**
  22392. * Gets the active textures from the material
  22393. * @returns an array of textures
  22394. */
  22395. getActiveTextures(): BaseTexture[];
  22396. /**
  22397. * Specifies if the material uses a texture
  22398. * @param texture defines the texture to check against the material
  22399. * @returns a boolean specifying if the material uses the texture
  22400. */
  22401. hasTexture(texture: BaseTexture): boolean;
  22402. /**
  22403. * Makes a duplicate of the material, and gives it a new name
  22404. * @param name defines the new name for the duplicated material
  22405. * @returns the cloned material
  22406. */
  22407. clone(name: string): Nullable<Material>;
  22408. /**
  22409. * Gets the meshes bound to the material
  22410. * @returns an array of meshes bound to the material
  22411. */
  22412. getBindedMeshes(): AbstractMesh[];
  22413. /**
  22414. * Force shader compilation
  22415. * @param mesh defines the mesh associated with this material
  22416. * @param onCompiled defines a function to execute once the material is compiled
  22417. * @param options defines the options to configure the compilation
  22418. */
  22419. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22420. clipPlane: boolean;
  22421. }>): void;
  22422. /**
  22423. * Force shader compilation
  22424. * @param mesh defines the mesh that will use this material
  22425. * @param options defines additional options for compiling the shaders
  22426. * @returns a promise that resolves when the compilation completes
  22427. */
  22428. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22429. clipPlane: boolean;
  22430. }>): Promise<void>;
  22431. private static readonly _ImageProcessingDirtyCallBack;
  22432. private static readonly _TextureDirtyCallBack;
  22433. private static readonly _FresnelDirtyCallBack;
  22434. private static readonly _MiscDirtyCallBack;
  22435. private static readonly _LightsDirtyCallBack;
  22436. private static readonly _AttributeDirtyCallBack;
  22437. private static _FresnelAndMiscDirtyCallBack;
  22438. private static _TextureAndMiscDirtyCallBack;
  22439. private static readonly _DirtyCallbackArray;
  22440. private static readonly _RunDirtyCallBacks;
  22441. /**
  22442. * Marks a define in the material to indicate that it needs to be re-computed
  22443. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22444. */
  22445. markAsDirty(flag: number): void;
  22446. /**
  22447. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22448. * @param func defines a function which checks material defines against the submeshes
  22449. */
  22450. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22451. /**
  22452. * Indicates that image processing needs to be re-calculated for all submeshes
  22453. */
  22454. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22455. /**
  22456. * Indicates that textures need to be re-calculated for all submeshes
  22457. */
  22458. protected _markAllSubMeshesAsTexturesDirty(): void;
  22459. /**
  22460. * Indicates that fresnel needs to be re-calculated for all submeshes
  22461. */
  22462. protected _markAllSubMeshesAsFresnelDirty(): void;
  22463. /**
  22464. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22465. */
  22466. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22467. /**
  22468. * Indicates that lights need to be re-calculated for all submeshes
  22469. */
  22470. protected _markAllSubMeshesAsLightsDirty(): void;
  22471. /**
  22472. * Indicates that attributes need to be re-calculated for all submeshes
  22473. */
  22474. protected _markAllSubMeshesAsAttributesDirty(): void;
  22475. /**
  22476. * Indicates that misc needs to be re-calculated for all submeshes
  22477. */
  22478. protected _markAllSubMeshesAsMiscDirty(): void;
  22479. /**
  22480. * Indicates that textures and misc need to be re-calculated for all submeshes
  22481. */
  22482. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22483. /**
  22484. * Disposes the material
  22485. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22486. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22487. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22488. */
  22489. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22490. /** @hidden */
  22491. private releaseVertexArrayObject;
  22492. /**
  22493. * Serializes this material
  22494. * @returns the serialized material object
  22495. */
  22496. serialize(): any;
  22497. /**
  22498. * Creates a material from parsed material data
  22499. * @param parsedMaterial defines parsed material data
  22500. * @param scene defines the hosting scene
  22501. * @param rootUrl defines the root URL to use to load textures
  22502. * @returns a new material
  22503. */
  22504. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22505. }
  22506. }
  22507. declare module BABYLON {
  22508. /**
  22509. * Base class for submeshes
  22510. */
  22511. export class BaseSubMesh {
  22512. /** @hidden */
  22513. _materialDefines: Nullable<MaterialDefines>;
  22514. /** @hidden */
  22515. _materialEffect: Nullable<Effect>;
  22516. /**
  22517. * Gets associated effect
  22518. */
  22519. readonly effect: Nullable<Effect>;
  22520. /**
  22521. * Sets associated effect (effect used to render this submesh)
  22522. * @param effect defines the effect to associate with
  22523. * @param defines defines the set of defines used to compile this effect
  22524. */
  22525. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22526. }
  22527. /**
  22528. * Defines a subdivision inside a mesh
  22529. */
  22530. export class SubMesh extends BaseSubMesh implements ICullable {
  22531. /** the material index to use */
  22532. materialIndex: number;
  22533. /** vertex index start */
  22534. verticesStart: number;
  22535. /** vertices count */
  22536. verticesCount: number;
  22537. /** index start */
  22538. indexStart: number;
  22539. /** indices count */
  22540. indexCount: number;
  22541. /** @hidden */
  22542. _linesIndexCount: number;
  22543. private _mesh;
  22544. private _renderingMesh;
  22545. private _boundingInfo;
  22546. private _linesIndexBuffer;
  22547. /** @hidden */
  22548. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22549. /** @hidden */
  22550. _trianglePlanes: Plane[];
  22551. /** @hidden */
  22552. _lastColliderTransformMatrix: Nullable<Matrix>;
  22553. /** @hidden */
  22554. _renderId: number;
  22555. /** @hidden */
  22556. _alphaIndex: number;
  22557. /** @hidden */
  22558. _distanceToCamera: number;
  22559. /** @hidden */
  22560. _id: number;
  22561. private _currentMaterial;
  22562. /**
  22563. * Add a new submesh to a mesh
  22564. * @param materialIndex defines the material index to use
  22565. * @param verticesStart defines vertex index start
  22566. * @param verticesCount defines vertices count
  22567. * @param indexStart defines index start
  22568. * @param indexCount defines indices count
  22569. * @param mesh defines the parent mesh
  22570. * @param renderingMesh defines an optional rendering mesh
  22571. * @param createBoundingBox defines if bounding box should be created for this submesh
  22572. * @returns the new submesh
  22573. */
  22574. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22575. /**
  22576. * Creates a new submesh
  22577. * @param materialIndex defines the material index to use
  22578. * @param verticesStart defines vertex index start
  22579. * @param verticesCount defines vertices count
  22580. * @param indexStart defines index start
  22581. * @param indexCount defines indices count
  22582. * @param mesh defines the parent mesh
  22583. * @param renderingMesh defines an optional rendering mesh
  22584. * @param createBoundingBox defines if bounding box should be created for this submesh
  22585. */
  22586. constructor(
  22587. /** the material index to use */
  22588. materialIndex: number,
  22589. /** vertex index start */
  22590. verticesStart: number,
  22591. /** vertices count */
  22592. verticesCount: number,
  22593. /** index start */
  22594. indexStart: number,
  22595. /** indices count */
  22596. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22597. /**
  22598. * Returns true if this submesh covers the entire parent mesh
  22599. * @ignorenaming
  22600. */
  22601. readonly IsGlobal: boolean;
  22602. /**
  22603. * Returns the submesh BoudingInfo object
  22604. * @returns current bounding info (or mesh's one if the submesh is global)
  22605. */
  22606. getBoundingInfo(): BoundingInfo;
  22607. /**
  22608. * Sets the submesh BoundingInfo
  22609. * @param boundingInfo defines the new bounding info to use
  22610. * @returns the SubMesh
  22611. */
  22612. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22613. /**
  22614. * Returns the mesh of the current submesh
  22615. * @return the parent mesh
  22616. */
  22617. getMesh(): AbstractMesh;
  22618. /**
  22619. * Returns the rendering mesh of the submesh
  22620. * @returns the rendering mesh (could be different from parent mesh)
  22621. */
  22622. getRenderingMesh(): Mesh;
  22623. /**
  22624. * Returns the submesh material
  22625. * @returns null or the current material
  22626. */
  22627. getMaterial(): Nullable<Material>;
  22628. /**
  22629. * Sets a new updated BoundingInfo object to the submesh
  22630. * @param data defines an optional position array to use to determine the bounding info
  22631. * @returns the SubMesh
  22632. */
  22633. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22634. /** @hidden */
  22635. _checkCollision(collider: Collider): boolean;
  22636. /**
  22637. * Updates the submesh BoundingInfo
  22638. * @param world defines the world matrix to use to update the bounding info
  22639. * @returns the submesh
  22640. */
  22641. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22642. /**
  22643. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22644. * @param frustumPlanes defines the frustum planes
  22645. * @returns true if the submesh is intersecting with the frustum
  22646. */
  22647. isInFrustum(frustumPlanes: Plane[]): boolean;
  22648. /**
  22649. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22650. * @param frustumPlanes defines the frustum planes
  22651. * @returns true if the submesh is inside the frustum
  22652. */
  22653. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22654. /**
  22655. * Renders the submesh
  22656. * @param enableAlphaMode defines if alpha needs to be used
  22657. * @returns the submesh
  22658. */
  22659. render(enableAlphaMode: boolean): SubMesh;
  22660. /**
  22661. * @hidden
  22662. */
  22663. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22664. /**
  22665. * Checks if the submesh intersects with a ray
  22666. * @param ray defines the ray to test
  22667. * @returns true is the passed ray intersects the submesh bounding box
  22668. */
  22669. canIntersects(ray: Ray): boolean;
  22670. /**
  22671. * Intersects current submesh with a ray
  22672. * @param ray defines the ray to test
  22673. * @param positions defines mesh's positions array
  22674. * @param indices defines mesh's indices array
  22675. * @param fastCheck defines if only bounding info should be used
  22676. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22677. * @returns intersection info or null if no intersection
  22678. */
  22679. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22680. /** @hidden */
  22681. private _intersectLines;
  22682. /** @hidden */
  22683. private _intersectTriangles;
  22684. /** @hidden */
  22685. private _intersectUnIndexedTriangles;
  22686. /** @hidden */
  22687. _rebuild(): void;
  22688. /**
  22689. * Creates a new submesh from the passed mesh
  22690. * @param newMesh defines the new hosting mesh
  22691. * @param newRenderingMesh defines an optional rendering mesh
  22692. * @returns the new submesh
  22693. */
  22694. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22695. /**
  22696. * Release associated resources
  22697. */
  22698. dispose(): void;
  22699. /**
  22700. * Gets the class name
  22701. * @returns the string "SubMesh".
  22702. */
  22703. getClassName(): string;
  22704. /**
  22705. * Creates a new submesh from indices data
  22706. * @param materialIndex the index of the main mesh material
  22707. * @param startIndex the index where to start the copy in the mesh indices array
  22708. * @param indexCount the number of indices to copy then from the startIndex
  22709. * @param mesh the main mesh to create the submesh from
  22710. * @param renderingMesh the optional rendering mesh
  22711. * @returns a new submesh
  22712. */
  22713. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22714. }
  22715. }
  22716. declare module BABYLON {
  22717. /**
  22718. * Class used to store geometry data (vertex buffers + index buffer)
  22719. */
  22720. export class Geometry implements IGetSetVerticesData {
  22721. /**
  22722. * Gets or sets the ID of the geometry
  22723. */
  22724. id: string;
  22725. /**
  22726. * Gets or sets the unique ID of the geometry
  22727. */
  22728. uniqueId: number;
  22729. /**
  22730. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22731. */
  22732. delayLoadState: number;
  22733. /**
  22734. * Gets the file containing the data to load when running in delay load state
  22735. */
  22736. delayLoadingFile: Nullable<string>;
  22737. /**
  22738. * Callback called when the geometry is updated
  22739. */
  22740. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22741. private _scene;
  22742. private _engine;
  22743. private _meshes;
  22744. private _totalVertices;
  22745. /** @hidden */
  22746. _indices: IndicesArray;
  22747. /** @hidden */
  22748. _vertexBuffers: {
  22749. [key: string]: VertexBuffer;
  22750. };
  22751. private _isDisposed;
  22752. private _extend;
  22753. private _boundingBias;
  22754. /** @hidden */
  22755. _delayInfo: Array<string>;
  22756. private _indexBuffer;
  22757. private _indexBufferIsUpdatable;
  22758. /** @hidden */
  22759. _boundingInfo: Nullable<BoundingInfo>;
  22760. /** @hidden */
  22761. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22762. /** @hidden */
  22763. _softwareSkinningFrameId: number;
  22764. private _vertexArrayObjects;
  22765. private _updatable;
  22766. /** @hidden */
  22767. _positions: Nullable<Vector3[]>;
  22768. /**
  22769. * 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
  22770. */
  22771. /**
  22772. * 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
  22773. */
  22774. boundingBias: Vector2;
  22775. /**
  22776. * Static function used to attach a new empty geometry to a mesh
  22777. * @param mesh defines the mesh to attach the geometry to
  22778. * @returns the new Geometry
  22779. */
  22780. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22781. /**
  22782. * Creates a new geometry
  22783. * @param id defines the unique ID
  22784. * @param scene defines the hosting scene
  22785. * @param vertexData defines the VertexData used to get geometry data
  22786. * @param updatable defines if geometry must be updatable (false by default)
  22787. * @param mesh defines the mesh that will be associated with the geometry
  22788. */
  22789. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22790. /**
  22791. * Gets the current extend of the geometry
  22792. */
  22793. readonly extend: {
  22794. minimum: Vector3;
  22795. maximum: Vector3;
  22796. };
  22797. /**
  22798. * Gets the hosting scene
  22799. * @returns the hosting Scene
  22800. */
  22801. getScene(): Scene;
  22802. /**
  22803. * Gets the hosting engine
  22804. * @returns the hosting Engine
  22805. */
  22806. getEngine(): Engine;
  22807. /**
  22808. * Defines if the geometry is ready to use
  22809. * @returns true if the geometry is ready to be used
  22810. */
  22811. isReady(): boolean;
  22812. /**
  22813. * Gets a value indicating that the geometry should not be serialized
  22814. */
  22815. readonly doNotSerialize: boolean;
  22816. /** @hidden */
  22817. _rebuild(): void;
  22818. /**
  22819. * Affects all geometry data in one call
  22820. * @param vertexData defines the geometry data
  22821. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22822. */
  22823. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22824. /**
  22825. * Set specific vertex data
  22826. * @param kind defines the data kind (Position, normal, etc...)
  22827. * @param data defines the vertex data to use
  22828. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22829. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22830. */
  22831. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22832. /**
  22833. * Removes a specific vertex data
  22834. * @param kind defines the data kind (Position, normal, etc...)
  22835. */
  22836. removeVerticesData(kind: string): void;
  22837. /**
  22838. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22839. * @param buffer defines the vertex buffer to use
  22840. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22841. */
  22842. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22843. /**
  22844. * Update a specific vertex buffer
  22845. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22846. * It will do nothing if the buffer is not updatable
  22847. * @param kind defines the data kind (Position, normal, etc...)
  22848. * @param data defines the data to use
  22849. * @param offset defines the offset in the target buffer where to store the data
  22850. * @param useBytes set to true if the offset is in bytes
  22851. */
  22852. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22853. /**
  22854. * Update a specific vertex buffer
  22855. * This function will create a new buffer if the current one is not updatable
  22856. * @param kind defines the data kind (Position, normal, etc...)
  22857. * @param data defines the data to use
  22858. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22859. */
  22860. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22861. private _updateBoundingInfo;
  22862. /** @hidden */
  22863. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22864. /**
  22865. * Gets total number of vertices
  22866. * @returns the total number of vertices
  22867. */
  22868. getTotalVertices(): number;
  22869. /**
  22870. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22871. * @param kind defines the data kind (Position, normal, etc...)
  22872. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22873. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22874. * @returns a float array containing vertex data
  22875. */
  22876. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22877. /**
  22878. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22879. * @param kind defines the data kind (Position, normal, etc...)
  22880. * @returns true if the vertex buffer with the specified kind is updatable
  22881. */
  22882. isVertexBufferUpdatable(kind: string): boolean;
  22883. /**
  22884. * Gets a specific vertex buffer
  22885. * @param kind defines the data kind (Position, normal, etc...)
  22886. * @returns a VertexBuffer
  22887. */
  22888. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22889. /**
  22890. * Returns all vertex buffers
  22891. * @return an object holding all vertex buffers indexed by kind
  22892. */
  22893. getVertexBuffers(): Nullable<{
  22894. [key: string]: VertexBuffer;
  22895. }>;
  22896. /**
  22897. * Gets a boolean indicating if specific vertex buffer is present
  22898. * @param kind defines the data kind (Position, normal, etc...)
  22899. * @returns true if data is present
  22900. */
  22901. isVerticesDataPresent(kind: string): boolean;
  22902. /**
  22903. * Gets a list of all attached data kinds (Position, normal, etc...)
  22904. * @returns a list of string containing all kinds
  22905. */
  22906. getVerticesDataKinds(): string[];
  22907. /**
  22908. * Update index buffer
  22909. * @param indices defines the indices to store in the index buffer
  22910. * @param offset defines the offset in the target buffer where to store the data
  22911. * @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)
  22912. */
  22913. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22914. /**
  22915. * Creates a new index buffer
  22916. * @param indices defines the indices to store in the index buffer
  22917. * @param totalVertices defines the total number of vertices (could be null)
  22918. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22919. */
  22920. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22921. /**
  22922. * Return the total number of indices
  22923. * @returns the total number of indices
  22924. */
  22925. getTotalIndices(): number;
  22926. /**
  22927. * Gets the index buffer array
  22928. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22929. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22930. * @returns the index buffer array
  22931. */
  22932. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22933. /**
  22934. * Gets the index buffer
  22935. * @return the index buffer
  22936. */
  22937. getIndexBuffer(): Nullable<DataBuffer>;
  22938. /** @hidden */
  22939. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22940. /**
  22941. * Release the associated resources for a specific mesh
  22942. * @param mesh defines the source mesh
  22943. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22944. */
  22945. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22946. /**
  22947. * Apply current geometry to a given mesh
  22948. * @param mesh defines the mesh to apply geometry to
  22949. */
  22950. applyToMesh(mesh: Mesh): void;
  22951. private _updateExtend;
  22952. private _applyToMesh;
  22953. private notifyUpdate;
  22954. /**
  22955. * Load the geometry if it was flagged as delay loaded
  22956. * @param scene defines the hosting scene
  22957. * @param onLoaded defines a callback called when the geometry is loaded
  22958. */
  22959. load(scene: Scene, onLoaded?: () => void): void;
  22960. private _queueLoad;
  22961. /**
  22962. * Invert the geometry to move from a right handed system to a left handed one.
  22963. */
  22964. toLeftHanded(): void;
  22965. /** @hidden */
  22966. _resetPointsArrayCache(): void;
  22967. /** @hidden */
  22968. _generatePointsArray(): boolean;
  22969. /**
  22970. * Gets a value indicating if the geometry is disposed
  22971. * @returns true if the geometry was disposed
  22972. */
  22973. isDisposed(): boolean;
  22974. private _disposeVertexArrayObjects;
  22975. /**
  22976. * Free all associated resources
  22977. */
  22978. dispose(): void;
  22979. /**
  22980. * Clone the current geometry into a new geometry
  22981. * @param id defines the unique ID of the new geometry
  22982. * @returns a new geometry object
  22983. */
  22984. copy(id: string): Geometry;
  22985. /**
  22986. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22987. * @return a JSON representation of the current geometry data (without the vertices data)
  22988. */
  22989. serialize(): any;
  22990. private toNumberArray;
  22991. /**
  22992. * Serialize all vertices data into a JSON oject
  22993. * @returns a JSON representation of the current geometry data
  22994. */
  22995. serializeVerticeData(): any;
  22996. /**
  22997. * Extracts a clone of a mesh geometry
  22998. * @param mesh defines the source mesh
  22999. * @param id defines the unique ID of the new geometry object
  23000. * @returns the new geometry object
  23001. */
  23002. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23003. /**
  23004. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23005. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23006. * Be aware Math.random() could cause collisions, but:
  23007. * "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"
  23008. * @returns a string containing a new GUID
  23009. */
  23010. static RandomId(): string;
  23011. /** @hidden */
  23012. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23013. private static _CleanMatricesWeights;
  23014. /**
  23015. * Create a new geometry from persisted data (Using .babylon file format)
  23016. * @param parsedVertexData defines the persisted data
  23017. * @param scene defines the hosting scene
  23018. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23019. * @returns the new geometry object
  23020. */
  23021. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23022. }
  23023. }
  23024. declare module BABYLON {
  23025. /**
  23026. * Define an interface for all classes that will get and set the data on vertices
  23027. */
  23028. export interface IGetSetVerticesData {
  23029. /**
  23030. * Gets a boolean indicating if specific vertex data is present
  23031. * @param kind defines the vertex data kind to use
  23032. * @returns true is data kind is present
  23033. */
  23034. isVerticesDataPresent(kind: string): boolean;
  23035. /**
  23036. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23037. * @param kind defines the data kind (Position, normal, etc...)
  23038. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23039. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23040. * @returns a float array containing vertex data
  23041. */
  23042. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23043. /**
  23044. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23045. * @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.
  23046. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23047. * @returns the indices array or an empty array if the mesh has no geometry
  23048. */
  23049. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23050. /**
  23051. * Set specific vertex data
  23052. * @param kind defines the data kind (Position, normal, etc...)
  23053. * @param data defines the vertex data to use
  23054. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23055. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23056. */
  23057. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23058. /**
  23059. * Update a specific associated vertex buffer
  23060. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23061. * - VertexBuffer.PositionKind
  23062. * - VertexBuffer.UVKind
  23063. * - VertexBuffer.UV2Kind
  23064. * - VertexBuffer.UV3Kind
  23065. * - VertexBuffer.UV4Kind
  23066. * - VertexBuffer.UV5Kind
  23067. * - VertexBuffer.UV6Kind
  23068. * - VertexBuffer.ColorKind
  23069. * - VertexBuffer.MatricesIndicesKind
  23070. * - VertexBuffer.MatricesIndicesExtraKind
  23071. * - VertexBuffer.MatricesWeightsKind
  23072. * - VertexBuffer.MatricesWeightsExtraKind
  23073. * @param data defines the data source
  23074. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23075. * @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)
  23076. */
  23077. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23078. /**
  23079. * Creates a new index buffer
  23080. * @param indices defines the indices to store in the index buffer
  23081. * @param totalVertices defines the total number of vertices (could be null)
  23082. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23083. */
  23084. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23085. }
  23086. /**
  23087. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23088. */
  23089. export class VertexData {
  23090. /**
  23091. * Mesh side orientation : usually the external or front surface
  23092. */
  23093. static readonly FRONTSIDE: number;
  23094. /**
  23095. * Mesh side orientation : usually the internal or back surface
  23096. */
  23097. static readonly BACKSIDE: number;
  23098. /**
  23099. * Mesh side orientation : both internal and external or front and back surfaces
  23100. */
  23101. static readonly DOUBLESIDE: number;
  23102. /**
  23103. * Mesh side orientation : by default, `FRONTSIDE`
  23104. */
  23105. static readonly DEFAULTSIDE: number;
  23106. /**
  23107. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23108. */
  23109. positions: Nullable<FloatArray>;
  23110. /**
  23111. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23112. */
  23113. normals: Nullable<FloatArray>;
  23114. /**
  23115. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23116. */
  23117. tangents: Nullable<FloatArray>;
  23118. /**
  23119. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23120. */
  23121. uvs: Nullable<FloatArray>;
  23122. /**
  23123. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23124. */
  23125. uvs2: Nullable<FloatArray>;
  23126. /**
  23127. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23128. */
  23129. uvs3: Nullable<FloatArray>;
  23130. /**
  23131. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23132. */
  23133. uvs4: Nullable<FloatArray>;
  23134. /**
  23135. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23136. */
  23137. uvs5: Nullable<FloatArray>;
  23138. /**
  23139. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23140. */
  23141. uvs6: Nullable<FloatArray>;
  23142. /**
  23143. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23144. */
  23145. colors: Nullable<FloatArray>;
  23146. /**
  23147. * 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).
  23148. */
  23149. matricesIndices: Nullable<FloatArray>;
  23150. /**
  23151. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23152. */
  23153. matricesWeights: Nullable<FloatArray>;
  23154. /**
  23155. * An array extending the number of possible indices
  23156. */
  23157. matricesIndicesExtra: Nullable<FloatArray>;
  23158. /**
  23159. * An array extending the number of possible weights when the number of indices is extended
  23160. */
  23161. matricesWeightsExtra: Nullable<FloatArray>;
  23162. /**
  23163. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23164. */
  23165. indices: Nullable<IndicesArray>;
  23166. /**
  23167. * Uses the passed data array to set the set the values for the specified kind of data
  23168. * @param data a linear array of floating numbers
  23169. * @param kind the type of data that is being set, eg positions, colors etc
  23170. */
  23171. set(data: FloatArray, kind: string): void;
  23172. /**
  23173. * Associates the vertexData to the passed Mesh.
  23174. * Sets it as updatable or not (default `false`)
  23175. * @param mesh the mesh the vertexData is applied to
  23176. * @param updatable when used and having the value true allows new data to update the vertexData
  23177. * @returns the VertexData
  23178. */
  23179. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23180. /**
  23181. * Associates the vertexData to the passed Geometry.
  23182. * Sets it as updatable or not (default `false`)
  23183. * @param geometry the geometry the vertexData is applied to
  23184. * @param updatable when used and having the value true allows new data to update the vertexData
  23185. * @returns VertexData
  23186. */
  23187. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23188. /**
  23189. * Updates the associated mesh
  23190. * @param mesh the mesh to be updated
  23191. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23192. * @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
  23193. * @returns VertexData
  23194. */
  23195. updateMesh(mesh: Mesh): VertexData;
  23196. /**
  23197. * Updates the associated geometry
  23198. * @param geometry the geometry to be updated
  23199. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23200. * @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
  23201. * @returns VertexData.
  23202. */
  23203. updateGeometry(geometry: Geometry): VertexData;
  23204. private _applyTo;
  23205. private _update;
  23206. /**
  23207. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23208. * @param matrix the transforming matrix
  23209. * @returns the VertexData
  23210. */
  23211. transform(matrix: Matrix): VertexData;
  23212. /**
  23213. * Merges the passed VertexData into the current one
  23214. * @param other the VertexData to be merged into the current one
  23215. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23216. * @returns the modified VertexData
  23217. */
  23218. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23219. private _mergeElement;
  23220. private _validate;
  23221. /**
  23222. * Serializes the VertexData
  23223. * @returns a serialized object
  23224. */
  23225. serialize(): any;
  23226. /**
  23227. * Extracts the vertexData from a mesh
  23228. * @param mesh the mesh from which to extract the VertexData
  23229. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23230. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23231. * @returns the object VertexData associated to the passed mesh
  23232. */
  23233. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23234. /**
  23235. * Extracts the vertexData from the geometry
  23236. * @param geometry the geometry from which to extract the VertexData
  23237. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23238. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23239. * @returns the object VertexData associated to the passed mesh
  23240. */
  23241. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23242. private static _ExtractFrom;
  23243. /**
  23244. * Creates the VertexData for a Ribbon
  23245. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23246. * * pathArray array of paths, each of which an array of successive Vector3
  23247. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23248. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23249. * * 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
  23250. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23251. * * 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)
  23252. * * 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)
  23253. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23254. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23255. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23256. * @returns the VertexData of the ribbon
  23257. */
  23258. static CreateRibbon(options: {
  23259. pathArray: Vector3[][];
  23260. closeArray?: boolean;
  23261. closePath?: boolean;
  23262. offset?: number;
  23263. sideOrientation?: number;
  23264. frontUVs?: Vector4;
  23265. backUVs?: Vector4;
  23266. invertUV?: boolean;
  23267. uvs?: Vector2[];
  23268. colors?: Color4[];
  23269. }): VertexData;
  23270. /**
  23271. * Creates the VertexData for a box
  23272. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23273. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23274. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23275. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23276. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23277. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23278. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23279. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23280. * * 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)
  23281. * * 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)
  23282. * @returns the VertexData of the box
  23283. */
  23284. static CreateBox(options: {
  23285. size?: number;
  23286. width?: number;
  23287. height?: number;
  23288. depth?: number;
  23289. faceUV?: Vector4[];
  23290. faceColors?: Color4[];
  23291. sideOrientation?: number;
  23292. frontUVs?: Vector4;
  23293. backUVs?: Vector4;
  23294. }): VertexData;
  23295. /**
  23296. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23297. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23298. * * segments sets the number of horizontal strips optional, default 32
  23299. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23300. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23301. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23302. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23303. * * 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
  23304. * * 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
  23305. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23306. * * 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)
  23307. * * 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)
  23308. * @returns the VertexData of the ellipsoid
  23309. */
  23310. static CreateSphere(options: {
  23311. segments?: number;
  23312. diameter?: number;
  23313. diameterX?: number;
  23314. diameterY?: number;
  23315. diameterZ?: number;
  23316. arc?: number;
  23317. slice?: number;
  23318. sideOrientation?: number;
  23319. frontUVs?: Vector4;
  23320. backUVs?: Vector4;
  23321. }): VertexData;
  23322. /**
  23323. * Creates the VertexData for a cylinder, cone or prism
  23324. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23325. * * height sets the height (y direction) of the cylinder, optional, default 2
  23326. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23327. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23328. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23329. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23330. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23331. * * 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
  23332. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23333. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23334. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23335. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23336. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23337. * * 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)
  23338. * * 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)
  23339. * @returns the VertexData of the cylinder, cone or prism
  23340. */
  23341. static CreateCylinder(options: {
  23342. height?: number;
  23343. diameterTop?: number;
  23344. diameterBottom?: number;
  23345. diameter?: number;
  23346. tessellation?: number;
  23347. subdivisions?: number;
  23348. arc?: number;
  23349. faceColors?: Color4[];
  23350. faceUV?: Vector4[];
  23351. hasRings?: boolean;
  23352. enclose?: boolean;
  23353. sideOrientation?: number;
  23354. frontUVs?: Vector4;
  23355. backUVs?: Vector4;
  23356. }): VertexData;
  23357. /**
  23358. * Creates the VertexData for a torus
  23359. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23360. * * diameter the diameter of the torus, optional default 1
  23361. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23362. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23363. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23364. * * 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)
  23365. * * 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)
  23366. * @returns the VertexData of the torus
  23367. */
  23368. static CreateTorus(options: {
  23369. diameter?: number;
  23370. thickness?: number;
  23371. tessellation?: number;
  23372. sideOrientation?: number;
  23373. frontUVs?: Vector4;
  23374. backUVs?: Vector4;
  23375. }): VertexData;
  23376. /**
  23377. * Creates the VertexData of the LineSystem
  23378. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23379. * - lines an array of lines, each line being an array of successive Vector3
  23380. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23381. * @returns the VertexData of the LineSystem
  23382. */
  23383. static CreateLineSystem(options: {
  23384. lines: Vector3[][];
  23385. colors?: Nullable<Color4[][]>;
  23386. }): VertexData;
  23387. /**
  23388. * Create the VertexData for a DashedLines
  23389. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23390. * - points an array successive Vector3
  23391. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23392. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23393. * - dashNb the intended total number of dashes, optional, default 200
  23394. * @returns the VertexData for the DashedLines
  23395. */
  23396. static CreateDashedLines(options: {
  23397. points: Vector3[];
  23398. dashSize?: number;
  23399. gapSize?: number;
  23400. dashNb?: number;
  23401. }): VertexData;
  23402. /**
  23403. * Creates the VertexData for a Ground
  23404. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23405. * - width the width (x direction) of the ground, optional, default 1
  23406. * - height the height (z direction) of the ground, optional, default 1
  23407. * - subdivisions the number of subdivisions per side, optional, default 1
  23408. * @returns the VertexData of the Ground
  23409. */
  23410. static CreateGround(options: {
  23411. width?: number;
  23412. height?: number;
  23413. subdivisions?: number;
  23414. subdivisionsX?: number;
  23415. subdivisionsY?: number;
  23416. }): VertexData;
  23417. /**
  23418. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23419. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23420. * * xmin the ground minimum X coordinate, optional, default -1
  23421. * * zmin the ground minimum Z coordinate, optional, default -1
  23422. * * xmax the ground maximum X coordinate, optional, default 1
  23423. * * zmax the ground maximum Z coordinate, optional, default 1
  23424. * * 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}
  23425. * * 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}
  23426. * @returns the VertexData of the TiledGround
  23427. */
  23428. static CreateTiledGround(options: {
  23429. xmin: number;
  23430. zmin: number;
  23431. xmax: number;
  23432. zmax: number;
  23433. subdivisions?: {
  23434. w: number;
  23435. h: number;
  23436. };
  23437. precision?: {
  23438. w: number;
  23439. h: number;
  23440. };
  23441. }): VertexData;
  23442. /**
  23443. * Creates the VertexData of the Ground designed from a heightmap
  23444. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23445. * * width the width (x direction) of the ground
  23446. * * height the height (z direction) of the ground
  23447. * * subdivisions the number of subdivisions per side
  23448. * * minHeight the minimum altitude on the ground, optional, default 0
  23449. * * maxHeight the maximum altitude on the ground, optional default 1
  23450. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23451. * * buffer the array holding the image color data
  23452. * * bufferWidth the width of image
  23453. * * bufferHeight the height of image
  23454. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23455. * @returns the VertexData of the Ground designed from a heightmap
  23456. */
  23457. static CreateGroundFromHeightMap(options: {
  23458. width: number;
  23459. height: number;
  23460. subdivisions: number;
  23461. minHeight: number;
  23462. maxHeight: number;
  23463. colorFilter: Color3;
  23464. buffer: Uint8Array;
  23465. bufferWidth: number;
  23466. bufferHeight: number;
  23467. alphaFilter: number;
  23468. }): VertexData;
  23469. /**
  23470. * Creates the VertexData for a Plane
  23471. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23472. * * size sets the width and height of the plane to the value of size, optional default 1
  23473. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23474. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23475. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23476. * * 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)
  23477. * * 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)
  23478. * @returns the VertexData of the box
  23479. */
  23480. static CreatePlane(options: {
  23481. size?: number;
  23482. width?: number;
  23483. height?: number;
  23484. sideOrientation?: number;
  23485. frontUVs?: Vector4;
  23486. backUVs?: Vector4;
  23487. }): VertexData;
  23488. /**
  23489. * Creates the VertexData of the Disc or regular Polygon
  23490. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23491. * * radius the radius of the disc, optional default 0.5
  23492. * * tessellation the number of polygon sides, optional, default 64
  23493. * * 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
  23494. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23495. * * 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)
  23496. * * 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)
  23497. * @returns the VertexData of the box
  23498. */
  23499. static CreateDisc(options: {
  23500. radius?: number;
  23501. tessellation?: number;
  23502. arc?: number;
  23503. sideOrientation?: number;
  23504. frontUVs?: Vector4;
  23505. backUVs?: Vector4;
  23506. }): VertexData;
  23507. /**
  23508. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23509. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23510. * @param polygon a mesh built from polygonTriangulation.build()
  23511. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23512. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23513. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23514. * @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)
  23515. * @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)
  23516. * @returns the VertexData of the Polygon
  23517. */
  23518. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23519. /**
  23520. * Creates the VertexData of the IcoSphere
  23521. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23522. * * radius the radius of the IcoSphere, optional default 1
  23523. * * radiusX allows stretching in the x direction, optional, default radius
  23524. * * radiusY allows stretching in the y direction, optional, default radius
  23525. * * radiusZ allows stretching in the z direction, optional, default radius
  23526. * * flat when true creates a flat shaded mesh, optional, default true
  23527. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23528. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23529. * * 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)
  23530. * * 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)
  23531. * @returns the VertexData of the IcoSphere
  23532. */
  23533. static CreateIcoSphere(options: {
  23534. radius?: number;
  23535. radiusX?: number;
  23536. radiusY?: number;
  23537. radiusZ?: number;
  23538. flat?: boolean;
  23539. subdivisions?: number;
  23540. sideOrientation?: number;
  23541. frontUVs?: Vector4;
  23542. backUVs?: Vector4;
  23543. }): VertexData;
  23544. /**
  23545. * Creates the VertexData for a Polyhedron
  23546. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23547. * * type provided types are:
  23548. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23549. * * 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)
  23550. * * size the size of the IcoSphere, optional default 1
  23551. * * sizeX allows stretching in the x direction, optional, default size
  23552. * * sizeY allows stretching in the y direction, optional, default size
  23553. * * sizeZ allows stretching in the z direction, optional, default size
  23554. * * 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
  23555. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23556. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23557. * * flat when true creates a flat shaded mesh, optional, default true
  23558. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23559. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23560. * * 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)
  23561. * * 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)
  23562. * @returns the VertexData of the Polyhedron
  23563. */
  23564. static CreatePolyhedron(options: {
  23565. type?: number;
  23566. size?: number;
  23567. sizeX?: number;
  23568. sizeY?: number;
  23569. sizeZ?: number;
  23570. custom?: any;
  23571. faceUV?: Vector4[];
  23572. faceColors?: Color4[];
  23573. flat?: boolean;
  23574. sideOrientation?: number;
  23575. frontUVs?: Vector4;
  23576. backUVs?: Vector4;
  23577. }): VertexData;
  23578. /**
  23579. * Creates the VertexData for a TorusKnot
  23580. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23581. * * radius the radius of the torus knot, optional, default 2
  23582. * * tube the thickness of the tube, optional, default 0.5
  23583. * * radialSegments the number of sides on each tube segments, optional, default 32
  23584. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23585. * * p the number of windings around the z axis, optional, default 2
  23586. * * q the number of windings around the x axis, optional, default 3
  23587. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23588. * * 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)
  23589. * * 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)
  23590. * @returns the VertexData of the Torus Knot
  23591. */
  23592. static CreateTorusKnot(options: {
  23593. radius?: number;
  23594. tube?: number;
  23595. radialSegments?: number;
  23596. tubularSegments?: number;
  23597. p?: number;
  23598. q?: number;
  23599. sideOrientation?: number;
  23600. frontUVs?: Vector4;
  23601. backUVs?: Vector4;
  23602. }): VertexData;
  23603. /**
  23604. * Compute normals for given positions and indices
  23605. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23606. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23607. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23608. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23609. * * facetNormals : optional array of facet normals (vector3)
  23610. * * facetPositions : optional array of facet positions (vector3)
  23611. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23612. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23613. * * bInfo : optional bounding info, required for facetPartitioning computation
  23614. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23615. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23616. * * useRightHandedSystem: optional boolean to for right handed system computation
  23617. * * depthSort : optional boolean to enable the facet depth sort computation
  23618. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23619. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23620. */
  23621. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23622. facetNormals?: any;
  23623. facetPositions?: any;
  23624. facetPartitioning?: any;
  23625. ratio?: number;
  23626. bInfo?: any;
  23627. bbSize?: Vector3;
  23628. subDiv?: any;
  23629. useRightHandedSystem?: boolean;
  23630. depthSort?: boolean;
  23631. distanceTo?: Vector3;
  23632. depthSortedFacets?: any;
  23633. }): void;
  23634. /** @hidden */
  23635. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23636. /**
  23637. * Applies VertexData created from the imported parameters to the geometry
  23638. * @param parsedVertexData the parsed data from an imported file
  23639. * @param geometry the geometry to apply the VertexData to
  23640. */
  23641. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23642. }
  23643. }
  23644. declare module BABYLON {
  23645. /**
  23646. * Class containing static functions to help procedurally build meshes
  23647. */
  23648. export class DiscBuilder {
  23649. /**
  23650. * Creates a plane polygonal mesh. By default, this is a disc
  23651. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23652. * * 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
  23653. * * 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
  23654. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23655. * * 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
  23656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23657. * @param name defines the name of the mesh
  23658. * @param options defines the options used to create the mesh
  23659. * @param scene defines the hosting scene
  23660. * @returns the plane polygonal mesh
  23661. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23662. */
  23663. static CreateDisc(name: string, options: {
  23664. radius?: number;
  23665. tessellation?: number;
  23666. arc?: number;
  23667. updatable?: boolean;
  23668. sideOrientation?: number;
  23669. frontUVs?: Vector4;
  23670. backUVs?: Vector4;
  23671. }, scene?: Nullable<Scene>): Mesh;
  23672. }
  23673. }
  23674. declare module BABYLON {
  23675. /**
  23676. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23677. *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.
  23678. * The SPS is also a particle system. It provides some methods to manage the particles.
  23679. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23680. *
  23681. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23682. */
  23683. export class SolidParticleSystem implements IDisposable {
  23684. /**
  23685. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23686. * Example : var p = SPS.particles[i];
  23687. */
  23688. particles: SolidParticle[];
  23689. /**
  23690. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23691. */
  23692. nbParticles: number;
  23693. /**
  23694. * If the particles must ever face the camera (default false). Useful for planar particles.
  23695. */
  23696. billboard: boolean;
  23697. /**
  23698. * Recompute normals when adding a shape
  23699. */
  23700. recomputeNormals: boolean;
  23701. /**
  23702. * This a counter ofr your own usage. It's not set by any SPS functions.
  23703. */
  23704. counter: number;
  23705. /**
  23706. * The SPS name. This name is also given to the underlying mesh.
  23707. */
  23708. name: string;
  23709. /**
  23710. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23711. */
  23712. mesh: Mesh;
  23713. /**
  23714. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23715. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23716. */
  23717. vars: any;
  23718. /**
  23719. * This array is populated when the SPS is set as 'pickable'.
  23720. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23721. * Each element of this array is an object `{idx: int, faceId: int}`.
  23722. * `idx` is the picked particle index in the `SPS.particles` array
  23723. * `faceId` is the picked face index counted within this particle.
  23724. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23725. */
  23726. pickedParticles: {
  23727. idx: number;
  23728. faceId: number;
  23729. }[];
  23730. /**
  23731. * This array is populated when `enableDepthSort` is set to true.
  23732. * Each element of this array is an instance of the class DepthSortedParticle.
  23733. */
  23734. depthSortedParticles: DepthSortedParticle[];
  23735. /**
  23736. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23737. * @hidden
  23738. */
  23739. _bSphereOnly: boolean;
  23740. /**
  23741. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23742. * @hidden
  23743. */
  23744. _bSphereRadiusFactor: number;
  23745. private _scene;
  23746. private _positions;
  23747. private _indices;
  23748. private _normals;
  23749. private _colors;
  23750. private _uvs;
  23751. private _indices32;
  23752. private _positions32;
  23753. private _normals32;
  23754. private _fixedNormal32;
  23755. private _colors32;
  23756. private _uvs32;
  23757. private _index;
  23758. private _updatable;
  23759. private _pickable;
  23760. private _isVisibilityBoxLocked;
  23761. private _alwaysVisible;
  23762. private _depthSort;
  23763. private _shapeCounter;
  23764. private _copy;
  23765. private _color;
  23766. private _computeParticleColor;
  23767. private _computeParticleTexture;
  23768. private _computeParticleRotation;
  23769. private _computeParticleVertex;
  23770. private _computeBoundingBox;
  23771. private _depthSortParticles;
  23772. private _camera;
  23773. private _mustUnrotateFixedNormals;
  23774. private _particlesIntersect;
  23775. private _needs32Bits;
  23776. /**
  23777. * Creates a SPS (Solid Particle System) object.
  23778. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23779. * @param scene (Scene) is the scene in which the SPS is added.
  23780. * @param options defines the options of the sps e.g.
  23781. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23782. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23783. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23784. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23785. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23786. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23787. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23788. */
  23789. constructor(name: string, scene: Scene, options?: {
  23790. updatable?: boolean;
  23791. isPickable?: boolean;
  23792. enableDepthSort?: boolean;
  23793. particleIntersection?: boolean;
  23794. boundingSphereOnly?: boolean;
  23795. bSphereRadiusFactor?: number;
  23796. });
  23797. /**
  23798. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23799. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23800. * @returns the created mesh
  23801. */
  23802. buildMesh(): Mesh;
  23803. /**
  23804. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23805. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23806. * Thus the particles generated from `digest()` have their property `position` set yet.
  23807. * @param mesh ( Mesh ) is the mesh to be digested
  23808. * @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
  23809. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23810. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23811. * @returns the current SPS
  23812. */
  23813. digest(mesh: Mesh, options?: {
  23814. facetNb?: number;
  23815. number?: number;
  23816. delta?: number;
  23817. }): SolidParticleSystem;
  23818. private _unrotateFixedNormals;
  23819. private _resetCopy;
  23820. private _meshBuilder;
  23821. private _posToShape;
  23822. private _uvsToShapeUV;
  23823. private _addParticle;
  23824. /**
  23825. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23826. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23827. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23828. * @param nb (positive integer) the number of particles to be created from this model
  23829. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23830. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23831. * @returns the number of shapes in the system
  23832. */
  23833. addShape(mesh: Mesh, nb: number, options?: {
  23834. positionFunction?: any;
  23835. vertexFunction?: any;
  23836. }): number;
  23837. private _rebuildParticle;
  23838. /**
  23839. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23840. * @returns the SPS.
  23841. */
  23842. rebuildMesh(): SolidParticleSystem;
  23843. /**
  23844. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23845. * This method calls `updateParticle()` for each particle of the SPS.
  23846. * For an animated SPS, it is usually called within the render loop.
  23847. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23848. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23849. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23850. * @returns the SPS.
  23851. */
  23852. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23853. /**
  23854. * Disposes the SPS.
  23855. */
  23856. dispose(): void;
  23857. /**
  23858. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23859. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23860. * @returns the SPS.
  23861. */
  23862. refreshVisibleSize(): SolidParticleSystem;
  23863. /**
  23864. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23865. * @param size the size (float) of the visibility box
  23866. * note : this doesn't lock the SPS mesh bounding box.
  23867. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23868. */
  23869. setVisibilityBox(size: number): void;
  23870. /**
  23871. * Gets whether the SPS as always visible or not
  23872. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23873. */
  23874. /**
  23875. * Sets the SPS as always visible or not
  23876. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23877. */
  23878. isAlwaysVisible: boolean;
  23879. /**
  23880. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23881. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23882. */
  23883. /**
  23884. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23885. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23886. */
  23887. isVisibilityBoxLocked: boolean;
  23888. /**
  23889. * Tells to `setParticles()` to compute the particle rotations or not.
  23890. * Default value : true. The SPS is faster when it's set to false.
  23891. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23892. */
  23893. /**
  23894. * Gets if `setParticles()` computes the particle rotations or not.
  23895. * Default value : true. The SPS is faster when it's set to false.
  23896. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23897. */
  23898. computeParticleRotation: boolean;
  23899. /**
  23900. * Tells to `setParticles()` to compute the particle colors or not.
  23901. * Default value : true. The SPS is faster when it's set to false.
  23902. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23903. */
  23904. /**
  23905. * Gets if `setParticles()` computes the particle colors or not.
  23906. * Default value : true. The SPS is faster when it's set to false.
  23907. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23908. */
  23909. computeParticleColor: boolean;
  23910. /**
  23911. * Gets if `setParticles()` computes the particle textures or not.
  23912. * Default value : true. The SPS is faster when it's set to false.
  23913. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23914. */
  23915. computeParticleTexture: boolean;
  23916. /**
  23917. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23918. * Default value : false. The SPS is faster when it's set to false.
  23919. * Note : the particle custom vertex positions aren't stored values.
  23920. */
  23921. /**
  23922. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23923. * Default value : false. The SPS is faster when it's set to false.
  23924. * Note : the particle custom vertex positions aren't stored values.
  23925. */
  23926. computeParticleVertex: boolean;
  23927. /**
  23928. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23929. */
  23930. /**
  23931. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23932. */
  23933. computeBoundingBox: boolean;
  23934. /**
  23935. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23936. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23937. * Default : `true`
  23938. */
  23939. /**
  23940. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23941. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23942. * Default : `true`
  23943. */
  23944. depthSortParticles: boolean;
  23945. /**
  23946. * This function does nothing. It may be overwritten to set all the particle first values.
  23947. * The SPS doesn't call this function, you may have to call it by your own.
  23948. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23949. */
  23950. initParticles(): void;
  23951. /**
  23952. * This function does nothing. It may be overwritten to recycle a particle.
  23953. * The SPS doesn't call this function, you may have to call it by your own.
  23954. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23955. * @param particle The particle to recycle
  23956. * @returns the recycled particle
  23957. */
  23958. recycleParticle(particle: SolidParticle): SolidParticle;
  23959. /**
  23960. * Updates a particle : this function should be overwritten by the user.
  23961. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23962. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23963. * @example : just set a particle position or velocity and recycle conditions
  23964. * @param particle The particle to update
  23965. * @returns the updated particle
  23966. */
  23967. updateParticle(particle: SolidParticle): SolidParticle;
  23968. /**
  23969. * Updates a vertex of a particle : it can be overwritten by the user.
  23970. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23971. * @param particle the current particle
  23972. * @param vertex the current index of the current particle
  23973. * @param pt the index of the current vertex in the particle shape
  23974. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23975. * @example : just set a vertex particle position
  23976. * @returns the updated vertex
  23977. */
  23978. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23979. /**
  23980. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23981. * This does nothing and may be overwritten by the user.
  23982. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23983. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23984. * @param update the boolean update value actually passed to setParticles()
  23985. */
  23986. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23987. /**
  23988. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23989. * This 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. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23996. }
  23997. }
  23998. declare module BABYLON {
  23999. /**
  24000. * Represents one particle of a solid particle system.
  24001. */
  24002. export class SolidParticle {
  24003. /**
  24004. * particle global index
  24005. */
  24006. idx: number;
  24007. /**
  24008. * The color of the particle
  24009. */
  24010. color: Nullable<Color4>;
  24011. /**
  24012. * The world space position of the particle.
  24013. */
  24014. position: Vector3;
  24015. /**
  24016. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24017. */
  24018. rotation: Vector3;
  24019. /**
  24020. * The world space rotation quaternion of the particle.
  24021. */
  24022. rotationQuaternion: Nullable<Quaternion>;
  24023. /**
  24024. * The scaling of the particle.
  24025. */
  24026. scaling: Vector3;
  24027. /**
  24028. * The uvs of the particle.
  24029. */
  24030. uvs: Vector4;
  24031. /**
  24032. * The current speed of the particle.
  24033. */
  24034. velocity: Vector3;
  24035. /**
  24036. * The pivot point in the particle local space.
  24037. */
  24038. pivot: Vector3;
  24039. /**
  24040. * Must the particle be translated from its pivot point in its local space ?
  24041. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24042. * Default : false
  24043. */
  24044. translateFromPivot: boolean;
  24045. /**
  24046. * Is the particle active or not ?
  24047. */
  24048. alive: boolean;
  24049. /**
  24050. * Is the particle visible or not ?
  24051. */
  24052. isVisible: boolean;
  24053. /**
  24054. * Index of this particle in the global "positions" array (Internal use)
  24055. * @hidden
  24056. */
  24057. _pos: number;
  24058. /**
  24059. * @hidden Index of this particle in the global "indices" array (Internal use)
  24060. */
  24061. _ind: number;
  24062. /**
  24063. * @hidden ModelShape of this particle (Internal use)
  24064. */
  24065. _model: ModelShape;
  24066. /**
  24067. * ModelShape id of this particle
  24068. */
  24069. shapeId: number;
  24070. /**
  24071. * Index of the particle in its shape id (Internal use)
  24072. */
  24073. idxInShape: number;
  24074. /**
  24075. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24076. */
  24077. _modelBoundingInfo: BoundingInfo;
  24078. /**
  24079. * @hidden Particle BoundingInfo object (Internal use)
  24080. */
  24081. _boundingInfo: BoundingInfo;
  24082. /**
  24083. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24084. */
  24085. _sps: SolidParticleSystem;
  24086. /**
  24087. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24088. */
  24089. _stillInvisible: boolean;
  24090. /**
  24091. * @hidden Last computed particle rotation matrix
  24092. */
  24093. _rotationMatrix: number[];
  24094. /**
  24095. * Parent particle Id, if any.
  24096. * Default null.
  24097. */
  24098. parentId: Nullable<number>;
  24099. /**
  24100. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24101. * The possible values are :
  24102. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24103. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24104. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24105. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24106. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24107. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24108. * */
  24109. cullingStrategy: number;
  24110. /**
  24111. * @hidden Internal global position in the SPS.
  24112. */
  24113. _globalPosition: Vector3;
  24114. /**
  24115. * Creates a Solid Particle object.
  24116. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24117. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24118. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24119. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24120. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24121. * @param shapeId (integer) is the model shape identifier in the SPS.
  24122. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24123. * @param sps defines the sps it is associated to
  24124. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24125. */
  24126. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24127. /**
  24128. * Legacy support, changed scale to scaling
  24129. */
  24130. /**
  24131. * Legacy support, changed scale to scaling
  24132. */
  24133. scale: Vector3;
  24134. /**
  24135. * Legacy support, changed quaternion to rotationQuaternion
  24136. */
  24137. /**
  24138. * Legacy support, changed quaternion to rotationQuaternion
  24139. */
  24140. quaternion: Nullable<Quaternion>;
  24141. /**
  24142. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24143. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24144. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24145. * @returns true if it intersects
  24146. */
  24147. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24148. /**
  24149. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24150. * A particle is in the frustum if its bounding box intersects the frustum
  24151. * @param frustumPlanes defines the frustum to test
  24152. * @returns true if the particle is in the frustum planes
  24153. */
  24154. isInFrustum(frustumPlanes: Plane[]): boolean;
  24155. /**
  24156. * get the rotation matrix of the particle
  24157. * @hidden
  24158. */
  24159. getRotationMatrix(m: Matrix): void;
  24160. }
  24161. /**
  24162. * Represents the shape of the model used by one particle of a solid particle system.
  24163. * SPS internal tool, don't use it manually.
  24164. */
  24165. export class ModelShape {
  24166. /**
  24167. * The shape id
  24168. * @hidden
  24169. */
  24170. shapeID: number;
  24171. /**
  24172. * flat array of model positions (internal use)
  24173. * @hidden
  24174. */
  24175. _shape: Vector3[];
  24176. /**
  24177. * flat array of model UVs (internal use)
  24178. * @hidden
  24179. */
  24180. _shapeUV: number[];
  24181. /**
  24182. * length of the shape in the model indices array (internal use)
  24183. * @hidden
  24184. */
  24185. _indicesLength: number;
  24186. /**
  24187. * Custom position function (internal use)
  24188. * @hidden
  24189. */
  24190. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24191. /**
  24192. * Custom vertex function (internal use)
  24193. * @hidden
  24194. */
  24195. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24196. /**
  24197. * 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.
  24198. * SPS internal tool, don't use it manually.
  24199. * @hidden
  24200. */
  24201. 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>);
  24202. }
  24203. /**
  24204. * Represents a Depth Sorted Particle in the solid particle system.
  24205. */
  24206. export class DepthSortedParticle {
  24207. /**
  24208. * Index of the particle in the "indices" array
  24209. */
  24210. ind: number;
  24211. /**
  24212. * Length of the particle shape in the "indices" array
  24213. */
  24214. indicesLength: number;
  24215. /**
  24216. * Squared distance from the particle to the camera
  24217. */
  24218. sqDistance: number;
  24219. }
  24220. }
  24221. declare module BABYLON {
  24222. /**
  24223. * @hidden
  24224. */
  24225. export class _MeshCollisionData {
  24226. _checkCollisions: boolean;
  24227. _collisionMask: number;
  24228. _collisionGroup: number;
  24229. _collider: Nullable<Collider>;
  24230. _oldPositionForCollisions: Vector3;
  24231. _diffPositionForCollisions: Vector3;
  24232. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  24233. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  24234. }
  24235. }
  24236. declare module BABYLON {
  24237. /**
  24238. * Class used to store all common mesh properties
  24239. */
  24240. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24241. /** No occlusion */
  24242. static OCCLUSION_TYPE_NONE: number;
  24243. /** Occlusion set to optimisitic */
  24244. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24245. /** Occlusion set to strict */
  24246. static OCCLUSION_TYPE_STRICT: number;
  24247. /** Use an accurante occlusion algorithm */
  24248. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24249. /** Use a conservative occlusion algorithm */
  24250. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24251. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24252. * Test order :
  24253. * Is the bounding sphere outside the frustum ?
  24254. * If not, are the bounding box vertices outside the frustum ?
  24255. * It not, then the cullable object is in the frustum.
  24256. */
  24257. static readonly CULLINGSTRATEGY_STANDARD: number;
  24258. /** Culling strategy : Bounding Sphere Only.
  24259. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24260. * It's also less accurate than the standard because some not visible objects can still be selected.
  24261. * Test : is the bounding sphere outside the frustum ?
  24262. * If not, then the cullable object is in the frustum.
  24263. */
  24264. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24265. /** Culling strategy : Optimistic Inclusion.
  24266. * This in an inclusion test first, then the standard exclusion test.
  24267. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24268. * 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.
  24269. * Anyway, it's as accurate as the standard strategy.
  24270. * Test :
  24271. * Is the cullable object bounding sphere center in the frustum ?
  24272. * If not, apply the default culling strategy.
  24273. */
  24274. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24275. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24276. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24277. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24278. * 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.
  24279. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24280. * Test :
  24281. * Is the cullable object bounding sphere center in the frustum ?
  24282. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24283. */
  24284. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24285. /**
  24286. * No billboard
  24287. */
  24288. static readonly BILLBOARDMODE_NONE: number;
  24289. /** Billboard on X axis */
  24290. static readonly BILLBOARDMODE_X: number;
  24291. /** Billboard on Y axis */
  24292. static readonly BILLBOARDMODE_Y: number;
  24293. /** Billboard on Z axis */
  24294. static readonly BILLBOARDMODE_Z: number;
  24295. /** Billboard on all axes */
  24296. static readonly BILLBOARDMODE_ALL: number;
  24297. private _internalAbstractMeshDataInfo;
  24298. /**
  24299. * The culling strategy to use to check whether the mesh must be rendered or not.
  24300. * This value can be changed at any time and will be used on the next render mesh selection.
  24301. * The possible values are :
  24302. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24303. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24304. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24305. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24306. * Please read each static variable documentation to get details about the culling process.
  24307. * */
  24308. cullingStrategy: number;
  24309. /**
  24310. * Gets the number of facets in the mesh
  24311. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24312. */
  24313. readonly facetNb: number;
  24314. /**
  24315. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24316. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24317. */
  24318. partitioningSubdivisions: number;
  24319. /**
  24320. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24321. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24322. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24323. */
  24324. partitioningBBoxRatio: number;
  24325. /**
  24326. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24327. * Works only for updatable meshes.
  24328. * Doesn't work with multi-materials
  24329. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24330. */
  24331. mustDepthSortFacets: boolean;
  24332. /**
  24333. * The location (Vector3) where the facet depth sort must be computed from.
  24334. * By default, the active camera position.
  24335. * Used only when facet depth sort is enabled
  24336. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24337. */
  24338. facetDepthSortFrom: Vector3;
  24339. /**
  24340. * gets a boolean indicating if facetData is enabled
  24341. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24342. */
  24343. readonly isFacetDataEnabled: boolean;
  24344. /** @hidden */
  24345. _updateNonUniformScalingState(value: boolean): boolean;
  24346. /**
  24347. * An event triggered when this mesh collides with another one
  24348. */
  24349. onCollideObservable: Observable<AbstractMesh>;
  24350. /** Set a function to call when this mesh collides with another one */
  24351. onCollide: () => void;
  24352. /**
  24353. * An event triggered when the collision's position changes
  24354. */
  24355. onCollisionPositionChangeObservable: Observable<Vector3>;
  24356. /** Set a function to call when the collision's position changes */
  24357. onCollisionPositionChange: () => void;
  24358. /**
  24359. * An event triggered when material is changed
  24360. */
  24361. onMaterialChangedObservable: Observable<AbstractMesh>;
  24362. /**
  24363. * Gets or sets the orientation for POV movement & rotation
  24364. */
  24365. definedFacingForward: boolean;
  24366. /** @hidden */
  24367. _occlusionQuery: Nullable<WebGLQuery>;
  24368. /** @hidden */
  24369. _isActive: boolean;
  24370. /** @hidden */
  24371. _onlyForInstances: boolean;
  24372. /** @hidden */
  24373. _renderingGroup: Nullable<RenderingGroup>;
  24374. /**
  24375. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24376. */
  24377. /**
  24378. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24379. */
  24380. visibility: number;
  24381. /** Gets or sets the alpha index used to sort transparent meshes
  24382. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24383. */
  24384. alphaIndex: number;
  24385. /**
  24386. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24387. */
  24388. isVisible: boolean;
  24389. /**
  24390. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24391. */
  24392. isPickable: boolean;
  24393. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24394. showSubMeshesBoundingBox: boolean;
  24395. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24396. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24397. */
  24398. isBlocker: boolean;
  24399. /**
  24400. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24401. */
  24402. enablePointerMoveEvents: boolean;
  24403. /**
  24404. * Specifies the rendering group id for this mesh (0 by default)
  24405. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24406. */
  24407. renderingGroupId: number;
  24408. private _material;
  24409. /** Gets or sets current material */
  24410. material: Nullable<Material>;
  24411. /**
  24412. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24413. * @see http://doc.babylonjs.com/babylon101/shadows
  24414. */
  24415. receiveShadows: boolean;
  24416. /** Defines color to use when rendering outline */
  24417. outlineColor: Color3;
  24418. /** Define width to use when rendering outline */
  24419. outlineWidth: number;
  24420. /** Defines color to use when rendering overlay */
  24421. overlayColor: Color3;
  24422. /** Defines alpha to use when rendering overlay */
  24423. overlayAlpha: number;
  24424. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24425. hasVertexAlpha: boolean;
  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. /**
  24429. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24430. */
  24431. computeBonesUsingShaders: boolean;
  24432. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24433. numBoneInfluencers: number;
  24434. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24435. applyFog: boolean;
  24436. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24437. useOctreeForRenderingSelection: boolean;
  24438. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24439. useOctreeForPicking: boolean;
  24440. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24441. useOctreeForCollisions: boolean;
  24442. /**
  24443. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24444. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24445. */
  24446. layerMask: number;
  24447. /**
  24448. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24449. */
  24450. alwaysSelectAsActiveMesh: boolean;
  24451. /**
  24452. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24453. */
  24454. doNotSyncBoundingInfo: boolean;
  24455. /**
  24456. * Gets or sets the current action manager
  24457. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24458. */
  24459. actionManager: Nullable<AbstractActionManager>;
  24460. private _meshCollisionData;
  24461. /**
  24462. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24463. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24464. */
  24465. ellipsoid: Vector3;
  24466. /**
  24467. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24468. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24469. */
  24470. ellipsoidOffset: Vector3;
  24471. /**
  24472. * Gets or sets a collision mask used to mask collisions (default is -1).
  24473. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24474. */
  24475. collisionMask: number;
  24476. /**
  24477. * Gets or sets the current collision group mask (-1 by default).
  24478. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24479. */
  24480. collisionGroup: number;
  24481. /**
  24482. * Defines edge width used when edgesRenderer is enabled
  24483. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24484. */
  24485. edgesWidth: number;
  24486. /**
  24487. * Defines edge color used when edgesRenderer is enabled
  24488. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24489. */
  24490. edgesColor: Color4;
  24491. /** @hidden */
  24492. _edgesRenderer: Nullable<IEdgesRenderer>;
  24493. /** @hidden */
  24494. _masterMesh: Nullable<AbstractMesh>;
  24495. /** @hidden */
  24496. _boundingInfo: Nullable<BoundingInfo>;
  24497. /** @hidden */
  24498. _renderId: number;
  24499. /**
  24500. * Gets or sets the list of subMeshes
  24501. * @see http://doc.babylonjs.com/how_to/multi_materials
  24502. */
  24503. subMeshes: SubMesh[];
  24504. /** @hidden */
  24505. _intersectionsInProgress: AbstractMesh[];
  24506. /** @hidden */
  24507. _unIndexed: boolean;
  24508. /** @hidden */
  24509. _lightSources: Light[];
  24510. /** Gets the list of lights affecting that mesh */
  24511. readonly lightSources: Light[];
  24512. /** @hidden */
  24513. readonly _positions: Nullable<Vector3[]>;
  24514. /** @hidden */
  24515. _waitingData: {
  24516. lods: Nullable<any>;
  24517. actions: Nullable<any>;
  24518. freezeWorldMatrix: Nullable<boolean>;
  24519. };
  24520. /** @hidden */
  24521. _bonesTransformMatrices: Nullable<Float32Array>;
  24522. /**
  24523. * Gets or sets a skeleton to apply skining transformations
  24524. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24525. */
  24526. skeleton: Nullable<Skeleton>;
  24527. /**
  24528. * An event triggered when the mesh is rebuilt.
  24529. */
  24530. onRebuildObservable: Observable<AbstractMesh>;
  24531. /**
  24532. * Creates a new AbstractMesh
  24533. * @param name defines the name of the mesh
  24534. * @param scene defines the hosting scene
  24535. */
  24536. constructor(name: string, scene?: Nullable<Scene>);
  24537. /**
  24538. * Returns the string "AbstractMesh"
  24539. * @returns "AbstractMesh"
  24540. */
  24541. getClassName(): string;
  24542. /**
  24543. * Gets a string representation of the current mesh
  24544. * @param fullDetails defines a boolean indicating if full details must be included
  24545. * @returns a string representation of the current mesh
  24546. */
  24547. toString(fullDetails?: boolean): string;
  24548. /**
  24549. * @hidden
  24550. */
  24551. protected _getEffectiveParent(): Nullable<Node>;
  24552. /** @hidden */
  24553. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24554. /** @hidden */
  24555. _rebuild(): void;
  24556. /** @hidden */
  24557. _resyncLightSources(): void;
  24558. /** @hidden */
  24559. _resyncLighSource(light: Light): void;
  24560. /** @hidden */
  24561. _unBindEffect(): void;
  24562. /** @hidden */
  24563. _removeLightSource(light: Light): void;
  24564. private _markSubMeshesAsDirty;
  24565. /** @hidden */
  24566. _markSubMeshesAsLightDirty(): void;
  24567. /** @hidden */
  24568. _markSubMeshesAsAttributesDirty(): void;
  24569. /** @hidden */
  24570. _markSubMeshesAsMiscDirty(): void;
  24571. /**
  24572. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24573. */
  24574. scaling: Vector3;
  24575. /**
  24576. * Returns true if the mesh is blocked. Implemented by child classes
  24577. */
  24578. readonly isBlocked: boolean;
  24579. /**
  24580. * Returns the mesh itself by default. Implemented by child classes
  24581. * @param camera defines the camera to use to pick the right LOD level
  24582. * @returns the currentAbstractMesh
  24583. */
  24584. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24585. /**
  24586. * Returns 0 by default. Implemented by child classes
  24587. * @returns an integer
  24588. */
  24589. getTotalVertices(): number;
  24590. /**
  24591. * Returns a positive integer : the total number of indices in this mesh geometry.
  24592. * @returns the numner of indices or zero if the mesh has no geometry.
  24593. */
  24594. getTotalIndices(): number;
  24595. /**
  24596. * Returns null by default. Implemented by child classes
  24597. * @returns null
  24598. */
  24599. getIndices(): Nullable<IndicesArray>;
  24600. /**
  24601. * Returns the array of the requested vertex data kind. Implemented by child classes
  24602. * @param kind defines the vertex data kind to use
  24603. * @returns null
  24604. */
  24605. getVerticesData(kind: string): Nullable<FloatArray>;
  24606. /**
  24607. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24608. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24609. * Note that a new underlying VertexBuffer object is created each call.
  24610. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24611. * @param kind defines vertex data kind:
  24612. * * VertexBuffer.PositionKind
  24613. * * VertexBuffer.UVKind
  24614. * * VertexBuffer.UV2Kind
  24615. * * VertexBuffer.UV3Kind
  24616. * * VertexBuffer.UV4Kind
  24617. * * VertexBuffer.UV5Kind
  24618. * * VertexBuffer.UV6Kind
  24619. * * VertexBuffer.ColorKind
  24620. * * VertexBuffer.MatricesIndicesKind
  24621. * * VertexBuffer.MatricesIndicesExtraKind
  24622. * * VertexBuffer.MatricesWeightsKind
  24623. * * VertexBuffer.MatricesWeightsExtraKind
  24624. * @param data defines the data source
  24625. * @param updatable defines if the data must be flagged as updatable (or static)
  24626. * @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
  24627. * @returns the current mesh
  24628. */
  24629. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24630. /**
  24631. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24632. * If the mesh has no geometry, it is simply returned as it is.
  24633. * @param kind defines vertex data kind:
  24634. * * VertexBuffer.PositionKind
  24635. * * VertexBuffer.UVKind
  24636. * * VertexBuffer.UV2Kind
  24637. * * VertexBuffer.UV3Kind
  24638. * * VertexBuffer.UV4Kind
  24639. * * VertexBuffer.UV5Kind
  24640. * * VertexBuffer.UV6Kind
  24641. * * VertexBuffer.ColorKind
  24642. * * VertexBuffer.MatricesIndicesKind
  24643. * * VertexBuffer.MatricesIndicesExtraKind
  24644. * * VertexBuffer.MatricesWeightsKind
  24645. * * VertexBuffer.MatricesWeightsExtraKind
  24646. * @param data defines the data source
  24647. * @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
  24648. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24649. * @returns the current mesh
  24650. */
  24651. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24652. /**
  24653. * Sets the mesh indices,
  24654. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24655. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24656. * @param totalVertices Defines the total number of vertices
  24657. * @returns the current mesh
  24658. */
  24659. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24660. /**
  24661. * Gets a boolean indicating if specific vertex data is present
  24662. * @param kind defines the vertex data kind to use
  24663. * @returns true is data kind is present
  24664. */
  24665. isVerticesDataPresent(kind: string): boolean;
  24666. /**
  24667. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24668. * @returns a BoundingInfo
  24669. */
  24670. getBoundingInfo(): BoundingInfo;
  24671. /**
  24672. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24673. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24674. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24675. * @returns the current mesh
  24676. */
  24677. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24678. /**
  24679. * Overwrite the current bounding info
  24680. * @param boundingInfo defines the new bounding info
  24681. * @returns the current mesh
  24682. */
  24683. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24684. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24685. readonly useBones: boolean;
  24686. /** @hidden */
  24687. _preActivate(): void;
  24688. /** @hidden */
  24689. _preActivateForIntermediateRendering(renderId: number): void;
  24690. /** @hidden */
  24691. _activate(renderId: number): boolean;
  24692. /** @hidden */
  24693. _postActivate(): void;
  24694. /** @hidden */
  24695. _freeze(): void;
  24696. /** @hidden */
  24697. _unFreeze(): void;
  24698. /**
  24699. * Gets the current world matrix
  24700. * @returns a Matrix
  24701. */
  24702. getWorldMatrix(): Matrix;
  24703. /** @hidden */
  24704. _getWorldMatrixDeterminant(): number;
  24705. /**
  24706. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  24707. */
  24708. readonly isAnInstance: boolean;
  24709. /**
  24710. * Perform relative position change from the point of view of behind the front of the mesh.
  24711. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24712. * Supports definition of mesh facing forward or backward
  24713. * @param amountRight defines the distance on the right axis
  24714. * @param amountUp defines the distance on the up axis
  24715. * @param amountForward defines the distance on the forward axis
  24716. * @returns the current mesh
  24717. */
  24718. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24719. /**
  24720. * Calculate 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 new displacement vector
  24727. */
  24728. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24729. /**
  24730. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24731. * Supports definition of mesh facing forward or backward
  24732. * @param flipBack defines the flip
  24733. * @param twirlClockwise defines the twirl
  24734. * @param tiltRight defines the tilt
  24735. * @returns the current mesh
  24736. */
  24737. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24738. /**
  24739. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24740. * Supports definition of mesh facing forward or backward.
  24741. * @param flipBack defines the flip
  24742. * @param twirlClockwise defines the twirl
  24743. * @param tiltRight defines the tilt
  24744. * @returns the new rotation vector
  24745. */
  24746. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24747. /**
  24748. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24749. * This means the mesh underlying bounding box and sphere are recomputed.
  24750. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24751. * @returns the current mesh
  24752. */
  24753. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24754. /** @hidden */
  24755. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24756. /** @hidden */
  24757. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24758. /** @hidden */
  24759. _updateBoundingInfo(): AbstractMesh;
  24760. /** @hidden */
  24761. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24762. /** @hidden */
  24763. protected _afterComputeWorldMatrix(): void;
  24764. /** @hidden */
  24765. readonly _effectiveMesh: AbstractMesh;
  24766. /**
  24767. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24768. * A mesh is in the frustum if its bounding box intersects the frustum
  24769. * @param frustumPlanes defines the frustum to test
  24770. * @returns true if the mesh is in the frustum planes
  24771. */
  24772. isInFrustum(frustumPlanes: Plane[]): boolean;
  24773. /**
  24774. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24775. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24776. * @param frustumPlanes defines the frustum to test
  24777. * @returns true if the mesh is completely in the frustum planes
  24778. */
  24779. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24780. /**
  24781. * True if the mesh intersects another mesh or a SolidParticle object
  24782. * @param mesh defines a target mesh or SolidParticle to test
  24783. * @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)
  24784. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24785. * @returns true if there is an intersection
  24786. */
  24787. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24788. /**
  24789. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24790. * @param point defines the point to test
  24791. * @returns true if there is an intersection
  24792. */
  24793. intersectsPoint(point: Vector3): boolean;
  24794. /**
  24795. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24796. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24797. */
  24798. checkCollisions: boolean;
  24799. /**
  24800. * Gets Collider object used to compute collisions (not physics)
  24801. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24802. */
  24803. readonly collider: Nullable<Collider>;
  24804. /**
  24805. * Move the mesh using collision engine
  24806. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24807. * @param displacement defines the requested displacement vector
  24808. * @returns the current mesh
  24809. */
  24810. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24811. private _onCollisionPositionChange;
  24812. /** @hidden */
  24813. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24814. /** @hidden */
  24815. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24816. /** @hidden */
  24817. _checkCollision(collider: Collider): AbstractMesh;
  24818. /** @hidden */
  24819. _generatePointsArray(): boolean;
  24820. /**
  24821. * Checks if the passed Ray intersects with the mesh
  24822. * @param ray defines the ray to use
  24823. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24824. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24825. * @returns the picking info
  24826. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24827. */
  24828. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24829. /**
  24830. * Clones the current mesh
  24831. * @param name defines the mesh name
  24832. * @param newParent defines the new mesh parent
  24833. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24834. * @returns the new mesh
  24835. */
  24836. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24837. /**
  24838. * Disposes all the submeshes of the current meshnp
  24839. * @returns the current mesh
  24840. */
  24841. releaseSubMeshes(): AbstractMesh;
  24842. /**
  24843. * Releases resources associated with this abstract mesh.
  24844. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24845. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24846. */
  24847. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24848. /**
  24849. * Adds the passed mesh as a child to the current mesh
  24850. * @param mesh defines the child mesh
  24851. * @returns the current mesh
  24852. */
  24853. addChild(mesh: AbstractMesh): AbstractMesh;
  24854. /**
  24855. * Removes the passed mesh from the current mesh children list
  24856. * @param mesh defines the child mesh
  24857. * @returns the current mesh
  24858. */
  24859. removeChild(mesh: AbstractMesh): AbstractMesh;
  24860. /** @hidden */
  24861. private _initFacetData;
  24862. /**
  24863. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24864. * This method can be called within the render loop.
  24865. * 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
  24866. * @returns the current mesh
  24867. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24868. */
  24869. updateFacetData(): AbstractMesh;
  24870. /**
  24871. * Returns the facetLocalNormals array.
  24872. * The normals are expressed in the mesh local spac
  24873. * @returns an array of Vector3
  24874. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24875. */
  24876. getFacetLocalNormals(): Vector3[];
  24877. /**
  24878. * Returns the facetLocalPositions array.
  24879. * The facet positions are expressed in the mesh local space
  24880. * @returns an array of Vector3
  24881. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24882. */
  24883. getFacetLocalPositions(): Vector3[];
  24884. /**
  24885. * Returns the facetLocalPartioning array
  24886. * @returns an array of array of numbers
  24887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24888. */
  24889. getFacetLocalPartitioning(): number[][];
  24890. /**
  24891. * Returns the i-th facet position in the world system.
  24892. * This method allocates a new Vector3 per call
  24893. * @param i defines the facet index
  24894. * @returns a new Vector3
  24895. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24896. */
  24897. getFacetPosition(i: number): Vector3;
  24898. /**
  24899. * Sets the reference Vector3 with the i-th facet position in the world system
  24900. * @param i defines the facet index
  24901. * @param ref defines the target vector
  24902. * @returns the current mesh
  24903. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24904. */
  24905. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24906. /**
  24907. * Returns the i-th facet normal in the world system.
  24908. * This method allocates a new Vector3 per call
  24909. * @param i defines the facet index
  24910. * @returns a new Vector3
  24911. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24912. */
  24913. getFacetNormal(i: number): Vector3;
  24914. /**
  24915. * Sets the reference Vector3 with the i-th facet normal in the world system
  24916. * @param i defines the facet index
  24917. * @param ref defines the target vector
  24918. * @returns the current mesh
  24919. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24920. */
  24921. getFacetNormalToRef(i: number, ref: Vector3): this;
  24922. /**
  24923. * 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)
  24924. * @param x defines x coordinate
  24925. * @param y defines y coordinate
  24926. * @param z defines z coordinate
  24927. * @returns the array of facet indexes
  24928. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24929. */
  24930. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24931. /**
  24932. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24933. * @param projected sets as the (x,y,z) world projection on the facet
  24934. * @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
  24935. * @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
  24936. * @param x defines x coordinate
  24937. * @param y defines y coordinate
  24938. * @param z defines z coordinate
  24939. * @returns the face index if found (or null instead)
  24940. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24941. */
  24942. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24943. /**
  24944. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24945. * @param projected sets as the (x,y,z) local projection on the facet
  24946. * @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
  24947. * @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
  24948. * @param x defines x coordinate
  24949. * @param y defines y coordinate
  24950. * @param z defines z coordinate
  24951. * @returns the face index if found (or null instead)
  24952. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24953. */
  24954. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24955. /**
  24956. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24957. * @returns the parameters
  24958. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24959. */
  24960. getFacetDataParameters(): any;
  24961. /**
  24962. * Disables the feature FacetData and frees the related memory
  24963. * @returns the current mesh
  24964. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24965. */
  24966. disableFacetData(): AbstractMesh;
  24967. /**
  24968. * Updates the AbstractMesh indices array
  24969. * @param indices defines the data source
  24970. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24971. * @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)
  24972. * @returns the current mesh
  24973. */
  24974. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24975. /**
  24976. * Creates new normals data for the mesh
  24977. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24978. * @returns the current mesh
  24979. */
  24980. createNormals(updatable: boolean): AbstractMesh;
  24981. /**
  24982. * Align the mesh with a normal
  24983. * @param normal defines the normal to use
  24984. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24985. * @returns the current mesh
  24986. */
  24987. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24988. /** @hidden */
  24989. _checkOcclusionQuery(): boolean;
  24990. }
  24991. }
  24992. declare module BABYLON {
  24993. /**
  24994. * Interface used to define ActionEvent
  24995. */
  24996. export interface IActionEvent {
  24997. /** The mesh or sprite that triggered the action */
  24998. source: any;
  24999. /** The X mouse cursor position at the time of the event */
  25000. pointerX: number;
  25001. /** The Y mouse cursor position at the time of the event */
  25002. pointerY: number;
  25003. /** The mesh that is currently pointed at (can be null) */
  25004. meshUnderPointer: Nullable<AbstractMesh>;
  25005. /** the original (browser) event that triggered the ActionEvent */
  25006. sourceEvent?: any;
  25007. /** additional data for the event */
  25008. additionalData?: any;
  25009. }
  25010. /**
  25011. * ActionEvent is the event being sent when an action is triggered.
  25012. */
  25013. export class ActionEvent implements IActionEvent {
  25014. /** The mesh or sprite that triggered the action */
  25015. source: any;
  25016. /** The X mouse cursor position at the time of the event */
  25017. pointerX: number;
  25018. /** The Y mouse cursor position at the time of the event */
  25019. pointerY: number;
  25020. /** The mesh that is currently pointed at (can be null) */
  25021. meshUnderPointer: Nullable<AbstractMesh>;
  25022. /** the original (browser) event that triggered the ActionEvent */
  25023. sourceEvent?: any;
  25024. /** additional data for the event */
  25025. additionalData?: any;
  25026. /**
  25027. * Creates a new ActionEvent
  25028. * @param source The mesh or sprite that triggered the action
  25029. * @param pointerX The X mouse cursor position at the time of the event
  25030. * @param pointerY The Y mouse cursor position at the time of the event
  25031. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25032. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25033. * @param additionalData additional data for the event
  25034. */
  25035. constructor(
  25036. /** The mesh or sprite that triggered the action */
  25037. source: any,
  25038. /** The X mouse cursor position at the time of the event */
  25039. pointerX: number,
  25040. /** The Y mouse cursor position at the time of the event */
  25041. pointerY: number,
  25042. /** The mesh that is currently pointed at (can be null) */
  25043. meshUnderPointer: Nullable<AbstractMesh>,
  25044. /** the original (browser) event that triggered the ActionEvent */
  25045. sourceEvent?: any,
  25046. /** additional data for the event */
  25047. additionalData?: any);
  25048. /**
  25049. * Helper function to auto-create an ActionEvent from a source mesh.
  25050. * @param source The source mesh that triggered the event
  25051. * @param evt The original (browser) event
  25052. * @param additionalData additional data for the event
  25053. * @returns the new ActionEvent
  25054. */
  25055. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25056. /**
  25057. * Helper function to auto-create an ActionEvent from a source sprite
  25058. * @param source The source sprite that triggered the event
  25059. * @param scene Scene associated with the sprite
  25060. * @param evt The original (browser) event
  25061. * @param additionalData additional data for the event
  25062. * @returns the new ActionEvent
  25063. */
  25064. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25065. /**
  25066. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25067. * @param scene the scene where the event occurred
  25068. * @param evt The original (browser) event
  25069. * @returns the new ActionEvent
  25070. */
  25071. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25072. /**
  25073. * Helper function to auto-create an ActionEvent from a primitive
  25074. * @param prim defines the target primitive
  25075. * @param pointerPos defines the pointer position
  25076. * @param evt The original (browser) event
  25077. * @param additionalData additional data for the event
  25078. * @returns the new ActionEvent
  25079. */
  25080. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25081. }
  25082. }
  25083. declare module BABYLON {
  25084. /**
  25085. * Abstract class used to decouple action Manager from scene and meshes.
  25086. * Do not instantiate.
  25087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25088. */
  25089. export abstract class AbstractActionManager implements IDisposable {
  25090. /** Gets the list of active triggers */
  25091. static Triggers: {
  25092. [key: string]: number;
  25093. };
  25094. /** Gets the cursor to use when hovering items */
  25095. hoverCursor: string;
  25096. /** Gets the list of actions */
  25097. actions: IAction[];
  25098. /**
  25099. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25100. */
  25101. isRecursive: boolean;
  25102. /**
  25103. * Releases all associated resources
  25104. */
  25105. abstract dispose(): void;
  25106. /**
  25107. * Does this action manager has pointer triggers
  25108. */
  25109. abstract readonly hasPointerTriggers: boolean;
  25110. /**
  25111. * Does this action manager has pick triggers
  25112. */
  25113. abstract readonly hasPickTriggers: boolean;
  25114. /**
  25115. * Process a specific trigger
  25116. * @param trigger defines the trigger to process
  25117. * @param evt defines the event details to be processed
  25118. */
  25119. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25120. /**
  25121. * Does this action manager handles actions of any of the given triggers
  25122. * @param triggers defines the triggers to be tested
  25123. * @return a boolean indicating whether one (or more) of the triggers is handled
  25124. */
  25125. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25126. /**
  25127. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25128. * speed.
  25129. * @param triggerA defines the trigger to be tested
  25130. * @param triggerB defines the trigger to be tested
  25131. * @return a boolean indicating whether one (or more) of the triggers is handled
  25132. */
  25133. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25134. /**
  25135. * Does this action manager handles actions of a given trigger
  25136. * @param trigger defines the trigger to be tested
  25137. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25138. * @return whether the trigger is handled
  25139. */
  25140. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25141. /**
  25142. * Serialize this manager to a JSON object
  25143. * @param name defines the property name to store this manager
  25144. * @returns a JSON representation of this manager
  25145. */
  25146. abstract serialize(name: string): any;
  25147. /**
  25148. * Registers an action to this action manager
  25149. * @param action defines the action to be registered
  25150. * @return the action amended (prepared) after registration
  25151. */
  25152. abstract registerAction(action: IAction): Nullable<IAction>;
  25153. /**
  25154. * Unregisters an action to this action manager
  25155. * @param action defines the action to be unregistered
  25156. * @return a boolean indicating whether the action has been unregistered
  25157. */
  25158. abstract unregisterAction(action: IAction): Boolean;
  25159. /**
  25160. * Does exist one action manager with at least one trigger
  25161. **/
  25162. static readonly HasTriggers: boolean;
  25163. /**
  25164. * Does exist one action manager with at least one pick trigger
  25165. **/
  25166. static readonly HasPickTriggers: boolean;
  25167. /**
  25168. * Does exist one action manager that handles actions of a given trigger
  25169. * @param trigger defines the trigger to be tested
  25170. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25171. **/
  25172. static HasSpecificTrigger(trigger: number): boolean;
  25173. }
  25174. }
  25175. declare module BABYLON {
  25176. /**
  25177. * Defines how a node can be built from a string name.
  25178. */
  25179. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25180. /**
  25181. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25182. */
  25183. export class Node implements IBehaviorAware<Node> {
  25184. /** @hidden */
  25185. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  25186. private static _NodeConstructors;
  25187. /**
  25188. * Add a new node constructor
  25189. * @param type defines the type name of the node to construct
  25190. * @param constructorFunc defines the constructor function
  25191. */
  25192. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25193. /**
  25194. * Returns a node constructor based on type name
  25195. * @param type defines the type name
  25196. * @param name defines the new node name
  25197. * @param scene defines the hosting scene
  25198. * @param options defines optional options to transmit to constructors
  25199. * @returns the new constructor or null
  25200. */
  25201. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25202. /**
  25203. * Gets or sets the name of the node
  25204. */
  25205. name: string;
  25206. /**
  25207. * Gets or sets the id of the node
  25208. */
  25209. id: string;
  25210. /**
  25211. * Gets or sets the unique id of the node
  25212. */
  25213. uniqueId: number;
  25214. /**
  25215. * Gets or sets a string used to store user defined state for the node
  25216. */
  25217. state: string;
  25218. /**
  25219. * Gets or sets an object used to store user defined information for the node
  25220. */
  25221. metadata: any;
  25222. /**
  25223. * For internal use only. Please do not use.
  25224. */
  25225. reservedDataStore: any;
  25226. /**
  25227. * List of inspectable custom properties (used by the Inspector)
  25228. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25229. */
  25230. inspectableCustomProperties: IInspectable[];
  25231. /**
  25232. * Gets or sets a boolean used to define if the node must be serialized
  25233. */
  25234. doNotSerialize: boolean;
  25235. /** @hidden */
  25236. _isDisposed: boolean;
  25237. /**
  25238. * Gets a list of Animations associated with the node
  25239. */
  25240. animations: Animation[];
  25241. protected _ranges: {
  25242. [name: string]: Nullable<AnimationRange>;
  25243. };
  25244. /**
  25245. * Callback raised when the node is ready to be used
  25246. */
  25247. onReady: Nullable<(node: Node) => void>;
  25248. private _isEnabled;
  25249. private _isParentEnabled;
  25250. private _isReady;
  25251. /** @hidden */
  25252. _currentRenderId: number;
  25253. private _parentUpdateId;
  25254. /** @hidden */
  25255. _childUpdateId: number;
  25256. /** @hidden */
  25257. _waitingParentId: Nullable<string>;
  25258. /** @hidden */
  25259. _scene: Scene;
  25260. /** @hidden */
  25261. _cache: any;
  25262. private _parentNode;
  25263. private _children;
  25264. /** @hidden */
  25265. _worldMatrix: Matrix;
  25266. /** @hidden */
  25267. _worldMatrixDeterminant: number;
  25268. /** @hidden */
  25269. _worldMatrixDeterminantIsDirty: boolean;
  25270. /** @hidden */
  25271. private _sceneRootNodesIndex;
  25272. /**
  25273. * Gets a boolean indicating if the node has been disposed
  25274. * @returns true if the node was disposed
  25275. */
  25276. isDisposed(): boolean;
  25277. /**
  25278. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25279. * @see https://doc.babylonjs.com/how_to/parenting
  25280. */
  25281. parent: Nullable<Node>;
  25282. private addToSceneRootNodes;
  25283. private removeFromSceneRootNodes;
  25284. private _animationPropertiesOverride;
  25285. /**
  25286. * Gets or sets the animation properties override
  25287. */
  25288. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25289. /**
  25290. * Gets a string idenfifying the name of the class
  25291. * @returns "Node" string
  25292. */
  25293. getClassName(): string;
  25294. /** @hidden */
  25295. readonly _isNode: boolean;
  25296. /**
  25297. * An event triggered when the mesh is disposed
  25298. */
  25299. onDisposeObservable: Observable<Node>;
  25300. private _onDisposeObserver;
  25301. /**
  25302. * Sets a callback that will be raised when the node will be disposed
  25303. */
  25304. onDispose: () => void;
  25305. /**
  25306. * Creates a new Node
  25307. * @param name the name and id to be given to this node
  25308. * @param scene the scene this node will be added to
  25309. * @param addToRootNodes the node will be added to scene.rootNodes
  25310. */
  25311. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25312. /**
  25313. * Gets the scene of the node
  25314. * @returns a scene
  25315. */
  25316. getScene(): Scene;
  25317. /**
  25318. * Gets the engine of the node
  25319. * @returns a Engine
  25320. */
  25321. getEngine(): Engine;
  25322. private _behaviors;
  25323. /**
  25324. * Attach a behavior to the node
  25325. * @see http://doc.babylonjs.com/features/behaviour
  25326. * @param behavior defines the behavior to attach
  25327. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25328. * @returns the current Node
  25329. */
  25330. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25331. /**
  25332. * Remove an attached behavior
  25333. * @see http://doc.babylonjs.com/features/behaviour
  25334. * @param behavior defines the behavior to attach
  25335. * @returns the current Node
  25336. */
  25337. removeBehavior(behavior: Behavior<Node>): Node;
  25338. /**
  25339. * Gets the list of attached behaviors
  25340. * @see http://doc.babylonjs.com/features/behaviour
  25341. */
  25342. readonly behaviors: Behavior<Node>[];
  25343. /**
  25344. * Gets an attached behavior by name
  25345. * @param name defines the name of the behavior to look for
  25346. * @see http://doc.babylonjs.com/features/behaviour
  25347. * @returns null if behavior was not found else the requested behavior
  25348. */
  25349. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25350. /**
  25351. * Returns the latest update of the World matrix
  25352. * @returns a Matrix
  25353. */
  25354. getWorldMatrix(): Matrix;
  25355. /** @hidden */
  25356. _getWorldMatrixDeterminant(): number;
  25357. /**
  25358. * Returns directly the latest state of the mesh World matrix.
  25359. * A Matrix is returned.
  25360. */
  25361. readonly worldMatrixFromCache: Matrix;
  25362. /** @hidden */
  25363. _initCache(): void;
  25364. /** @hidden */
  25365. updateCache(force?: boolean): void;
  25366. /** @hidden */
  25367. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25368. /** @hidden */
  25369. _updateCache(ignoreParentClass?: boolean): void;
  25370. /** @hidden */
  25371. _isSynchronized(): boolean;
  25372. /** @hidden */
  25373. _markSyncedWithParent(): void;
  25374. /** @hidden */
  25375. isSynchronizedWithParent(): boolean;
  25376. /** @hidden */
  25377. isSynchronized(): boolean;
  25378. /**
  25379. * Is this node ready to be used/rendered
  25380. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25381. * @return true if the node is ready
  25382. */
  25383. isReady(completeCheck?: boolean): boolean;
  25384. /**
  25385. * Is this node enabled?
  25386. * 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
  25387. * @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
  25388. * @return whether this node (and its parent) is enabled
  25389. */
  25390. isEnabled(checkAncestors?: boolean): boolean;
  25391. /** @hidden */
  25392. protected _syncParentEnabledState(): void;
  25393. /**
  25394. * Set the enabled state of this node
  25395. * @param value defines the new enabled state
  25396. */
  25397. setEnabled(value: boolean): void;
  25398. /**
  25399. * Is this node a descendant of the given node?
  25400. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25401. * @param ancestor defines the parent node to inspect
  25402. * @returns a boolean indicating if this node is a descendant of the given node
  25403. */
  25404. isDescendantOf(ancestor: Node): boolean;
  25405. /** @hidden */
  25406. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25407. /**
  25408. * Will return all nodes that have this node as ascendant
  25409. * @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
  25410. * @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
  25411. * @return all children nodes of all types
  25412. */
  25413. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25414. /**
  25415. * Get all child-meshes of this node
  25416. * @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)
  25417. * @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
  25418. * @returns an array of AbstractMesh
  25419. */
  25420. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25421. /**
  25422. * Get all direct children of this node
  25423. * @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
  25424. * @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)
  25425. * @returns an array of Node
  25426. */
  25427. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25428. /** @hidden */
  25429. _setReady(state: boolean): void;
  25430. /**
  25431. * Get an animation by name
  25432. * @param name defines the name of the animation to look for
  25433. * @returns null if not found else the requested animation
  25434. */
  25435. getAnimationByName(name: string): Nullable<Animation>;
  25436. /**
  25437. * Creates an animation range for this node
  25438. * @param name defines the name of the range
  25439. * @param from defines the starting key
  25440. * @param to defines the end key
  25441. */
  25442. createAnimationRange(name: string, from: number, to: number): void;
  25443. /**
  25444. * Delete a specific animation range
  25445. * @param name defines the name of the range to delete
  25446. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25447. */
  25448. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25449. /**
  25450. * Get an animation range by name
  25451. * @param name defines the name of the animation range to look for
  25452. * @returns null if not found else the requested animation range
  25453. */
  25454. getAnimationRange(name: string): Nullable<AnimationRange>;
  25455. /**
  25456. * Gets the list of all animation ranges defined on this node
  25457. * @returns an array
  25458. */
  25459. getAnimationRanges(): Nullable<AnimationRange>[];
  25460. /**
  25461. * Will start the animation sequence
  25462. * @param name defines the range frames for animation sequence
  25463. * @param loop defines if the animation should loop (false by default)
  25464. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25465. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25466. * @returns the object created for this animation. If range does not exist, it will return null
  25467. */
  25468. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25469. /**
  25470. * Serialize animation ranges into a JSON compatible object
  25471. * @returns serialization object
  25472. */
  25473. serializeAnimationRanges(): any;
  25474. /**
  25475. * Computes the world matrix of the node
  25476. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25477. * @returns the world matrix
  25478. */
  25479. computeWorldMatrix(force?: boolean): Matrix;
  25480. /**
  25481. * Releases resources associated with this node.
  25482. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25483. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25484. */
  25485. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25486. /**
  25487. * Parse animation range data from a serialization object and store them into a given node
  25488. * @param node defines where to store the animation ranges
  25489. * @param parsedNode defines the serialization object to read data from
  25490. * @param scene defines the hosting scene
  25491. */
  25492. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25493. /**
  25494. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25495. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25496. * @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
  25497. * @returns the new bounding vectors
  25498. */
  25499. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25500. min: Vector3;
  25501. max: Vector3;
  25502. };
  25503. }
  25504. }
  25505. declare module BABYLON {
  25506. /**
  25507. * @hidden
  25508. */
  25509. export class _IAnimationState {
  25510. key: number;
  25511. repeatCount: number;
  25512. workValue?: any;
  25513. loopMode?: number;
  25514. offsetValue?: any;
  25515. highLimitValue?: any;
  25516. }
  25517. /**
  25518. * Class used to store any kind of animation
  25519. */
  25520. export class Animation {
  25521. /**Name of the animation */
  25522. name: string;
  25523. /**Property to animate */
  25524. targetProperty: string;
  25525. /**The frames per second of the animation */
  25526. framePerSecond: number;
  25527. /**The data type of the animation */
  25528. dataType: number;
  25529. /**The loop mode of the animation */
  25530. loopMode?: number | undefined;
  25531. /**Specifies if blending should be enabled */
  25532. enableBlending?: boolean | undefined;
  25533. /**
  25534. * Use matrix interpolation instead of using direct key value when animating matrices
  25535. */
  25536. static AllowMatricesInterpolation: boolean;
  25537. /**
  25538. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25539. */
  25540. static AllowMatrixDecomposeForInterpolation: boolean;
  25541. /**
  25542. * Stores the key frames of the animation
  25543. */
  25544. private _keys;
  25545. /**
  25546. * Stores the easing function of the animation
  25547. */
  25548. private _easingFunction;
  25549. /**
  25550. * @hidden Internal use only
  25551. */
  25552. _runtimeAnimations: RuntimeAnimation[];
  25553. /**
  25554. * The set of event that will be linked to this animation
  25555. */
  25556. private _events;
  25557. /**
  25558. * Stores an array of target property paths
  25559. */
  25560. targetPropertyPath: string[];
  25561. /**
  25562. * Stores the blending speed of the animation
  25563. */
  25564. blendingSpeed: number;
  25565. /**
  25566. * Stores the animation ranges for the animation
  25567. */
  25568. private _ranges;
  25569. /**
  25570. * @hidden Internal use
  25571. */
  25572. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25573. /**
  25574. * Sets up an animation
  25575. * @param property The property to animate
  25576. * @param animationType The animation type to apply
  25577. * @param framePerSecond The frames per second of the animation
  25578. * @param easingFunction The easing function used in the animation
  25579. * @returns The created animation
  25580. */
  25581. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25582. /**
  25583. * Create and start an animation on a node
  25584. * @param name defines the name of the global animation that will be run on all nodes
  25585. * @param node defines the root node where the animation will take place
  25586. * @param targetProperty defines property to animate
  25587. * @param framePerSecond defines the number of frame per second yo use
  25588. * @param totalFrame defines the number of frames in total
  25589. * @param from defines the initial value
  25590. * @param to defines the final value
  25591. * @param loopMode defines which loop mode you want to use (off by default)
  25592. * @param easingFunction defines the easing function to use (linear by default)
  25593. * @param onAnimationEnd defines the callback to call when animation end
  25594. * @returns the animatable created for this animation
  25595. */
  25596. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25597. /**
  25598. * Create and start an animation on a node and its descendants
  25599. * @param name defines the name of the global animation that will be run on all nodes
  25600. * @param node defines the root node where the animation will take place
  25601. * @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
  25602. * @param targetProperty defines property to animate
  25603. * @param framePerSecond defines the number of frame per second to use
  25604. * @param totalFrame defines the number of frames in total
  25605. * @param from defines the initial value
  25606. * @param to defines the final value
  25607. * @param loopMode defines which loop mode you want to use (off by default)
  25608. * @param easingFunction defines the easing function to use (linear by default)
  25609. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25610. * @returns the list of animatables created for all nodes
  25611. * @example https://www.babylonjs-playground.com/#MH0VLI
  25612. */
  25613. 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[]>;
  25614. /**
  25615. * Creates a new animation, merges it with the existing animations and starts it
  25616. * @param name Name of the animation
  25617. * @param node Node which contains the scene that begins the animations
  25618. * @param targetProperty Specifies which property to animate
  25619. * @param framePerSecond The frames per second of the animation
  25620. * @param totalFrame The total number of frames
  25621. * @param from The frame at the beginning of the animation
  25622. * @param to The frame at the end of the animation
  25623. * @param loopMode Specifies the loop mode of the animation
  25624. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25625. * @param onAnimationEnd Callback to run once the animation is complete
  25626. * @returns Nullable animation
  25627. */
  25628. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25629. /**
  25630. * Transition property of an host to the target Value
  25631. * @param property The property to transition
  25632. * @param targetValue The target Value of the property
  25633. * @param host The object where the property to animate belongs
  25634. * @param scene Scene used to run the animation
  25635. * @param frameRate Framerate (in frame/s) to use
  25636. * @param transition The transition type we want to use
  25637. * @param duration The duration of the animation, in milliseconds
  25638. * @param onAnimationEnd Callback trigger at the end of the animation
  25639. * @returns Nullable animation
  25640. */
  25641. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25642. /**
  25643. * Return the array of runtime animations currently using this animation
  25644. */
  25645. readonly runtimeAnimations: RuntimeAnimation[];
  25646. /**
  25647. * Specifies if any of the runtime animations are currently running
  25648. */
  25649. readonly hasRunningRuntimeAnimations: boolean;
  25650. /**
  25651. * Initializes the animation
  25652. * @param name Name of the animation
  25653. * @param targetProperty Property to animate
  25654. * @param framePerSecond The frames per second of the animation
  25655. * @param dataType The data type of the animation
  25656. * @param loopMode The loop mode of the animation
  25657. * @param enableBlending Specifies if blending should be enabled
  25658. */
  25659. constructor(
  25660. /**Name of the animation */
  25661. name: string,
  25662. /**Property to animate */
  25663. targetProperty: string,
  25664. /**The frames per second of the animation */
  25665. framePerSecond: number,
  25666. /**The data type of the animation */
  25667. dataType: number,
  25668. /**The loop mode of the animation */
  25669. loopMode?: number | undefined,
  25670. /**Specifies if blending should be enabled */
  25671. enableBlending?: boolean | undefined);
  25672. /**
  25673. * Converts the animation to a string
  25674. * @param fullDetails support for multiple levels of logging within scene loading
  25675. * @returns String form of the animation
  25676. */
  25677. toString(fullDetails?: boolean): string;
  25678. /**
  25679. * Add an event to this animation
  25680. * @param event Event to add
  25681. */
  25682. addEvent(event: AnimationEvent): void;
  25683. /**
  25684. * Remove all events found at the given frame
  25685. * @param frame The frame to remove events from
  25686. */
  25687. removeEvents(frame: number): void;
  25688. /**
  25689. * Retrieves all the events from the animation
  25690. * @returns Events from the animation
  25691. */
  25692. getEvents(): AnimationEvent[];
  25693. /**
  25694. * Creates an animation range
  25695. * @param name Name of the animation range
  25696. * @param from Starting frame of the animation range
  25697. * @param to Ending frame of the animation
  25698. */
  25699. createRange(name: string, from: number, to: number): void;
  25700. /**
  25701. * Deletes an animation range by name
  25702. * @param name Name of the animation range to delete
  25703. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25704. */
  25705. deleteRange(name: string, deleteFrames?: boolean): void;
  25706. /**
  25707. * Gets the animation range by name, or null if not defined
  25708. * @param name Name of the animation range
  25709. * @returns Nullable animation range
  25710. */
  25711. getRange(name: string): Nullable<AnimationRange>;
  25712. /**
  25713. * Gets the key frames from the animation
  25714. * @returns The key frames of the animation
  25715. */
  25716. getKeys(): Array<IAnimationKey>;
  25717. /**
  25718. * Gets the highest frame rate of the animation
  25719. * @returns Highest frame rate of the animation
  25720. */
  25721. getHighestFrame(): number;
  25722. /**
  25723. * Gets the easing function of the animation
  25724. * @returns Easing function of the animation
  25725. */
  25726. getEasingFunction(): IEasingFunction;
  25727. /**
  25728. * Sets the easing function of the animation
  25729. * @param easingFunction A custom mathematical formula for animation
  25730. */
  25731. setEasingFunction(easingFunction: EasingFunction): void;
  25732. /**
  25733. * Interpolates a scalar linearly
  25734. * @param startValue Start value of the animation curve
  25735. * @param endValue End value of the animation curve
  25736. * @param gradient Scalar amount to interpolate
  25737. * @returns Interpolated scalar value
  25738. */
  25739. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25740. /**
  25741. * Interpolates a scalar cubically
  25742. * @param startValue Start value of the animation curve
  25743. * @param outTangent End tangent of the animation
  25744. * @param endValue End value of the animation curve
  25745. * @param inTangent Start tangent of the animation curve
  25746. * @param gradient Scalar amount to interpolate
  25747. * @returns Interpolated scalar value
  25748. */
  25749. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25750. /**
  25751. * Interpolates a quaternion using a spherical linear interpolation
  25752. * @param startValue Start value of the animation curve
  25753. * @param endValue End value of the animation curve
  25754. * @param gradient Scalar amount to interpolate
  25755. * @returns Interpolated quaternion value
  25756. */
  25757. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25758. /**
  25759. * Interpolates a quaternion cubically
  25760. * @param startValue Start value of the animation curve
  25761. * @param outTangent End tangent of the animation curve
  25762. * @param endValue End value of the animation curve
  25763. * @param inTangent Start tangent of the animation curve
  25764. * @param gradient Scalar amount to interpolate
  25765. * @returns Interpolated quaternion value
  25766. */
  25767. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25768. /**
  25769. * Interpolates a Vector3 linearl
  25770. * @param startValue Start value of the animation curve
  25771. * @param endValue End value of the animation curve
  25772. * @param gradient Scalar amount to interpolate
  25773. * @returns Interpolated scalar value
  25774. */
  25775. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25776. /**
  25777. * Interpolates a Vector3 cubically
  25778. * @param startValue Start value of the animation curve
  25779. * @param outTangent End tangent of the animation
  25780. * @param endValue End value of the animation curve
  25781. * @param inTangent Start tangent of the animation curve
  25782. * @param gradient Scalar amount to interpolate
  25783. * @returns InterpolatedVector3 value
  25784. */
  25785. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25786. /**
  25787. * Interpolates a Vector2 linearly
  25788. * @param startValue Start value of the animation curve
  25789. * @param endValue End value of the animation curve
  25790. * @param gradient Scalar amount to interpolate
  25791. * @returns Interpolated Vector2 value
  25792. */
  25793. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25794. /**
  25795. * Interpolates a Vector2 cubically
  25796. * @param startValue Start value of the animation curve
  25797. * @param outTangent End tangent of the animation
  25798. * @param endValue End value of the animation curve
  25799. * @param inTangent Start tangent of the animation curve
  25800. * @param gradient Scalar amount to interpolate
  25801. * @returns Interpolated Vector2 value
  25802. */
  25803. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25804. /**
  25805. * Interpolates a size linearly
  25806. * @param startValue Start value of the animation curve
  25807. * @param endValue End value of the animation curve
  25808. * @param gradient Scalar amount to interpolate
  25809. * @returns Interpolated Size value
  25810. */
  25811. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25812. /**
  25813. * Interpolates a Color3 linearly
  25814. * @param startValue Start value of the animation curve
  25815. * @param endValue End value of the animation curve
  25816. * @param gradient Scalar amount to interpolate
  25817. * @returns Interpolated Color3 value
  25818. */
  25819. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25820. /**
  25821. * @hidden Internal use only
  25822. */
  25823. _getKeyValue(value: any): any;
  25824. /**
  25825. * @hidden Internal use only
  25826. */
  25827. _interpolate(currentFrame: number, state: _IAnimationState): any;
  25828. /**
  25829. * Defines the function to use to interpolate matrices
  25830. * @param startValue defines the start matrix
  25831. * @param endValue defines the end matrix
  25832. * @param gradient defines the gradient between both matrices
  25833. * @param result defines an optional target matrix where to store the interpolation
  25834. * @returns the interpolated matrix
  25835. */
  25836. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25837. /**
  25838. * Makes a copy of the animation
  25839. * @returns Cloned animation
  25840. */
  25841. clone(): Animation;
  25842. /**
  25843. * Sets the key frames of the animation
  25844. * @param values The animation key frames to set
  25845. */
  25846. setKeys(values: Array<IAnimationKey>): void;
  25847. /**
  25848. * Serializes the animation to an object
  25849. * @returns Serialized object
  25850. */
  25851. serialize(): any;
  25852. /**
  25853. * Float animation type
  25854. */
  25855. private static _ANIMATIONTYPE_FLOAT;
  25856. /**
  25857. * Vector3 animation type
  25858. */
  25859. private static _ANIMATIONTYPE_VECTOR3;
  25860. /**
  25861. * Quaternion animation type
  25862. */
  25863. private static _ANIMATIONTYPE_QUATERNION;
  25864. /**
  25865. * Matrix animation type
  25866. */
  25867. private static _ANIMATIONTYPE_MATRIX;
  25868. /**
  25869. * Color3 animation type
  25870. */
  25871. private static _ANIMATIONTYPE_COLOR3;
  25872. /**
  25873. * Vector2 animation type
  25874. */
  25875. private static _ANIMATIONTYPE_VECTOR2;
  25876. /**
  25877. * Size animation type
  25878. */
  25879. private static _ANIMATIONTYPE_SIZE;
  25880. /**
  25881. * Relative Loop Mode
  25882. */
  25883. private static _ANIMATIONLOOPMODE_RELATIVE;
  25884. /**
  25885. * Cycle Loop Mode
  25886. */
  25887. private static _ANIMATIONLOOPMODE_CYCLE;
  25888. /**
  25889. * Constant Loop Mode
  25890. */
  25891. private static _ANIMATIONLOOPMODE_CONSTANT;
  25892. /**
  25893. * Get the float animation type
  25894. */
  25895. static readonly ANIMATIONTYPE_FLOAT: number;
  25896. /**
  25897. * Get the Vector3 animation type
  25898. */
  25899. static readonly ANIMATIONTYPE_VECTOR3: number;
  25900. /**
  25901. * Get the Vector2 animation type
  25902. */
  25903. static readonly ANIMATIONTYPE_VECTOR2: number;
  25904. /**
  25905. * Get the Size animation type
  25906. */
  25907. static readonly ANIMATIONTYPE_SIZE: number;
  25908. /**
  25909. * Get the Quaternion animation type
  25910. */
  25911. static readonly ANIMATIONTYPE_QUATERNION: number;
  25912. /**
  25913. * Get the Matrix animation type
  25914. */
  25915. static readonly ANIMATIONTYPE_MATRIX: number;
  25916. /**
  25917. * Get the Color3 animation type
  25918. */
  25919. static readonly ANIMATIONTYPE_COLOR3: number;
  25920. /**
  25921. * Get the Relative Loop Mode
  25922. */
  25923. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25924. /**
  25925. * Get the Cycle Loop Mode
  25926. */
  25927. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25928. /**
  25929. * Get the Constant Loop Mode
  25930. */
  25931. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25932. /** @hidden */
  25933. static _UniversalLerp(left: any, right: any, amount: number): any;
  25934. /**
  25935. * Parses an animation object and creates an animation
  25936. * @param parsedAnimation Parsed animation object
  25937. * @returns Animation object
  25938. */
  25939. static Parse(parsedAnimation: any): Animation;
  25940. /**
  25941. * Appends the serialized animations from the source animations
  25942. * @param source Source containing the animations
  25943. * @param destination Target to store the animations
  25944. */
  25945. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25946. }
  25947. }
  25948. declare module BABYLON {
  25949. /**
  25950. * Base class of all the textures in babylon.
  25951. * It groups all the common properties the materials, post process, lights... might need
  25952. * in order to make a correct use of the texture.
  25953. */
  25954. export class BaseTexture implements IAnimatable {
  25955. /**
  25956. * Default anisotropic filtering level for the application.
  25957. * It is set to 4 as a good tradeoff between perf and quality.
  25958. */
  25959. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25960. /**
  25961. * Gets or sets the unique id of the texture
  25962. */
  25963. uniqueId: number;
  25964. /**
  25965. * Define the name of the texture.
  25966. */
  25967. name: string;
  25968. /**
  25969. * Gets or sets an object used to store user defined information.
  25970. */
  25971. metadata: any;
  25972. /**
  25973. * For internal use only. Please do not use.
  25974. */
  25975. reservedDataStore: any;
  25976. private _hasAlpha;
  25977. /**
  25978. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25979. */
  25980. hasAlpha: boolean;
  25981. /**
  25982. * Defines if the alpha value should be determined via the rgb values.
  25983. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25984. */
  25985. getAlphaFromRGB: boolean;
  25986. /**
  25987. * Intensity or strength of the texture.
  25988. * It is commonly used by materials to fine tune the intensity of the texture
  25989. */
  25990. level: number;
  25991. /**
  25992. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25993. * This is part of the texture as textures usually maps to one uv set.
  25994. */
  25995. coordinatesIndex: number;
  25996. private _coordinatesMode;
  25997. /**
  25998. * How a texture is mapped.
  25999. *
  26000. * | Value | Type | Description |
  26001. * | ----- | ----------------------------------- | ----------- |
  26002. * | 0 | EXPLICIT_MODE | |
  26003. * | 1 | SPHERICAL_MODE | |
  26004. * | 2 | PLANAR_MODE | |
  26005. * | 3 | CUBIC_MODE | |
  26006. * | 4 | PROJECTION_MODE | |
  26007. * | 5 | SKYBOX_MODE | |
  26008. * | 6 | INVCUBIC_MODE | |
  26009. * | 7 | EQUIRECTANGULAR_MODE | |
  26010. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26011. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26012. */
  26013. coordinatesMode: number;
  26014. /**
  26015. * | Value | Type | Description |
  26016. * | ----- | ------------------ | ----------- |
  26017. * | 0 | CLAMP_ADDRESSMODE | |
  26018. * | 1 | WRAP_ADDRESSMODE | |
  26019. * | 2 | MIRROR_ADDRESSMODE | |
  26020. */
  26021. wrapU: number;
  26022. /**
  26023. * | Value | Type | Description |
  26024. * | ----- | ------------------ | ----------- |
  26025. * | 0 | CLAMP_ADDRESSMODE | |
  26026. * | 1 | WRAP_ADDRESSMODE | |
  26027. * | 2 | MIRROR_ADDRESSMODE | |
  26028. */
  26029. wrapV: number;
  26030. /**
  26031. * | Value | Type | Description |
  26032. * | ----- | ------------------ | ----------- |
  26033. * | 0 | CLAMP_ADDRESSMODE | |
  26034. * | 1 | WRAP_ADDRESSMODE | |
  26035. * | 2 | MIRROR_ADDRESSMODE | |
  26036. */
  26037. wrapR: number;
  26038. /**
  26039. * With compliant hardware and browser (supporting anisotropic filtering)
  26040. * this defines the level of anisotropic filtering in the texture.
  26041. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26042. */
  26043. anisotropicFilteringLevel: number;
  26044. /**
  26045. * Define if the texture is a cube texture or if false a 2d texture.
  26046. */
  26047. isCube: boolean;
  26048. /**
  26049. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26050. */
  26051. is3D: boolean;
  26052. /**
  26053. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26054. * HDR texture are usually stored in linear space.
  26055. * This only impacts the PBR and Background materials
  26056. */
  26057. gammaSpace: boolean;
  26058. /**
  26059. * Gets whether or not the texture contains RGBD data.
  26060. */
  26061. readonly isRGBD: boolean;
  26062. /**
  26063. * Is Z inverted in the texture (useful in a cube texture).
  26064. */
  26065. invertZ: boolean;
  26066. /**
  26067. * Are mip maps generated for this texture or not.
  26068. */
  26069. readonly noMipmap: boolean;
  26070. /**
  26071. * @hidden
  26072. */
  26073. lodLevelInAlpha: boolean;
  26074. /**
  26075. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26076. */
  26077. lodGenerationOffset: number;
  26078. /**
  26079. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26080. */
  26081. lodGenerationScale: number;
  26082. /**
  26083. * Define if the texture is a render target.
  26084. */
  26085. isRenderTarget: boolean;
  26086. /**
  26087. * Define the unique id of the texture in the scene.
  26088. */
  26089. readonly uid: string;
  26090. /**
  26091. * Return a string representation of the texture.
  26092. * @returns the texture as a string
  26093. */
  26094. toString(): string;
  26095. /**
  26096. * Get the class name of the texture.
  26097. * @returns "BaseTexture"
  26098. */
  26099. getClassName(): string;
  26100. /**
  26101. * Define the list of animation attached to the texture.
  26102. */
  26103. animations: Animation[];
  26104. /**
  26105. * An event triggered when the texture is disposed.
  26106. */
  26107. onDisposeObservable: Observable<BaseTexture>;
  26108. private _onDisposeObserver;
  26109. /**
  26110. * Callback triggered when the texture has been disposed.
  26111. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26112. */
  26113. onDispose: () => void;
  26114. /**
  26115. * Define the current state of the loading sequence when in delayed load mode.
  26116. */
  26117. delayLoadState: number;
  26118. private _scene;
  26119. /** @hidden */
  26120. _texture: Nullable<InternalTexture>;
  26121. private _uid;
  26122. /**
  26123. * Define if the texture is preventinga material to render or not.
  26124. * If not and the texture is not ready, the engine will use a default black texture instead.
  26125. */
  26126. readonly isBlocking: boolean;
  26127. /**
  26128. * Instantiates a new BaseTexture.
  26129. * Base class of all the textures in babylon.
  26130. * It groups all the common properties the materials, post process, lights... might need
  26131. * in order to make a correct use of the texture.
  26132. * @param scene Define the scene the texture blongs to
  26133. */
  26134. constructor(scene: Nullable<Scene>);
  26135. /**
  26136. * Get the scene the texture belongs to.
  26137. * @returns the scene or null if undefined
  26138. */
  26139. getScene(): Nullable<Scene>;
  26140. /**
  26141. * Get the texture transform matrix used to offset tile the texture for istance.
  26142. * @returns the transformation matrix
  26143. */
  26144. getTextureMatrix(): Matrix;
  26145. /**
  26146. * Get the texture reflection matrix used to rotate/transform the reflection.
  26147. * @returns the reflection matrix
  26148. */
  26149. getReflectionTextureMatrix(): Matrix;
  26150. /**
  26151. * Get the underlying lower level texture from Babylon.
  26152. * @returns the insternal texture
  26153. */
  26154. getInternalTexture(): Nullable<InternalTexture>;
  26155. /**
  26156. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26157. * @returns true if ready or not blocking
  26158. */
  26159. isReadyOrNotBlocking(): boolean;
  26160. /**
  26161. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26162. * @returns true if fully ready
  26163. */
  26164. isReady(): boolean;
  26165. private _cachedSize;
  26166. /**
  26167. * Get the size of the texture.
  26168. * @returns the texture size.
  26169. */
  26170. getSize(): ISize;
  26171. /**
  26172. * Get the base size of the texture.
  26173. * It can be different from the size if the texture has been resized for POT for instance
  26174. * @returns the base size
  26175. */
  26176. getBaseSize(): ISize;
  26177. /**
  26178. * Update the sampling mode of the texture.
  26179. * Default is Trilinear mode.
  26180. *
  26181. * | Value | Type | Description |
  26182. * | ----- | ------------------ | ----------- |
  26183. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26184. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26185. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26186. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26187. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26188. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26189. * | 7 | NEAREST_LINEAR | |
  26190. * | 8 | NEAREST_NEAREST | |
  26191. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26192. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26193. * | 11 | LINEAR_LINEAR | |
  26194. * | 12 | LINEAR_NEAREST | |
  26195. *
  26196. * > _mag_: magnification filter (close to the viewer)
  26197. * > _min_: minification filter (far from the viewer)
  26198. * > _mip_: filter used between mip map levels
  26199. *@param samplingMode Define the new sampling mode of the texture
  26200. */
  26201. updateSamplingMode(samplingMode: number): void;
  26202. /**
  26203. * Scales the texture if is `canRescale()`
  26204. * @param ratio the resize factor we want to use to rescale
  26205. */
  26206. scale(ratio: number): void;
  26207. /**
  26208. * Get if the texture can rescale.
  26209. */
  26210. readonly canRescale: boolean;
  26211. /** @hidden */
  26212. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26213. /** @hidden */
  26214. _rebuild(): void;
  26215. /**
  26216. * Triggers the load sequence in delayed load mode.
  26217. */
  26218. delayLoad(): void;
  26219. /**
  26220. * Clones the texture.
  26221. * @returns the cloned texture
  26222. */
  26223. clone(): Nullable<BaseTexture>;
  26224. /**
  26225. * Get the texture underlying type (INT, FLOAT...)
  26226. */
  26227. readonly textureType: number;
  26228. /**
  26229. * Get the texture underlying format (RGB, RGBA...)
  26230. */
  26231. readonly textureFormat: number;
  26232. /**
  26233. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26234. * This will returns an RGBA array buffer containing either in values (0-255) or
  26235. * float values (0-1) depending of the underlying buffer type.
  26236. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26237. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26238. * @param buffer defines a user defined buffer to fill with data (can be null)
  26239. * @returns The Array buffer containing the pixels data.
  26240. */
  26241. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26242. /**
  26243. * Release and destroy the underlying lower level texture aka internalTexture.
  26244. */
  26245. releaseInternalTexture(): void;
  26246. /**
  26247. * Get the polynomial representation of the texture data.
  26248. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26249. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26250. */
  26251. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26252. /** @hidden */
  26253. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26254. /** @hidden */
  26255. readonly _lodTextureMid: Nullable<BaseTexture>;
  26256. /** @hidden */
  26257. readonly _lodTextureLow: Nullable<BaseTexture>;
  26258. /**
  26259. * Dispose the texture and release its associated resources.
  26260. */
  26261. dispose(): void;
  26262. /**
  26263. * Serialize the texture into a JSON representation that can be parsed later on.
  26264. * @returns the JSON representation of the texture
  26265. */
  26266. serialize(): any;
  26267. /**
  26268. * Helper function to be called back once a list of texture contains only ready textures.
  26269. * @param textures Define the list of textures to wait for
  26270. * @param callback Define the callback triggered once the entire list will be ready
  26271. */
  26272. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26273. }
  26274. }
  26275. declare module BABYLON {
  26276. /**
  26277. * Uniform buffer objects.
  26278. *
  26279. * Handles blocks of uniform on the GPU.
  26280. *
  26281. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26282. *
  26283. * For more information, please refer to :
  26284. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26285. */
  26286. export class UniformBuffer {
  26287. private _engine;
  26288. private _buffer;
  26289. private _data;
  26290. private _bufferData;
  26291. private _dynamic?;
  26292. private _uniformLocations;
  26293. private _uniformSizes;
  26294. private _uniformLocationPointer;
  26295. private _needSync;
  26296. private _noUBO;
  26297. private _currentEffect;
  26298. private static _MAX_UNIFORM_SIZE;
  26299. private static _tempBuffer;
  26300. /**
  26301. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26302. * This is dynamic to allow compat with webgl 1 and 2.
  26303. * You will need to pass the name of the uniform as well as the value.
  26304. */
  26305. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26306. /**
  26307. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26308. * This is dynamic to allow compat with webgl 1 and 2.
  26309. * You will need to pass the name of the uniform as well as the value.
  26310. */
  26311. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26312. /**
  26313. * Lambda to Update a single float in a uniform buffer.
  26314. * This is dynamic to allow compat with webgl 1 and 2.
  26315. * You will need to pass the name of the uniform as well as the value.
  26316. */
  26317. updateFloat: (name: string, x: number) => void;
  26318. /**
  26319. * Lambda to Update a vec2 of float in a uniform buffer.
  26320. * This is dynamic to allow compat with webgl 1 and 2.
  26321. * You will need to pass the name of the uniform as well as the value.
  26322. */
  26323. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26324. /**
  26325. * Lambda to Update a vec3 of float in a uniform buffer.
  26326. * This is dynamic to allow compat with webgl 1 and 2.
  26327. * You will need to pass the name of the uniform as well as the value.
  26328. */
  26329. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26330. /**
  26331. * Lambda to Update a vec4 of float in a uniform buffer.
  26332. * This is dynamic to allow compat with webgl 1 and 2.
  26333. * You will need to pass the name of the uniform as well as the value.
  26334. */
  26335. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26336. /**
  26337. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26338. * This is dynamic to allow compat with webgl 1 and 2.
  26339. * You will need to pass the name of the uniform as well as the value.
  26340. */
  26341. updateMatrix: (name: string, mat: Matrix) => void;
  26342. /**
  26343. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26344. * This is dynamic to allow compat with webgl 1 and 2.
  26345. * You will need to pass the name of the uniform as well as the value.
  26346. */
  26347. updateVector3: (name: string, vector: Vector3) => void;
  26348. /**
  26349. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26350. * This is dynamic to allow compat with webgl 1 and 2.
  26351. * You will need to pass the name of the uniform as well as the value.
  26352. */
  26353. updateVector4: (name: string, vector: Vector4) => void;
  26354. /**
  26355. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26356. * This is dynamic to allow compat with webgl 1 and 2.
  26357. * You will need to pass the name of the uniform as well as the value.
  26358. */
  26359. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26360. /**
  26361. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26362. * This is dynamic to allow compat with webgl 1 and 2.
  26363. * You will need to pass the name of the uniform as well as the value.
  26364. */
  26365. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26366. /**
  26367. * Instantiates a new Uniform buffer objects.
  26368. *
  26369. * Handles blocks of uniform on the GPU.
  26370. *
  26371. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26372. *
  26373. * For more information, please refer to :
  26374. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26375. * @param engine Define the engine the buffer is associated with
  26376. * @param data Define the data contained in the buffer
  26377. * @param dynamic Define if the buffer is updatable
  26378. */
  26379. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26380. /**
  26381. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26382. * or just falling back on setUniformXXX calls.
  26383. */
  26384. readonly useUbo: boolean;
  26385. /**
  26386. * Indicates if the WebGL underlying uniform buffer is in sync
  26387. * with the javascript cache data.
  26388. */
  26389. readonly isSync: boolean;
  26390. /**
  26391. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26392. * Also, a dynamic UniformBuffer will disable cache verification and always
  26393. * update the underlying WebGL uniform buffer to the GPU.
  26394. * @returns if Dynamic, otherwise false
  26395. */
  26396. isDynamic(): boolean;
  26397. /**
  26398. * The data cache on JS side.
  26399. * @returns the underlying data as a float array
  26400. */
  26401. getData(): Float32Array;
  26402. /**
  26403. * The underlying WebGL Uniform buffer.
  26404. * @returns the webgl buffer
  26405. */
  26406. getBuffer(): Nullable<DataBuffer>;
  26407. /**
  26408. * std140 layout specifies how to align data within an UBO structure.
  26409. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26410. * for specs.
  26411. */
  26412. private _fillAlignment;
  26413. /**
  26414. * Adds an uniform in the buffer.
  26415. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26416. * for the layout to be correct !
  26417. * @param name Name of the uniform, as used in the uniform block in the shader.
  26418. * @param size Data size, or data directly.
  26419. */
  26420. addUniform(name: string, size: number | number[]): void;
  26421. /**
  26422. * Adds a Matrix 4x4 to the uniform buffer.
  26423. * @param name Name of the uniform, as used in the uniform block in the shader.
  26424. * @param mat A 4x4 matrix.
  26425. */
  26426. addMatrix(name: string, mat: Matrix): void;
  26427. /**
  26428. * Adds a vec2 to the uniform buffer.
  26429. * @param name Name of the uniform, as used in the uniform block in the shader.
  26430. * @param x Define the x component value of the vec2
  26431. * @param y Define the y component value of the vec2
  26432. */
  26433. addFloat2(name: string, x: number, y: number): void;
  26434. /**
  26435. * Adds a vec3 to the uniform buffer.
  26436. * @param name Name of the uniform, as used in the uniform block in the shader.
  26437. * @param x Define the x component value of the vec3
  26438. * @param y Define the y component value of the vec3
  26439. * @param z Define the z component value of the vec3
  26440. */
  26441. addFloat3(name: string, x: number, y: number, z: number): void;
  26442. /**
  26443. * Adds a vec3 to the uniform buffer.
  26444. * @param name Name of the uniform, as used in the uniform block in the shader.
  26445. * @param color Define the vec3 from a Color
  26446. */
  26447. addColor3(name: string, color: Color3): void;
  26448. /**
  26449. * Adds a vec4 to the uniform buffer.
  26450. * @param name Name of the uniform, as used in the uniform block in the shader.
  26451. * @param color Define the rgb components from a Color
  26452. * @param alpha Define the a component of the vec4
  26453. */
  26454. addColor4(name: string, color: Color3, alpha: number): void;
  26455. /**
  26456. * Adds a vec3 to the uniform buffer.
  26457. * @param name Name of the uniform, as used in the uniform block in the shader.
  26458. * @param vector Define the vec3 components from a Vector
  26459. */
  26460. addVector3(name: string, vector: Vector3): void;
  26461. /**
  26462. * Adds a Matrix 3x3 to the uniform buffer.
  26463. * @param name Name of the uniform, as used in the uniform block in the shader.
  26464. */
  26465. addMatrix3x3(name: string): void;
  26466. /**
  26467. * Adds a Matrix 2x2 to the uniform buffer.
  26468. * @param name Name of the uniform, as used in the uniform block in the shader.
  26469. */
  26470. addMatrix2x2(name: string): void;
  26471. /**
  26472. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26473. */
  26474. create(): void;
  26475. /** @hidden */
  26476. _rebuild(): void;
  26477. /**
  26478. * Updates the WebGL Uniform Buffer on the GPU.
  26479. * If the `dynamic` flag is set to true, no cache comparison is done.
  26480. * Otherwise, the buffer will be updated only if the cache differs.
  26481. */
  26482. update(): void;
  26483. /**
  26484. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26485. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26486. * @param data Define the flattened data
  26487. * @param size Define the size of the data.
  26488. */
  26489. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26490. private _updateMatrix3x3ForUniform;
  26491. private _updateMatrix3x3ForEffect;
  26492. private _updateMatrix2x2ForEffect;
  26493. private _updateMatrix2x2ForUniform;
  26494. private _updateFloatForEffect;
  26495. private _updateFloatForUniform;
  26496. private _updateFloat2ForEffect;
  26497. private _updateFloat2ForUniform;
  26498. private _updateFloat3ForEffect;
  26499. private _updateFloat3ForUniform;
  26500. private _updateFloat4ForEffect;
  26501. private _updateFloat4ForUniform;
  26502. private _updateMatrixForEffect;
  26503. private _updateMatrixForUniform;
  26504. private _updateVector3ForEffect;
  26505. private _updateVector3ForUniform;
  26506. private _updateVector4ForEffect;
  26507. private _updateVector4ForUniform;
  26508. private _updateColor3ForEffect;
  26509. private _updateColor3ForUniform;
  26510. private _updateColor4ForEffect;
  26511. private _updateColor4ForUniform;
  26512. /**
  26513. * Sets a sampler uniform on the effect.
  26514. * @param name Define the name of the sampler.
  26515. * @param texture Define the texture to set in the sampler
  26516. */
  26517. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26518. /**
  26519. * Directly updates the value of the uniform in the cache AND on the GPU.
  26520. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26521. * @param data Define the flattened data
  26522. */
  26523. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26524. /**
  26525. * Binds this uniform buffer to an effect.
  26526. * @param effect Define the effect to bind the buffer to
  26527. * @param name Name of the uniform block in the shader.
  26528. */
  26529. bindToEffect(effect: Effect, name: string): void;
  26530. /**
  26531. * Disposes the uniform buffer.
  26532. */
  26533. dispose(): void;
  26534. }
  26535. }
  26536. declare module BABYLON {
  26537. /**
  26538. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26539. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26540. */
  26541. export class Analyser {
  26542. /**
  26543. * Gets or sets the smoothing
  26544. * @ignorenaming
  26545. */
  26546. SMOOTHING: number;
  26547. /**
  26548. * Gets or sets the FFT table size
  26549. * @ignorenaming
  26550. */
  26551. FFT_SIZE: number;
  26552. /**
  26553. * Gets or sets the bar graph amplitude
  26554. * @ignorenaming
  26555. */
  26556. BARGRAPHAMPLITUDE: number;
  26557. /**
  26558. * Gets or sets the position of the debug canvas
  26559. * @ignorenaming
  26560. */
  26561. DEBUGCANVASPOS: {
  26562. x: number;
  26563. y: number;
  26564. };
  26565. /**
  26566. * Gets or sets the debug canvas size
  26567. * @ignorenaming
  26568. */
  26569. DEBUGCANVASSIZE: {
  26570. width: number;
  26571. height: number;
  26572. };
  26573. private _byteFreqs;
  26574. private _byteTime;
  26575. private _floatFreqs;
  26576. private _webAudioAnalyser;
  26577. private _debugCanvas;
  26578. private _debugCanvasContext;
  26579. private _scene;
  26580. private _registerFunc;
  26581. private _audioEngine;
  26582. /**
  26583. * Creates a new analyser
  26584. * @param scene defines hosting scene
  26585. */
  26586. constructor(scene: Scene);
  26587. /**
  26588. * Get the number of data values you will have to play with for the visualization
  26589. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26590. * @returns a number
  26591. */
  26592. getFrequencyBinCount(): number;
  26593. /**
  26594. * Gets the current frequency data as a byte array
  26595. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26596. * @returns a Uint8Array
  26597. */
  26598. getByteFrequencyData(): Uint8Array;
  26599. /**
  26600. * Gets the current waveform as a byte array
  26601. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26602. * @returns a Uint8Array
  26603. */
  26604. getByteTimeDomainData(): Uint8Array;
  26605. /**
  26606. * Gets the current frequency data as a float array
  26607. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26608. * @returns a Float32Array
  26609. */
  26610. getFloatFrequencyData(): Float32Array;
  26611. /**
  26612. * Renders the debug canvas
  26613. */
  26614. drawDebugCanvas(): void;
  26615. /**
  26616. * Stops rendering the debug canvas and removes it
  26617. */
  26618. stopDebugCanvas(): void;
  26619. /**
  26620. * Connects two audio nodes
  26621. * @param inputAudioNode defines first node to connect
  26622. * @param outputAudioNode defines second node to connect
  26623. */
  26624. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26625. /**
  26626. * Releases all associated resources
  26627. */
  26628. dispose(): void;
  26629. }
  26630. }
  26631. declare module BABYLON {
  26632. /**
  26633. * This represents an audio engine and it is responsible
  26634. * to play, synchronize and analyse sounds throughout the application.
  26635. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26636. */
  26637. export interface IAudioEngine extends IDisposable {
  26638. /**
  26639. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26640. */
  26641. readonly canUseWebAudio: boolean;
  26642. /**
  26643. * Gets the current AudioContext if available.
  26644. */
  26645. readonly audioContext: Nullable<AudioContext>;
  26646. /**
  26647. * The master gain node defines the global audio volume of your audio engine.
  26648. */
  26649. readonly masterGain: GainNode;
  26650. /**
  26651. * Gets whether or not mp3 are supported by your browser.
  26652. */
  26653. readonly isMP3supported: boolean;
  26654. /**
  26655. * Gets whether or not ogg are supported by your browser.
  26656. */
  26657. readonly isOGGsupported: boolean;
  26658. /**
  26659. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26660. * @ignoreNaming
  26661. */
  26662. WarnedWebAudioUnsupported: boolean;
  26663. /**
  26664. * Defines if the audio engine relies on a custom unlocked button.
  26665. * In this case, the embedded button will not be displayed.
  26666. */
  26667. useCustomUnlockedButton: boolean;
  26668. /**
  26669. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26670. */
  26671. readonly unlocked: boolean;
  26672. /**
  26673. * Event raised when audio has been unlocked on the browser.
  26674. */
  26675. onAudioUnlockedObservable: Observable<AudioEngine>;
  26676. /**
  26677. * Event raised when audio has been locked on the browser.
  26678. */
  26679. onAudioLockedObservable: Observable<AudioEngine>;
  26680. /**
  26681. * Flags the audio engine in Locked state.
  26682. * This happens due to new browser policies preventing audio to autoplay.
  26683. */
  26684. lock(): void;
  26685. /**
  26686. * Unlocks the audio engine once a user action has been done on the dom.
  26687. * This is helpful to resume play once browser policies have been satisfied.
  26688. */
  26689. unlock(): void;
  26690. }
  26691. /**
  26692. * This represents the default audio engine used in babylon.
  26693. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26694. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26695. */
  26696. export class AudioEngine implements IAudioEngine {
  26697. private _audioContext;
  26698. private _audioContextInitialized;
  26699. private _muteButton;
  26700. private _hostElement;
  26701. /**
  26702. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26703. */
  26704. canUseWebAudio: boolean;
  26705. /**
  26706. * The master gain node defines the global audio volume of your audio engine.
  26707. */
  26708. masterGain: GainNode;
  26709. /**
  26710. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26711. * @ignoreNaming
  26712. */
  26713. WarnedWebAudioUnsupported: boolean;
  26714. /**
  26715. * Gets whether or not mp3 are supported by your browser.
  26716. */
  26717. isMP3supported: boolean;
  26718. /**
  26719. * Gets whether or not ogg are supported by your browser.
  26720. */
  26721. isOGGsupported: boolean;
  26722. /**
  26723. * Gets whether audio has been unlocked on the device.
  26724. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26725. * a user interaction has happened.
  26726. */
  26727. unlocked: boolean;
  26728. /**
  26729. * Defines if the audio engine relies on a custom unlocked button.
  26730. * In this case, the embedded button will not be displayed.
  26731. */
  26732. useCustomUnlockedButton: boolean;
  26733. /**
  26734. * Event raised when audio has been unlocked on the browser.
  26735. */
  26736. onAudioUnlockedObservable: Observable<AudioEngine>;
  26737. /**
  26738. * Event raised when audio has been locked on the browser.
  26739. */
  26740. onAudioLockedObservable: Observable<AudioEngine>;
  26741. /**
  26742. * Gets the current AudioContext if available.
  26743. */
  26744. readonly audioContext: Nullable<AudioContext>;
  26745. private _connectedAnalyser;
  26746. /**
  26747. * Instantiates a new audio engine.
  26748. *
  26749. * There should be only one per page as some browsers restrict the number
  26750. * of audio contexts you can create.
  26751. * @param hostElement defines the host element where to display the mute icon if necessary
  26752. */
  26753. constructor(hostElement?: Nullable<HTMLElement>);
  26754. /**
  26755. * Flags the audio engine in Locked state.
  26756. * This happens due to new browser policies preventing audio to autoplay.
  26757. */
  26758. lock(): void;
  26759. /**
  26760. * Unlocks the audio engine once a user action has been done on the dom.
  26761. * This is helpful to resume play once browser policies have been satisfied.
  26762. */
  26763. unlock(): void;
  26764. private _resumeAudioContext;
  26765. private _initializeAudioContext;
  26766. private _tryToRun;
  26767. private _triggerRunningState;
  26768. private _triggerSuspendedState;
  26769. private _displayMuteButton;
  26770. private _moveButtonToTopLeft;
  26771. private _onResize;
  26772. private _hideMuteButton;
  26773. /**
  26774. * Destroy and release the resources associated with the audio ccontext.
  26775. */
  26776. dispose(): void;
  26777. /**
  26778. * Gets the global volume sets on the master gain.
  26779. * @returns the global volume if set or -1 otherwise
  26780. */
  26781. getGlobalVolume(): number;
  26782. /**
  26783. * Sets the global volume of your experience (sets on the master gain).
  26784. * @param newVolume Defines the new global volume of the application
  26785. */
  26786. setGlobalVolume(newVolume: number): void;
  26787. /**
  26788. * Connect the audio engine to an audio analyser allowing some amazing
  26789. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26790. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26791. * @param analyser The analyser to connect to the engine
  26792. */
  26793. connectToAnalyser(analyser: Analyser): void;
  26794. }
  26795. }
  26796. declare module BABYLON {
  26797. /**
  26798. * Interface used to present a loading screen while loading a scene
  26799. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26800. */
  26801. export interface ILoadingScreen {
  26802. /**
  26803. * Function called to display the loading screen
  26804. */
  26805. displayLoadingUI: () => void;
  26806. /**
  26807. * Function called to hide the loading screen
  26808. */
  26809. hideLoadingUI: () => void;
  26810. /**
  26811. * Gets or sets the color to use for the background
  26812. */
  26813. loadingUIBackgroundColor: string;
  26814. /**
  26815. * Gets or sets the text to display while loading
  26816. */
  26817. loadingUIText: string;
  26818. }
  26819. /**
  26820. * Class used for the default loading screen
  26821. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26822. */
  26823. export class DefaultLoadingScreen implements ILoadingScreen {
  26824. private _renderingCanvas;
  26825. private _loadingText;
  26826. private _loadingDivBackgroundColor;
  26827. private _loadingDiv;
  26828. private _loadingTextDiv;
  26829. /**
  26830. * Creates a new default loading screen
  26831. * @param _renderingCanvas defines the canvas used to render the scene
  26832. * @param _loadingText defines the default text to display
  26833. * @param _loadingDivBackgroundColor defines the default background color
  26834. */
  26835. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26836. /**
  26837. * Function called to display the loading screen
  26838. */
  26839. displayLoadingUI(): void;
  26840. /**
  26841. * Function called to hide the loading screen
  26842. */
  26843. hideLoadingUI(): void;
  26844. /**
  26845. * Gets or sets the text to display while loading
  26846. */
  26847. loadingUIText: string;
  26848. /**
  26849. * Gets or sets the color to use for the background
  26850. */
  26851. loadingUIBackgroundColor: string;
  26852. private _resizeLoadingUI;
  26853. }
  26854. }
  26855. declare module BABYLON {
  26856. /** @hidden */
  26857. export class WebGLPipelineContext implements IPipelineContext {
  26858. engine: Engine;
  26859. program: Nullable<WebGLProgram>;
  26860. context?: WebGLRenderingContext;
  26861. vertexShader?: WebGLShader;
  26862. fragmentShader?: WebGLShader;
  26863. isParallelCompiled: boolean;
  26864. onCompiled?: () => void;
  26865. transformFeedback?: WebGLTransformFeedback | null;
  26866. readonly isAsync: boolean;
  26867. readonly isReady: boolean;
  26868. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  26869. }
  26870. }
  26871. declare module BABYLON {
  26872. /** @hidden */
  26873. export class WebGLDataBuffer extends DataBuffer {
  26874. private _buffer;
  26875. constructor(resource: WebGLBuffer);
  26876. readonly underlyingResource: any;
  26877. }
  26878. }
  26879. declare module BABYLON {
  26880. /**
  26881. * Settings for finer control over video usage
  26882. */
  26883. export interface VideoTextureSettings {
  26884. /**
  26885. * Applies `autoplay` to video, if specified
  26886. */
  26887. autoPlay?: boolean;
  26888. /**
  26889. * Applies `loop` to video, if specified
  26890. */
  26891. loop?: boolean;
  26892. /**
  26893. * Automatically updates internal texture from video at every frame in the render loop
  26894. */
  26895. autoUpdateTexture: boolean;
  26896. /**
  26897. * Image src displayed during the video loading or until the user interacts with the video.
  26898. */
  26899. poster?: string;
  26900. }
  26901. /**
  26902. * If you want to display a video in your scene, this is the special texture for that.
  26903. * This special texture works similar to other textures, with the exception of a few parameters.
  26904. * @see https://doc.babylonjs.com/how_to/video_texture
  26905. */
  26906. export class VideoTexture extends Texture {
  26907. /**
  26908. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26909. */
  26910. readonly autoUpdateTexture: boolean;
  26911. /**
  26912. * The video instance used by the texture internally
  26913. */
  26914. readonly video: HTMLVideoElement;
  26915. private _onUserActionRequestedObservable;
  26916. /**
  26917. * Event triggerd when a dom action is required by the user to play the video.
  26918. * This happens due to recent changes in browser policies preventing video to auto start.
  26919. */
  26920. readonly onUserActionRequestedObservable: Observable<Texture>;
  26921. private _generateMipMaps;
  26922. private _engine;
  26923. private _stillImageCaptured;
  26924. private _displayingPosterTexture;
  26925. private _settings;
  26926. private _createInternalTextureOnEvent;
  26927. /**
  26928. * Creates a video texture.
  26929. * If you want to display a video in your scene, this is the special texture for that.
  26930. * This special texture works similar to other textures, with the exception of a few parameters.
  26931. * @see https://doc.babylonjs.com/how_to/video_texture
  26932. * @param name optional name, will detect from video source, if not defined
  26933. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26934. * @param scene is obviously the current scene.
  26935. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26936. * @param invertY is false by default but can be used to invert video on Y axis
  26937. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26938. * @param settings allows finer control over video usage
  26939. */
  26940. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26941. private _getName;
  26942. private _getVideo;
  26943. private _createInternalTexture;
  26944. private reset;
  26945. /**
  26946. * @hidden Internal method to initiate `update`.
  26947. */
  26948. _rebuild(): void;
  26949. /**
  26950. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26951. */
  26952. update(): void;
  26953. /**
  26954. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26955. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26956. */
  26957. updateTexture(isVisible: boolean): void;
  26958. protected _updateInternalTexture: () => void;
  26959. /**
  26960. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26961. * @param url New url.
  26962. */
  26963. updateURL(url: string): void;
  26964. /**
  26965. * Dispose the texture and release its associated resources.
  26966. */
  26967. dispose(): void;
  26968. /**
  26969. * Creates a video texture straight from a stream.
  26970. * @param scene Define the scene the texture should be created in
  26971. * @param stream Define the stream the texture should be created from
  26972. * @returns The created video texture as a promise
  26973. */
  26974. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26975. /**
  26976. * Creates a video texture straight from your WebCam video feed.
  26977. * @param scene Define the scene the texture should be created in
  26978. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26979. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26980. * @returns The created video texture as a promise
  26981. */
  26982. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26983. minWidth: number;
  26984. maxWidth: number;
  26985. minHeight: number;
  26986. maxHeight: number;
  26987. deviceId: string;
  26988. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26989. /**
  26990. * Creates a video texture straight from your WebCam video feed.
  26991. * @param scene Define the scene the texture should be created in
  26992. * @param onReady Define a callback to triggered once the texture will be ready
  26993. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26994. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26995. */
  26996. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26997. minWidth: number;
  26998. maxWidth: number;
  26999. minHeight: number;
  27000. maxHeight: number;
  27001. deviceId: string;
  27002. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27003. }
  27004. }
  27005. declare module BABYLON {
  27006. /**
  27007. * Interface for attribute information associated with buffer instanciation
  27008. */
  27009. export class InstancingAttributeInfo {
  27010. /**
  27011. * Index/offset of the attribute in the vertex shader
  27012. */
  27013. index: number;
  27014. /**
  27015. * size of the attribute, 1, 2, 3 or 4
  27016. */
  27017. attributeSize: number;
  27018. /**
  27019. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27020. * default is FLOAT
  27021. */
  27022. attribyteType: number;
  27023. /**
  27024. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27025. */
  27026. normalized: boolean;
  27027. /**
  27028. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27029. */
  27030. offset: number;
  27031. /**
  27032. * Name of the GLSL attribute, for debugging purpose only
  27033. */
  27034. attributeName: string;
  27035. }
  27036. /**
  27037. * Define options used to create a depth texture
  27038. */
  27039. export class DepthTextureCreationOptions {
  27040. /** Specifies whether or not a stencil should be allocated in the texture */
  27041. generateStencil?: boolean;
  27042. /** Specifies whether or not bilinear filtering is enable on the texture */
  27043. bilinearFiltering?: boolean;
  27044. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27045. comparisonFunction?: number;
  27046. /** Specifies if the created texture is a cube texture */
  27047. isCube?: boolean;
  27048. }
  27049. /**
  27050. * Class used to describe the capabilities of the engine relatively to the current browser
  27051. */
  27052. export class EngineCapabilities {
  27053. /** Maximum textures units per fragment shader */
  27054. maxTexturesImageUnits: number;
  27055. /** Maximum texture units per vertex shader */
  27056. maxVertexTextureImageUnits: number;
  27057. /** Maximum textures units in the entire pipeline */
  27058. maxCombinedTexturesImageUnits: number;
  27059. /** Maximum texture size */
  27060. maxTextureSize: number;
  27061. /** Maximum cube texture size */
  27062. maxCubemapTextureSize: number;
  27063. /** Maximum render texture size */
  27064. maxRenderTextureSize: number;
  27065. /** Maximum number of vertex attributes */
  27066. maxVertexAttribs: number;
  27067. /** Maximum number of varyings */
  27068. maxVaryingVectors: number;
  27069. /** Maximum number of uniforms per vertex shader */
  27070. maxVertexUniformVectors: number;
  27071. /** Maximum number of uniforms per fragment shader */
  27072. maxFragmentUniformVectors: number;
  27073. /** Defines if standard derivates (dx/dy) are supported */
  27074. standardDerivatives: boolean;
  27075. /** Defines if s3tc texture compression is supported */
  27076. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27077. /** Defines if pvrtc texture compression is supported */
  27078. pvrtc: any;
  27079. /** Defines if etc1 texture compression is supported */
  27080. etc1: any;
  27081. /** Defines if etc2 texture compression is supported */
  27082. etc2: any;
  27083. /** Defines if astc texture compression is supported */
  27084. astc: any;
  27085. /** Defines if float textures are supported */
  27086. textureFloat: boolean;
  27087. /** Defines if vertex array objects are supported */
  27088. vertexArrayObject: boolean;
  27089. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27090. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27091. /** Gets the maximum level of anisotropy supported */
  27092. maxAnisotropy: number;
  27093. /** Defines if instancing is supported */
  27094. instancedArrays: boolean;
  27095. /** Defines if 32 bits indices are supported */
  27096. uintIndices: boolean;
  27097. /** Defines if high precision shaders are supported */
  27098. highPrecisionShaderSupported: boolean;
  27099. /** Defines if depth reading in the fragment shader is supported */
  27100. fragmentDepthSupported: boolean;
  27101. /** Defines if float texture linear filtering is supported*/
  27102. textureFloatLinearFiltering: boolean;
  27103. /** Defines if rendering to float textures is supported */
  27104. textureFloatRender: boolean;
  27105. /** Defines if half float textures are supported*/
  27106. textureHalfFloat: boolean;
  27107. /** Defines if half float texture linear filtering is supported*/
  27108. textureHalfFloatLinearFiltering: boolean;
  27109. /** Defines if rendering to half float textures is supported */
  27110. textureHalfFloatRender: boolean;
  27111. /** Defines if textureLOD shader command is supported */
  27112. textureLOD: boolean;
  27113. /** Defines if draw buffers extension is supported */
  27114. drawBuffersExtension: boolean;
  27115. /** Defines if depth textures are supported */
  27116. depthTextureExtension: boolean;
  27117. /** Defines if float color buffer are supported */
  27118. colorBufferFloat: boolean;
  27119. /** Gets disjoint timer query extension (null if not supported) */
  27120. timerQuery: EXT_disjoint_timer_query;
  27121. /** Defines if timestamp can be used with timer query */
  27122. canUseTimestampForTimerQuery: boolean;
  27123. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27124. multiview: any;
  27125. /** Function used to let the system compiles shaders in background */
  27126. parallelShaderCompile: {
  27127. COMPLETION_STATUS_KHR: number;
  27128. };
  27129. }
  27130. /** Interface defining initialization parameters for Engine class */
  27131. export interface EngineOptions extends WebGLContextAttributes {
  27132. /**
  27133. * Defines if the engine should no exceed a specified device ratio
  27134. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27135. */
  27136. limitDeviceRatio?: number;
  27137. /**
  27138. * Defines if webvr should be enabled automatically
  27139. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27140. */
  27141. autoEnableWebVR?: boolean;
  27142. /**
  27143. * Defines if webgl2 should be turned off even if supported
  27144. * @see http://doc.babylonjs.com/features/webgl2
  27145. */
  27146. disableWebGL2Support?: boolean;
  27147. /**
  27148. * Defines if webaudio should be initialized as well
  27149. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27150. */
  27151. audioEngine?: boolean;
  27152. /**
  27153. * Defines if animations should run using a deterministic lock step
  27154. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27155. */
  27156. deterministicLockstep?: boolean;
  27157. /** Defines the maximum steps to use with deterministic lock step mode */
  27158. lockstepMaxSteps?: number;
  27159. /**
  27160. * Defines that engine should ignore context lost events
  27161. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27162. */
  27163. doNotHandleContextLost?: boolean;
  27164. /**
  27165. * Defines that engine should ignore modifying touch action attribute and style
  27166. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27167. */
  27168. doNotHandleTouchAction?: boolean;
  27169. /**
  27170. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27171. */
  27172. useHighPrecisionFloats?: boolean;
  27173. }
  27174. /**
  27175. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27176. */
  27177. export class Engine {
  27178. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27179. static ExceptionList: ({
  27180. key: string;
  27181. capture: string;
  27182. captureConstraint: number;
  27183. targets: string[];
  27184. } | {
  27185. key: string;
  27186. capture: null;
  27187. captureConstraint: null;
  27188. targets: string[];
  27189. })[];
  27190. /** Gets the list of created engines */
  27191. static readonly Instances: Engine[];
  27192. /**
  27193. * Gets the latest created engine
  27194. */
  27195. static readonly LastCreatedEngine: Nullable<Engine>;
  27196. /**
  27197. * Gets the latest created scene
  27198. */
  27199. static readonly LastCreatedScene: Nullable<Scene>;
  27200. /**
  27201. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27202. * @param flag defines which part of the materials must be marked as dirty
  27203. * @param predicate defines a predicate used to filter which materials should be affected
  27204. */
  27205. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27206. /**
  27207. * Hidden
  27208. */
  27209. static _TextureLoaders: IInternalTextureLoader[];
  27210. /** Defines that alpha blending is disabled */
  27211. static readonly ALPHA_DISABLE: number;
  27212. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27213. static readonly ALPHA_ADD: number;
  27214. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27215. static readonly ALPHA_COMBINE: number;
  27216. /** Defines that alpha blending to DEST - SRC * DEST */
  27217. static readonly ALPHA_SUBTRACT: number;
  27218. /** Defines that alpha blending to SRC * DEST */
  27219. static readonly ALPHA_MULTIPLY: number;
  27220. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27221. static readonly ALPHA_MAXIMIZED: number;
  27222. /** Defines that alpha blending to SRC + DEST */
  27223. static readonly ALPHA_ONEONE: number;
  27224. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27225. static readonly ALPHA_PREMULTIPLIED: number;
  27226. /**
  27227. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27228. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27229. */
  27230. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27231. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27232. static readonly ALPHA_INTERPOLATE: number;
  27233. /**
  27234. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27235. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27236. */
  27237. static readonly ALPHA_SCREENMODE: number;
  27238. /** Defines that the ressource is not delayed*/
  27239. static readonly DELAYLOADSTATE_NONE: number;
  27240. /** Defines that the ressource was successfully delay loaded */
  27241. static readonly DELAYLOADSTATE_LOADED: number;
  27242. /** Defines that the ressource is currently delay loading */
  27243. static readonly DELAYLOADSTATE_LOADING: number;
  27244. /** Defines that the ressource is delayed and has not started loading */
  27245. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27246. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27247. static readonly NEVER: number;
  27248. /** 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 */
  27249. static readonly ALWAYS: number;
  27250. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27251. static readonly LESS: number;
  27252. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27253. static readonly EQUAL: number;
  27254. /** 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 */
  27255. static readonly LEQUAL: number;
  27256. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27257. static readonly GREATER: number;
  27258. /** 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 */
  27259. static readonly GEQUAL: number;
  27260. /** 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 */
  27261. static readonly NOTEQUAL: number;
  27262. /** Passed to stencilOperation to specify that stencil value must be kept */
  27263. static readonly KEEP: number;
  27264. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27265. static readonly REPLACE: number;
  27266. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27267. static readonly INCR: number;
  27268. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27269. static readonly DECR: number;
  27270. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27271. static readonly INVERT: number;
  27272. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27273. static readonly INCR_WRAP: number;
  27274. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27275. static readonly DECR_WRAP: number;
  27276. /** Texture is not repeating outside of 0..1 UVs */
  27277. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27278. /** Texture is repeating outside of 0..1 UVs */
  27279. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27280. /** Texture is repeating and mirrored */
  27281. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27282. /** ALPHA */
  27283. static readonly TEXTUREFORMAT_ALPHA: number;
  27284. /** LUMINANCE */
  27285. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27286. /** LUMINANCE_ALPHA */
  27287. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27288. /** RGB */
  27289. static readonly TEXTUREFORMAT_RGB: number;
  27290. /** RGBA */
  27291. static readonly TEXTUREFORMAT_RGBA: number;
  27292. /** RED */
  27293. static readonly TEXTUREFORMAT_RED: number;
  27294. /** RED (2nd reference) */
  27295. static readonly TEXTUREFORMAT_R: number;
  27296. /** RG */
  27297. static readonly TEXTUREFORMAT_RG: number;
  27298. /** RED_INTEGER */
  27299. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27300. /** RED_INTEGER (2nd reference) */
  27301. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27302. /** RG_INTEGER */
  27303. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27304. /** RGB_INTEGER */
  27305. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27306. /** RGBA_INTEGER */
  27307. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27308. /** UNSIGNED_BYTE */
  27309. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27310. /** UNSIGNED_BYTE (2nd reference) */
  27311. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27312. /** FLOAT */
  27313. static readonly TEXTURETYPE_FLOAT: number;
  27314. /** HALF_FLOAT */
  27315. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27316. /** BYTE */
  27317. static readonly TEXTURETYPE_BYTE: number;
  27318. /** SHORT */
  27319. static readonly TEXTURETYPE_SHORT: number;
  27320. /** UNSIGNED_SHORT */
  27321. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27322. /** INT */
  27323. static readonly TEXTURETYPE_INT: number;
  27324. /** UNSIGNED_INT */
  27325. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27326. /** UNSIGNED_SHORT_4_4_4_4 */
  27327. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27328. /** UNSIGNED_SHORT_5_5_5_1 */
  27329. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27330. /** UNSIGNED_SHORT_5_6_5 */
  27331. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27332. /** UNSIGNED_INT_2_10_10_10_REV */
  27333. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27334. /** UNSIGNED_INT_24_8 */
  27335. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27336. /** UNSIGNED_INT_10F_11F_11F_REV */
  27337. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27338. /** UNSIGNED_INT_5_9_9_9_REV */
  27339. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27340. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27341. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27342. /** nearest is mag = nearest and min = nearest and mip = linear */
  27343. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27344. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27345. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27346. /** Trilinear is mag = linear and min = linear and mip = linear */
  27347. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27348. /** nearest is mag = nearest and min = nearest and mip = linear */
  27349. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27350. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27351. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27352. /** Trilinear is mag = linear and min = linear and mip = linear */
  27353. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27354. /** mag = nearest and min = nearest and mip = nearest */
  27355. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27356. /** mag = nearest and min = linear and mip = nearest */
  27357. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27358. /** mag = nearest and min = linear and mip = linear */
  27359. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27360. /** mag = nearest and min = linear and mip = none */
  27361. static readonly TEXTURE_NEAREST_LINEAR: number;
  27362. /** mag = nearest and min = nearest and mip = none */
  27363. static readonly TEXTURE_NEAREST_NEAREST: number;
  27364. /** mag = linear and min = nearest and mip = nearest */
  27365. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27366. /** mag = linear and min = nearest and mip = linear */
  27367. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27368. /** mag = linear and min = linear and mip = none */
  27369. static readonly TEXTURE_LINEAR_LINEAR: number;
  27370. /** mag = linear and min = nearest and mip = none */
  27371. static readonly TEXTURE_LINEAR_NEAREST: number;
  27372. /** Explicit coordinates mode */
  27373. static readonly TEXTURE_EXPLICIT_MODE: number;
  27374. /** Spherical coordinates mode */
  27375. static readonly TEXTURE_SPHERICAL_MODE: number;
  27376. /** Planar coordinates mode */
  27377. static readonly TEXTURE_PLANAR_MODE: number;
  27378. /** Cubic coordinates mode */
  27379. static readonly TEXTURE_CUBIC_MODE: number;
  27380. /** Projection coordinates mode */
  27381. static readonly TEXTURE_PROJECTION_MODE: number;
  27382. /** Skybox coordinates mode */
  27383. static readonly TEXTURE_SKYBOX_MODE: number;
  27384. /** Inverse Cubic coordinates mode */
  27385. static readonly TEXTURE_INVCUBIC_MODE: number;
  27386. /** Equirectangular coordinates mode */
  27387. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27388. /** Equirectangular Fixed coordinates mode */
  27389. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27390. /** Equirectangular Fixed Mirrored coordinates mode */
  27391. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27392. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27393. static readonly SCALEMODE_FLOOR: number;
  27394. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27395. static readonly SCALEMODE_NEAREST: number;
  27396. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27397. static readonly SCALEMODE_CEILING: number;
  27398. /**
  27399. * Returns the current npm package of the sdk
  27400. */
  27401. static readonly NpmPackage: string;
  27402. /**
  27403. * Returns the current version of the framework
  27404. */
  27405. static readonly Version: string;
  27406. /**
  27407. * Returns a string describing the current engine
  27408. */
  27409. readonly description: string;
  27410. /**
  27411. * Gets or sets the epsilon value used by collision engine
  27412. */
  27413. static CollisionsEpsilon: number;
  27414. /**
  27415. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27416. */
  27417. static ShadersRepository: string;
  27418. /**
  27419. * Method called to create the default loading screen.
  27420. * This can be overriden in your own app.
  27421. * @param canvas The rendering canvas element
  27422. * @returns The loading screen
  27423. */
  27424. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27425. /**
  27426. * Method called to create the default rescale post process on each engine.
  27427. */
  27428. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27429. /**
  27430. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27431. */
  27432. forcePOTTextures: boolean;
  27433. /**
  27434. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27435. */
  27436. isFullscreen: boolean;
  27437. /**
  27438. * Gets a boolean indicating if the pointer is currently locked
  27439. */
  27440. isPointerLock: boolean;
  27441. /**
  27442. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27443. */
  27444. cullBackFaces: boolean;
  27445. /**
  27446. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27447. */
  27448. renderEvenInBackground: boolean;
  27449. /**
  27450. * Gets or sets a boolean indicating that cache can be kept between frames
  27451. */
  27452. preventCacheWipeBetweenFrames: boolean;
  27453. /**
  27454. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27455. **/
  27456. enableOfflineSupport: boolean;
  27457. /**
  27458. * 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)
  27459. **/
  27460. disableManifestCheck: boolean;
  27461. /**
  27462. * Gets the list of created scenes
  27463. */
  27464. scenes: Scene[];
  27465. /**
  27466. * Event raised when a new scene is created
  27467. */
  27468. onNewSceneAddedObservable: Observable<Scene>;
  27469. /**
  27470. * Gets the list of created postprocesses
  27471. */
  27472. postProcesses: PostProcess[];
  27473. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27474. validateShaderPrograms: boolean;
  27475. /**
  27476. * Observable event triggered each time the rendering canvas is resized
  27477. */
  27478. onResizeObservable: Observable<Engine>;
  27479. /**
  27480. * Observable event triggered each time the canvas loses focus
  27481. */
  27482. onCanvasBlurObservable: Observable<Engine>;
  27483. /**
  27484. * Observable event triggered each time the canvas gains focus
  27485. */
  27486. onCanvasFocusObservable: Observable<Engine>;
  27487. /**
  27488. * Observable event triggered each time the canvas receives pointerout event
  27489. */
  27490. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27491. /**
  27492. * Observable event triggered before each texture is initialized
  27493. */
  27494. onBeforeTextureInitObservable: Observable<Texture>;
  27495. /**
  27496. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27497. */
  27498. disableUniformBuffers: boolean;
  27499. /** @hidden */
  27500. _uniformBuffers: UniformBuffer[];
  27501. /**
  27502. * Gets a boolean indicating that the engine supports uniform buffers
  27503. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27504. */
  27505. readonly supportsUniformBuffers: boolean;
  27506. /**
  27507. * Observable raised when the engine begins a new frame
  27508. */
  27509. onBeginFrameObservable: Observable<Engine>;
  27510. /**
  27511. * If set, will be used to request the next animation frame for the render loop
  27512. */
  27513. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27514. /**
  27515. * Observable raised when the engine ends the current frame
  27516. */
  27517. onEndFrameObservable: Observable<Engine>;
  27518. /**
  27519. * Observable raised when the engine is about to compile a shader
  27520. */
  27521. onBeforeShaderCompilationObservable: Observable<Engine>;
  27522. /**
  27523. * Observable raised when the engine has jsut compiled a shader
  27524. */
  27525. onAfterShaderCompilationObservable: Observable<Engine>;
  27526. /** @hidden */
  27527. _gl: WebGLRenderingContext;
  27528. private _renderingCanvas;
  27529. private _windowIsBackground;
  27530. private _webGLVersion;
  27531. protected _highPrecisionShadersAllowed: boolean;
  27532. /** @hidden */
  27533. readonly _shouldUseHighPrecisionShader: boolean;
  27534. /**
  27535. * Gets a boolean indicating that only power of 2 textures are supported
  27536. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27537. */
  27538. readonly needPOTTextures: boolean;
  27539. /** @hidden */
  27540. _badOS: boolean;
  27541. /** @hidden */
  27542. _badDesktopOS: boolean;
  27543. /**
  27544. * Gets the audio engine
  27545. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27546. * @ignorenaming
  27547. */
  27548. static audioEngine: IAudioEngine;
  27549. /**
  27550. * Default AudioEngine factory responsible of creating the Audio Engine.
  27551. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27552. */
  27553. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27554. /**
  27555. * Default offline support factory responsible of creating a tool used to store data locally.
  27556. * By default, this will create a Database object if the workload has been embedded.
  27557. */
  27558. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27559. private _onFocus;
  27560. private _onBlur;
  27561. private _onCanvasPointerOut;
  27562. private _onCanvasBlur;
  27563. private _onCanvasFocus;
  27564. private _onFullscreenChange;
  27565. private _onPointerLockChange;
  27566. private _hardwareScalingLevel;
  27567. /** @hidden */
  27568. _caps: EngineCapabilities;
  27569. private _pointerLockRequested;
  27570. private _isStencilEnable;
  27571. private _colorWrite;
  27572. private _loadingScreen;
  27573. /** @hidden */
  27574. _drawCalls: PerfCounter;
  27575. private _glVersion;
  27576. private _glRenderer;
  27577. private _glVendor;
  27578. private _videoTextureSupported;
  27579. private _renderingQueueLaunched;
  27580. private _activeRenderLoops;
  27581. private _deterministicLockstep;
  27582. private _lockstepMaxSteps;
  27583. /**
  27584. * Observable signaled when a context lost event is raised
  27585. */
  27586. onContextLostObservable: Observable<Engine>;
  27587. /**
  27588. * Observable signaled when a context restored event is raised
  27589. */
  27590. onContextRestoredObservable: Observable<Engine>;
  27591. private _onContextLost;
  27592. private _onContextRestored;
  27593. private _contextWasLost;
  27594. /** @hidden */
  27595. _doNotHandleContextLost: boolean;
  27596. /**
  27597. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27598. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27599. */
  27600. doNotHandleContextLost: boolean;
  27601. private _performanceMonitor;
  27602. private _fps;
  27603. private _deltaTime;
  27604. /**
  27605. * Turn this value on if you want to pause FPS computation when in background
  27606. */
  27607. disablePerformanceMonitorInBackground: boolean;
  27608. /**
  27609. * Gets the performance monitor attached to this engine
  27610. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27611. */
  27612. readonly performanceMonitor: PerformanceMonitor;
  27613. /**
  27614. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27615. */
  27616. disableVertexArrayObjects: boolean;
  27617. /** @hidden */
  27618. protected _depthCullingState: _DepthCullingState;
  27619. /** @hidden */
  27620. protected _stencilState: _StencilState;
  27621. /** @hidden */
  27622. protected _alphaState: _AlphaState;
  27623. /** @hidden */
  27624. protected _alphaMode: number;
  27625. /** @hidden */
  27626. _internalTexturesCache: InternalTexture[];
  27627. /** @hidden */
  27628. protected _activeChannel: number;
  27629. private _currentTextureChannel;
  27630. /** @hidden */
  27631. protected _boundTexturesCache: {
  27632. [key: string]: Nullable<InternalTexture>;
  27633. };
  27634. /** @hidden */
  27635. protected _currentEffect: Nullable<Effect>;
  27636. /** @hidden */
  27637. protected _currentProgram: Nullable<WebGLProgram>;
  27638. private _compiledEffects;
  27639. private _vertexAttribArraysEnabled;
  27640. /** @hidden */
  27641. protected _cachedViewport: Nullable<Viewport>;
  27642. private _cachedVertexArrayObject;
  27643. /** @hidden */
  27644. protected _cachedVertexBuffers: any;
  27645. /** @hidden */
  27646. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27647. /** @hidden */
  27648. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27649. /** @hidden */
  27650. _currentRenderTarget: Nullable<InternalTexture>;
  27651. private _uintIndicesCurrentlySet;
  27652. private _currentBoundBuffer;
  27653. /** @hidden */
  27654. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27655. private _currentBufferPointers;
  27656. private _currentInstanceLocations;
  27657. private _currentInstanceBuffers;
  27658. private _textureUnits;
  27659. /** @hidden */
  27660. _workingCanvas: Nullable<HTMLCanvasElement>;
  27661. /** @hidden */
  27662. _workingContext: Nullable<CanvasRenderingContext2D>;
  27663. private _rescalePostProcess;
  27664. private _dummyFramebuffer;
  27665. private _externalData;
  27666. /** @hidden */
  27667. _bindedRenderFunction: any;
  27668. private _vaoRecordInProgress;
  27669. private _mustWipeVertexAttributes;
  27670. private _emptyTexture;
  27671. private _emptyCubeTexture;
  27672. private _emptyTexture3D;
  27673. /** @hidden */
  27674. _frameHandler: number;
  27675. private _nextFreeTextureSlots;
  27676. private _maxSimultaneousTextures;
  27677. private _activeRequests;
  27678. private _texturesSupported;
  27679. /** @hidden */
  27680. _textureFormatInUse: Nullable<string>;
  27681. /**
  27682. * Gets the list of texture formats supported
  27683. */
  27684. readonly texturesSupported: Array<string>;
  27685. /**
  27686. * Gets the list of texture formats in use
  27687. */
  27688. readonly textureFormatInUse: Nullable<string>;
  27689. /**
  27690. * Gets the current viewport
  27691. */
  27692. readonly currentViewport: Nullable<Viewport>;
  27693. /**
  27694. * Gets the default empty texture
  27695. */
  27696. readonly emptyTexture: InternalTexture;
  27697. /**
  27698. * Gets the default empty 3D texture
  27699. */
  27700. readonly emptyTexture3D: InternalTexture;
  27701. /**
  27702. * Gets the default empty cube texture
  27703. */
  27704. readonly emptyCubeTexture: InternalTexture;
  27705. /**
  27706. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27707. */
  27708. readonly premultipliedAlpha: boolean;
  27709. /**
  27710. * Creates a new engine
  27711. * @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
  27712. * @param antialias defines enable antialiasing (default: false)
  27713. * @param options defines further options to be sent to the getContext() function
  27714. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27715. */
  27716. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27717. /**
  27718. * Initializes a webVR display and starts listening to display change events
  27719. * The onVRDisplayChangedObservable will be notified upon these changes
  27720. * @returns The onVRDisplayChangedObservable
  27721. */
  27722. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27723. /** @hidden */
  27724. _prepareVRComponent(): void;
  27725. /** @hidden */
  27726. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  27727. /** @hidden */
  27728. _submitVRFrame(): void;
  27729. /**
  27730. * Call this function to leave webVR mode
  27731. * Will do nothing if webVR is not supported or if there is no webVR device
  27732. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27733. */
  27734. disableVR(): void;
  27735. /**
  27736. * Gets a boolean indicating that the system is in VR mode and is presenting
  27737. * @returns true if VR mode is engaged
  27738. */
  27739. isVRPresenting(): boolean;
  27740. /** @hidden */
  27741. _requestVRFrame(): void;
  27742. private _disableTouchAction;
  27743. private _rebuildInternalTextures;
  27744. private _rebuildEffects;
  27745. /**
  27746. * Gets a boolean indicating if all created effects are ready
  27747. * @returns true if all effects are ready
  27748. */
  27749. areAllEffectsReady(): boolean;
  27750. private _rebuildBuffers;
  27751. private _initGLContext;
  27752. /**
  27753. * Gets version of the current webGL context
  27754. */
  27755. readonly webGLVersion: number;
  27756. /**
  27757. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27758. */
  27759. readonly isStencilEnable: boolean;
  27760. /** @hidden */
  27761. _prepareWorkingCanvas(): void;
  27762. /**
  27763. * Reset the texture cache to empty state
  27764. */
  27765. resetTextureCache(): void;
  27766. /**
  27767. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27768. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27769. * @returns true if engine is in deterministic lock step mode
  27770. */
  27771. isDeterministicLockStep(): boolean;
  27772. /**
  27773. * Gets the max steps when engine is running in deterministic lock step
  27774. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27775. * @returns the max steps
  27776. */
  27777. getLockstepMaxSteps(): number;
  27778. /**
  27779. * Gets an object containing information about the current webGL context
  27780. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27781. */
  27782. getGlInfo(): {
  27783. vendor: string;
  27784. renderer: string;
  27785. version: string;
  27786. };
  27787. /**
  27788. * Gets current aspect ratio
  27789. * @param camera defines the camera to use to get the aspect ratio
  27790. * @param useScreen defines if screen size must be used (or the current render target if any)
  27791. * @returns a number defining the aspect ratio
  27792. */
  27793. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27794. /**
  27795. * Gets current screen aspect ratio
  27796. * @returns a number defining the aspect ratio
  27797. */
  27798. getScreenAspectRatio(): number;
  27799. /**
  27800. * Gets the current render width
  27801. * @param useScreen defines if screen size must be used (or the current render target if any)
  27802. * @returns a number defining the current render width
  27803. */
  27804. getRenderWidth(useScreen?: boolean): number;
  27805. /**
  27806. * Gets the current render height
  27807. * @param useScreen defines if screen size must be used (or the current render target if any)
  27808. * @returns a number defining the current render height
  27809. */
  27810. getRenderHeight(useScreen?: boolean): number;
  27811. /**
  27812. * Gets the HTML canvas attached with the current webGL context
  27813. * @returns a HTML canvas
  27814. */
  27815. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27816. /**
  27817. * Gets the client rect of the HTML canvas attached with the current webGL context
  27818. * @returns a client rectanglee
  27819. */
  27820. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27821. /**
  27822. * Defines the hardware scaling level.
  27823. * By default the hardware scaling level is computed from the window device ratio.
  27824. * 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.
  27825. * @param level defines the level to use
  27826. */
  27827. setHardwareScalingLevel(level: number): void;
  27828. /**
  27829. * Gets the current hardware scaling level.
  27830. * By default the hardware scaling level is computed from the window device ratio.
  27831. * 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.
  27832. * @returns a number indicating the current hardware scaling level
  27833. */
  27834. getHardwareScalingLevel(): number;
  27835. /**
  27836. * Gets the list of loaded textures
  27837. * @returns an array containing all loaded textures
  27838. */
  27839. getLoadedTexturesCache(): InternalTexture[];
  27840. /**
  27841. * Gets the object containing all engine capabilities
  27842. * @returns the EngineCapabilities object
  27843. */
  27844. getCaps(): EngineCapabilities;
  27845. /**
  27846. * Gets the current depth function
  27847. * @returns a number defining the depth function
  27848. */
  27849. getDepthFunction(): Nullable<number>;
  27850. /**
  27851. * Sets the current depth function
  27852. * @param depthFunc defines the function to use
  27853. */
  27854. setDepthFunction(depthFunc: number): void;
  27855. /**
  27856. * Sets the current depth function to GREATER
  27857. */
  27858. setDepthFunctionToGreater(): void;
  27859. /**
  27860. * Sets the current depth function to GEQUAL
  27861. */
  27862. setDepthFunctionToGreaterOrEqual(): void;
  27863. /**
  27864. * Sets the current depth function to LESS
  27865. */
  27866. setDepthFunctionToLess(): void;
  27867. private _cachedStencilBuffer;
  27868. private _cachedStencilFunction;
  27869. private _cachedStencilMask;
  27870. private _cachedStencilOperationPass;
  27871. private _cachedStencilOperationFail;
  27872. private _cachedStencilOperationDepthFail;
  27873. private _cachedStencilReference;
  27874. /**
  27875. * Caches the the state of the stencil buffer
  27876. */
  27877. cacheStencilState(): void;
  27878. /**
  27879. * Restores the state of the stencil buffer
  27880. */
  27881. restoreStencilState(): void;
  27882. /**
  27883. * Sets the current depth function to LEQUAL
  27884. */
  27885. setDepthFunctionToLessOrEqual(): void;
  27886. /**
  27887. * Gets a boolean indicating if stencil buffer is enabled
  27888. * @returns the current stencil buffer state
  27889. */
  27890. getStencilBuffer(): boolean;
  27891. /**
  27892. * Enable or disable the stencil buffer
  27893. * @param enable defines if the stencil buffer must be enabled or disabled
  27894. */
  27895. setStencilBuffer(enable: boolean): void;
  27896. /**
  27897. * Gets the current stencil mask
  27898. * @returns a number defining the new stencil mask to use
  27899. */
  27900. getStencilMask(): number;
  27901. /**
  27902. * Sets the current stencil mask
  27903. * @param mask defines the new stencil mask to use
  27904. */
  27905. setStencilMask(mask: number): void;
  27906. /**
  27907. * Gets the current stencil function
  27908. * @returns a number defining the stencil function to use
  27909. */
  27910. getStencilFunction(): number;
  27911. /**
  27912. * Gets the current stencil reference value
  27913. * @returns a number defining the stencil reference value to use
  27914. */
  27915. getStencilFunctionReference(): number;
  27916. /**
  27917. * Gets the current stencil mask
  27918. * @returns a number defining the stencil mask to use
  27919. */
  27920. getStencilFunctionMask(): number;
  27921. /**
  27922. * Sets the current stencil function
  27923. * @param stencilFunc defines the new stencil function to use
  27924. */
  27925. setStencilFunction(stencilFunc: number): void;
  27926. /**
  27927. * Sets the current stencil reference
  27928. * @param reference defines the new stencil reference to use
  27929. */
  27930. setStencilFunctionReference(reference: number): void;
  27931. /**
  27932. * Sets the current stencil mask
  27933. * @param mask defines the new stencil mask to use
  27934. */
  27935. setStencilFunctionMask(mask: number): void;
  27936. /**
  27937. * Gets the current stencil operation when stencil fails
  27938. * @returns a number defining stencil operation to use when stencil fails
  27939. */
  27940. getStencilOperationFail(): number;
  27941. /**
  27942. * Gets the current stencil operation when depth fails
  27943. * @returns a number defining stencil operation to use when depth fails
  27944. */
  27945. getStencilOperationDepthFail(): number;
  27946. /**
  27947. * Gets the current stencil operation when stencil passes
  27948. * @returns a number defining stencil operation to use when stencil passes
  27949. */
  27950. getStencilOperationPass(): number;
  27951. /**
  27952. * Sets the stencil operation to use when stencil fails
  27953. * @param operation defines the stencil operation to use when stencil fails
  27954. */
  27955. setStencilOperationFail(operation: number): void;
  27956. /**
  27957. * Sets the stencil operation to use when depth fails
  27958. * @param operation defines the stencil operation to use when depth fails
  27959. */
  27960. setStencilOperationDepthFail(operation: number): void;
  27961. /**
  27962. * Sets the stencil operation to use when stencil passes
  27963. * @param operation defines the stencil operation to use when stencil passes
  27964. */
  27965. setStencilOperationPass(operation: number): void;
  27966. /**
  27967. * Sets a boolean indicating if the dithering state is enabled or disabled
  27968. * @param value defines the dithering state
  27969. */
  27970. setDitheringState(value: boolean): void;
  27971. /**
  27972. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27973. * @param value defines the rasterizer state
  27974. */
  27975. setRasterizerState(value: boolean): void;
  27976. /**
  27977. * stop executing a render loop function and remove it from the execution array
  27978. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27979. */
  27980. stopRenderLoop(renderFunction?: () => void): void;
  27981. /** @hidden */
  27982. _renderLoop(): void;
  27983. /**
  27984. * Register and execute a render loop. The engine can have more than one render function
  27985. * @param renderFunction defines the function to continuously execute
  27986. */
  27987. runRenderLoop(renderFunction: () => void): void;
  27988. /**
  27989. * Toggle full screen mode
  27990. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27991. */
  27992. switchFullscreen(requestPointerLock: boolean): void;
  27993. /**
  27994. * Enters full screen mode
  27995. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27996. */
  27997. enterFullscreen(requestPointerLock: boolean): void;
  27998. /**
  27999. * Exits full screen mode
  28000. */
  28001. exitFullscreen(): void;
  28002. /**
  28003. * Clear the current render buffer or the current render target (if any is set up)
  28004. * @param color defines the color to use
  28005. * @param backBuffer defines if the back buffer must be cleared
  28006. * @param depth defines if the depth buffer must be cleared
  28007. * @param stencil defines if the stencil buffer must be cleared
  28008. */
  28009. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28010. /**
  28011. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28012. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28013. * @param y defines the y-coordinate of the corner of the clear rectangle
  28014. * @param width defines the width of the clear rectangle
  28015. * @param height defines the height of the clear rectangle
  28016. * @param clearColor defines the clear color
  28017. */
  28018. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28019. /**
  28020. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28021. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28022. * @param y defines the y-coordinate of the corner of the clear rectangle
  28023. * @param width defines the width of the clear rectangle
  28024. * @param height defines the height of the clear rectangle
  28025. */
  28026. enableScissor(x: number, y: number, width: number, height: number): void;
  28027. /**
  28028. * Disable previously set scissor test rectangle
  28029. */
  28030. disableScissor(): void;
  28031. private _viewportCached;
  28032. /** @hidden */
  28033. _viewport(x: number, y: number, width: number, height: number): void;
  28034. /**
  28035. * Set the WebGL's viewport
  28036. * @param viewport defines the viewport element to be used
  28037. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28038. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28039. */
  28040. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28041. /**
  28042. * Directly set the WebGL Viewport
  28043. * @param x defines the x coordinate of the viewport (in screen space)
  28044. * @param y defines the y coordinate of the viewport (in screen space)
  28045. * @param width defines the width of the viewport (in screen space)
  28046. * @param height defines the height of the viewport (in screen space)
  28047. * @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
  28048. */
  28049. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28050. /**
  28051. * Begin a new frame
  28052. */
  28053. beginFrame(): void;
  28054. /**
  28055. * Enf the current frame
  28056. */
  28057. endFrame(): void;
  28058. /**
  28059. * Resize the view according to the canvas' size
  28060. */
  28061. resize(): void;
  28062. /**
  28063. * Force a specific size of the canvas
  28064. * @param width defines the new canvas' width
  28065. * @param height defines the new canvas' height
  28066. */
  28067. setSize(width: number, height: number): void;
  28068. /**
  28069. * Binds the frame buffer to the specified texture.
  28070. * @param texture The texture to render to or null for the default canvas
  28071. * @param faceIndex The face of the texture to render to in case of cube texture
  28072. * @param requiredWidth The width of the target to render to
  28073. * @param requiredHeight The height of the target to render to
  28074. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28075. * @param depthStencilTexture The depth stencil texture to use to render
  28076. * @param lodLevel defines le lod level to bind to the frame buffer
  28077. */
  28078. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28079. /** @hidden */
  28080. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28081. /**
  28082. * Unbind the current render target texture from the webGL context
  28083. * @param texture defines the render target texture to unbind
  28084. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28085. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28086. */
  28087. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28088. /**
  28089. * Force the mipmap generation for the given render target texture
  28090. * @param texture defines the render target texture to use
  28091. */
  28092. generateMipMapsForCubemap(texture: InternalTexture): void;
  28093. /**
  28094. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28095. */
  28096. flushFramebuffer(): void;
  28097. /**
  28098. * Unbind the current render target and bind the default framebuffer
  28099. */
  28100. restoreDefaultFramebuffer(): void;
  28101. /**
  28102. * Create an uniform buffer
  28103. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28104. * @param elements defines the content of the uniform buffer
  28105. * @returns the webGL uniform buffer
  28106. */
  28107. createUniformBuffer(elements: FloatArray): DataBuffer;
  28108. /**
  28109. * Create a dynamic uniform buffer
  28110. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28111. * @param elements defines the content of the uniform buffer
  28112. * @returns the webGL uniform buffer
  28113. */
  28114. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28115. /**
  28116. * Update an existing uniform buffer
  28117. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28118. * @param uniformBuffer defines the target uniform buffer
  28119. * @param elements defines the content to update
  28120. * @param offset defines the offset in the uniform buffer where update should start
  28121. * @param count defines the size of the data to update
  28122. */
  28123. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28124. private _resetVertexBufferBinding;
  28125. /**
  28126. * Creates a vertex buffer
  28127. * @param data the data for the vertex buffer
  28128. * @returns the new WebGL static buffer
  28129. */
  28130. createVertexBuffer(data: DataArray): DataBuffer;
  28131. /**
  28132. * Creates a dynamic vertex buffer
  28133. * @param data the data for the dynamic vertex buffer
  28134. * @returns the new WebGL dynamic buffer
  28135. */
  28136. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28137. /**
  28138. * Update a dynamic index buffer
  28139. * @param indexBuffer defines the target index buffer
  28140. * @param indices defines the data to update
  28141. * @param offset defines the offset in the target index buffer where update should start
  28142. */
  28143. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28144. /**
  28145. * Updates a dynamic vertex buffer.
  28146. * @param vertexBuffer the vertex buffer to update
  28147. * @param data the data used to update the vertex buffer
  28148. * @param byteOffset the byte offset of the data
  28149. * @param byteLength the byte length of the data
  28150. */
  28151. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28152. private _resetIndexBufferBinding;
  28153. /**
  28154. * Creates a new index buffer
  28155. * @param indices defines the content of the index buffer
  28156. * @param updatable defines if the index buffer must be updatable
  28157. * @returns a new webGL buffer
  28158. */
  28159. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28160. /**
  28161. * Bind a webGL buffer to the webGL context
  28162. * @param buffer defines the buffer to bind
  28163. */
  28164. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28165. /**
  28166. * Bind an uniform buffer to the current webGL context
  28167. * @param buffer defines the buffer to bind
  28168. */
  28169. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28170. /**
  28171. * Bind a buffer to the current webGL context at a given location
  28172. * @param buffer defines the buffer to bind
  28173. * @param location defines the index where to bind the buffer
  28174. */
  28175. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28176. /**
  28177. * Bind a specific block at a given index in a specific shader program
  28178. * @param pipelineContext defines the pipeline context to use
  28179. * @param blockName defines the block name
  28180. * @param index defines the index where to bind the block
  28181. */
  28182. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28183. private bindIndexBuffer;
  28184. private bindBuffer;
  28185. /**
  28186. * update the bound buffer with the given data
  28187. * @param data defines the data to update
  28188. */
  28189. updateArrayBuffer(data: Float32Array): void;
  28190. private _vertexAttribPointer;
  28191. private _bindIndexBufferWithCache;
  28192. private _bindVertexBuffersAttributes;
  28193. /**
  28194. * Records a vertex array object
  28195. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28196. * @param vertexBuffers defines the list of vertex buffers to store
  28197. * @param indexBuffer defines the index buffer to store
  28198. * @param effect defines the effect to store
  28199. * @returns the new vertex array object
  28200. */
  28201. recordVertexArrayObject(vertexBuffers: {
  28202. [key: string]: VertexBuffer;
  28203. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28204. /**
  28205. * Bind a specific vertex array object
  28206. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28207. * @param vertexArrayObject defines the vertex array object to bind
  28208. * @param indexBuffer defines the index buffer to bind
  28209. */
  28210. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28211. /**
  28212. * Bind webGl buffers directly to the webGL context
  28213. * @param vertexBuffer defines the vertex buffer to bind
  28214. * @param indexBuffer defines the index buffer to bind
  28215. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28216. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28217. * @param effect defines the effect associated with the vertex buffer
  28218. */
  28219. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28220. private _unbindVertexArrayObject;
  28221. /**
  28222. * Bind a list of vertex buffers to the webGL context
  28223. * @param vertexBuffers defines the list of vertex buffers to bind
  28224. * @param indexBuffer defines the index buffer to bind
  28225. * @param effect defines the effect associated with the vertex buffers
  28226. */
  28227. bindBuffers(vertexBuffers: {
  28228. [key: string]: Nullable<VertexBuffer>;
  28229. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28230. /**
  28231. * Unbind all instance attributes
  28232. */
  28233. unbindInstanceAttributes(): void;
  28234. /**
  28235. * Release and free the memory of a vertex array object
  28236. * @param vao defines the vertex array object to delete
  28237. */
  28238. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28239. /** @hidden */
  28240. _releaseBuffer(buffer: DataBuffer): boolean;
  28241. /**
  28242. * Creates a webGL buffer to use with instanciation
  28243. * @param capacity defines the size of the buffer
  28244. * @returns the webGL buffer
  28245. */
  28246. createInstancesBuffer(capacity: number): DataBuffer;
  28247. /**
  28248. * Delete a webGL buffer used with instanciation
  28249. * @param buffer defines the webGL buffer to delete
  28250. */
  28251. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28252. /**
  28253. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28254. * @param instancesBuffer defines the webGL buffer to update and bind
  28255. * @param data defines the data to store in the buffer
  28256. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28257. */
  28258. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28259. /**
  28260. * Apply all cached states (depth, culling, stencil and alpha)
  28261. */
  28262. applyStates(): void;
  28263. /**
  28264. * Send a draw order
  28265. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28266. * @param indexStart defines the starting index
  28267. * @param indexCount defines the number of index to draw
  28268. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28269. */
  28270. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28271. /**
  28272. * Draw a list of points
  28273. * @param verticesStart defines the index of first vertex to draw
  28274. * @param verticesCount defines the count of vertices to draw
  28275. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28276. */
  28277. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28278. /**
  28279. * Draw a list of unindexed primitives
  28280. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28281. * @param verticesStart defines the index of first vertex to draw
  28282. * @param verticesCount defines the count of vertices to draw
  28283. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28284. */
  28285. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28286. /**
  28287. * Draw a list of indexed primitives
  28288. * @param fillMode defines the primitive to use
  28289. * @param indexStart defines the starting index
  28290. * @param indexCount defines the number of index to draw
  28291. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28292. */
  28293. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28294. /**
  28295. * Draw a list of unindexed primitives
  28296. * @param fillMode defines the primitive to use
  28297. * @param verticesStart defines the index of first vertex to draw
  28298. * @param verticesCount defines the count of vertices to draw
  28299. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28300. */
  28301. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28302. private _drawMode;
  28303. /** @hidden */
  28304. _releaseEffect(effect: Effect): void;
  28305. /** @hidden */
  28306. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  28307. /**
  28308. * Create a new effect (used to store vertex/fragment shaders)
  28309. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28310. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28311. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28312. * @param samplers defines an array of string used to represent textures
  28313. * @param defines defines the string containing the defines to use to compile the shaders
  28314. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28315. * @param onCompiled defines a function to call when the effect creation is successful
  28316. * @param onError defines a function to call when the effect creation has failed
  28317. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28318. * @returns the new Effect
  28319. */
  28320. 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;
  28321. private _compileShader;
  28322. private _compileRawShader;
  28323. /**
  28324. * Directly creates a webGL program
  28325. * @param pipelineContext defines the pipeline context to attach to
  28326. * @param vertexCode defines the vertex shader code to use
  28327. * @param fragmentCode defines the fragment shader code to use
  28328. * @param context defines the webGL context to use (if not set, the current one will be used)
  28329. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28330. * @returns the new webGL program
  28331. */
  28332. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28333. /**
  28334. * 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 defines defines the string containing the defines to use to compile the shaders
  28339. * @param context defines the webGL context to use (if not set, the current one will be used)
  28340. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28341. * @returns the new webGL program
  28342. */
  28343. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28344. /**
  28345. * Creates a new pipeline context
  28346. * @returns the new pipeline
  28347. */
  28348. createPipelineContext(): WebGLPipelineContext;
  28349. private _createShaderProgram;
  28350. private _finalizePipelineContext;
  28351. /** @hidden */
  28352. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  28353. /** @hidden */
  28354. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  28355. /** @hidden */
  28356. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  28357. /**
  28358. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28359. * @param pipelineContext defines the pipeline context to use
  28360. * @param uniformsNames defines the list of uniform names
  28361. * @returns an array of webGL uniform locations
  28362. */
  28363. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28364. /**
  28365. * Gets the lsit of active attributes for a given webGL program
  28366. * @param pipelineContext defines the pipeline context to use
  28367. * @param attributesNames defines the list of attribute names to get
  28368. * @returns an array of indices indicating the offset of each attribute
  28369. */
  28370. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  28371. /**
  28372. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28373. * @param effect defines the effect to activate
  28374. */
  28375. enableEffect(effect: Nullable<Effect>): void;
  28376. /**
  28377. * Set the value of an uniform to an array of int32
  28378. * @param uniform defines the webGL uniform location where to store the value
  28379. * @param array defines the array of int32 to store
  28380. */
  28381. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28382. /**
  28383. * Set the value of an uniform to an array of int32 (stored as vec2)
  28384. * @param uniform defines the webGL uniform location where to store the value
  28385. * @param array defines the array of int32 to store
  28386. */
  28387. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28388. /**
  28389. * Set the value of an uniform to an array of int32 (stored as vec3)
  28390. * @param uniform defines the webGL uniform location where to store the value
  28391. * @param array defines the array of int32 to store
  28392. */
  28393. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28394. /**
  28395. * Set the value of an uniform to an array of int32 (stored as vec4)
  28396. * @param uniform defines the webGL uniform location where to store the value
  28397. * @param array defines the array of int32 to store
  28398. */
  28399. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28400. /**
  28401. * Set the value of an uniform to an array of float32
  28402. * @param uniform defines the webGL uniform location where to store the value
  28403. * @param array defines the array of float32 to store
  28404. */
  28405. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28406. /**
  28407. * Set the value of an uniform to an array of float32 (stored as vec2)
  28408. * @param uniform defines the webGL uniform location where to store the value
  28409. * @param array defines the array of float32 to store
  28410. */
  28411. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28412. /**
  28413. * Set the value of an uniform to an array of float32 (stored as vec3)
  28414. * @param uniform defines the webGL uniform location where to store the value
  28415. * @param array defines the array of float32 to store
  28416. */
  28417. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28418. /**
  28419. * Set the value of an uniform to an array of float32 (stored as vec4)
  28420. * @param uniform defines the webGL uniform location where to store the value
  28421. * @param array defines the array of float32 to store
  28422. */
  28423. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28424. /**
  28425. * Set the value of an uniform to an array of number
  28426. * @param uniform defines the webGL uniform location where to store the value
  28427. * @param array defines the array of number to store
  28428. */
  28429. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28430. /**
  28431. * Set the value of an uniform to an array of number (stored as vec2)
  28432. * @param uniform defines the webGL uniform location where to store the value
  28433. * @param array defines the array of number to store
  28434. */
  28435. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28436. /**
  28437. * Set the value of an uniform to an array of number (stored as vec3)
  28438. * @param uniform defines the webGL uniform location where to store the value
  28439. * @param array defines the array of number to store
  28440. */
  28441. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28442. /**
  28443. * Set the value of an uniform to an array of number (stored as vec4)
  28444. * @param uniform defines the webGL uniform location where to store the value
  28445. * @param array defines the array of number to store
  28446. */
  28447. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28448. /**
  28449. * Set the value of an uniform to an array of float32 (stored as matrices)
  28450. * @param uniform defines the webGL uniform location where to store the value
  28451. * @param matrices defines the array of float32 to store
  28452. */
  28453. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28454. /**
  28455. * Set the value of an uniform to a matrix
  28456. * @param uniform defines the webGL uniform location where to store the value
  28457. * @param matrix defines the matrix to store
  28458. */
  28459. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28460. /**
  28461. * Set the value of an uniform to a matrix (3x3)
  28462. * @param uniform defines the webGL uniform location where to store the value
  28463. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28464. */
  28465. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28466. /**
  28467. * Set the value of an uniform to a matrix (2x2)
  28468. * @param uniform defines the webGL uniform location where to store the value
  28469. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28470. */
  28471. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28472. /**
  28473. * Set the value of an uniform to a number (int)
  28474. * @param uniform defines the webGL uniform location where to store the value
  28475. * @param value defines the int number to store
  28476. */
  28477. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28478. /**
  28479. * Set the value of an uniform to a number (float)
  28480. * @param uniform defines the webGL uniform location where to store the value
  28481. * @param value defines the float number to store
  28482. */
  28483. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28484. /**
  28485. * Set the value of an uniform to a vec2
  28486. * @param uniform defines the webGL uniform location where to store the value
  28487. * @param x defines the 1st component of the value
  28488. * @param y defines the 2nd component of the value
  28489. */
  28490. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28491. /**
  28492. * Set the value of an uniform to a vec3
  28493. * @param uniform defines the webGL uniform location where to store the value
  28494. * @param x defines the 1st component of the value
  28495. * @param y defines the 2nd component of the value
  28496. * @param z defines the 3rd component of the value
  28497. */
  28498. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28499. /**
  28500. * Set the value of an uniform to a boolean
  28501. * @param uniform defines the webGL uniform location where to store the value
  28502. * @param bool defines the boolean to store
  28503. */
  28504. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28505. /**
  28506. * Set the value of an uniform to a vec4
  28507. * @param uniform defines the webGL uniform location where to store the value
  28508. * @param x defines the 1st component of the value
  28509. * @param y defines the 2nd component of the value
  28510. * @param z defines the 3rd component of the value
  28511. * @param w defines the 4th component of the value
  28512. */
  28513. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28514. /**
  28515. * Set the value of an uniform to a Color3
  28516. * @param uniform defines the webGL uniform location where to store the value
  28517. * @param color3 defines the color to store
  28518. */
  28519. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28520. /**
  28521. * Set the value of an uniform to a Color3 and an alpha value
  28522. * @param uniform defines the webGL uniform location where to store the value
  28523. * @param color3 defines the color to store
  28524. * @param alpha defines the alpha component to store
  28525. */
  28526. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28527. /**
  28528. * Sets a Color4 on a uniform variable
  28529. * @param uniform defines the uniform location
  28530. * @param color4 defines the value to be set
  28531. */
  28532. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28533. /**
  28534. * Set various states to the webGL context
  28535. * @param culling defines backface culling state
  28536. * @param zOffset defines the value to apply to zOffset (0 by default)
  28537. * @param force defines if states must be applied even if cache is up to date
  28538. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28539. */
  28540. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28541. /**
  28542. * Set the z offset to apply to current rendering
  28543. * @param value defines the offset to apply
  28544. */
  28545. setZOffset(value: number): void;
  28546. /**
  28547. * Gets the current value of the zOffset
  28548. * @returns the current zOffset state
  28549. */
  28550. getZOffset(): number;
  28551. /**
  28552. * Enable or disable depth buffering
  28553. * @param enable defines the state to set
  28554. */
  28555. setDepthBuffer(enable: boolean): void;
  28556. /**
  28557. * Gets a boolean indicating if depth writing is enabled
  28558. * @returns the current depth writing state
  28559. */
  28560. getDepthWrite(): boolean;
  28561. /**
  28562. * Enable or disable depth writing
  28563. * @param enable defines the state to set
  28564. */
  28565. setDepthWrite(enable: boolean): void;
  28566. /**
  28567. * Enable or disable color writing
  28568. * @param enable defines the state to set
  28569. */
  28570. setColorWrite(enable: boolean): void;
  28571. /**
  28572. * Gets a boolean indicating if color writing is enabled
  28573. * @returns the current color writing state
  28574. */
  28575. getColorWrite(): boolean;
  28576. /**
  28577. * Sets alpha constants used by some alpha blending modes
  28578. * @param r defines the red component
  28579. * @param g defines the green component
  28580. * @param b defines the blue component
  28581. * @param a defines the alpha component
  28582. */
  28583. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28584. /**
  28585. * Sets the current alpha mode
  28586. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28587. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28588. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28589. */
  28590. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28591. /**
  28592. * Gets the current alpha mode
  28593. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28594. * @returns the current alpha mode
  28595. */
  28596. getAlphaMode(): number;
  28597. /**
  28598. * Clears the list of texture accessible through engine.
  28599. * This can help preventing texture load conflict due to name collision.
  28600. */
  28601. clearInternalTexturesCache(): void;
  28602. /**
  28603. * Force the entire cache to be cleared
  28604. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28605. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28606. */
  28607. wipeCaches(bruteForce?: boolean): void;
  28608. /**
  28609. * Set the compressed texture format to use, based on the formats you have, and the formats
  28610. * supported by the hardware / browser.
  28611. *
  28612. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28613. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28614. * to API arguments needed to compressed textures. This puts the burden on the container
  28615. * generator to house the arcane code for determining these for current & future formats.
  28616. *
  28617. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28618. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28619. *
  28620. * Note: The result of this call is not taken into account when a texture is base64.
  28621. *
  28622. * @param formatsAvailable defines the list of those format families you have created
  28623. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28624. *
  28625. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28626. * @returns The extension selected.
  28627. */
  28628. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28629. /** @hidden */
  28630. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28631. min: number;
  28632. mag: number;
  28633. };
  28634. /** @hidden */
  28635. _createTexture(): WebGLTexture;
  28636. /**
  28637. * Usually called from Texture.ts.
  28638. * Passed information to create a WebGLTexture
  28639. * @param urlArg defines a value which contains one of the following:
  28640. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28641. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28642. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28643. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28644. * @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)
  28645. * @param scene needed for loading to the correct scene
  28646. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28647. * @param onLoad optional callback to be called upon successful completion
  28648. * @param onError optional callback to be called upon failure
  28649. * @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
  28650. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28651. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28652. * @param forcedExtension defines the extension to use to pick the right loader
  28653. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28654. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28655. */
  28656. 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;
  28657. private _rescaleTexture;
  28658. private _unpackFlipYCached;
  28659. /**
  28660. * In case you are sharing the context with other applications, it might
  28661. * be interested to not cache the unpack flip y state to ensure a consistent
  28662. * value would be set.
  28663. */
  28664. enableUnpackFlipYCached: boolean;
  28665. /** @hidden */
  28666. _unpackFlipY(value: boolean): void;
  28667. /** @hidden */
  28668. _getUnpackAlignement(): number;
  28669. /**
  28670. * Creates a dynamic texture
  28671. * @param width defines the width of the texture
  28672. * @param height defines the height of the texture
  28673. * @param generateMipMaps defines if the engine should generate the mip levels
  28674. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28675. * @returns the dynamic texture inside an InternalTexture
  28676. */
  28677. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28678. /**
  28679. * Update the sampling mode of a given texture
  28680. * @param samplingMode defines the required sampling mode
  28681. * @param texture defines the texture to update
  28682. */
  28683. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28684. /**
  28685. * Update the content of a dynamic texture
  28686. * @param texture defines the texture to update
  28687. * @param canvas defines the canvas containing the source
  28688. * @param invertY defines if data must be stored with Y axis inverted
  28689. * @param premulAlpha defines if alpha is stored as premultiplied
  28690. * @param format defines the format of the data
  28691. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28692. */
  28693. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28694. /**
  28695. * Update a video texture
  28696. * @param texture defines the texture to update
  28697. * @param video defines the video element to use
  28698. * @param invertY defines if data must be stored with Y axis inverted
  28699. */
  28700. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28701. /**
  28702. * Updates a depth texture Comparison Mode and Function.
  28703. * If the comparison Function is equal to 0, the mode will be set to none.
  28704. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28705. * @param texture The texture to set the comparison function for
  28706. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28707. */
  28708. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28709. /** @hidden */
  28710. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  28711. width: number;
  28712. height: number;
  28713. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  28714. /**
  28715. * Creates a depth stencil texture.
  28716. * This is only available in WebGL 2 or with the depth texture extension available.
  28717. * @param size The size of face edge in the texture.
  28718. * @param options The options defining the texture.
  28719. * @returns The texture
  28720. */
  28721. createDepthStencilTexture(size: number | {
  28722. width: number;
  28723. height: number;
  28724. }, options: DepthTextureCreationOptions): InternalTexture;
  28725. /**
  28726. * Creates a depth stencil texture.
  28727. * This is only available in WebGL 2 or with the depth texture extension available.
  28728. * @param size The size of face edge in the texture.
  28729. * @param options The options defining the texture.
  28730. * @returns The texture
  28731. */
  28732. private _createDepthStencilTexture;
  28733. /**
  28734. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28735. * @param renderTarget The render target to set the frame buffer for
  28736. */
  28737. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28738. /**
  28739. * Creates a new render target texture
  28740. * @param size defines the size of the texture
  28741. * @param options defines the options used to create the texture
  28742. * @returns a new render target texture stored in an InternalTexture
  28743. */
  28744. createRenderTargetTexture(size: number | {
  28745. width: number;
  28746. height: number;
  28747. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28748. /** @hidden */
  28749. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  28750. /**
  28751. * Updates the sample count of a render target texture
  28752. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28753. * @param texture defines the texture to update
  28754. * @param samples defines the sample count to set
  28755. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28756. */
  28757. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28758. /** @hidden */
  28759. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28760. /** @hidden */
  28761. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28762. /** @hidden */
  28763. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28764. /** @hidden */
  28765. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28766. /**
  28767. * @hidden
  28768. */
  28769. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28770. private _prepareWebGLTextureContinuation;
  28771. private _prepareWebGLTexture;
  28772. /** @hidden */
  28773. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  28774. /** @hidden */
  28775. _releaseFramebufferObjects(texture: InternalTexture): void;
  28776. /** @hidden */
  28777. _releaseTexture(texture: InternalTexture): void;
  28778. private setProgram;
  28779. private _boundUniforms;
  28780. /**
  28781. * Binds an effect to the webGL context
  28782. * @param effect defines the effect to bind
  28783. */
  28784. bindSamplers(effect: Effect): void;
  28785. private _activateCurrentTexture;
  28786. /** @hidden */
  28787. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28788. /** @hidden */
  28789. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28790. /**
  28791. * Sets a texture to the webGL context from a postprocess
  28792. * @param channel defines the channel to use
  28793. * @param postProcess defines the source postprocess
  28794. */
  28795. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28796. /**
  28797. * Binds the output of the passed in post process to the texture channel specified
  28798. * @param channel The channel the texture should be bound to
  28799. * @param postProcess The post process which's output should be bound
  28800. */
  28801. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28802. /**
  28803. * Unbind all textures from the webGL context
  28804. */
  28805. unbindAllTextures(): void;
  28806. /**
  28807. * Sets a texture to the according uniform.
  28808. * @param channel The texture channel
  28809. * @param uniform The uniform to set
  28810. * @param texture The texture to apply
  28811. */
  28812. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28813. /**
  28814. * Sets a depth stencil texture from a render target to the according uniform.
  28815. * @param channel The texture channel
  28816. * @param uniform The uniform to set
  28817. * @param texture The render target texture containing the depth stencil texture to apply
  28818. */
  28819. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28820. private _bindSamplerUniformToChannel;
  28821. private _getTextureWrapMode;
  28822. private _setTexture;
  28823. /**
  28824. * Sets an array of texture to the webGL context
  28825. * @param channel defines the channel where the texture array must be set
  28826. * @param uniform defines the associated uniform location
  28827. * @param textures defines the array of textures to bind
  28828. */
  28829. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28830. /** @hidden */
  28831. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28832. private _setTextureParameterFloat;
  28833. private _setTextureParameterInteger;
  28834. /**
  28835. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28836. * @param x defines the x coordinate of the rectangle where pixels must be read
  28837. * @param y defines the y coordinate of the rectangle where pixels must be read
  28838. * @param width defines the width of the rectangle where pixels must be read
  28839. * @param height defines the height of the rectangle where pixels must be read
  28840. * @returns a Uint8Array containing RGBA colors
  28841. */
  28842. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28843. /**
  28844. * Add an externaly attached data from its key.
  28845. * This method call will fail and return false, if such key already exists.
  28846. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28847. * @param key the unique key that identifies the data
  28848. * @param data the data object to associate to the key for this Engine instance
  28849. * @return true if no such key were already present and the data was added successfully, false otherwise
  28850. */
  28851. addExternalData<T>(key: string, data: T): boolean;
  28852. /**
  28853. * Get an externaly attached data from its key
  28854. * @param key the unique key that identifies the data
  28855. * @return the associated data, if present (can be null), or undefined if not present
  28856. */
  28857. getExternalData<T>(key: string): T;
  28858. /**
  28859. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28860. * @param key the unique key that identifies the data
  28861. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28862. * @return the associated data, can be null if the factory returned null.
  28863. */
  28864. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28865. /**
  28866. * Remove an externaly attached data from the Engine instance
  28867. * @param key the unique key that identifies the data
  28868. * @return true if the data was successfully removed, false if it doesn't exist
  28869. */
  28870. removeExternalData(key: string): boolean;
  28871. /**
  28872. * Unbind all vertex attributes from the webGL context
  28873. */
  28874. unbindAllAttributes(): void;
  28875. /**
  28876. * 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
  28877. */
  28878. releaseEffects(): void;
  28879. /**
  28880. * Dispose and release all associated resources
  28881. */
  28882. dispose(): void;
  28883. /**
  28884. * Display the loading screen
  28885. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28886. */
  28887. displayLoadingUI(): void;
  28888. /**
  28889. * Hide the loading screen
  28890. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28891. */
  28892. hideLoadingUI(): void;
  28893. /**
  28894. * Gets the current loading screen object
  28895. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28896. */
  28897. /**
  28898. * Sets the current loading screen object
  28899. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28900. */
  28901. loadingScreen: ILoadingScreen;
  28902. /**
  28903. * Sets the current loading screen text
  28904. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28905. */
  28906. loadingUIText: string;
  28907. /**
  28908. * Sets the current loading screen background color
  28909. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28910. */
  28911. loadingUIBackgroundColor: string;
  28912. /**
  28913. * Attach a new callback raised when context lost event is fired
  28914. * @param callback defines the callback to call
  28915. */
  28916. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28917. /**
  28918. * Attach a new callback raised when context restored event is fired
  28919. * @param callback defines the callback to call
  28920. */
  28921. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28922. /**
  28923. * Gets the source code of the vertex shader associated with a specific webGL program
  28924. * @param program defines the program to use
  28925. * @returns a string containing the source code of the vertex shader associated with the program
  28926. */
  28927. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28928. /**
  28929. * Gets the source code of the fragment shader associated with a specific webGL program
  28930. * @param program defines the program to use
  28931. * @returns a string containing the source code of the fragment shader associated with the program
  28932. */
  28933. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28934. /**
  28935. * Get the current error code of the webGL context
  28936. * @returns the error code
  28937. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28938. */
  28939. getError(): number;
  28940. /**
  28941. * Gets the current framerate
  28942. * @returns a number representing the framerate
  28943. */
  28944. getFps(): number;
  28945. /**
  28946. * Gets the time spent between current and previous frame
  28947. * @returns a number representing the delta time in ms
  28948. */
  28949. getDeltaTime(): number;
  28950. private _measureFps;
  28951. /** @hidden */
  28952. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28953. private _canRenderToFloatFramebuffer;
  28954. private _canRenderToHalfFloatFramebuffer;
  28955. private _canRenderToFramebuffer;
  28956. /** @hidden */
  28957. _getWebGLTextureType(type: number): number;
  28958. /** @hidden */
  28959. _getInternalFormat(format: number): number;
  28960. /** @hidden */
  28961. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28962. /** @hidden */
  28963. _getRGBAMultiSampleBufferFormat(type: number): number;
  28964. /** @hidden */
  28965. _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;
  28966. /** @hidden */
  28967. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28968. /**
  28969. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28970. * @returns true if the engine can be created
  28971. * @ignorenaming
  28972. */
  28973. static isSupported(): boolean;
  28974. }
  28975. }
  28976. declare module BABYLON {
  28977. /**
  28978. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28979. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28980. */
  28981. export class EffectFallbacks {
  28982. private _defines;
  28983. private _currentRank;
  28984. private _maxRank;
  28985. private _mesh;
  28986. /**
  28987. * Removes the fallback from the bound mesh.
  28988. */
  28989. unBindMesh(): void;
  28990. /**
  28991. * Adds a fallback on the specified property.
  28992. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28993. * @param define The name of the define in the shader
  28994. */
  28995. addFallback(rank: number, define: string): void;
  28996. /**
  28997. * Sets the mesh to use CPU skinning when needing to fallback.
  28998. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28999. * @param mesh The mesh to use the fallbacks.
  29000. */
  29001. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29002. /**
  29003. * Checks to see if more fallbacks are still availible.
  29004. */
  29005. readonly isMoreFallbacks: boolean;
  29006. /**
  29007. * Removes the defines that shoould be removed when falling back.
  29008. * @param currentDefines defines the current define statements for the shader.
  29009. * @param effect defines the current effect we try to compile
  29010. * @returns The resulting defines with defines of the current rank removed.
  29011. */
  29012. reduce(currentDefines: string, effect: Effect): string;
  29013. }
  29014. /**
  29015. * Options to be used when creating an effect.
  29016. */
  29017. export class EffectCreationOptions {
  29018. /**
  29019. * Atrributes that will be used in the shader.
  29020. */
  29021. attributes: string[];
  29022. /**
  29023. * Uniform varible names that will be set in the shader.
  29024. */
  29025. uniformsNames: string[];
  29026. /**
  29027. * Uniform buffer varible names that will be set in the shader.
  29028. */
  29029. uniformBuffersNames: string[];
  29030. /**
  29031. * Sampler texture variable names that will be set in the shader.
  29032. */
  29033. samplers: string[];
  29034. /**
  29035. * Define statements that will be set in the shader.
  29036. */
  29037. defines: any;
  29038. /**
  29039. * Possible fallbacks for this effect to improve performance when needed.
  29040. */
  29041. fallbacks: Nullable<EffectFallbacks>;
  29042. /**
  29043. * Callback that will be called when the shader is compiled.
  29044. */
  29045. onCompiled: Nullable<(effect: Effect) => void>;
  29046. /**
  29047. * Callback that will be called if an error occurs during shader compilation.
  29048. */
  29049. onError: Nullable<(effect: Effect, errors: string) => void>;
  29050. /**
  29051. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29052. */
  29053. indexParameters: any;
  29054. /**
  29055. * Max number of lights that can be used in the shader.
  29056. */
  29057. maxSimultaneousLights: number;
  29058. /**
  29059. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29060. */
  29061. transformFeedbackVaryings: Nullable<string[]>;
  29062. }
  29063. /**
  29064. * Effect containing vertex and fragment shader that can be executed on an object.
  29065. */
  29066. export class Effect implements IDisposable {
  29067. /**
  29068. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29069. */
  29070. static ShadersRepository: string;
  29071. /**
  29072. * Name of the effect.
  29073. */
  29074. name: any;
  29075. /**
  29076. * String container all the define statements that should be set on the shader.
  29077. */
  29078. defines: string;
  29079. /**
  29080. * Callback that will be called when the shader is compiled.
  29081. */
  29082. onCompiled: Nullable<(effect: Effect) => void>;
  29083. /**
  29084. * Callback that will be called if an error occurs during shader compilation.
  29085. */
  29086. onError: Nullable<(effect: Effect, errors: string) => void>;
  29087. /**
  29088. * Callback that will be called when effect is bound.
  29089. */
  29090. onBind: Nullable<(effect: Effect) => void>;
  29091. /**
  29092. * Unique ID of the effect.
  29093. */
  29094. uniqueId: number;
  29095. /**
  29096. * Observable that will be called when the shader is compiled.
  29097. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29098. */
  29099. onCompileObservable: Observable<Effect>;
  29100. /**
  29101. * Observable that will be called if an error occurs during shader compilation.
  29102. */
  29103. onErrorObservable: Observable<Effect>;
  29104. /** @hidden */
  29105. _onBindObservable: Nullable<Observable<Effect>>;
  29106. /**
  29107. * Observable that will be called when effect is bound.
  29108. */
  29109. readonly onBindObservable: Observable<Effect>;
  29110. /** @hidden */
  29111. _bonesComputationForcedToCPU: boolean;
  29112. private static _uniqueIdSeed;
  29113. private _engine;
  29114. private _uniformBuffersNames;
  29115. private _uniformsNames;
  29116. private _samplerList;
  29117. private _samplers;
  29118. private _isReady;
  29119. private _compilationError;
  29120. private _attributesNames;
  29121. private _attributes;
  29122. private _uniforms;
  29123. /**
  29124. * Key for the effect.
  29125. * @hidden
  29126. */
  29127. _key: string;
  29128. private _indexParameters;
  29129. private _fallbacks;
  29130. private _vertexSourceCode;
  29131. private _fragmentSourceCode;
  29132. private _vertexSourceCodeOverride;
  29133. private _fragmentSourceCodeOverride;
  29134. private _transformFeedbackVaryings;
  29135. /**
  29136. * Compiled shader to webGL program.
  29137. * @hidden
  29138. */
  29139. _pipelineContext: Nullable<IPipelineContext>;
  29140. private _valueCache;
  29141. private static _baseCache;
  29142. /**
  29143. * Instantiates an effect.
  29144. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29145. * @param baseName Name of the effect.
  29146. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29147. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29148. * @param samplers List of sampler variables that will be passed to the shader.
  29149. * @param engine Engine to be used to render the effect
  29150. * @param defines Define statements to be added to the shader.
  29151. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29152. * @param onCompiled Callback that will be called when the shader is compiled.
  29153. * @param onError Callback that will be called if an error occurs during shader compilation.
  29154. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29155. */
  29156. 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);
  29157. /**
  29158. * Unique key for this effect
  29159. */
  29160. readonly key: string;
  29161. /**
  29162. * If the effect has been compiled and prepared.
  29163. * @returns if the effect is compiled and prepared.
  29164. */
  29165. isReady(): boolean;
  29166. /**
  29167. * The engine the effect was initialized with.
  29168. * @returns the engine.
  29169. */
  29170. getEngine(): Engine;
  29171. /**
  29172. * The pipeline context for this effect
  29173. * @returns the associated pipeline context
  29174. */
  29175. getPipelineContext(): Nullable<IPipelineContext>;
  29176. /**
  29177. * The set of names of attribute variables for the shader.
  29178. * @returns An array of attribute names.
  29179. */
  29180. getAttributesNames(): string[];
  29181. /**
  29182. * Returns the attribute at the given index.
  29183. * @param index The index of the attribute.
  29184. * @returns The location of the attribute.
  29185. */
  29186. getAttributeLocation(index: number): number;
  29187. /**
  29188. * Returns the attribute based on the name of the variable.
  29189. * @param name of the attribute to look up.
  29190. * @returns the attribute location.
  29191. */
  29192. getAttributeLocationByName(name: string): number;
  29193. /**
  29194. * The number of attributes.
  29195. * @returns the numnber of attributes.
  29196. */
  29197. getAttributesCount(): number;
  29198. /**
  29199. * Gets the index of a uniform variable.
  29200. * @param uniformName of the uniform to look up.
  29201. * @returns the index.
  29202. */
  29203. getUniformIndex(uniformName: string): number;
  29204. /**
  29205. * Returns the attribute based on the name of the variable.
  29206. * @param uniformName of the uniform to look up.
  29207. * @returns the location of the uniform.
  29208. */
  29209. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29210. /**
  29211. * Returns an array of sampler variable names
  29212. * @returns The array of sampler variable neames.
  29213. */
  29214. getSamplers(): string[];
  29215. /**
  29216. * The error from the last compilation.
  29217. * @returns the error string.
  29218. */
  29219. getCompilationError(): string;
  29220. /**
  29221. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29222. * @param func The callback to be used.
  29223. */
  29224. executeWhenCompiled(func: (effect: Effect) => void): void;
  29225. private _checkIsReady;
  29226. /** @hidden */
  29227. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29228. /** @hidden */
  29229. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29230. /** @hidden */
  29231. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29232. private _processShaderConversion;
  29233. private _processIncludes;
  29234. private _processPrecision;
  29235. /**
  29236. * Recompiles the webGL program
  29237. * @param vertexSourceCode The source code for the vertex shader.
  29238. * @param fragmentSourceCode The source code for the fragment shader.
  29239. * @param onCompiled Callback called when completed.
  29240. * @param onError Callback called on error.
  29241. * @hidden
  29242. */
  29243. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29244. /**
  29245. * Prepares the effect
  29246. * @hidden
  29247. */
  29248. _prepareEffect(): void;
  29249. /**
  29250. * Checks if the effect is supported. (Must be called after compilation)
  29251. */
  29252. readonly isSupported: boolean;
  29253. /**
  29254. * Binds a texture to the engine to be used as output of the shader.
  29255. * @param channel Name of the output variable.
  29256. * @param texture Texture to bind.
  29257. * @hidden
  29258. */
  29259. _bindTexture(channel: string, texture: InternalTexture): void;
  29260. /**
  29261. * Sets a texture on the engine to be used in the shader.
  29262. * @param channel Name of the sampler variable.
  29263. * @param texture Texture to set.
  29264. */
  29265. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29266. /**
  29267. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29268. * @param channel Name of the sampler variable.
  29269. * @param texture Texture to set.
  29270. */
  29271. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29272. /**
  29273. * Sets an array of textures on the engine to be used in the shader.
  29274. * @param channel Name of the variable.
  29275. * @param textures Textures to set.
  29276. */
  29277. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29278. /**
  29279. * 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)
  29280. * @param channel Name of the sampler variable.
  29281. * @param postProcess Post process to get the input texture from.
  29282. */
  29283. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29284. /**
  29285. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29286. * 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)
  29287. * @param channel Name of the sampler variable.
  29288. * @param postProcess Post process to get the output texture from.
  29289. */
  29290. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29291. /** @hidden */
  29292. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29293. /** @hidden */
  29294. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29295. /** @hidden */
  29296. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29297. /** @hidden */
  29298. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29299. /**
  29300. * Binds a buffer to a uniform.
  29301. * @param buffer Buffer to bind.
  29302. * @param name Name of the uniform variable to bind to.
  29303. */
  29304. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29305. /**
  29306. * Binds block to a uniform.
  29307. * @param blockName Name of the block to bind.
  29308. * @param index Index to bind.
  29309. */
  29310. bindUniformBlock(blockName: string, index: number): void;
  29311. /**
  29312. * Sets an interger value on a uniform variable.
  29313. * @param uniformName Name of the variable.
  29314. * @param value Value to be set.
  29315. * @returns this effect.
  29316. */
  29317. setInt(uniformName: string, value: number): Effect;
  29318. /**
  29319. * Sets an int array on a uniform variable.
  29320. * @param uniformName Name of the variable.
  29321. * @param array array to be set.
  29322. * @returns this effect.
  29323. */
  29324. setIntArray(uniformName: string, array: Int32Array): Effect;
  29325. /**
  29326. * 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)
  29327. * @param uniformName Name of the variable.
  29328. * @param array array to be set.
  29329. * @returns this effect.
  29330. */
  29331. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29332. /**
  29333. * 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)
  29334. * @param uniformName Name of the variable.
  29335. * @param array array to be set.
  29336. * @returns this effect.
  29337. */
  29338. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29339. /**
  29340. * 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)
  29341. * @param uniformName Name of the variable.
  29342. * @param array array to be set.
  29343. * @returns this effect.
  29344. */
  29345. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29346. /**
  29347. * Sets an float array on a uniform variable.
  29348. * @param uniformName Name of the variable.
  29349. * @param array array to be set.
  29350. * @returns this effect.
  29351. */
  29352. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29353. /**
  29354. * 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)
  29355. * @param uniformName Name of the variable.
  29356. * @param array array to be set.
  29357. * @returns this effect.
  29358. */
  29359. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29360. /**
  29361. * 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)
  29362. * @param uniformName Name of the variable.
  29363. * @param array array to be set.
  29364. * @returns this effect.
  29365. */
  29366. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29367. /**
  29368. * 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)
  29369. * @param uniformName Name of the variable.
  29370. * @param array array to be set.
  29371. * @returns this effect.
  29372. */
  29373. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29374. /**
  29375. * Sets an array on a uniform variable.
  29376. * @param uniformName Name of the variable.
  29377. * @param array array to be set.
  29378. * @returns this effect.
  29379. */
  29380. setArray(uniformName: string, array: number[]): Effect;
  29381. /**
  29382. * 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)
  29383. * @param uniformName Name of the variable.
  29384. * @param array array to be set.
  29385. * @returns this effect.
  29386. */
  29387. setArray2(uniformName: string, array: number[]): Effect;
  29388. /**
  29389. * 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)
  29390. * @param uniformName Name of the variable.
  29391. * @param array array to be set.
  29392. * @returns this effect.
  29393. */
  29394. setArray3(uniformName: string, array: number[]): Effect;
  29395. /**
  29396. * 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)
  29397. * @param uniformName Name of the variable.
  29398. * @param array array to be set.
  29399. * @returns this effect.
  29400. */
  29401. setArray4(uniformName: string, array: number[]): Effect;
  29402. /**
  29403. * Sets matrices on a uniform variable.
  29404. * @param uniformName Name of the variable.
  29405. * @param matrices matrices to be set.
  29406. * @returns this effect.
  29407. */
  29408. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29409. /**
  29410. * Sets matrix on a uniform variable.
  29411. * @param uniformName Name of the variable.
  29412. * @param matrix matrix to be set.
  29413. * @returns this effect.
  29414. */
  29415. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29416. /**
  29417. * 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)
  29418. * @param uniformName Name of the variable.
  29419. * @param matrix matrix to be set.
  29420. * @returns this effect.
  29421. */
  29422. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29423. /**
  29424. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29425. * @param uniformName Name of the variable.
  29426. * @param matrix matrix to be set.
  29427. * @returns this effect.
  29428. */
  29429. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29430. /**
  29431. * Sets a float on a uniform variable.
  29432. * @param uniformName Name of the variable.
  29433. * @param value value to be set.
  29434. * @returns this effect.
  29435. */
  29436. setFloat(uniformName: string, value: number): Effect;
  29437. /**
  29438. * Sets a boolean on a uniform variable.
  29439. * @param uniformName Name of the variable.
  29440. * @param bool value to be set.
  29441. * @returns this effect.
  29442. */
  29443. setBool(uniformName: string, bool: boolean): Effect;
  29444. /**
  29445. * Sets a Vector2 on a uniform variable.
  29446. * @param uniformName Name of the variable.
  29447. * @param vector2 vector2 to be set.
  29448. * @returns this effect.
  29449. */
  29450. setVector2(uniformName: string, vector2: Vector2): Effect;
  29451. /**
  29452. * Sets a float2 on a uniform variable.
  29453. * @param uniformName Name of the variable.
  29454. * @param x First float in float2.
  29455. * @param y Second float in float2.
  29456. * @returns this effect.
  29457. */
  29458. setFloat2(uniformName: string, x: number, y: number): Effect;
  29459. /**
  29460. * Sets a Vector3 on a uniform variable.
  29461. * @param uniformName Name of the variable.
  29462. * @param vector3 Value to be set.
  29463. * @returns this effect.
  29464. */
  29465. setVector3(uniformName: string, vector3: Vector3): Effect;
  29466. /**
  29467. * Sets a float3 on a uniform variable.
  29468. * @param uniformName Name of the variable.
  29469. * @param x First float in float3.
  29470. * @param y Second float in float3.
  29471. * @param z Third float in float3.
  29472. * @returns this effect.
  29473. */
  29474. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29475. /**
  29476. * Sets a Vector4 on a uniform variable.
  29477. * @param uniformName Name of the variable.
  29478. * @param vector4 Value to be set.
  29479. * @returns this effect.
  29480. */
  29481. setVector4(uniformName: string, vector4: Vector4): Effect;
  29482. /**
  29483. * Sets a float4 on a uniform variable.
  29484. * @param uniformName Name of the variable.
  29485. * @param x First float in float4.
  29486. * @param y Second float in float4.
  29487. * @param z Third float in float4.
  29488. * @param w Fourth float in float4.
  29489. * @returns this effect.
  29490. */
  29491. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29492. /**
  29493. * Sets a Color3 on a uniform variable.
  29494. * @param uniformName Name of the variable.
  29495. * @param color3 Value to be set.
  29496. * @returns this effect.
  29497. */
  29498. setColor3(uniformName: string, color3: Color3): Effect;
  29499. /**
  29500. * Sets a Color4 on a uniform variable.
  29501. * @param uniformName Name of the variable.
  29502. * @param color3 Value to be set.
  29503. * @param alpha Alpha value to be set.
  29504. * @returns this effect.
  29505. */
  29506. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29507. /**
  29508. * Sets a Color4 on a uniform variable
  29509. * @param uniformName defines the name of the variable
  29510. * @param color4 defines the value to be set
  29511. * @returns this effect.
  29512. */
  29513. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29514. /** Release all associated resources */
  29515. dispose(): void;
  29516. /**
  29517. * This function will add a new shader to the shader store
  29518. * @param name the name of the shader
  29519. * @param pixelShader optional pixel shader content
  29520. * @param vertexShader optional vertex shader content
  29521. */
  29522. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29523. /**
  29524. * Store of each shader (The can be looked up using effect.key)
  29525. */
  29526. static ShadersStore: {
  29527. [key: string]: string;
  29528. };
  29529. /**
  29530. * Store of each included file for a shader (The can be looked up using effect.key)
  29531. */
  29532. static IncludesShadersStore: {
  29533. [key: string]: string;
  29534. };
  29535. /**
  29536. * Resets the cache of effects.
  29537. */
  29538. static ResetCache(): void;
  29539. }
  29540. }
  29541. declare module BABYLON {
  29542. /**
  29543. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29544. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29545. * 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;
  29546. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29547. */
  29548. export class ColorCurves {
  29549. private _dirty;
  29550. private _tempColor;
  29551. private _globalCurve;
  29552. private _highlightsCurve;
  29553. private _midtonesCurve;
  29554. private _shadowsCurve;
  29555. private _positiveCurve;
  29556. private _negativeCurve;
  29557. private _globalHue;
  29558. private _globalDensity;
  29559. private _globalSaturation;
  29560. private _globalExposure;
  29561. /**
  29562. * Gets the global Hue value.
  29563. * 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).
  29564. */
  29565. /**
  29566. * Sets the global Hue value.
  29567. * 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).
  29568. */
  29569. globalHue: number;
  29570. /**
  29571. * Gets the global Density value.
  29572. * 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.
  29573. * Values less than zero provide a filter of opposite hue.
  29574. */
  29575. /**
  29576. * Sets the global Density value.
  29577. * 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.
  29578. * Values less than zero provide a filter of opposite hue.
  29579. */
  29580. globalDensity: number;
  29581. /**
  29582. * Gets the global Saturation value.
  29583. * 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.
  29584. */
  29585. /**
  29586. * Sets the global Saturation value.
  29587. * 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.
  29588. */
  29589. globalSaturation: number;
  29590. /**
  29591. * Gets the global Exposure value.
  29592. * 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.
  29593. */
  29594. /**
  29595. * Sets the global Exposure value.
  29596. * 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.
  29597. */
  29598. globalExposure: number;
  29599. private _highlightsHue;
  29600. private _highlightsDensity;
  29601. private _highlightsSaturation;
  29602. private _highlightsExposure;
  29603. /**
  29604. * Gets the highlights Hue value.
  29605. * 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).
  29606. */
  29607. /**
  29608. * Sets the highlights Hue value.
  29609. * 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).
  29610. */
  29611. highlightsHue: number;
  29612. /**
  29613. * Gets the highlights Density value.
  29614. * 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.
  29615. * Values less than zero provide a filter of opposite hue.
  29616. */
  29617. /**
  29618. * Sets the highlights Density value.
  29619. * 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.
  29620. * Values less than zero provide a filter of opposite hue.
  29621. */
  29622. highlightsDensity: number;
  29623. /**
  29624. * Gets the highlights Saturation value.
  29625. * 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.
  29626. */
  29627. /**
  29628. * Sets the highlights Saturation value.
  29629. * 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.
  29630. */
  29631. highlightsSaturation: number;
  29632. /**
  29633. * Gets the highlights Exposure value.
  29634. * 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.
  29635. */
  29636. /**
  29637. * Sets the highlights Exposure value.
  29638. * 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.
  29639. */
  29640. highlightsExposure: number;
  29641. private _midtonesHue;
  29642. private _midtonesDensity;
  29643. private _midtonesSaturation;
  29644. private _midtonesExposure;
  29645. /**
  29646. * Gets the midtones Hue value.
  29647. * 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).
  29648. */
  29649. /**
  29650. * Sets the midtones Hue value.
  29651. * 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).
  29652. */
  29653. midtonesHue: number;
  29654. /**
  29655. * Gets the midtones Density value.
  29656. * 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.
  29657. * Values less than zero provide a filter of opposite hue.
  29658. */
  29659. /**
  29660. * Sets the midtones Density value.
  29661. * 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.
  29662. * Values less than zero provide a filter of opposite hue.
  29663. */
  29664. midtonesDensity: number;
  29665. /**
  29666. * Gets the midtones Saturation value.
  29667. * 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.
  29668. */
  29669. /**
  29670. * Sets the midtones Saturation value.
  29671. * 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.
  29672. */
  29673. midtonesSaturation: number;
  29674. /**
  29675. * Gets the midtones Exposure value.
  29676. * 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.
  29677. */
  29678. /**
  29679. * Sets the midtones Exposure value.
  29680. * 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.
  29681. */
  29682. midtonesExposure: number;
  29683. private _shadowsHue;
  29684. private _shadowsDensity;
  29685. private _shadowsSaturation;
  29686. private _shadowsExposure;
  29687. /**
  29688. * Gets the shadows Hue value.
  29689. * 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).
  29690. */
  29691. /**
  29692. * Sets the shadows Hue value.
  29693. * 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).
  29694. */
  29695. shadowsHue: number;
  29696. /**
  29697. * Gets the shadows Density value.
  29698. * 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.
  29699. * Values less than zero provide a filter of opposite hue.
  29700. */
  29701. /**
  29702. * Sets the shadows Density value.
  29703. * 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.
  29704. * Values less than zero provide a filter of opposite hue.
  29705. */
  29706. shadowsDensity: number;
  29707. /**
  29708. * Gets the shadows Saturation value.
  29709. * 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.
  29710. */
  29711. /**
  29712. * Sets the shadows Saturation value.
  29713. * 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.
  29714. */
  29715. shadowsSaturation: number;
  29716. /**
  29717. * Gets the shadows Exposure value.
  29718. * 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.
  29719. */
  29720. /**
  29721. * Sets the shadows Exposure value.
  29722. * 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.
  29723. */
  29724. shadowsExposure: number;
  29725. /**
  29726. * Returns the class name
  29727. * @returns The class name
  29728. */
  29729. getClassName(): string;
  29730. /**
  29731. * Binds the color curves to the shader.
  29732. * @param colorCurves The color curve to bind
  29733. * @param effect The effect to bind to
  29734. * @param positiveUniform The positive uniform shader parameter
  29735. * @param neutralUniform The neutral uniform shader parameter
  29736. * @param negativeUniform The negative uniform shader parameter
  29737. */
  29738. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29739. /**
  29740. * Prepare the list of uniforms associated with the ColorCurves effects.
  29741. * @param uniformsList The list of uniforms used in the effect
  29742. */
  29743. static PrepareUniforms(uniformsList: string[]): void;
  29744. /**
  29745. * Returns color grading data based on a hue, density, saturation and exposure value.
  29746. * @param filterHue The hue of the color filter.
  29747. * @param filterDensity The density of the color filter.
  29748. * @param saturation The saturation.
  29749. * @param exposure The exposure.
  29750. * @param result The result data container.
  29751. */
  29752. private getColorGradingDataToRef;
  29753. /**
  29754. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29755. * @param value The input slider value in range [-100,100].
  29756. * @returns Adjusted value.
  29757. */
  29758. private static applyColorGradingSliderNonlinear;
  29759. /**
  29760. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29761. * @param hue The hue (H) input.
  29762. * @param saturation The saturation (S) input.
  29763. * @param brightness The brightness (B) input.
  29764. * @result An RGBA color represented as Vector4.
  29765. */
  29766. private static fromHSBToRef;
  29767. /**
  29768. * Returns a value clamped between min and max
  29769. * @param value The value to clamp
  29770. * @param min The minimum of value
  29771. * @param max The maximum of value
  29772. * @returns The clamped value.
  29773. */
  29774. private static clamp;
  29775. /**
  29776. * Clones the current color curve instance.
  29777. * @return The cloned curves
  29778. */
  29779. clone(): ColorCurves;
  29780. /**
  29781. * Serializes the current color curve instance to a json representation.
  29782. * @return a JSON representation
  29783. */
  29784. serialize(): any;
  29785. /**
  29786. * Parses the color curve from a json representation.
  29787. * @param source the JSON source to parse
  29788. * @return The parsed curves
  29789. */
  29790. static Parse(source: any): ColorCurves;
  29791. }
  29792. }
  29793. declare module BABYLON {
  29794. /**
  29795. * Interface to follow in your material defines to integrate easily the
  29796. * Image proccessing functions.
  29797. * @hidden
  29798. */
  29799. export interface IImageProcessingConfigurationDefines {
  29800. IMAGEPROCESSING: boolean;
  29801. VIGNETTE: boolean;
  29802. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29803. VIGNETTEBLENDMODEOPAQUE: boolean;
  29804. TONEMAPPING: boolean;
  29805. TONEMAPPING_ACES: boolean;
  29806. CONTRAST: boolean;
  29807. EXPOSURE: boolean;
  29808. COLORCURVES: boolean;
  29809. COLORGRADING: boolean;
  29810. COLORGRADING3D: boolean;
  29811. SAMPLER3DGREENDEPTH: boolean;
  29812. SAMPLER3DBGRMAP: boolean;
  29813. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29814. }
  29815. /**
  29816. * @hidden
  29817. */
  29818. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29819. IMAGEPROCESSING: boolean;
  29820. VIGNETTE: boolean;
  29821. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29822. VIGNETTEBLENDMODEOPAQUE: boolean;
  29823. TONEMAPPING: boolean;
  29824. TONEMAPPING_ACES: boolean;
  29825. CONTRAST: boolean;
  29826. COLORCURVES: boolean;
  29827. COLORGRADING: boolean;
  29828. COLORGRADING3D: boolean;
  29829. SAMPLER3DGREENDEPTH: boolean;
  29830. SAMPLER3DBGRMAP: boolean;
  29831. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29832. EXPOSURE: boolean;
  29833. constructor();
  29834. }
  29835. /**
  29836. * This groups together the common properties used for image processing either in direct forward pass
  29837. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29838. * or not.
  29839. */
  29840. export class ImageProcessingConfiguration {
  29841. /**
  29842. * Default tone mapping applied in BabylonJS.
  29843. */
  29844. static readonly TONEMAPPING_STANDARD: number;
  29845. /**
  29846. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29847. * to other engines rendering to increase portability.
  29848. */
  29849. static readonly TONEMAPPING_ACES: number;
  29850. /**
  29851. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29852. */
  29853. colorCurves: Nullable<ColorCurves>;
  29854. private _colorCurvesEnabled;
  29855. /**
  29856. * Gets wether the color curves effect is enabled.
  29857. */
  29858. /**
  29859. * Sets wether the color curves effect is enabled.
  29860. */
  29861. colorCurvesEnabled: boolean;
  29862. private _colorGradingTexture;
  29863. /**
  29864. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29865. */
  29866. /**
  29867. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29868. */
  29869. colorGradingTexture: Nullable<BaseTexture>;
  29870. private _colorGradingEnabled;
  29871. /**
  29872. * Gets wether the color grading effect is enabled.
  29873. */
  29874. /**
  29875. * Sets wether the color grading effect is enabled.
  29876. */
  29877. colorGradingEnabled: boolean;
  29878. private _colorGradingWithGreenDepth;
  29879. /**
  29880. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29881. */
  29882. /**
  29883. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29884. */
  29885. colorGradingWithGreenDepth: boolean;
  29886. private _colorGradingBGR;
  29887. /**
  29888. * Gets wether the color grading texture contains BGR values.
  29889. */
  29890. /**
  29891. * Sets wether the color grading texture contains BGR values.
  29892. */
  29893. colorGradingBGR: boolean;
  29894. /** @hidden */
  29895. _exposure: number;
  29896. /**
  29897. * Gets the Exposure used in the effect.
  29898. */
  29899. /**
  29900. * Sets the Exposure used in the effect.
  29901. */
  29902. exposure: number;
  29903. private _toneMappingEnabled;
  29904. /**
  29905. * Gets wether the tone mapping effect is enabled.
  29906. */
  29907. /**
  29908. * Sets wether the tone mapping effect is enabled.
  29909. */
  29910. toneMappingEnabled: boolean;
  29911. private _toneMappingType;
  29912. /**
  29913. * Gets the type of tone mapping effect.
  29914. */
  29915. /**
  29916. * Sets the type of tone mapping effect used in BabylonJS.
  29917. */
  29918. toneMappingType: number;
  29919. protected _contrast: number;
  29920. /**
  29921. * Gets the contrast used in the effect.
  29922. */
  29923. /**
  29924. * Sets the contrast used in the effect.
  29925. */
  29926. contrast: number;
  29927. /**
  29928. * Vignette stretch size.
  29929. */
  29930. vignetteStretch: number;
  29931. /**
  29932. * Vignette centre X Offset.
  29933. */
  29934. vignetteCentreX: number;
  29935. /**
  29936. * Vignette centre Y Offset.
  29937. */
  29938. vignetteCentreY: number;
  29939. /**
  29940. * Vignette weight or intensity of the vignette effect.
  29941. */
  29942. vignetteWeight: number;
  29943. /**
  29944. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29945. * if vignetteEnabled is set to true.
  29946. */
  29947. vignetteColor: Color4;
  29948. /**
  29949. * Camera field of view used by the Vignette effect.
  29950. */
  29951. vignetteCameraFov: number;
  29952. private _vignetteBlendMode;
  29953. /**
  29954. * Gets the vignette blend mode allowing different kind of effect.
  29955. */
  29956. /**
  29957. * Sets the vignette blend mode allowing different kind of effect.
  29958. */
  29959. vignetteBlendMode: number;
  29960. private _vignetteEnabled;
  29961. /**
  29962. * Gets wether the vignette effect is enabled.
  29963. */
  29964. /**
  29965. * Sets wether the vignette effect is enabled.
  29966. */
  29967. vignetteEnabled: boolean;
  29968. private _applyByPostProcess;
  29969. /**
  29970. * Gets wether the image processing is applied through a post process or not.
  29971. */
  29972. /**
  29973. * Sets wether the image processing is applied through a post process or not.
  29974. */
  29975. applyByPostProcess: boolean;
  29976. private _isEnabled;
  29977. /**
  29978. * Gets wether the image processing is enabled or not.
  29979. */
  29980. /**
  29981. * Sets wether the image processing is enabled or not.
  29982. */
  29983. isEnabled: boolean;
  29984. /**
  29985. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29986. */
  29987. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29988. /**
  29989. * Method called each time the image processing information changes requires to recompile the effect.
  29990. */
  29991. protected _updateParameters(): void;
  29992. /**
  29993. * Gets the current class name.
  29994. * @return "ImageProcessingConfiguration"
  29995. */
  29996. getClassName(): string;
  29997. /**
  29998. * Prepare the list of uniforms associated with the Image Processing effects.
  29999. * @param uniforms The list of uniforms used in the effect
  30000. * @param defines the list of defines currently in use
  30001. */
  30002. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30003. /**
  30004. * Prepare the list of samplers associated with the Image Processing effects.
  30005. * @param samplersList The list of uniforms used in the effect
  30006. * @param defines the list of defines currently in use
  30007. */
  30008. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30009. /**
  30010. * Prepare the list of defines associated to the shader.
  30011. * @param defines the list of defines to complete
  30012. * @param forPostProcess Define if we are currently in post process mode or not
  30013. */
  30014. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30015. /**
  30016. * Returns true if all the image processing information are ready.
  30017. * @returns True if ready, otherwise, false
  30018. */
  30019. isReady(): boolean;
  30020. /**
  30021. * Binds the image processing to the shader.
  30022. * @param effect The effect to bind to
  30023. * @param aspectRatio Define the current aspect ratio of the effect
  30024. */
  30025. bind(effect: Effect, aspectRatio?: number): void;
  30026. /**
  30027. * Clones the current image processing instance.
  30028. * @return The cloned image processing
  30029. */
  30030. clone(): ImageProcessingConfiguration;
  30031. /**
  30032. * Serializes the current image processing instance to a json representation.
  30033. * @return a JSON representation
  30034. */
  30035. serialize(): any;
  30036. /**
  30037. * Parses the image processing from a json representation.
  30038. * @param source the JSON source to parse
  30039. * @return The parsed image processing
  30040. */
  30041. static Parse(source: any): ImageProcessingConfiguration;
  30042. private static _VIGNETTEMODE_MULTIPLY;
  30043. private static _VIGNETTEMODE_OPAQUE;
  30044. /**
  30045. * Used to apply the vignette as a mix with the pixel color.
  30046. */
  30047. static readonly VIGNETTEMODE_MULTIPLY: number;
  30048. /**
  30049. * Used to apply the vignette as a replacement of the pixel color.
  30050. */
  30051. static readonly VIGNETTEMODE_OPAQUE: number;
  30052. }
  30053. }
  30054. declare module BABYLON {
  30055. /**
  30056. * This represents all the required information to add a fresnel effect on a material:
  30057. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30058. */
  30059. export class FresnelParameters {
  30060. private _isEnabled;
  30061. /**
  30062. * Define if the fresnel effect is enable or not.
  30063. */
  30064. isEnabled: boolean;
  30065. /**
  30066. * Define the color used on edges (grazing angle)
  30067. */
  30068. leftColor: Color3;
  30069. /**
  30070. * Define the color used on center
  30071. */
  30072. rightColor: Color3;
  30073. /**
  30074. * Define bias applied to computed fresnel term
  30075. */
  30076. bias: number;
  30077. /**
  30078. * Defined the power exponent applied to fresnel term
  30079. */
  30080. power: number;
  30081. /**
  30082. * Clones the current fresnel and its valuues
  30083. * @returns a clone fresnel configuration
  30084. */
  30085. clone(): FresnelParameters;
  30086. /**
  30087. * Serializes the current fresnel parameters to a JSON representation.
  30088. * @return the JSON serialization
  30089. */
  30090. serialize(): any;
  30091. /**
  30092. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30093. * @param parsedFresnelParameters Define the JSON representation
  30094. * @returns the parsed parameters
  30095. */
  30096. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30097. }
  30098. }
  30099. declare module BABYLON {
  30100. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30101. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30102. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30103. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30104. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30105. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30106. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30107. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30108. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30109. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30110. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30111. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30112. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30113. /**
  30114. * Decorator used to define property that can be serialized as reference to a camera
  30115. * @param sourceName defines the name of the property to decorate
  30116. */
  30117. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30118. /**
  30119. * Class used to help serialization objects
  30120. */
  30121. export class SerializationHelper {
  30122. /** hidden */
  30123. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30124. /** hidden */
  30125. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30126. /** hidden */
  30127. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30128. /** hidden */
  30129. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30130. /**
  30131. * Appends the serialized animations from the source animations
  30132. * @param source Source containing the animations
  30133. * @param destination Target to store the animations
  30134. */
  30135. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30136. /**
  30137. * Static function used to serialized a specific entity
  30138. * @param entity defines the entity to serialize
  30139. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30140. * @returns a JSON compatible object representing the serialization of the entity
  30141. */
  30142. static Serialize<T>(entity: T, serializationObject?: any): any;
  30143. /**
  30144. * Creates a new entity from a serialization data object
  30145. * @param creationFunction defines a function used to instanciated the new entity
  30146. * @param source defines the source serialization data
  30147. * @param scene defines the hosting scene
  30148. * @param rootUrl defines the root url for resources
  30149. * @returns a new entity
  30150. */
  30151. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30152. /**
  30153. * Clones an object
  30154. * @param creationFunction defines the function used to instanciate the new object
  30155. * @param source defines the source object
  30156. * @returns the cloned object
  30157. */
  30158. static Clone<T>(creationFunction: () => T, source: T): T;
  30159. /**
  30160. * Instanciates a new object based on a source one (some data will be shared between both object)
  30161. * @param creationFunction defines the function used to instanciate the new object
  30162. * @param source defines the source object
  30163. * @returns the new object
  30164. */
  30165. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30166. }
  30167. }
  30168. declare module BABYLON {
  30169. /**
  30170. * This is the base class of all the camera used in the application.
  30171. * @see http://doc.babylonjs.com/features/cameras
  30172. */
  30173. export class Camera extends Node {
  30174. /** @hidden */
  30175. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30176. /**
  30177. * This is the default projection mode used by the cameras.
  30178. * It helps recreating a feeling of perspective and better appreciate depth.
  30179. * This is the best way to simulate real life cameras.
  30180. */
  30181. static readonly PERSPECTIVE_CAMERA: number;
  30182. /**
  30183. * This helps creating camera with an orthographic mode.
  30184. * 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.
  30185. */
  30186. static readonly ORTHOGRAPHIC_CAMERA: number;
  30187. /**
  30188. * This is the default FOV mode for perspective cameras.
  30189. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30190. */
  30191. static readonly FOVMODE_VERTICAL_FIXED: number;
  30192. /**
  30193. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30194. */
  30195. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30196. /**
  30197. * This specifies ther is no need for a camera rig.
  30198. * Basically only one eye is rendered corresponding to the camera.
  30199. */
  30200. static readonly RIG_MODE_NONE: number;
  30201. /**
  30202. * Simulates a camera Rig with one blue eye and one red eye.
  30203. * This can be use with 3d blue and red glasses.
  30204. */
  30205. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30206. /**
  30207. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30208. */
  30209. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30210. /**
  30211. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30212. */
  30213. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30214. /**
  30215. * Defines that both eyes of the camera will be rendered over under each other.
  30216. */
  30217. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30218. /**
  30219. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30220. */
  30221. static readonly RIG_MODE_VR: number;
  30222. /**
  30223. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30224. */
  30225. static readonly RIG_MODE_WEBVR: number;
  30226. /**
  30227. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30228. */
  30229. static readonly RIG_MODE_CUSTOM: number;
  30230. /**
  30231. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30232. */
  30233. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30234. /**
  30235. * Define the input manager associated with the camera.
  30236. */
  30237. inputs: CameraInputsManager<Camera>;
  30238. /** @hidden */
  30239. _position: Vector3;
  30240. /**
  30241. * Define the current local position of the camera in the scene
  30242. */
  30243. position: Vector3;
  30244. /**
  30245. * The vector the camera should consider as up.
  30246. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30247. */
  30248. upVector: Vector3;
  30249. /**
  30250. * Define the current limit on the left side for an orthographic camera
  30251. * In scene unit
  30252. */
  30253. orthoLeft: Nullable<number>;
  30254. /**
  30255. * Define the current limit on the right side for an orthographic camera
  30256. * In scene unit
  30257. */
  30258. orthoRight: Nullable<number>;
  30259. /**
  30260. * Define the current limit on the bottom side for an orthographic camera
  30261. * In scene unit
  30262. */
  30263. orthoBottom: Nullable<number>;
  30264. /**
  30265. * Define the current limit on the top side for an orthographic camera
  30266. * In scene unit
  30267. */
  30268. orthoTop: Nullable<number>;
  30269. /**
  30270. * Field Of View is set in Radians. (default is 0.8)
  30271. */
  30272. fov: number;
  30273. /**
  30274. * Define the minimum distance the camera can see from.
  30275. * This is important to note that the depth buffer are not infinite and the closer it starts
  30276. * the more your scene might encounter depth fighting issue.
  30277. */
  30278. minZ: number;
  30279. /**
  30280. * Define the maximum distance the camera can see to.
  30281. * This is important to note that the depth buffer are not infinite and the further it end
  30282. * the more your scene might encounter depth fighting issue.
  30283. */
  30284. maxZ: number;
  30285. /**
  30286. * Define the default inertia of the camera.
  30287. * This helps giving a smooth feeling to the camera movement.
  30288. */
  30289. inertia: number;
  30290. /**
  30291. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30292. */
  30293. mode: number;
  30294. /**
  30295. * Define wether the camera is intermediate.
  30296. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30297. */
  30298. isIntermediate: boolean;
  30299. /**
  30300. * Define the viewport of the camera.
  30301. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30302. */
  30303. viewport: Viewport;
  30304. /**
  30305. * Restricts the camera to viewing objects with the same layerMask.
  30306. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30307. */
  30308. layerMask: number;
  30309. /**
  30310. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30311. */
  30312. fovMode: number;
  30313. /**
  30314. * Rig mode of the camera.
  30315. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30316. * This is normally controlled byt the camera themselves as internal use.
  30317. */
  30318. cameraRigMode: number;
  30319. /**
  30320. * Defines the distance between both "eyes" in case of a RIG
  30321. */
  30322. interaxialDistance: number;
  30323. /**
  30324. * Defines if stereoscopic rendering is done side by side or over under.
  30325. */
  30326. isStereoscopicSideBySide: boolean;
  30327. /**
  30328. * 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
  30329. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30330. * else in the scene.
  30331. */
  30332. customRenderTargets: RenderTargetTexture[];
  30333. /**
  30334. * When set, the camera will render to this render target instead of the default canvas
  30335. */
  30336. outputRenderTarget: Nullable<RenderTargetTexture>;
  30337. /**
  30338. * Observable triggered when the camera view matrix has changed.
  30339. */
  30340. onViewMatrixChangedObservable: Observable<Camera>;
  30341. /**
  30342. * Observable triggered when the camera Projection matrix has changed.
  30343. */
  30344. onProjectionMatrixChangedObservable: Observable<Camera>;
  30345. /**
  30346. * Observable triggered when the inputs have been processed.
  30347. */
  30348. onAfterCheckInputsObservable: Observable<Camera>;
  30349. /**
  30350. * Observable triggered when reset has been called and applied to the camera.
  30351. */
  30352. onRestoreStateObservable: Observable<Camera>;
  30353. /** @hidden */
  30354. _cameraRigParams: any;
  30355. /** @hidden */
  30356. _rigCameras: Camera[];
  30357. /** @hidden */
  30358. _rigPostProcess: Nullable<PostProcess>;
  30359. protected _webvrViewMatrix: Matrix;
  30360. /** @hidden */
  30361. _skipRendering: boolean;
  30362. /** @hidden */
  30363. _projectionMatrix: Matrix;
  30364. /** @hidden */
  30365. _postProcesses: Nullable<PostProcess>[];
  30366. /** @hidden */
  30367. _activeMeshes: SmartArray<AbstractMesh>;
  30368. protected _globalPosition: Vector3;
  30369. /** hidden */
  30370. _computedViewMatrix: Matrix;
  30371. private _doNotComputeProjectionMatrix;
  30372. private _transformMatrix;
  30373. private _frustumPlanes;
  30374. private _refreshFrustumPlanes;
  30375. private _storedFov;
  30376. private _stateStored;
  30377. /**
  30378. * Instantiates a new camera object.
  30379. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30380. * @see http://doc.babylonjs.com/features/cameras
  30381. * @param name Defines the name of the camera in the scene
  30382. * @param position Defines the position of the camera
  30383. * @param scene Defines the scene the camera belongs too
  30384. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30385. */
  30386. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30387. /**
  30388. * Store current camera state (fov, position, etc..)
  30389. * @returns the camera
  30390. */
  30391. storeState(): Camera;
  30392. /**
  30393. * Restores the camera state values if it has been stored. You must call storeState() first
  30394. */
  30395. protected _restoreStateValues(): boolean;
  30396. /**
  30397. * Restored camera state. You must call storeState() first.
  30398. * @returns true if restored and false otherwise
  30399. */
  30400. restoreState(): boolean;
  30401. /**
  30402. * Gets the class name of the camera.
  30403. * @returns the class name
  30404. */
  30405. getClassName(): string;
  30406. /** @hidden */
  30407. readonly _isCamera: boolean;
  30408. /**
  30409. * Gets a string representation of the camera useful for debug purpose.
  30410. * @param fullDetails Defines that a more verboe level of logging is required
  30411. * @returns the string representation
  30412. */
  30413. toString(fullDetails?: boolean): string;
  30414. /**
  30415. * Gets the current world space position of the camera.
  30416. */
  30417. readonly globalPosition: Vector3;
  30418. /**
  30419. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30420. * @returns the active meshe list
  30421. */
  30422. getActiveMeshes(): SmartArray<AbstractMesh>;
  30423. /**
  30424. * Check wether a mesh is part of the current active mesh list of the camera
  30425. * @param mesh Defines the mesh to check
  30426. * @returns true if active, false otherwise
  30427. */
  30428. isActiveMesh(mesh: Mesh): boolean;
  30429. /**
  30430. * Is this camera ready to be used/rendered
  30431. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30432. * @return true if the camera is ready
  30433. */
  30434. isReady(completeCheck?: boolean): boolean;
  30435. /** @hidden */
  30436. _initCache(): void;
  30437. /** @hidden */
  30438. _updateCache(ignoreParentClass?: boolean): void;
  30439. /** @hidden */
  30440. _isSynchronized(): boolean;
  30441. /** @hidden */
  30442. _isSynchronizedViewMatrix(): boolean;
  30443. /** @hidden */
  30444. _isSynchronizedProjectionMatrix(): boolean;
  30445. /**
  30446. * Attach the input controls to a specific dom element to get the input from.
  30447. * @param element Defines the element the controls should be listened from
  30448. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30449. */
  30450. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30451. /**
  30452. * Detach the current controls from the specified dom element.
  30453. * @param element Defines the element to stop listening the inputs from
  30454. */
  30455. detachControl(element: HTMLElement): void;
  30456. /**
  30457. * Update the camera state according to the different inputs gathered during the frame.
  30458. */
  30459. update(): void;
  30460. /** @hidden */
  30461. _checkInputs(): void;
  30462. /** @hidden */
  30463. readonly rigCameras: Camera[];
  30464. /**
  30465. * Gets the post process used by the rig cameras
  30466. */
  30467. readonly rigPostProcess: Nullable<PostProcess>;
  30468. /**
  30469. * Internal, gets the first post proces.
  30470. * @returns the first post process to be run on this camera.
  30471. */
  30472. _getFirstPostProcess(): Nullable<PostProcess>;
  30473. private _cascadePostProcessesToRigCams;
  30474. /**
  30475. * Attach a post process to the camera.
  30476. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30477. * @param postProcess The post process to attach to the camera
  30478. * @param insertAt The position of the post process in case several of them are in use in the scene
  30479. * @returns the position the post process has been inserted at
  30480. */
  30481. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30482. /**
  30483. * Detach a post process to the camera.
  30484. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30485. * @param postProcess The post process to detach from the camera
  30486. */
  30487. detachPostProcess(postProcess: PostProcess): void;
  30488. /**
  30489. * Gets the current world matrix of the camera
  30490. */
  30491. getWorldMatrix(): Matrix;
  30492. /** @hidden */
  30493. _getViewMatrix(): Matrix;
  30494. /**
  30495. * Gets the current view matrix of the camera.
  30496. * @param force forces the camera to recompute the matrix without looking at the cached state
  30497. * @returns the view matrix
  30498. */
  30499. getViewMatrix(force?: boolean): Matrix;
  30500. /**
  30501. * Freeze the projection matrix.
  30502. * It will prevent the cache check of the camera projection compute and can speed up perf
  30503. * if no parameter of the camera are meant to change
  30504. * @param projection Defines manually a projection if necessary
  30505. */
  30506. freezeProjectionMatrix(projection?: Matrix): void;
  30507. /**
  30508. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30509. */
  30510. unfreezeProjectionMatrix(): void;
  30511. /**
  30512. * Gets the current projection matrix of the camera.
  30513. * @param force forces the camera to recompute the matrix without looking at the cached state
  30514. * @returns the projection matrix
  30515. */
  30516. getProjectionMatrix(force?: boolean): Matrix;
  30517. /**
  30518. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30519. * @returns a Matrix
  30520. */
  30521. getTransformationMatrix(): Matrix;
  30522. private _updateFrustumPlanes;
  30523. /**
  30524. * Checks if a cullable object (mesh...) is in the camera frustum
  30525. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30526. * @param target The object to check
  30527. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30528. * @returns true if the object is in frustum otherwise false
  30529. */
  30530. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30531. /**
  30532. * Checks if a cullable object (mesh...) is in the camera frustum
  30533. * Unlike isInFrustum this cheks the full bounding box
  30534. * @param target The object to check
  30535. * @returns true if the object is in frustum otherwise false
  30536. */
  30537. isCompletelyInFrustum(target: ICullable): boolean;
  30538. /**
  30539. * Gets a ray in the forward direction from the camera.
  30540. * @param length Defines the length of the ray to create
  30541. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30542. * @param origin Defines the start point of the ray which defaults to the camera position
  30543. * @returns the forward ray
  30544. */
  30545. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30546. /**
  30547. * Releases resources associated with this node.
  30548. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30549. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30550. */
  30551. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30552. /** @hidden */
  30553. _isLeftCamera: boolean;
  30554. /**
  30555. * Gets the left camera of a rig setup in case of Rigged Camera
  30556. */
  30557. readonly isLeftCamera: boolean;
  30558. /** @hidden */
  30559. _isRightCamera: boolean;
  30560. /**
  30561. * Gets the right camera of a rig setup in case of Rigged Camera
  30562. */
  30563. readonly isRightCamera: boolean;
  30564. /**
  30565. * Gets the left camera of a rig setup in case of Rigged Camera
  30566. */
  30567. readonly leftCamera: Nullable<FreeCamera>;
  30568. /**
  30569. * Gets the right camera of a rig setup in case of Rigged Camera
  30570. */
  30571. readonly rightCamera: Nullable<FreeCamera>;
  30572. /**
  30573. * Gets the left camera target of a rig setup in case of Rigged Camera
  30574. * @returns the target position
  30575. */
  30576. getLeftTarget(): Nullable<Vector3>;
  30577. /**
  30578. * Gets the right camera target of a rig setup in case of Rigged Camera
  30579. * @returns the target position
  30580. */
  30581. getRightTarget(): Nullable<Vector3>;
  30582. /**
  30583. * @hidden
  30584. */
  30585. setCameraRigMode(mode: number, rigParams: any): void;
  30586. /** @hidden */
  30587. static _setStereoscopicRigMode(camera: Camera): void;
  30588. /** @hidden */
  30589. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30590. /** @hidden */
  30591. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30592. /** @hidden */
  30593. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30594. /** @hidden */
  30595. _getVRProjectionMatrix(): Matrix;
  30596. protected _updateCameraRotationMatrix(): void;
  30597. protected _updateWebVRCameraRotationMatrix(): void;
  30598. /**
  30599. * This function MUST be overwritten by the different WebVR cameras available.
  30600. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30601. * @hidden
  30602. */
  30603. _getWebVRProjectionMatrix(): Matrix;
  30604. /**
  30605. * This function MUST be overwritten by the different WebVR cameras available.
  30606. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30607. * @hidden
  30608. */
  30609. _getWebVRViewMatrix(): Matrix;
  30610. /** @hidden */
  30611. setCameraRigParameter(name: string, value: any): void;
  30612. /**
  30613. * needs to be overridden by children so sub has required properties to be copied
  30614. * @hidden
  30615. */
  30616. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30617. /**
  30618. * May need to be overridden by children
  30619. * @hidden
  30620. */
  30621. _updateRigCameras(): void;
  30622. /** @hidden */
  30623. _setupInputs(): void;
  30624. /**
  30625. * Serialiaze the camera setup to a json represention
  30626. * @returns the JSON representation
  30627. */
  30628. serialize(): any;
  30629. /**
  30630. * Clones the current camera.
  30631. * @param name The cloned camera name
  30632. * @returns the cloned camera
  30633. */
  30634. clone(name: string): Camera;
  30635. /**
  30636. * Gets the direction of the camera relative to a given local axis.
  30637. * @param localAxis Defines the reference axis to provide a relative direction.
  30638. * @return the direction
  30639. */
  30640. getDirection(localAxis: Vector3): Vector3;
  30641. /**
  30642. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30643. * @param localAxis Defines the reference axis to provide a relative direction.
  30644. * @param result Defines the vector to store the result in
  30645. */
  30646. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30647. /**
  30648. * Gets a camera constructor for a given camera type
  30649. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30650. * @param name The name of the camera the result will be able to instantiate
  30651. * @param scene The scene the result will construct the camera in
  30652. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30653. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30654. * @returns a factory method to construc the camera
  30655. */
  30656. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30657. /**
  30658. * Compute the world matrix of the camera.
  30659. * @returns the camera workd matrix
  30660. */
  30661. computeWorldMatrix(): Matrix;
  30662. /**
  30663. * Parse a JSON and creates the camera from the parsed information
  30664. * @param parsedCamera The JSON to parse
  30665. * @param scene The scene to instantiate the camera in
  30666. * @returns the newly constructed camera
  30667. */
  30668. static Parse(parsedCamera: any, scene: Scene): Camera;
  30669. }
  30670. }
  30671. declare module BABYLON {
  30672. /**
  30673. * Interface for any object that can request an animation frame
  30674. */
  30675. export interface ICustomAnimationFrameRequester {
  30676. /**
  30677. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30678. */
  30679. renderFunction?: Function;
  30680. /**
  30681. * Called to request the next frame to render to
  30682. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30683. */
  30684. requestAnimationFrame: Function;
  30685. /**
  30686. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30687. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30688. */
  30689. requestID?: number;
  30690. }
  30691. /**
  30692. * Interface containing an array of animations
  30693. */
  30694. export interface IAnimatable {
  30695. /**
  30696. * Array of animations
  30697. */
  30698. animations: Nullable<Array<Animation>>;
  30699. }
  30700. /** Interface used by value gradients (color, factor, ...) */
  30701. export interface IValueGradient {
  30702. /**
  30703. * Gets or sets the gradient value (between 0 and 1)
  30704. */
  30705. gradient: number;
  30706. }
  30707. /** Class used to store color4 gradient */
  30708. export class ColorGradient implements IValueGradient {
  30709. /**
  30710. * Gets or sets the gradient value (between 0 and 1)
  30711. */
  30712. gradient: number;
  30713. /**
  30714. * Gets or sets first associated color
  30715. */
  30716. color1: Color4;
  30717. /**
  30718. * Gets or sets second associated color
  30719. */
  30720. color2?: Color4;
  30721. /**
  30722. * Will get a color picked randomly between color1 and color2.
  30723. * If color2 is undefined then color1 will be used
  30724. * @param result defines the target Color4 to store the result in
  30725. */
  30726. getColorToRef(result: Color4): void;
  30727. }
  30728. /** Class used to store color 3 gradient */
  30729. export class Color3Gradient implements IValueGradient {
  30730. /**
  30731. * Gets or sets the gradient value (between 0 and 1)
  30732. */
  30733. gradient: number;
  30734. /**
  30735. * Gets or sets the associated color
  30736. */
  30737. color: Color3;
  30738. }
  30739. /** Class used to store factor gradient */
  30740. export class FactorGradient implements IValueGradient {
  30741. /**
  30742. * Gets or sets the gradient value (between 0 and 1)
  30743. */
  30744. gradient: number;
  30745. /**
  30746. * Gets or sets first associated factor
  30747. */
  30748. factor1: number;
  30749. /**
  30750. * Gets or sets second associated factor
  30751. */
  30752. factor2?: number;
  30753. /**
  30754. * Will get a number picked randomly between factor1 and factor2.
  30755. * If factor2 is undefined then factor1 will be used
  30756. * @returns the picked number
  30757. */
  30758. getFactor(): number;
  30759. }
  30760. /**
  30761. * @ignore
  30762. * Application error to support additional information when loading a file
  30763. */
  30764. export class LoadFileError extends Error {
  30765. /** defines the optional web request */
  30766. request?: WebRequest | undefined;
  30767. private static _setPrototypeOf;
  30768. /**
  30769. * Creates a new LoadFileError
  30770. * @param message defines the message of the error
  30771. * @param request defines the optional web request
  30772. */
  30773. constructor(message: string,
  30774. /** defines the optional web request */
  30775. request?: WebRequest | undefined);
  30776. }
  30777. /**
  30778. * Class used to define a retry strategy when error happens while loading assets
  30779. */
  30780. export class RetryStrategy {
  30781. /**
  30782. * Function used to defines an exponential back off strategy
  30783. * @param maxRetries defines the maximum number of retries (3 by default)
  30784. * @param baseInterval defines the interval between retries
  30785. * @returns the strategy function to use
  30786. */
  30787. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30788. }
  30789. /**
  30790. * File request interface
  30791. */
  30792. export interface IFileRequest {
  30793. /**
  30794. * Raised when the request is complete (success or error).
  30795. */
  30796. onCompleteObservable: Observable<IFileRequest>;
  30797. /**
  30798. * Aborts the request for a file.
  30799. */
  30800. abort: () => void;
  30801. }
  30802. /**
  30803. * Class containing a set of static utilities functions
  30804. */
  30805. export class Tools {
  30806. /**
  30807. * Gets or sets the base URL to use to load assets
  30808. */
  30809. static BaseUrl: string;
  30810. /**
  30811. * Enable/Disable Custom HTTP Request Headers globally.
  30812. * default = false
  30813. * @see CustomRequestHeaders
  30814. */
  30815. static UseCustomRequestHeaders: boolean;
  30816. /**
  30817. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30818. * i.e. when loading files, where the server/service expects an Authorization header
  30819. */
  30820. static CustomRequestHeaders: {
  30821. [key: string]: string;
  30822. };
  30823. /**
  30824. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30825. */
  30826. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30827. /**
  30828. * Default behaviour for cors in the application.
  30829. * It can be a string if the expected behavior is identical in the entire app.
  30830. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30831. */
  30832. static CorsBehavior: string | ((url: string | string[]) => string);
  30833. /**
  30834. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30835. * @ignorenaming
  30836. */
  30837. static UseFallbackTexture: boolean;
  30838. /**
  30839. * Use this object to register external classes like custom textures or material
  30840. * to allow the laoders to instantiate them
  30841. */
  30842. static RegisteredExternalClasses: {
  30843. [key: string]: Object;
  30844. };
  30845. /**
  30846. * Texture content used if a texture cannot loaded
  30847. * @ignorenaming
  30848. */
  30849. static fallbackTexture: string;
  30850. /**
  30851. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30852. * @param u defines the coordinate on X axis
  30853. * @param v defines the coordinate on Y axis
  30854. * @param width defines the width of the source data
  30855. * @param height defines the height of the source data
  30856. * @param pixels defines the source byte array
  30857. * @param color defines the output color
  30858. */
  30859. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30860. /**
  30861. * Interpolates between a and b via alpha
  30862. * @param a The lower value (returned when alpha = 0)
  30863. * @param b The upper value (returned when alpha = 1)
  30864. * @param alpha The interpolation-factor
  30865. * @return The mixed value
  30866. */
  30867. static Mix(a: number, b: number, alpha: number): number;
  30868. /**
  30869. * Tries to instantiate a new object from a given class name
  30870. * @param className defines the class name to instantiate
  30871. * @returns the new object or null if the system was not able to do the instantiation
  30872. */
  30873. static Instantiate(className: string): any;
  30874. /**
  30875. * Provides a slice function that will work even on IE
  30876. * @param data defines the array to slice
  30877. * @param start defines the start of the data (optional)
  30878. * @param end defines the end of the data (optional)
  30879. * @returns the new sliced array
  30880. */
  30881. static Slice<T>(data: T, start?: number, end?: number): T;
  30882. /**
  30883. * Polyfill for setImmediate
  30884. * @param action defines the action to execute after the current execution block
  30885. */
  30886. static SetImmediate(action: () => void): void;
  30887. /**
  30888. * Function indicating if a number is an exponent of 2
  30889. * @param value defines the value to test
  30890. * @returns true if the value is an exponent of 2
  30891. */
  30892. static IsExponentOfTwo(value: number): boolean;
  30893. private static _tmpFloatArray;
  30894. /**
  30895. * Returns the nearest 32-bit single precision float representation of a Number
  30896. * @param value A Number. If the parameter is of a different type, it will get converted
  30897. * to a number or to NaN if it cannot be converted
  30898. * @returns number
  30899. */
  30900. static FloatRound(value: number): number;
  30901. /**
  30902. * Find the next highest power of two.
  30903. * @param x Number to start search from.
  30904. * @return Next highest power of two.
  30905. */
  30906. static CeilingPOT(x: number): number;
  30907. /**
  30908. * Find the next lowest power of two.
  30909. * @param x Number to start search from.
  30910. * @return Next lowest power of two.
  30911. */
  30912. static FloorPOT(x: number): number;
  30913. /**
  30914. * Find the nearest power of two.
  30915. * @param x Number to start search from.
  30916. * @return Next nearest power of two.
  30917. */
  30918. static NearestPOT(x: number): number;
  30919. /**
  30920. * Get the closest exponent of two
  30921. * @param value defines the value to approximate
  30922. * @param max defines the maximum value to return
  30923. * @param mode defines how to define the closest value
  30924. * @returns closest exponent of two of the given value
  30925. */
  30926. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30927. /**
  30928. * Extracts the filename from a path
  30929. * @param path defines the path to use
  30930. * @returns the filename
  30931. */
  30932. static GetFilename(path: string): string;
  30933. /**
  30934. * Extracts the "folder" part of a path (everything before the filename).
  30935. * @param uri The URI to extract the info from
  30936. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30937. * @returns The "folder" part of the path
  30938. */
  30939. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30940. /**
  30941. * Extracts text content from a DOM element hierarchy
  30942. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30943. */
  30944. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30945. /**
  30946. * Convert an angle in radians to degrees
  30947. * @param angle defines the angle to convert
  30948. * @returns the angle in degrees
  30949. */
  30950. static ToDegrees(angle: number): number;
  30951. /**
  30952. * Convert an angle in degrees to radians
  30953. * @param angle defines the angle to convert
  30954. * @returns the angle in radians
  30955. */
  30956. static ToRadians(angle: number): number;
  30957. /**
  30958. * Encode a buffer to a base64 string
  30959. * @param buffer defines the buffer to encode
  30960. * @returns the encoded string
  30961. */
  30962. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30963. /**
  30964. * Extracts minimum and maximum values from a list of indexed positions
  30965. * @param positions defines the positions to use
  30966. * @param indices defines the indices to the positions
  30967. * @param indexStart defines the start index
  30968. * @param indexCount defines the end index
  30969. * @param bias defines bias value to add to the result
  30970. * @return minimum and maximum values
  30971. */
  30972. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30973. minimum: Vector3;
  30974. maximum: Vector3;
  30975. };
  30976. /**
  30977. * Extracts minimum and maximum values from a list of positions
  30978. * @param positions defines the positions to use
  30979. * @param start defines the start index in the positions array
  30980. * @param count defines the number of positions to handle
  30981. * @param bias defines bias value to add to the result
  30982. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30983. * @return minimum and maximum values
  30984. */
  30985. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30986. minimum: Vector3;
  30987. maximum: Vector3;
  30988. };
  30989. /**
  30990. * Returns an array if obj is not an array
  30991. * @param obj defines the object to evaluate as an array
  30992. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30993. * @returns either obj directly if obj is an array or a new array containing obj
  30994. */
  30995. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30996. /**
  30997. * Gets the pointer prefix to use
  30998. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30999. */
  31000. static GetPointerPrefix(): string;
  31001. /**
  31002. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31003. * @param func - the function to be called
  31004. * @param requester - the object that will request the next frame. Falls back to window.
  31005. * @returns frame number
  31006. */
  31007. static QueueNewFrame(func: () => void, requester?: any): number;
  31008. /**
  31009. * Ask the browser to promote the current element to fullscreen rendering mode
  31010. * @param element defines the DOM element to promote
  31011. */
  31012. static RequestFullscreen(element: HTMLElement): void;
  31013. /**
  31014. * Asks the browser to exit fullscreen mode
  31015. */
  31016. static ExitFullscreen(): void;
  31017. /**
  31018. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31019. * @param url define the url we are trying
  31020. * @param element define the dom element where to configure the cors policy
  31021. */
  31022. static SetCorsBehavior(url: string | string[], element: {
  31023. crossOrigin: string | null;
  31024. }): void;
  31025. /**
  31026. * Removes unwanted characters from an url
  31027. * @param url defines the url to clean
  31028. * @returns the cleaned url
  31029. */
  31030. static CleanUrl(url: string): string;
  31031. /**
  31032. * Gets or sets a function used to pre-process url before using them to load assets
  31033. */
  31034. static PreprocessUrl: (url: string) => string;
  31035. /**
  31036. * Loads an image as an HTMLImageElement.
  31037. * @param input url string, ArrayBuffer, or Blob to load
  31038. * @param onLoad callback called when the image successfully loads
  31039. * @param onError callback called when the image fails to load
  31040. * @param offlineProvider offline provider for caching
  31041. * @returns the HTMLImageElement of the loaded image
  31042. */
  31043. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31044. /**
  31045. * Loads a file
  31046. * @param url url string, ArrayBuffer, or Blob to load
  31047. * @param onSuccess callback called when the file successfully loads
  31048. * @param onProgress callback called while file is loading (if the server supports this mode)
  31049. * @param offlineProvider defines the offline provider for caching
  31050. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31051. * @param onError callback called when the file fails to load
  31052. * @returns a file request object
  31053. */
  31054. 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;
  31055. /**
  31056. * Load a script (identified by an url). When the url returns, the
  31057. * content of this file is added into a new script element, attached to the DOM (body element)
  31058. * @param scriptUrl defines the url of the script to laod
  31059. * @param onSuccess defines the callback called when the script is loaded
  31060. * @param onError defines the callback to call if an error occurs
  31061. * @param scriptId defines the id of the script element
  31062. */
  31063. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31064. /**
  31065. * Load an asynchronous script (identified by an url). When the url returns, the
  31066. * content of this file is added into a new script element, attached to the DOM (body element)
  31067. * @param scriptUrl defines the url of the script to laod
  31068. * @param scriptId defines the id of the script element
  31069. * @returns a promise request object
  31070. */
  31071. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31072. /**
  31073. * Loads a file from a blob
  31074. * @param fileToLoad defines the blob to use
  31075. * @param callback defines the callback to call when data is loaded
  31076. * @param progressCallback defines the callback to call during loading process
  31077. * @returns a file request object
  31078. */
  31079. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31080. /**
  31081. * Loads a file
  31082. * @param fileToLoad defines the file to load
  31083. * @param callback defines the callback to call when data is loaded
  31084. * @param progressCallBack defines the callback to call during loading process
  31085. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31086. * @returns a file request object
  31087. */
  31088. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31089. /**
  31090. * Creates a data url from a given string content
  31091. * @param content defines the content to convert
  31092. * @returns the new data url link
  31093. */
  31094. static FileAsURL(content: string): string;
  31095. /**
  31096. * Format the given number to a specific decimal format
  31097. * @param value defines the number to format
  31098. * @param decimals defines the number of decimals to use
  31099. * @returns the formatted string
  31100. */
  31101. static Format(value: number, decimals?: number): string;
  31102. /**
  31103. * Checks if a given vector is inside a specific range
  31104. * @param v defines the vector to test
  31105. * @param min defines the minimum range
  31106. * @param max defines the maximum range
  31107. */
  31108. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31109. /**
  31110. * Tries to copy an object by duplicating every property
  31111. * @param source defines the source object
  31112. * @param destination defines the target object
  31113. * @param doNotCopyList defines a list of properties to avoid
  31114. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31115. */
  31116. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31117. /**
  31118. * Gets a boolean indicating if the given object has no own property
  31119. * @param obj defines the object to test
  31120. * @returns true if object has no own property
  31121. */
  31122. static IsEmpty(obj: any): boolean;
  31123. /**
  31124. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31125. * @param str Source string
  31126. * @param suffix Suffix to search for in the source string
  31127. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31128. */
  31129. static EndsWith(str: string, suffix: string): boolean;
  31130. /**
  31131. * Function used to register events at window level
  31132. * @param events defines the events to register
  31133. */
  31134. static RegisterTopRootEvents(events: {
  31135. name: string;
  31136. handler: Nullable<(e: FocusEvent) => any>;
  31137. }[]): void;
  31138. /**
  31139. * Function used to unregister events from window level
  31140. * @param events defines the events to unregister
  31141. */
  31142. static UnregisterTopRootEvents(events: {
  31143. name: string;
  31144. handler: Nullable<(e: FocusEvent) => any>;
  31145. }[]): void;
  31146. /**
  31147. * @ignore
  31148. */
  31149. static _ScreenshotCanvas: HTMLCanvasElement;
  31150. /**
  31151. * Dumps the current bound framebuffer
  31152. * @param width defines the rendering width
  31153. * @param height defines the rendering height
  31154. * @param engine defines the hosting engine
  31155. * @param successCallback defines the callback triggered once the data are available
  31156. * @param mimeType defines the mime type of the result
  31157. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31158. */
  31159. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31160. /**
  31161. * Converts the canvas data to blob.
  31162. * This acts as a polyfill for browsers not supporting the to blob function.
  31163. * @param canvas Defines the canvas to extract the data from
  31164. * @param successCallback Defines the callback triggered once the data are available
  31165. * @param mimeType Defines the mime type of the result
  31166. */
  31167. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31168. /**
  31169. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31170. * @param successCallback defines the callback triggered once the data are available
  31171. * @param mimeType defines the mime type of the result
  31172. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31173. */
  31174. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31175. /**
  31176. * Downloads a blob in the browser
  31177. * @param blob defines the blob to download
  31178. * @param fileName defines the name of the downloaded file
  31179. */
  31180. static Download(blob: Blob, fileName: string): void;
  31181. /**
  31182. * Captures a screenshot of the current rendering
  31183. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31184. * @param engine defines the rendering engine
  31185. * @param camera defines the source camera
  31186. * @param size This parameter can be set to a single number or to an object with the
  31187. * following (optional) properties: precision, width, height. If a single number is passed,
  31188. * it will be used for both width and height. If an object is passed, the screenshot size
  31189. * will be derived from the parameters. The precision property is a multiplier allowing
  31190. * rendering at a higher or lower resolution
  31191. * @param successCallback defines the callback receives a single parameter which contains the
  31192. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31193. * src parameter of an <img> to display it
  31194. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31195. * Check your browser for supported MIME types
  31196. */
  31197. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31198. /**
  31199. * Generates an image screenshot from the specified camera.
  31200. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31201. * @param engine The engine to use for rendering
  31202. * @param camera The camera to use for rendering
  31203. * @param size This parameter can be set to a single number or to an object with the
  31204. * following (optional) properties: precision, width, height. If a single number is passed,
  31205. * it will be used for both width and height. If an object is passed, the screenshot size
  31206. * will be derived from the parameters. The precision property is a multiplier allowing
  31207. * rendering at a higher or lower resolution
  31208. * @param successCallback The callback receives a single parameter which contains the
  31209. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31210. * src parameter of an <img> to display it
  31211. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31212. * Check your browser for supported MIME types
  31213. * @param samples Texture samples (default: 1)
  31214. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31215. * @param fileName A name for for the downloaded file.
  31216. */
  31217. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31218. /**
  31219. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31220. * Be aware Math.random() could cause collisions, but:
  31221. * "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"
  31222. * @returns a pseudo random id
  31223. */
  31224. static RandomId(): string;
  31225. /**
  31226. * Test if the given uri is a base64 string
  31227. * @param uri The uri to test
  31228. * @return True if the uri is a base64 string or false otherwise
  31229. */
  31230. static IsBase64(uri: string): boolean;
  31231. /**
  31232. * Decode the given base64 uri.
  31233. * @param uri The uri to decode
  31234. * @return The decoded base64 data.
  31235. */
  31236. static DecodeBase64(uri: string): ArrayBuffer;
  31237. /**
  31238. * Gets the absolute url.
  31239. * @param url the input url
  31240. * @return the absolute url
  31241. */
  31242. static GetAbsoluteUrl(url: string): string;
  31243. /**
  31244. * No log
  31245. */
  31246. static readonly NoneLogLevel: number;
  31247. /**
  31248. * Only message logs
  31249. */
  31250. static readonly MessageLogLevel: number;
  31251. /**
  31252. * Only warning logs
  31253. */
  31254. static readonly WarningLogLevel: number;
  31255. /**
  31256. * Only error logs
  31257. */
  31258. static readonly ErrorLogLevel: number;
  31259. /**
  31260. * All logs
  31261. */
  31262. static readonly AllLogLevel: number;
  31263. /**
  31264. * Gets a value indicating the number of loading errors
  31265. * @ignorenaming
  31266. */
  31267. static readonly errorsCount: number;
  31268. /**
  31269. * Callback called when a new log is added
  31270. */
  31271. static OnNewCacheEntry: (entry: string) => void;
  31272. /**
  31273. * Log a message to the console
  31274. * @param message defines the message to log
  31275. */
  31276. static Log(message: string): void;
  31277. /**
  31278. * Write a warning message to the console
  31279. * @param message defines the message to log
  31280. */
  31281. static Warn(message: string): void;
  31282. /**
  31283. * Write an error message to the console
  31284. * @param message defines the message to log
  31285. */
  31286. static Error(message: string): void;
  31287. /**
  31288. * Gets current log cache (list of logs)
  31289. */
  31290. static readonly LogCache: string;
  31291. /**
  31292. * Clears the log cache
  31293. */
  31294. static ClearLogCache(): void;
  31295. /**
  31296. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31297. */
  31298. static LogLevels: number;
  31299. /**
  31300. * Checks if the loaded document was accessed via `file:`-Protocol.
  31301. * @returns boolean
  31302. */
  31303. static IsFileURL(): boolean;
  31304. /**
  31305. * Checks if the window object exists
  31306. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31307. */
  31308. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31309. /**
  31310. * No performance log
  31311. */
  31312. static readonly PerformanceNoneLogLevel: number;
  31313. /**
  31314. * Use user marks to log performance
  31315. */
  31316. static readonly PerformanceUserMarkLogLevel: number;
  31317. /**
  31318. * Log performance to the console
  31319. */
  31320. static readonly PerformanceConsoleLogLevel: number;
  31321. private static _performance;
  31322. /**
  31323. * Sets the current performance log level
  31324. */
  31325. static PerformanceLogLevel: number;
  31326. private static _StartPerformanceCounterDisabled;
  31327. private static _EndPerformanceCounterDisabled;
  31328. private static _StartUserMark;
  31329. private static _EndUserMark;
  31330. private static _StartPerformanceConsole;
  31331. private static _EndPerformanceConsole;
  31332. /**
  31333. * Starts a performance counter
  31334. */
  31335. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31336. /**
  31337. * Ends a specific performance coutner
  31338. */
  31339. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31340. /**
  31341. * Gets either window.performance.now() if supported or Date.now() else
  31342. */
  31343. static readonly Now: number;
  31344. /**
  31345. * This method will return the name of the class used to create the instance of the given object.
  31346. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31347. * @param object the object to get the class name from
  31348. * @param isType defines if the object is actually a type
  31349. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31350. */
  31351. static GetClassName(object: any, isType?: boolean): string;
  31352. /**
  31353. * Gets the first element of an array satisfying a given predicate
  31354. * @param array defines the array to browse
  31355. * @param predicate defines the predicate to use
  31356. * @returns null if not found or the element
  31357. */
  31358. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31359. /**
  31360. * This method will return the name of the full name of the class, including its owning module (if any).
  31361. * 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).
  31362. * @param object the object to get the class name from
  31363. * @param isType defines if the object is actually a type
  31364. * @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.
  31365. * @ignorenaming
  31366. */
  31367. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31368. /**
  31369. * Returns a promise that resolves after the given amount of time.
  31370. * @param delay Number of milliseconds to delay
  31371. * @returns Promise that resolves after the given amount of time
  31372. */
  31373. static DelayAsync(delay: number): Promise<void>;
  31374. /**
  31375. * Gets the current gradient from an array of IValueGradient
  31376. * @param ratio defines the current ratio to get
  31377. * @param gradients defines the array of IValueGradient
  31378. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31379. */
  31380. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31381. }
  31382. /**
  31383. * This class is used to track a performance counter which is number based.
  31384. * The user has access to many properties which give statistics of different nature.
  31385. *
  31386. * The implementer can track two kinds of Performance Counter: time and count.
  31387. * 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.
  31388. * 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.
  31389. */
  31390. export class PerfCounter {
  31391. /**
  31392. * Gets or sets a global boolean to turn on and off all the counters
  31393. */
  31394. static Enabled: boolean;
  31395. /**
  31396. * Returns the smallest value ever
  31397. */
  31398. readonly min: number;
  31399. /**
  31400. * Returns the biggest value ever
  31401. */
  31402. readonly max: number;
  31403. /**
  31404. * Returns the average value since the performance counter is running
  31405. */
  31406. readonly average: number;
  31407. /**
  31408. * Returns the average value of the last second the counter was monitored
  31409. */
  31410. readonly lastSecAverage: number;
  31411. /**
  31412. * Returns the current value
  31413. */
  31414. readonly current: number;
  31415. /**
  31416. * Gets the accumulated total
  31417. */
  31418. readonly total: number;
  31419. /**
  31420. * Gets the total value count
  31421. */
  31422. readonly count: number;
  31423. /**
  31424. * Creates a new counter
  31425. */
  31426. constructor();
  31427. /**
  31428. * Call this method to start monitoring a new frame.
  31429. * 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.
  31430. */
  31431. fetchNewFrame(): void;
  31432. /**
  31433. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31434. * @param newCount the count value to add to the monitored count
  31435. * @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.
  31436. */
  31437. addCount(newCount: number, fetchResult: boolean): void;
  31438. /**
  31439. * Start monitoring this performance counter
  31440. */
  31441. beginMonitoring(): void;
  31442. /**
  31443. * Compute the time lapsed since the previous beginMonitoring() call.
  31444. * @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
  31445. */
  31446. endMonitoring(newFrame?: boolean): void;
  31447. private _fetchResult;
  31448. private _startMonitoringTime;
  31449. private _min;
  31450. private _max;
  31451. private _average;
  31452. private _current;
  31453. private _totalValueCount;
  31454. private _totalAccumulated;
  31455. private _lastSecAverage;
  31456. private _lastSecAccumulated;
  31457. private _lastSecTime;
  31458. private _lastSecValueCount;
  31459. }
  31460. /**
  31461. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31462. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31463. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31464. * @param name The name of the class, case should be preserved
  31465. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31466. */
  31467. export function className(name: string, module?: string): (target: Object) => void;
  31468. /**
  31469. * An implementation of a loop for asynchronous functions.
  31470. */
  31471. export class AsyncLoop {
  31472. /**
  31473. * Defines the number of iterations for the loop
  31474. */
  31475. iterations: number;
  31476. /**
  31477. * Defines the current index of the loop.
  31478. */
  31479. index: number;
  31480. private _done;
  31481. private _fn;
  31482. private _successCallback;
  31483. /**
  31484. * Constructor.
  31485. * @param iterations the number of iterations.
  31486. * @param func the function to run each iteration
  31487. * @param successCallback the callback that will be called upon succesful execution
  31488. * @param offset starting offset.
  31489. */
  31490. constructor(
  31491. /**
  31492. * Defines the number of iterations for the loop
  31493. */
  31494. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31495. /**
  31496. * Execute the next iteration. Must be called after the last iteration was finished.
  31497. */
  31498. executeNext(): void;
  31499. /**
  31500. * Break the loop and run the success callback.
  31501. */
  31502. breakLoop(): void;
  31503. /**
  31504. * Create and run an async loop.
  31505. * @param iterations the number of iterations.
  31506. * @param fn the function to run each iteration
  31507. * @param successCallback the callback that will be called upon succesful execution
  31508. * @param offset starting offset.
  31509. * @returns the created async loop object
  31510. */
  31511. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31512. /**
  31513. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31514. * @param iterations total number of iterations
  31515. * @param syncedIterations number of synchronous iterations in each async iteration.
  31516. * @param fn the function to call each iteration.
  31517. * @param callback a success call back that will be called when iterating stops.
  31518. * @param breakFunction a break condition (optional)
  31519. * @param timeout timeout settings for the setTimeout function. default - 0.
  31520. * @returns the created async loop object
  31521. */
  31522. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31523. }
  31524. }
  31525. declare module BABYLON {
  31526. /** @hidden */
  31527. export interface ICollisionCoordinator {
  31528. createCollider(): Collider;
  31529. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31530. init(scene: Scene): void;
  31531. }
  31532. /** @hidden */
  31533. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31534. private _scene;
  31535. private _scaledPosition;
  31536. private _scaledVelocity;
  31537. private _finalPosition;
  31538. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31539. createCollider(): Collider;
  31540. init(scene: Scene): void;
  31541. private _collideWithWorld;
  31542. }
  31543. }
  31544. declare module BABYLON {
  31545. /**
  31546. * Class used to manage all inputs for the scene.
  31547. */
  31548. export class InputManager {
  31549. /** The distance in pixel that you have to move to prevent some events */
  31550. static DragMovementThreshold: number;
  31551. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31552. static LongPressDelay: number;
  31553. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31554. static DoubleClickDelay: number;
  31555. /** If you need to check double click without raising a single click at first click, enable this flag */
  31556. static ExclusiveDoubleClickMode: boolean;
  31557. private _wheelEventName;
  31558. private _onPointerMove;
  31559. private _onPointerDown;
  31560. private _onPointerUp;
  31561. private _initClickEvent;
  31562. private _initActionManager;
  31563. private _delayedSimpleClick;
  31564. private _delayedSimpleClickTimeout;
  31565. private _previousDelayedSimpleClickTimeout;
  31566. private _meshPickProceed;
  31567. private _previousButtonPressed;
  31568. private _currentPickResult;
  31569. private _previousPickResult;
  31570. private _totalPointersPressed;
  31571. private _doubleClickOccured;
  31572. private _pointerOverMesh;
  31573. private _pickedDownMesh;
  31574. private _pickedUpMesh;
  31575. private _pointerX;
  31576. private _pointerY;
  31577. private _unTranslatedPointerX;
  31578. private _unTranslatedPointerY;
  31579. private _startingPointerPosition;
  31580. private _previousStartingPointerPosition;
  31581. private _startingPointerTime;
  31582. private _previousStartingPointerTime;
  31583. private _pointerCaptures;
  31584. private _onKeyDown;
  31585. private _onKeyUp;
  31586. private _onCanvasFocusObserver;
  31587. private _onCanvasBlurObserver;
  31588. private _scene;
  31589. /**
  31590. * Creates a new InputManager
  31591. * @param scene defines the hosting scene
  31592. */
  31593. constructor(scene: Scene);
  31594. /**
  31595. * Gets the mesh that is currently under the pointer
  31596. */
  31597. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31598. /**
  31599. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31600. */
  31601. readonly unTranslatedPointer: Vector2;
  31602. /**
  31603. * Gets or sets the current on-screen X position of the pointer
  31604. */
  31605. pointerX: number;
  31606. /**
  31607. * Gets or sets the current on-screen Y position of the pointer
  31608. */
  31609. pointerY: number;
  31610. private _updatePointerPosition;
  31611. private _processPointerMove;
  31612. private _setRayOnPointerInfo;
  31613. private _checkPrePointerObservable;
  31614. /**
  31615. * Use this method to simulate a pointer move on a mesh
  31616. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31617. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31618. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31619. */
  31620. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31621. /**
  31622. * Use this method to simulate a pointer down on a mesh
  31623. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31624. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31625. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31626. */
  31627. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31628. private _processPointerDown;
  31629. /** @hidden */
  31630. _isPointerSwiping(): boolean;
  31631. /**
  31632. * Use this method to simulate a pointer up 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. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31637. */
  31638. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31639. private _processPointerUp;
  31640. /**
  31641. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31642. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31643. * @returns true if the pointer was captured
  31644. */
  31645. isPointerCaptured(pointerId?: number): boolean;
  31646. /**
  31647. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31648. * @param attachUp defines if you want to attach events to pointerup
  31649. * @param attachDown defines if you want to attach events to pointerdown
  31650. * @param attachMove defines if you want to attach events to pointermove
  31651. */
  31652. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31653. /**
  31654. * Detaches all event handlers
  31655. */
  31656. detachControl(): void;
  31657. /**
  31658. * Force the value of meshUnderPointer
  31659. * @param mesh defines the mesh to use
  31660. */
  31661. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31662. /**
  31663. * Gets the mesh under the pointer
  31664. * @returns a Mesh or null if no mesh is under the pointer
  31665. */
  31666. getPointerOverMesh(): Nullable<AbstractMesh>;
  31667. }
  31668. }
  31669. declare module BABYLON {
  31670. /**
  31671. * This class defines the direct association between an animation and a target
  31672. */
  31673. export class TargetedAnimation {
  31674. /**
  31675. * Animation to perform
  31676. */
  31677. animation: Animation;
  31678. /**
  31679. * Target to animate
  31680. */
  31681. target: any;
  31682. }
  31683. /**
  31684. * Use this class to create coordinated animations on multiple targets
  31685. */
  31686. export class AnimationGroup implements IDisposable {
  31687. /** The name of the animation group */
  31688. name: string;
  31689. private _scene;
  31690. private _targetedAnimations;
  31691. private _animatables;
  31692. private _from;
  31693. private _to;
  31694. private _isStarted;
  31695. private _isPaused;
  31696. private _speedRatio;
  31697. private _loopAnimation;
  31698. /**
  31699. * Gets or sets the unique id of the node
  31700. */
  31701. uniqueId: number;
  31702. /**
  31703. * This observable will notify when one animation have ended
  31704. */
  31705. onAnimationEndObservable: Observable<TargetedAnimation>;
  31706. /**
  31707. * Observer raised when one animation loops
  31708. */
  31709. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31710. /**
  31711. * This observable will notify when all animations have ended.
  31712. */
  31713. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31714. /**
  31715. * This observable will notify when all animations have paused.
  31716. */
  31717. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31718. /**
  31719. * This observable will notify when all animations are playing.
  31720. */
  31721. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31722. /**
  31723. * Gets the first frame
  31724. */
  31725. readonly from: number;
  31726. /**
  31727. * Gets the last frame
  31728. */
  31729. readonly to: number;
  31730. /**
  31731. * Define if the animations are started
  31732. */
  31733. readonly isStarted: boolean;
  31734. /**
  31735. * Gets a value indicating that the current group is playing
  31736. */
  31737. readonly isPlaying: boolean;
  31738. /**
  31739. * Gets or sets the speed ratio to use for all animations
  31740. */
  31741. /**
  31742. * Gets or sets the speed ratio to use for all animations
  31743. */
  31744. speedRatio: number;
  31745. /**
  31746. * Gets or sets if all animations should loop or not
  31747. */
  31748. loopAnimation: boolean;
  31749. /**
  31750. * Gets the targeted animations for this animation group
  31751. */
  31752. readonly targetedAnimations: Array<TargetedAnimation>;
  31753. /**
  31754. * returning the list of animatables controlled by this animation group.
  31755. */
  31756. readonly animatables: Array<Animatable>;
  31757. /**
  31758. * Instantiates a new Animation Group.
  31759. * This helps managing several animations at once.
  31760. * @see http://doc.babylonjs.com/how_to/group
  31761. * @param name Defines the name of the group
  31762. * @param scene Defines the scene the group belongs to
  31763. */
  31764. constructor(
  31765. /** The name of the animation group */
  31766. name: string, scene?: Nullable<Scene>);
  31767. /**
  31768. * Add an animation (with its target) in the group
  31769. * @param animation defines the animation we want to add
  31770. * @param target defines the target of the animation
  31771. * @returns the TargetedAnimation object
  31772. */
  31773. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31774. /**
  31775. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31776. * It can add constant keys at begin or end
  31777. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31778. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31779. * @returns the animation group
  31780. */
  31781. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31782. /**
  31783. * Start all animations on given targets
  31784. * @param loop defines if animations must loop
  31785. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31786. * @param from defines the from key (optional)
  31787. * @param to defines the to key (optional)
  31788. * @returns the current animation group
  31789. */
  31790. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31791. /**
  31792. * Pause all animations
  31793. * @returns the animation group
  31794. */
  31795. pause(): AnimationGroup;
  31796. /**
  31797. * Play all animations to initial state
  31798. * This function will start() the animations if they were not started or will restart() them if they were paused
  31799. * @param loop defines if animations must loop
  31800. * @returns the animation group
  31801. */
  31802. play(loop?: boolean): AnimationGroup;
  31803. /**
  31804. * Reset all animations to initial state
  31805. * @returns the animation group
  31806. */
  31807. reset(): AnimationGroup;
  31808. /**
  31809. * Restart animations from key 0
  31810. * @returns the animation group
  31811. */
  31812. restart(): AnimationGroup;
  31813. /**
  31814. * Stop all animations
  31815. * @returns the animation group
  31816. */
  31817. stop(): AnimationGroup;
  31818. /**
  31819. * Set animation weight for all animatables
  31820. * @param weight defines the weight to use
  31821. * @return the animationGroup
  31822. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31823. */
  31824. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31825. /**
  31826. * Synchronize and normalize all animatables with a source animatable
  31827. * @param root defines the root animatable to synchronize with
  31828. * @return the animationGroup
  31829. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31830. */
  31831. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31832. /**
  31833. * Goes to a specific frame in this animation group
  31834. * @param frame the frame number to go to
  31835. * @return the animationGroup
  31836. */
  31837. goToFrame(frame: number): AnimationGroup;
  31838. /**
  31839. * Dispose all associated resources
  31840. */
  31841. dispose(): void;
  31842. private _checkAnimationGroupEnded;
  31843. /**
  31844. * Clone the current animation group and returns a copy
  31845. * @param newName defines the name of the new group
  31846. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31847. * @returns the new aniamtion group
  31848. */
  31849. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31850. /**
  31851. * Returns a new AnimationGroup object parsed from the source provided.
  31852. * @param parsedAnimationGroup defines the source
  31853. * @param scene defines the scene that will receive the animationGroup
  31854. * @returns a new AnimationGroup
  31855. */
  31856. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31857. /**
  31858. * Returns the string "AnimationGroup"
  31859. * @returns "AnimationGroup"
  31860. */
  31861. getClassName(): string;
  31862. /**
  31863. * Creates a detailled string about the object
  31864. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31865. * @returns a string representing the object
  31866. */
  31867. toString(fullDetails?: boolean): string;
  31868. }
  31869. }
  31870. declare module BABYLON {
  31871. /**
  31872. * Define an interface for all classes that will hold resources
  31873. */
  31874. export interface IDisposable {
  31875. /**
  31876. * Releases all held resources
  31877. */
  31878. dispose(): void;
  31879. }
  31880. /** Interface defining initialization parameters for Scene class */
  31881. export interface SceneOptions {
  31882. /**
  31883. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31884. * It will improve performance when the number of geometries becomes important.
  31885. */
  31886. useGeometryUniqueIdsMap?: boolean;
  31887. /**
  31888. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31889. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31890. */
  31891. useMaterialMeshMap?: boolean;
  31892. /**
  31893. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned 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. useClonedMeshhMap?: boolean;
  31897. }
  31898. /**
  31899. * Represents a scene to be rendered by the engine.
  31900. * @see http://doc.babylonjs.com/features/scene
  31901. */
  31902. export class Scene extends AbstractScene implements IAnimatable {
  31903. private static _uniqueIdCounter;
  31904. /** The fog is deactivated */
  31905. static readonly FOGMODE_NONE: number;
  31906. /** The fog density is following an exponential function */
  31907. static readonly FOGMODE_EXP: number;
  31908. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31909. static readonly FOGMODE_EXP2: number;
  31910. /** The fog density is following a linear function. */
  31911. static readonly FOGMODE_LINEAR: number;
  31912. /**
  31913. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31914. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31915. */
  31916. static MinDeltaTime: number;
  31917. /**
  31918. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31919. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31920. */
  31921. static MaxDeltaTime: number;
  31922. /**
  31923. * Factory used to create the default material.
  31924. * @param name The name of the material to create
  31925. * @param scene The scene to create the material for
  31926. * @returns The default material
  31927. */
  31928. static DefaultMaterialFactory(scene: Scene): Material;
  31929. /**
  31930. * Factory used to create the a collision coordinator.
  31931. * @returns The collision coordinator
  31932. */
  31933. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31934. /** @hidden */
  31935. _inputManager: InputManager;
  31936. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31937. cameraToUseForPointers: Nullable<Camera>;
  31938. /** @hidden */
  31939. readonly _isScene: boolean;
  31940. /**
  31941. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31942. */
  31943. autoClear: boolean;
  31944. /**
  31945. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31946. */
  31947. autoClearDepthAndStencil: boolean;
  31948. /**
  31949. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31950. */
  31951. clearColor: Color4;
  31952. /**
  31953. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31954. */
  31955. ambientColor: Color3;
  31956. /**
  31957. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31958. * It should only be one of the following (if not the default embedded one):
  31959. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31960. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31961. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31962. * The material properties need to be setup according to the type of texture in use.
  31963. */
  31964. environmentBRDFTexture: BaseTexture;
  31965. /** @hidden */
  31966. protected _environmentTexture: Nullable<BaseTexture>;
  31967. /**
  31968. * Texture used in all pbr material as the reflection texture.
  31969. * As in the majority of the scene they are the same (exception for multi room and so on),
  31970. * this is easier to reference from here than from all the materials.
  31971. */
  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 set here than in all the materials.
  31976. */
  31977. environmentTexture: Nullable<BaseTexture>;
  31978. /** @hidden */
  31979. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31980. /**
  31981. * Default image processing configuration used either in the rendering
  31982. * Forward main pass or through the imageProcessingPostProcess if present.
  31983. * As in the majority of the scene they are the same (exception for multi camera),
  31984. * this is easier to reference from here than from all the materials and post process.
  31985. *
  31986. * No setter as we it is a shared configuration, you can set the values instead.
  31987. */
  31988. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31989. private _forceWireframe;
  31990. /**
  31991. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31992. */
  31993. forceWireframe: boolean;
  31994. private _forcePointsCloud;
  31995. /**
  31996. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31997. */
  31998. forcePointsCloud: boolean;
  31999. /**
  32000. * Gets or sets the active clipplane 1
  32001. */
  32002. clipPlane: Nullable<Plane>;
  32003. /**
  32004. * Gets or sets the active clipplane 2
  32005. */
  32006. clipPlane2: Nullable<Plane>;
  32007. /**
  32008. * Gets or sets the active clipplane 3
  32009. */
  32010. clipPlane3: Nullable<Plane>;
  32011. /**
  32012. * Gets or sets the active clipplane 4
  32013. */
  32014. clipPlane4: Nullable<Plane>;
  32015. /**
  32016. * Gets or sets a boolean indicating if animations are enabled
  32017. */
  32018. animationsEnabled: boolean;
  32019. private _animationPropertiesOverride;
  32020. /**
  32021. * Gets or sets the animation properties override
  32022. */
  32023. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32024. /**
  32025. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32026. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32027. */
  32028. useConstantAnimationDeltaTime: boolean;
  32029. /**
  32030. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32031. * Please note that it requires to run a ray cast through the scene on every frame
  32032. */
  32033. constantlyUpdateMeshUnderPointer: boolean;
  32034. /**
  32035. * Defines the HTML cursor to use when hovering over interactive elements
  32036. */
  32037. hoverCursor: string;
  32038. /**
  32039. * Defines the HTML default cursor to use (empty by default)
  32040. */
  32041. defaultCursor: string;
  32042. /**
  32043. * This is used to call preventDefault() on pointer down
  32044. * in order to block unwanted artifacts like system double clicks
  32045. */
  32046. preventDefaultOnPointerDown: boolean;
  32047. /**
  32048. * This is used to call preventDefault() on pointer up
  32049. * in order to block unwanted artifacts like system double clicks
  32050. */
  32051. preventDefaultOnPointerUp: boolean;
  32052. /**
  32053. * Gets or sets user defined metadata
  32054. */
  32055. metadata: any;
  32056. /**
  32057. * For internal use only. Please do not use.
  32058. */
  32059. reservedDataStore: any;
  32060. /**
  32061. * Gets the name of the plugin used to load this scene (null by default)
  32062. */
  32063. loadingPluginName: string;
  32064. /**
  32065. * Use this array to add regular expressions used to disable offline support for specific urls
  32066. */
  32067. disableOfflineSupportExceptionRules: RegExp[];
  32068. /**
  32069. * An event triggered when the scene is disposed.
  32070. */
  32071. onDisposeObservable: Observable<Scene>;
  32072. private _onDisposeObserver;
  32073. /** Sets a function to be executed when this scene is disposed. */
  32074. onDispose: () => void;
  32075. /**
  32076. * An event triggered before rendering the scene (right after animations and physics)
  32077. */
  32078. onBeforeRenderObservable: Observable<Scene>;
  32079. private _onBeforeRenderObserver;
  32080. /** Sets a function to be executed before rendering this scene */
  32081. beforeRender: Nullable<() => void>;
  32082. /**
  32083. * An event triggered after rendering the scene
  32084. */
  32085. onAfterRenderObservable: Observable<Scene>;
  32086. private _onAfterRenderObserver;
  32087. /** Sets a function to be executed after rendering this scene */
  32088. afterRender: Nullable<() => void>;
  32089. /**
  32090. * An event triggered before animating the scene
  32091. */
  32092. onBeforeAnimationsObservable: Observable<Scene>;
  32093. /**
  32094. * An event triggered after animations processing
  32095. */
  32096. onAfterAnimationsObservable: Observable<Scene>;
  32097. /**
  32098. * An event triggered before draw calls are ready to be sent
  32099. */
  32100. onBeforeDrawPhaseObservable: Observable<Scene>;
  32101. /**
  32102. * An event triggered after draw calls have been sent
  32103. */
  32104. onAfterDrawPhaseObservable: Observable<Scene>;
  32105. /**
  32106. * An event triggered when the scene is ready
  32107. */
  32108. onReadyObservable: Observable<Scene>;
  32109. /**
  32110. * An event triggered before rendering a camera
  32111. */
  32112. onBeforeCameraRenderObservable: Observable<Camera>;
  32113. private _onBeforeCameraRenderObserver;
  32114. /** Sets a function to be executed before rendering a camera*/
  32115. beforeCameraRender: () => void;
  32116. /**
  32117. * An event triggered after rendering a camera
  32118. */
  32119. onAfterCameraRenderObservable: Observable<Camera>;
  32120. private _onAfterCameraRenderObserver;
  32121. /** Sets a function to be executed after rendering a camera*/
  32122. afterCameraRender: () => void;
  32123. /**
  32124. * An event triggered when active meshes evaluation is about to start
  32125. */
  32126. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32127. /**
  32128. * An event triggered when active meshes evaluation is done
  32129. */
  32130. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32131. /**
  32132. * An event triggered when particles rendering is about to start
  32133. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32134. */
  32135. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32136. /**
  32137. * An event triggered when particles rendering is done
  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. onAfterParticlesRenderingObservable: Observable<Scene>;
  32141. /**
  32142. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32143. */
  32144. onDataLoadedObservable: Observable<Scene>;
  32145. /**
  32146. * An event triggered when a camera is created
  32147. */
  32148. onNewCameraAddedObservable: Observable<Camera>;
  32149. /**
  32150. * An event triggered when a camera is removed
  32151. */
  32152. onCameraRemovedObservable: Observable<Camera>;
  32153. /**
  32154. * An event triggered when a light is created
  32155. */
  32156. onNewLightAddedObservable: Observable<Light>;
  32157. /**
  32158. * An event triggered when a light is removed
  32159. */
  32160. onLightRemovedObservable: Observable<Light>;
  32161. /**
  32162. * An event triggered when a geometry is created
  32163. */
  32164. onNewGeometryAddedObservable: Observable<Geometry>;
  32165. /**
  32166. * An event triggered when a geometry is removed
  32167. */
  32168. onGeometryRemovedObservable: Observable<Geometry>;
  32169. /**
  32170. * An event triggered when a transform node is created
  32171. */
  32172. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32173. /**
  32174. * An event triggered when a transform node is removed
  32175. */
  32176. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32177. /**
  32178. * An event triggered when a mesh is created
  32179. */
  32180. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32181. /**
  32182. * An event triggered when a mesh is removed
  32183. */
  32184. onMeshRemovedObservable: Observable<AbstractMesh>;
  32185. /**
  32186. * An event triggered when a skeleton is created
  32187. */
  32188. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32189. /**
  32190. * An event triggered when a skeleton is removed
  32191. */
  32192. onSkeletonRemovedObservable: Observable<Skeleton>;
  32193. /**
  32194. * An event triggered when a material is created
  32195. */
  32196. onNewMaterialAddedObservable: Observable<Material>;
  32197. /**
  32198. * An event triggered when a material is removed
  32199. */
  32200. onMaterialRemovedObservable: Observable<Material>;
  32201. /**
  32202. * An event triggered when a texture is created
  32203. */
  32204. onNewTextureAddedObservable: Observable<BaseTexture>;
  32205. /**
  32206. * An event triggered when a texture is removed
  32207. */
  32208. onTextureRemovedObservable: Observable<BaseTexture>;
  32209. /**
  32210. * An event triggered when render targets are about to be rendered
  32211. * Can happen multiple times per frame.
  32212. */
  32213. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32214. /**
  32215. * An event triggered when render targets were rendered.
  32216. * Can happen multiple times per frame.
  32217. */
  32218. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32219. /**
  32220. * An event triggered before calculating deterministic simulation step
  32221. */
  32222. onBeforeStepObservable: Observable<Scene>;
  32223. /**
  32224. * An event triggered after calculating deterministic simulation step
  32225. */
  32226. onAfterStepObservable: Observable<Scene>;
  32227. /**
  32228. * An event triggered when the activeCamera property is updated
  32229. */
  32230. onActiveCameraChanged: Observable<Scene>;
  32231. /**
  32232. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32233. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32234. * 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)
  32235. */
  32236. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32237. /**
  32238. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32239. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32240. * 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)
  32241. */
  32242. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32243. /**
  32244. * This Observable will when a mesh has been imported into the scene.
  32245. */
  32246. onMeshImportedObservable: Observable<AbstractMesh>;
  32247. /**
  32248. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32249. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32250. */
  32251. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32252. /** @hidden */
  32253. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32254. /**
  32255. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32256. */
  32257. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32258. /**
  32259. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32260. */
  32261. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32262. /**
  32263. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32264. */
  32265. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32266. /** Callback called when a pointer move is detected */
  32267. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32268. /** Callback called when a pointer down is detected */
  32269. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32270. /** Callback called when a pointer up is detected */
  32271. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32272. /** Callback called when a pointer pick is detected */
  32273. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32274. /**
  32275. * 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).
  32276. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32277. */
  32278. onPrePointerObservable: Observable<PointerInfoPre>;
  32279. /**
  32280. * Observable event triggered each time an input event is received from the rendering canvas
  32281. */
  32282. onPointerObservable: Observable<PointerInfo>;
  32283. /**
  32284. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32285. */
  32286. readonly unTranslatedPointer: Vector2;
  32287. /**
  32288. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32289. */
  32290. static DragMovementThreshold: number;
  32291. /**
  32292. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32293. */
  32294. static LongPressDelay: number;
  32295. /**
  32296. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32297. */
  32298. static DoubleClickDelay: number;
  32299. /** If you need to check double click without raising a single click at first click, enable this flag */
  32300. static ExclusiveDoubleClickMode: boolean;
  32301. /** @hidden */
  32302. _mirroredCameraPosition: Nullable<Vector3>;
  32303. /**
  32304. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32305. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32306. */
  32307. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32308. /**
  32309. * Observable event triggered each time an keyboard event is received from the hosting window
  32310. */
  32311. onKeyboardObservable: Observable<KeyboardInfo>;
  32312. private _useRightHandedSystem;
  32313. /**
  32314. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32315. */
  32316. useRightHandedSystem: boolean;
  32317. private _timeAccumulator;
  32318. private _currentStepId;
  32319. private _currentInternalStep;
  32320. /**
  32321. * Sets the step Id used by deterministic lock step
  32322. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32323. * @param newStepId defines the step Id
  32324. */
  32325. setStepId(newStepId: number): void;
  32326. /**
  32327. * Gets the step Id used by deterministic lock step
  32328. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32329. * @returns the step Id
  32330. */
  32331. getStepId(): number;
  32332. /**
  32333. * Gets the internal step used by deterministic lock step
  32334. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32335. * @returns the internal step
  32336. */
  32337. getInternalStep(): number;
  32338. private _fogEnabled;
  32339. /**
  32340. * Gets or sets a boolean indicating if fog is enabled on this scene
  32341. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32342. * (Default is true)
  32343. */
  32344. fogEnabled: boolean;
  32345. private _fogMode;
  32346. /**
  32347. * Gets or sets the fog mode to use
  32348. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32349. * | mode | value |
  32350. * | --- | --- |
  32351. * | FOGMODE_NONE | 0 |
  32352. * | FOGMODE_EXP | 1 |
  32353. * | FOGMODE_EXP2 | 2 |
  32354. * | FOGMODE_LINEAR | 3 |
  32355. */
  32356. fogMode: number;
  32357. /**
  32358. * Gets or sets the fog color to use
  32359. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32360. * (Default is Color3(0.2, 0.2, 0.3))
  32361. */
  32362. fogColor: Color3;
  32363. /**
  32364. * Gets or sets the fog density to use
  32365. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32366. * (Default is 0.1)
  32367. */
  32368. fogDensity: number;
  32369. /**
  32370. * Gets or sets the fog start distance to use
  32371. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32372. * (Default is 0)
  32373. */
  32374. fogStart: number;
  32375. /**
  32376. * Gets or sets the fog end distance to use
  32377. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32378. * (Default is 1000)
  32379. */
  32380. fogEnd: number;
  32381. private _shadowsEnabled;
  32382. /**
  32383. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32384. */
  32385. shadowsEnabled: boolean;
  32386. private _lightsEnabled;
  32387. /**
  32388. * Gets or sets a boolean indicating if lights are enabled on this scene
  32389. */
  32390. lightsEnabled: boolean;
  32391. /** All of the active cameras added to this scene. */
  32392. activeCameras: Camera[];
  32393. /** @hidden */
  32394. _activeCamera: Nullable<Camera>;
  32395. /** Gets or sets the current active camera */
  32396. activeCamera: Nullable<Camera>;
  32397. private _defaultMaterial;
  32398. /** The default material used on meshes when no material is affected */
  32399. /** The default material used on meshes when no material is affected */
  32400. defaultMaterial: Material;
  32401. private _texturesEnabled;
  32402. /**
  32403. * Gets or sets a boolean indicating if textures are enabled on this scene
  32404. */
  32405. texturesEnabled: boolean;
  32406. /**
  32407. * Gets or sets a boolean indicating if particles are enabled on this scene
  32408. */
  32409. particlesEnabled: boolean;
  32410. /**
  32411. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32412. */
  32413. spritesEnabled: boolean;
  32414. private _skeletonsEnabled;
  32415. /**
  32416. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32417. */
  32418. skeletonsEnabled: boolean;
  32419. /**
  32420. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32421. */
  32422. lensFlaresEnabled: boolean;
  32423. /**
  32424. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32425. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32426. */
  32427. collisionsEnabled: boolean;
  32428. private _collisionCoordinator;
  32429. /** @hidden */
  32430. readonly collisionCoordinator: ICollisionCoordinator;
  32431. /**
  32432. * Defines the gravity applied to this scene (used only for collisions)
  32433. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32434. */
  32435. gravity: Vector3;
  32436. /**
  32437. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32438. */
  32439. postProcessesEnabled: boolean;
  32440. /**
  32441. * The list of postprocesses added to the scene
  32442. */
  32443. postProcesses: PostProcess[];
  32444. /**
  32445. * Gets the current postprocess manager
  32446. */
  32447. postProcessManager: PostProcessManager;
  32448. /**
  32449. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32450. */
  32451. renderTargetsEnabled: boolean;
  32452. /**
  32453. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32454. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32455. */
  32456. dumpNextRenderTargets: boolean;
  32457. /**
  32458. * The list of user defined render targets added to the scene
  32459. */
  32460. customRenderTargets: RenderTargetTexture[];
  32461. /**
  32462. * Defines if texture loading must be delayed
  32463. * If true, textures will only be loaded when they need to be rendered
  32464. */
  32465. useDelayedTextureLoading: boolean;
  32466. /**
  32467. * Gets the list of meshes imported to the scene through SceneLoader
  32468. */
  32469. importedMeshesFiles: String[];
  32470. /**
  32471. * Gets or sets a boolean indicating if probes are enabled on this scene
  32472. */
  32473. probesEnabled: boolean;
  32474. /**
  32475. * Gets or sets the current offline provider to use to store scene data
  32476. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32477. */
  32478. offlineProvider: IOfflineProvider;
  32479. /**
  32480. * Gets or sets the action manager associated with the scene
  32481. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32482. */
  32483. actionManager: AbstractActionManager;
  32484. private _meshesForIntersections;
  32485. /**
  32486. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32487. */
  32488. proceduralTexturesEnabled: boolean;
  32489. private _engine;
  32490. private _totalVertices;
  32491. /** @hidden */
  32492. _activeIndices: PerfCounter;
  32493. /** @hidden */
  32494. _activeParticles: PerfCounter;
  32495. /** @hidden */
  32496. _activeBones: PerfCounter;
  32497. private _animationRatio;
  32498. /** @hidden */
  32499. _animationTimeLast: number;
  32500. /** @hidden */
  32501. _animationTime: number;
  32502. /**
  32503. * Gets or sets a general scale for animation speed
  32504. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32505. */
  32506. animationTimeScale: number;
  32507. /** @hidden */
  32508. _cachedMaterial: Nullable<Material>;
  32509. /** @hidden */
  32510. _cachedEffect: Nullable<Effect>;
  32511. /** @hidden */
  32512. _cachedVisibility: Nullable<number>;
  32513. private _renderId;
  32514. private _frameId;
  32515. private _executeWhenReadyTimeoutId;
  32516. private _intermediateRendering;
  32517. private _viewUpdateFlag;
  32518. private _projectionUpdateFlag;
  32519. /** @hidden */
  32520. _toBeDisposed: Nullable<IDisposable>[];
  32521. private _activeRequests;
  32522. /** @hidden */
  32523. _pendingData: any[];
  32524. private _isDisposed;
  32525. /**
  32526. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32527. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32528. */
  32529. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32530. private _activeMeshes;
  32531. private _processedMaterials;
  32532. private _renderTargets;
  32533. /** @hidden */
  32534. _activeParticleSystems: SmartArray<IParticleSystem>;
  32535. private _activeSkeletons;
  32536. private _softwareSkinnedMeshes;
  32537. private _renderingManager;
  32538. /** @hidden */
  32539. _activeAnimatables: Animatable[];
  32540. private _transformMatrix;
  32541. private _sceneUbo;
  32542. /** @hidden */
  32543. _viewMatrix: Matrix;
  32544. private _projectionMatrix;
  32545. /** @hidden */
  32546. _forcedViewPosition: Nullable<Vector3>;
  32547. /** @hidden */
  32548. _frustumPlanes: Plane[];
  32549. /**
  32550. * Gets the list of frustum planes (built from the active camera)
  32551. */
  32552. readonly frustumPlanes: Plane[];
  32553. /**
  32554. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32555. * This is useful if there are more lights that the maximum simulteanous authorized
  32556. */
  32557. requireLightSorting: boolean;
  32558. /** @hidden */
  32559. readonly useMaterialMeshMap: boolean;
  32560. /** @hidden */
  32561. readonly useClonedMeshhMap: boolean;
  32562. private _externalData;
  32563. private _uid;
  32564. /**
  32565. * @hidden
  32566. * Backing store of defined scene components.
  32567. */
  32568. _components: ISceneComponent[];
  32569. /**
  32570. * @hidden
  32571. * Backing store of defined scene components.
  32572. */
  32573. _serializableComponents: ISceneSerializableComponent[];
  32574. /**
  32575. * List of components to register on the next registration step.
  32576. */
  32577. private _transientComponents;
  32578. /**
  32579. * Registers the transient components if needed.
  32580. */
  32581. private _registerTransientComponents;
  32582. /**
  32583. * @hidden
  32584. * Add a component to the scene.
  32585. * Note that the ccomponent could be registered on th next frame if this is called after
  32586. * the register component stage.
  32587. * @param component Defines the component to add to the scene
  32588. */
  32589. _addComponent(component: ISceneComponent): void;
  32590. /**
  32591. * @hidden
  32592. * Gets a component from the scene.
  32593. * @param name defines the name of the component to retrieve
  32594. * @returns the component or null if not present
  32595. */
  32596. _getComponent(name: string): Nullable<ISceneComponent>;
  32597. /**
  32598. * @hidden
  32599. * Defines the actions happening before camera updates.
  32600. */
  32601. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32602. /**
  32603. * @hidden
  32604. * Defines the actions happening before clear the canvas.
  32605. */
  32606. _beforeClearStage: Stage<SimpleStageAction>;
  32607. /**
  32608. * @hidden
  32609. * Defines the actions when collecting render targets for the frame.
  32610. */
  32611. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32612. /**
  32613. * @hidden
  32614. * Defines the actions happening for one camera in the frame.
  32615. */
  32616. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32617. /**
  32618. * @hidden
  32619. * Defines the actions happening during the per mesh ready checks.
  32620. */
  32621. _isReadyForMeshStage: Stage<MeshStageAction>;
  32622. /**
  32623. * @hidden
  32624. * Defines the actions happening before evaluate active mesh checks.
  32625. */
  32626. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32627. /**
  32628. * @hidden
  32629. * Defines the actions happening during the evaluate sub mesh checks.
  32630. */
  32631. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32632. /**
  32633. * @hidden
  32634. * Defines the actions happening during the active mesh stage.
  32635. */
  32636. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32637. /**
  32638. * @hidden
  32639. * Defines the actions happening during the per camera render target step.
  32640. */
  32641. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32642. /**
  32643. * @hidden
  32644. * Defines the actions happening just before the active camera is drawing.
  32645. */
  32646. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32647. /**
  32648. * @hidden
  32649. * Defines the actions happening just before a render target is drawing.
  32650. */
  32651. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32652. /**
  32653. * @hidden
  32654. * Defines the actions happening just before a rendering group is drawing.
  32655. */
  32656. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32657. /**
  32658. * @hidden
  32659. * Defines the actions happening just before a mesh is drawing.
  32660. */
  32661. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32662. /**
  32663. * @hidden
  32664. * Defines the actions happening just after a mesh has been drawn.
  32665. */
  32666. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32667. /**
  32668. * @hidden
  32669. * Defines the actions happening just after a rendering group has been drawn.
  32670. */
  32671. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32672. /**
  32673. * @hidden
  32674. * Defines the actions happening just after the active camera has been drawn.
  32675. */
  32676. _afterCameraDrawStage: Stage<CameraStageAction>;
  32677. /**
  32678. * @hidden
  32679. * Defines the actions happening just after a render target has been drawn.
  32680. */
  32681. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32682. /**
  32683. * @hidden
  32684. * Defines the actions happening just after rendering all cameras and computing intersections.
  32685. */
  32686. _afterRenderStage: Stage<SimpleStageAction>;
  32687. /**
  32688. * @hidden
  32689. * Defines the actions happening when a pointer move event happens.
  32690. */
  32691. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32692. /**
  32693. * @hidden
  32694. * Defines the actions happening when a pointer down event happens.
  32695. */
  32696. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32697. /**
  32698. * @hidden
  32699. * Defines the actions happening when a pointer up event happens.
  32700. */
  32701. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32702. /**
  32703. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32704. */
  32705. private geometriesByUniqueId;
  32706. /**
  32707. * Creates a new Scene
  32708. * @param engine defines the engine to use to render this scene
  32709. * @param options defines the scene options
  32710. */
  32711. constructor(engine: Engine, options?: SceneOptions);
  32712. /**
  32713. * Gets a string idenfifying the name of the class
  32714. * @returns "Scene" string
  32715. */
  32716. getClassName(): string;
  32717. private _defaultMeshCandidates;
  32718. /**
  32719. * @hidden
  32720. */
  32721. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32722. private _defaultSubMeshCandidates;
  32723. /**
  32724. * @hidden
  32725. */
  32726. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32727. /**
  32728. * Sets the default candidate providers for the scene.
  32729. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32730. * and getCollidingSubMeshCandidates to their default function
  32731. */
  32732. setDefaultCandidateProviders(): void;
  32733. /**
  32734. * Gets the mesh that is currently under the pointer
  32735. */
  32736. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32737. /**
  32738. * Gets or sets the current on-screen X position of the pointer
  32739. */
  32740. pointerX: number;
  32741. /**
  32742. * Gets or sets the current on-screen Y position of the pointer
  32743. */
  32744. pointerY: number;
  32745. /**
  32746. * Gets the cached material (ie. the latest rendered one)
  32747. * @returns the cached material
  32748. */
  32749. getCachedMaterial(): Nullable<Material>;
  32750. /**
  32751. * Gets the cached effect (ie. the latest rendered one)
  32752. * @returns the cached effect
  32753. */
  32754. getCachedEffect(): Nullable<Effect>;
  32755. /**
  32756. * Gets the cached visibility state (ie. the latest rendered one)
  32757. * @returns the cached visibility state
  32758. */
  32759. getCachedVisibility(): Nullable<number>;
  32760. /**
  32761. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32762. * @param material defines the current material
  32763. * @param effect defines the current effect
  32764. * @param visibility defines the current visibility state
  32765. * @returns true if one parameter is not cached
  32766. */
  32767. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32768. /**
  32769. * Gets the engine associated with the scene
  32770. * @returns an Engine
  32771. */
  32772. getEngine(): Engine;
  32773. /**
  32774. * Gets the total number of vertices rendered per frame
  32775. * @returns the total number of vertices rendered per frame
  32776. */
  32777. getTotalVertices(): number;
  32778. /**
  32779. * Gets the performance counter for total vertices
  32780. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32781. */
  32782. readonly totalVerticesPerfCounter: PerfCounter;
  32783. /**
  32784. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32785. * @returns the total number of active indices rendered per frame
  32786. */
  32787. getActiveIndices(): number;
  32788. /**
  32789. * Gets the performance counter for active indices
  32790. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32791. */
  32792. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32793. /**
  32794. * Gets the total number of active particles rendered per frame
  32795. * @returns the total number of active particles rendered per frame
  32796. */
  32797. getActiveParticles(): number;
  32798. /**
  32799. * Gets the performance counter for active particles
  32800. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32801. */
  32802. readonly activeParticlesPerfCounter: PerfCounter;
  32803. /**
  32804. * Gets the total number of active bones rendered per frame
  32805. * @returns the total number of active bones rendered per frame
  32806. */
  32807. getActiveBones(): number;
  32808. /**
  32809. * Gets the performance counter for active bones
  32810. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32811. */
  32812. readonly activeBonesPerfCounter: PerfCounter;
  32813. /**
  32814. * Gets the array of active meshes
  32815. * @returns an array of AbstractMesh
  32816. */
  32817. getActiveMeshes(): SmartArray<AbstractMesh>;
  32818. /**
  32819. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32820. * @returns a number
  32821. */
  32822. getAnimationRatio(): number;
  32823. /**
  32824. * Gets an unique Id for the current render phase
  32825. * @returns a number
  32826. */
  32827. getRenderId(): number;
  32828. /**
  32829. * Gets an unique Id for the current frame
  32830. * @returns a number
  32831. */
  32832. getFrameId(): number;
  32833. /** Call this function if you want to manually increment the render Id*/
  32834. incrementRenderId(): void;
  32835. private _createUbo;
  32836. /**
  32837. * Use this method to simulate a pointer move on a mesh
  32838. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32839. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32840. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32841. * @returns the current scene
  32842. */
  32843. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32844. /**
  32845. * Use this method to simulate a pointer down on a mesh
  32846. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32847. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32848. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32849. * @returns the current scene
  32850. */
  32851. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32852. /**
  32853. * Use this method to simulate a pointer up on a mesh
  32854. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32855. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32856. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32857. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32858. * @returns the current scene
  32859. */
  32860. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32861. /**
  32862. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32863. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32864. * @returns true if the pointer was captured
  32865. */
  32866. isPointerCaptured(pointerId?: number): boolean;
  32867. /**
  32868. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32869. * @param attachUp defines if you want to attach events to pointerup
  32870. * @param attachDown defines if you want to attach events to pointerdown
  32871. * @param attachMove defines if you want to attach events to pointermove
  32872. */
  32873. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32874. /** Detaches all event handlers*/
  32875. detachControl(): void;
  32876. /**
  32877. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32878. * Delay loaded resources are not taking in account
  32879. * @return true if all required resources are ready
  32880. */
  32881. isReady(): boolean;
  32882. /** Resets all cached information relative to material (including effect and visibility) */
  32883. resetCachedMaterial(): void;
  32884. /**
  32885. * Registers a function to be called before every frame render
  32886. * @param func defines the function to register
  32887. */
  32888. registerBeforeRender(func: () => void): void;
  32889. /**
  32890. * Unregisters a function called before every frame render
  32891. * @param func defines the function to unregister
  32892. */
  32893. unregisterBeforeRender(func: () => void): void;
  32894. /**
  32895. * Registers a function to be called after every frame render
  32896. * @param func defines the function to register
  32897. */
  32898. registerAfterRender(func: () => void): void;
  32899. /**
  32900. * Unregisters a function called after every frame render
  32901. * @param func defines the function to unregister
  32902. */
  32903. unregisterAfterRender(func: () => void): void;
  32904. private _executeOnceBeforeRender;
  32905. /**
  32906. * The provided function will run before render once and will be disposed afterwards.
  32907. * A timeout delay can be provided so that the function will be executed in N ms.
  32908. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32909. * @param func The function to be executed.
  32910. * @param timeout optional delay in ms
  32911. */
  32912. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32913. /** @hidden */
  32914. _addPendingData(data: any): void;
  32915. /** @hidden */
  32916. _removePendingData(data: any): void;
  32917. /**
  32918. * Returns the number of items waiting to be loaded
  32919. * @returns the number of items waiting to be loaded
  32920. */
  32921. getWaitingItemsCount(): number;
  32922. /**
  32923. * Returns a boolean indicating if the scene is still loading data
  32924. */
  32925. readonly isLoading: boolean;
  32926. /**
  32927. * Registers a function to be executed when the scene is ready
  32928. * @param {Function} func - the function to be executed
  32929. */
  32930. executeWhenReady(func: () => void): void;
  32931. /**
  32932. * Returns a promise that resolves when the scene is ready
  32933. * @returns A promise that resolves when the scene is ready
  32934. */
  32935. whenReadyAsync(): Promise<void>;
  32936. /** @hidden */
  32937. _checkIsReady(): void;
  32938. /**
  32939. * Gets all animatable attached to the scene
  32940. */
  32941. readonly animatables: Animatable[];
  32942. /**
  32943. * Resets the last animation time frame.
  32944. * Useful to override when animations start running when loading a scene for the first time.
  32945. */
  32946. resetLastAnimationTimeFrame(): void;
  32947. /**
  32948. * Gets the current view matrix
  32949. * @returns a Matrix
  32950. */
  32951. getViewMatrix(): Matrix;
  32952. /**
  32953. * Gets the current projection matrix
  32954. * @returns a Matrix
  32955. */
  32956. getProjectionMatrix(): Matrix;
  32957. /**
  32958. * Gets the current transform matrix
  32959. * @returns a Matrix made of View * Projection
  32960. */
  32961. getTransformMatrix(): Matrix;
  32962. /**
  32963. * Sets the current transform matrix
  32964. * @param viewL defines the View matrix to use
  32965. * @param projectionL defines the Projection matrix to use
  32966. * @param viewR defines the right View matrix to use (if provided)
  32967. * @param projectionR defines the right Projection matrix to use (if provided)
  32968. */
  32969. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32970. /**
  32971. * Gets the uniform buffer used to store scene data
  32972. * @returns a UniformBuffer
  32973. */
  32974. getSceneUniformBuffer(): UniformBuffer;
  32975. /**
  32976. * Gets an unique (relatively to the current scene) Id
  32977. * @returns an unique number for the scene
  32978. */
  32979. getUniqueId(): number;
  32980. /**
  32981. * Add a mesh to the list of scene's meshes
  32982. * @param newMesh defines the mesh to add
  32983. * @param recursive if all child meshes should also be added to the scene
  32984. */
  32985. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32986. /**
  32987. * Remove a mesh for the list of scene's meshes
  32988. * @param toRemove defines the mesh to remove
  32989. * @param recursive if all child meshes should also be removed from the scene
  32990. * @returns the index where the mesh was in the mesh list
  32991. */
  32992. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32993. /**
  32994. * Add a transform node to the list of scene's transform nodes
  32995. * @param newTransformNode defines the transform node to add
  32996. */
  32997. addTransformNode(newTransformNode: TransformNode): void;
  32998. /**
  32999. * Remove a transform node for the list of scene's transform nodes
  33000. * @param toRemove defines the transform node to remove
  33001. * @returns the index where the transform node was in the transform node list
  33002. */
  33003. removeTransformNode(toRemove: TransformNode): number;
  33004. /**
  33005. * Remove a skeleton for the list of scene's skeletons
  33006. * @param toRemove defines the skeleton to remove
  33007. * @returns the index where the skeleton was in the skeleton list
  33008. */
  33009. removeSkeleton(toRemove: Skeleton): number;
  33010. /**
  33011. * Remove a morph target for the list of scene's morph targets
  33012. * @param toRemove defines the morph target to remove
  33013. * @returns the index where the morph target was in the morph target list
  33014. */
  33015. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33016. /**
  33017. * Remove a light for the list of scene's lights
  33018. * @param toRemove defines the light to remove
  33019. * @returns the index where the light was in the light list
  33020. */
  33021. removeLight(toRemove: Light): number;
  33022. /**
  33023. * Remove a camera for the list of scene's cameras
  33024. * @param toRemove defines the camera to remove
  33025. * @returns the index where the camera was in the camera list
  33026. */
  33027. removeCamera(toRemove: Camera): number;
  33028. /**
  33029. * Remove a particle system for the list of scene's particle systems
  33030. * @param toRemove defines the particle system to remove
  33031. * @returns the index where the particle system was in the particle system list
  33032. */
  33033. removeParticleSystem(toRemove: IParticleSystem): number;
  33034. /**
  33035. * Remove a animation for the list of scene's animations
  33036. * @param toRemove defines the animation to remove
  33037. * @returns the index where the animation was in the animation list
  33038. */
  33039. removeAnimation(toRemove: Animation): number;
  33040. /**
  33041. * Will stop the animation of the given target
  33042. * @param target - the target
  33043. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33044. * @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)
  33045. */
  33046. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33047. /**
  33048. * Removes the given animation group from this scene.
  33049. * @param toRemove The animation group to remove
  33050. * @returns The index of the removed animation group
  33051. */
  33052. removeAnimationGroup(toRemove: AnimationGroup): number;
  33053. /**
  33054. * Removes the given multi-material from this scene.
  33055. * @param toRemove The multi-material to remove
  33056. * @returns The index of the removed multi-material
  33057. */
  33058. removeMultiMaterial(toRemove: MultiMaterial): number;
  33059. /**
  33060. * Removes the given material from this scene.
  33061. * @param toRemove The material to remove
  33062. * @returns The index of the removed material
  33063. */
  33064. removeMaterial(toRemove: Material): number;
  33065. /**
  33066. * Removes the given action manager from this scene.
  33067. * @param toRemove The action manager to remove
  33068. * @returns The index of the removed action manager
  33069. */
  33070. removeActionManager(toRemove: AbstractActionManager): number;
  33071. /**
  33072. * Removes the given texture from this scene.
  33073. * @param toRemove The texture to remove
  33074. * @returns The index of the removed texture
  33075. */
  33076. removeTexture(toRemove: BaseTexture): number;
  33077. /**
  33078. * Adds the given light to this scene
  33079. * @param newLight The light to add
  33080. */
  33081. addLight(newLight: Light): void;
  33082. /**
  33083. * Sorts the list list based on light priorities
  33084. */
  33085. sortLightsByPriority(): void;
  33086. /**
  33087. * Adds the given camera to this scene
  33088. * @param newCamera The camera to add
  33089. */
  33090. addCamera(newCamera: Camera): void;
  33091. /**
  33092. * Adds the given skeleton to this scene
  33093. * @param newSkeleton The skeleton to add
  33094. */
  33095. addSkeleton(newSkeleton: Skeleton): void;
  33096. /**
  33097. * Adds the given particle system to this scene
  33098. * @param newParticleSystem The particle system to add
  33099. */
  33100. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33101. /**
  33102. * Adds the given animation to this scene
  33103. * @param newAnimation The animation to add
  33104. */
  33105. addAnimation(newAnimation: Animation): void;
  33106. /**
  33107. * Adds the given animation group to this scene.
  33108. * @param newAnimationGroup The animation group to add
  33109. */
  33110. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33111. /**
  33112. * Adds the given multi-material to this scene
  33113. * @param newMultiMaterial The multi-material to add
  33114. */
  33115. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33116. /**
  33117. * Adds the given material to this scene
  33118. * @param newMaterial The material to add
  33119. */
  33120. addMaterial(newMaterial: Material): void;
  33121. /**
  33122. * Adds the given morph target to this scene
  33123. * @param newMorphTargetManager The morph target to add
  33124. */
  33125. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33126. /**
  33127. * Adds the given geometry to this scene
  33128. * @param newGeometry The geometry to add
  33129. */
  33130. addGeometry(newGeometry: Geometry): void;
  33131. /**
  33132. * Adds the given action manager to this scene
  33133. * @param newActionManager The action manager to add
  33134. */
  33135. addActionManager(newActionManager: AbstractActionManager): void;
  33136. /**
  33137. * Adds the given texture to this scene.
  33138. * @param newTexture The texture to add
  33139. */
  33140. addTexture(newTexture: BaseTexture): void;
  33141. /**
  33142. * Switch active camera
  33143. * @param newCamera defines the new active camera
  33144. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33145. */
  33146. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33147. /**
  33148. * sets the active camera of the scene using its ID
  33149. * @param id defines the camera's ID
  33150. * @return the new active camera or null if none found.
  33151. */
  33152. setActiveCameraByID(id: string): Nullable<Camera>;
  33153. /**
  33154. * sets the active camera of the scene using its name
  33155. * @param name defines the camera's name
  33156. * @returns the new active camera or null if none found.
  33157. */
  33158. setActiveCameraByName(name: string): Nullable<Camera>;
  33159. /**
  33160. * get an animation group using its name
  33161. * @param name defines the material's name
  33162. * @return the animation group or null if none found.
  33163. */
  33164. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33165. /**
  33166. * Get a material using its unique id
  33167. * @param uniqueId defines the material's unique id
  33168. * @return the material or null if none found.
  33169. */
  33170. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33171. /**
  33172. * get a material using its id
  33173. * @param id defines the material's ID
  33174. * @return the material or null if none found.
  33175. */
  33176. getMaterialByID(id: string): Nullable<Material>;
  33177. /**
  33178. * Gets a material using its name
  33179. * @param name defines the material's name
  33180. * @return the material or null if none found.
  33181. */
  33182. getMaterialByName(name: string): Nullable<Material>;
  33183. /**
  33184. * Gets a camera using its id
  33185. * @param id defines the id to look for
  33186. * @returns the camera or null if not found
  33187. */
  33188. getCameraByID(id: string): Nullable<Camera>;
  33189. /**
  33190. * Gets a camera using its unique id
  33191. * @param uniqueId defines the unique id to look for
  33192. * @returns the camera or null if not found
  33193. */
  33194. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33195. /**
  33196. * Gets a camera using its name
  33197. * @param name defines the camera's name
  33198. * @return the camera or null if none found.
  33199. */
  33200. getCameraByName(name: string): Nullable<Camera>;
  33201. /**
  33202. * Gets a bone using its id
  33203. * @param id defines the bone's id
  33204. * @return the bone or null if not found
  33205. */
  33206. getBoneByID(id: string): Nullable<Bone>;
  33207. /**
  33208. * Gets a bone using its id
  33209. * @param name defines the bone's name
  33210. * @return the bone or null if not found
  33211. */
  33212. getBoneByName(name: string): Nullable<Bone>;
  33213. /**
  33214. * Gets a light node using its name
  33215. * @param name defines the the light's name
  33216. * @return the light or null if none found.
  33217. */
  33218. getLightByName(name: string): Nullable<Light>;
  33219. /**
  33220. * Gets a light node using its id
  33221. * @param id defines the light's id
  33222. * @return the light or null if none found.
  33223. */
  33224. getLightByID(id: string): Nullable<Light>;
  33225. /**
  33226. * Gets a light node using its scene-generated unique ID
  33227. * @param uniqueId defines the light's unique id
  33228. * @return the light or null if none found.
  33229. */
  33230. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33231. /**
  33232. * Gets a particle system by id
  33233. * @param id defines the particle system id
  33234. * @return the corresponding system or null if none found
  33235. */
  33236. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33237. /**
  33238. * Gets a geometry using its ID
  33239. * @param id defines the geometry's id
  33240. * @return the geometry or null if none found.
  33241. */
  33242. getGeometryByID(id: string): Nullable<Geometry>;
  33243. private _getGeometryByUniqueID;
  33244. /**
  33245. * Add a new geometry to this scene
  33246. * @param geometry defines the geometry to be added to the scene.
  33247. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33248. * @return a boolean defining if the geometry was added or not
  33249. */
  33250. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33251. /**
  33252. * Removes an existing geometry
  33253. * @param geometry defines the geometry to be removed from the scene
  33254. * @return a boolean defining if the geometry was removed or not
  33255. */
  33256. removeGeometry(geometry: Geometry): boolean;
  33257. /**
  33258. * Gets the list of geometries attached to the scene
  33259. * @returns an array of Geometry
  33260. */
  33261. getGeometries(): Geometry[];
  33262. /**
  33263. * Gets the first added mesh found of a given ID
  33264. * @param id defines the id to search for
  33265. * @return the mesh found or null if not found at all
  33266. */
  33267. getMeshByID(id: string): Nullable<AbstractMesh>;
  33268. /**
  33269. * Gets a list of meshes using their id
  33270. * @param id defines the id to search for
  33271. * @returns a list of meshes
  33272. */
  33273. getMeshesByID(id: string): Array<AbstractMesh>;
  33274. /**
  33275. * Gets the first added transform node found of a given ID
  33276. * @param id defines the id to search for
  33277. * @return the found transform node or null if not found at all.
  33278. */
  33279. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33280. /**
  33281. * Gets a transform node with its auto-generated unique id
  33282. * @param uniqueId efines the unique id to search for
  33283. * @return the found transform node or null if not found at all.
  33284. */
  33285. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33286. /**
  33287. * Gets a list of transform nodes using their id
  33288. * @param id defines the id to search for
  33289. * @returns a list of transform nodes
  33290. */
  33291. getTransformNodesByID(id: string): Array<TransformNode>;
  33292. /**
  33293. * Gets a mesh with its auto-generated unique id
  33294. * @param uniqueId defines the unique id to search for
  33295. * @return the found mesh or null if not found at all.
  33296. */
  33297. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33298. /**
  33299. * Gets a the last added mesh using a given id
  33300. * @param id defines the id to search for
  33301. * @return the found mesh or null if not found at all.
  33302. */
  33303. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33304. /**
  33305. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33306. * @param id defines the id to search for
  33307. * @return the found node or null if not found at all
  33308. */
  33309. getLastEntryByID(id: string): Nullable<Node>;
  33310. /**
  33311. * Gets a node (Mesh, Camera, Light) using a given id
  33312. * @param id defines the id to search for
  33313. * @return the found node or null if not found at all
  33314. */
  33315. getNodeByID(id: string): Nullable<Node>;
  33316. /**
  33317. * Gets a node (Mesh, Camera, Light) using a given name
  33318. * @param name defines the name to search for
  33319. * @return the found node or null if not found at all.
  33320. */
  33321. getNodeByName(name: string): Nullable<Node>;
  33322. /**
  33323. * Gets a mesh using a given name
  33324. * @param name defines the name to search for
  33325. * @return the found mesh or null if not found at all.
  33326. */
  33327. getMeshByName(name: string): Nullable<AbstractMesh>;
  33328. /**
  33329. * Gets a transform node using a given name
  33330. * @param name defines the name to search for
  33331. * @return the found transform node or null if not found at all.
  33332. */
  33333. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33334. /**
  33335. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33336. * @param id defines the id to search for
  33337. * @return the found skeleton or null if not found at all.
  33338. */
  33339. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33340. /**
  33341. * Gets a skeleton using a given auto generated unique id
  33342. * @param uniqueId defines the unique id to search for
  33343. * @return the found skeleton or null if not found at all.
  33344. */
  33345. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33346. /**
  33347. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33348. * @param id defines the id to search for
  33349. * @return the found skeleton or null if not found at all.
  33350. */
  33351. getSkeletonById(id: string): Nullable<Skeleton>;
  33352. /**
  33353. * Gets a skeleton using a given name
  33354. * @param name defines the name to search for
  33355. * @return the found skeleton or null if not found at all.
  33356. */
  33357. getSkeletonByName(name: string): Nullable<Skeleton>;
  33358. /**
  33359. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33360. * @param id defines the id to search for
  33361. * @return the found morph target manager or null if not found at all.
  33362. */
  33363. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33364. /**
  33365. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33366. * @param id defines the id to search for
  33367. * @return the found morph target or null if not found at all.
  33368. */
  33369. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33370. /**
  33371. * Gets a boolean indicating if the given mesh is active
  33372. * @param mesh defines the mesh to look for
  33373. * @returns true if the mesh is in the active list
  33374. */
  33375. isActiveMesh(mesh: AbstractMesh): boolean;
  33376. /**
  33377. * Return a unique id as a string which can serve as an identifier for the scene
  33378. */
  33379. readonly uid: string;
  33380. /**
  33381. * Add an externaly attached data from its key.
  33382. * This method call will fail and return false, if such key already exists.
  33383. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33384. * @param key the unique key that identifies the data
  33385. * @param data the data object to associate to the key for this Engine instance
  33386. * @return true if no such key were already present and the data was added successfully, false otherwise
  33387. */
  33388. addExternalData<T>(key: string, data: T): boolean;
  33389. /**
  33390. * Get an externaly attached data from its key
  33391. * @param key the unique key that identifies the data
  33392. * @return the associated data, if present (can be null), or undefined if not present
  33393. */
  33394. getExternalData<T>(key: string): Nullable<T>;
  33395. /**
  33396. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33397. * @param key the unique key that identifies the data
  33398. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33399. * @return the associated data, can be null if the factory returned null.
  33400. */
  33401. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33402. /**
  33403. * Remove an externaly attached data from the Engine instance
  33404. * @param key the unique key that identifies the data
  33405. * @return true if the data was successfully removed, false if it doesn't exist
  33406. */
  33407. removeExternalData(key: string): boolean;
  33408. private _evaluateSubMesh;
  33409. /**
  33410. * Clear the processed materials smart array preventing retention point in material dispose.
  33411. */
  33412. freeProcessedMaterials(): void;
  33413. private _preventFreeActiveMeshesAndRenderingGroups;
  33414. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33415. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33416. * when disposing several meshes in a row or a hierarchy of meshes.
  33417. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33418. */
  33419. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33420. /**
  33421. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33422. */
  33423. freeActiveMeshes(): void;
  33424. /**
  33425. * Clear the info related to rendering groups preventing retention points during dispose.
  33426. */
  33427. freeRenderingGroups(): void;
  33428. /** @hidden */
  33429. _isInIntermediateRendering(): boolean;
  33430. /**
  33431. * Lambda returning the list of potentially active meshes.
  33432. */
  33433. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33434. /**
  33435. * Lambda returning the list of potentially active sub meshes.
  33436. */
  33437. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33438. /**
  33439. * Lambda returning the list of potentially intersecting sub meshes.
  33440. */
  33441. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33442. /**
  33443. * Lambda returning the list of potentially colliding sub meshes.
  33444. */
  33445. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33446. private _activeMeshesFrozen;
  33447. /**
  33448. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33449. * @returns the current scene
  33450. */
  33451. freezeActiveMeshes(): Scene;
  33452. /**
  33453. * Use this function to restart evaluating active meshes on every frame
  33454. * @returns the current scene
  33455. */
  33456. unfreezeActiveMeshes(): Scene;
  33457. private _evaluateActiveMeshes;
  33458. private _activeMesh;
  33459. /**
  33460. * Update the transform matrix to update from the current active camera
  33461. * @param force defines a boolean used to force the update even if cache is up to date
  33462. */
  33463. updateTransformMatrix(force?: boolean): void;
  33464. private _bindFrameBuffer;
  33465. /** @hidden */
  33466. _allowPostProcessClearColor: boolean;
  33467. /** @hidden */
  33468. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33469. private _processSubCameras;
  33470. private _checkIntersections;
  33471. /** @hidden */
  33472. _advancePhysicsEngineStep(step: number): void;
  33473. /**
  33474. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33475. */
  33476. getDeterministicFrameTime: () => number;
  33477. /** @hidden */
  33478. _animate(): void;
  33479. /** Execute all animations (for a frame) */
  33480. animate(): void;
  33481. /**
  33482. * Render the scene
  33483. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33484. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33485. */
  33486. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33487. /**
  33488. * Freeze all materials
  33489. * A frozen material will not be updatable but should be faster to render
  33490. */
  33491. freezeMaterials(): void;
  33492. /**
  33493. * Unfreeze all materials
  33494. * A frozen material will not be updatable but should be faster to render
  33495. */
  33496. unfreezeMaterials(): void;
  33497. /**
  33498. * Releases all held ressources
  33499. */
  33500. dispose(): void;
  33501. /**
  33502. * Gets if the scene is already disposed
  33503. */
  33504. readonly isDisposed: boolean;
  33505. /**
  33506. * Call this function to reduce memory footprint of the scene.
  33507. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33508. */
  33509. clearCachedVertexData(): void;
  33510. /**
  33511. * This function will remove the local cached buffer data from texture.
  33512. * It will save memory but will prevent the texture from being rebuilt
  33513. */
  33514. cleanCachedTextureBuffer(): void;
  33515. /**
  33516. * Get the world extend vectors with an optional filter
  33517. *
  33518. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33519. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33520. */
  33521. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33522. min: Vector3;
  33523. max: Vector3;
  33524. };
  33525. /**
  33526. * Creates a ray that can be used to pick in the scene
  33527. * @param x defines the x coordinate of the origin (on-screen)
  33528. * @param y defines the y coordinate of the origin (on-screen)
  33529. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33530. * @param camera defines the camera to use for the picking
  33531. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33532. * @returns a Ray
  33533. */
  33534. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33535. /**
  33536. * Creates a ray that can be used to pick in the scene
  33537. * @param x defines the x coordinate of the origin (on-screen)
  33538. * @param y defines the y coordinate of the origin (on-screen)
  33539. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33540. * @param result defines the ray where to store the picking ray
  33541. * @param camera defines the camera to use for the picking
  33542. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33543. * @returns the current scene
  33544. */
  33545. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33546. /**
  33547. * Creates a ray that can be used to pick in the scene
  33548. * @param x defines the x coordinate of the origin (on-screen)
  33549. * @param y defines the y coordinate of the origin (on-screen)
  33550. * @param camera defines the camera to use for the picking
  33551. * @returns a Ray
  33552. */
  33553. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33554. /**
  33555. * Creates a ray that can be used to pick in the scene
  33556. * @param x defines the x coordinate of the origin (on-screen)
  33557. * @param y defines the y coordinate of the origin (on-screen)
  33558. * @param result defines the ray where to store the picking ray
  33559. * @param camera defines the camera to use for the picking
  33560. * @returns the current scene
  33561. */
  33562. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33563. /** Launch a ray to try to pick a mesh in the scene
  33564. * @param x position on screen
  33565. * @param y position on screen
  33566. * @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
  33567. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33568. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33569. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33570. * @returns a PickingInfo
  33571. */
  33572. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33573. /** Use the given ray to pick a mesh in the scene
  33574. * @param ray The ray to use to pick meshes
  33575. * @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
  33576. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33577. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33578. * @returns a PickingInfo
  33579. */
  33580. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33581. /**
  33582. * Launch a ray to try to pick a mesh in the scene
  33583. * @param x X position on screen
  33584. * @param y Y position on screen
  33585. * @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
  33586. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33587. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33588. * @returns an array of PickingInfo
  33589. */
  33590. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33591. /**
  33592. * Launch a ray to try to pick a mesh in the scene
  33593. * @param ray Ray to use
  33594. * @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
  33595. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33596. * @returns an array of PickingInfo
  33597. */
  33598. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33599. /**
  33600. * Force the value of meshUnderPointer
  33601. * @param mesh defines the mesh to use
  33602. */
  33603. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33604. /**
  33605. * Gets the mesh under the pointer
  33606. * @returns a Mesh or null if no mesh is under the pointer
  33607. */
  33608. getPointerOverMesh(): Nullable<AbstractMesh>;
  33609. /** @hidden */
  33610. _rebuildGeometries(): void;
  33611. /** @hidden */
  33612. _rebuildTextures(): void;
  33613. private _getByTags;
  33614. /**
  33615. * Get a list of meshes by tags
  33616. * @param tagsQuery defines the tags query to use
  33617. * @param forEach defines a predicate used to filter results
  33618. * @returns an array of Mesh
  33619. */
  33620. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33621. /**
  33622. * Get a list of cameras by tags
  33623. * @param tagsQuery defines the tags query to use
  33624. * @param forEach defines a predicate used to filter results
  33625. * @returns an array of Camera
  33626. */
  33627. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33628. /**
  33629. * Get a list of lights by tags
  33630. * @param tagsQuery defines the tags query to use
  33631. * @param forEach defines a predicate used to filter results
  33632. * @returns an array of Light
  33633. */
  33634. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33635. /**
  33636. * Get a list of materials by tags
  33637. * @param tagsQuery defines the tags query to use
  33638. * @param forEach defines a predicate used to filter results
  33639. * @returns an array of Material
  33640. */
  33641. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33642. /**
  33643. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33644. * This allowed control for front to back rendering or reversly depending of the special needs.
  33645. *
  33646. * @param renderingGroupId The rendering group id corresponding to its index
  33647. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33648. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33649. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33650. */
  33651. 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;
  33652. /**
  33653. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33654. *
  33655. * @param renderingGroupId The rendering group id corresponding to its index
  33656. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33657. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33658. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33659. */
  33660. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33661. /**
  33662. * Gets the current auto clear configuration for one rendering group of the rendering
  33663. * manager.
  33664. * @param index the rendering group index to get the information for
  33665. * @returns The auto clear setup for the requested rendering group
  33666. */
  33667. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33668. private _blockMaterialDirtyMechanism;
  33669. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33670. blockMaterialDirtyMechanism: boolean;
  33671. /**
  33672. * Will flag all materials as dirty to trigger new shader compilation
  33673. * @param flag defines the flag used to specify which material part must be marked as dirty
  33674. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33675. */
  33676. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33677. /** @hidden */
  33678. _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;
  33679. /** @hidden */
  33680. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33681. }
  33682. }
  33683. declare module BABYLON {
  33684. /**
  33685. * Set of assets to keep when moving a scene into an asset container.
  33686. */
  33687. export class KeepAssets extends AbstractScene {
  33688. }
  33689. /**
  33690. * Container with a set of assets that can be added or removed from a scene.
  33691. */
  33692. export class AssetContainer extends AbstractScene {
  33693. /**
  33694. * The scene the AssetContainer belongs to.
  33695. */
  33696. scene: Scene;
  33697. /**
  33698. * Instantiates an AssetContainer.
  33699. * @param scene The scene the AssetContainer belongs to.
  33700. */
  33701. constructor(scene: Scene);
  33702. /**
  33703. * Adds all the assets from the container to the scene.
  33704. */
  33705. addAllToScene(): void;
  33706. /**
  33707. * Removes all the assets in the container from the scene
  33708. */
  33709. removeAllFromScene(): void;
  33710. /**
  33711. * Disposes all the assets in the container
  33712. */
  33713. dispose(): void;
  33714. private _moveAssets;
  33715. /**
  33716. * Removes all the assets contained in the scene and adds them to the container.
  33717. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33718. */
  33719. moveAllFromScene(keepAssets?: KeepAssets): void;
  33720. /**
  33721. * 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.
  33722. * @returns the root mesh
  33723. */
  33724. createRootMesh(): Mesh;
  33725. }
  33726. }
  33727. declare module BABYLON {
  33728. /**
  33729. * Defines how the parser contract is defined.
  33730. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33731. */
  33732. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33733. /**
  33734. * Defines how the individual parser contract is defined.
  33735. * These parser can parse an individual asset
  33736. */
  33737. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33738. /**
  33739. * Base class of the scene acting as a container for the different elements composing a scene.
  33740. * This class is dynamically extended by the different components of the scene increasing
  33741. * flexibility and reducing coupling
  33742. */
  33743. export abstract class AbstractScene {
  33744. /**
  33745. * Stores the list of available parsers in the application.
  33746. */
  33747. private static _BabylonFileParsers;
  33748. /**
  33749. * Stores the list of available individual parsers in the application.
  33750. */
  33751. private static _IndividualBabylonFileParsers;
  33752. /**
  33753. * Adds a parser in the list of available ones
  33754. * @param name Defines the name of the parser
  33755. * @param parser Defines the parser to add
  33756. */
  33757. static AddParser(name: string, parser: BabylonFileParser): void;
  33758. /**
  33759. * Gets a general parser from the list of avaialble ones
  33760. * @param name Defines the name of the parser
  33761. * @returns the requested parser or null
  33762. */
  33763. static GetParser(name: string): Nullable<BabylonFileParser>;
  33764. /**
  33765. * Adds n individual parser in the list of available ones
  33766. * @param name Defines the name of the parser
  33767. * @param parser Defines the parser to add
  33768. */
  33769. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33770. /**
  33771. * Gets an individual parser from the list of avaialble ones
  33772. * @param name Defines the name of the parser
  33773. * @returns the requested parser or null
  33774. */
  33775. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33776. /**
  33777. * Parser json data and populate both a scene and its associated container object
  33778. * @param jsonData Defines the data to parse
  33779. * @param scene Defines the scene to parse the data for
  33780. * @param container Defines the container attached to the parsing sequence
  33781. * @param rootUrl Defines the root url of the data
  33782. */
  33783. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33784. /**
  33785. * Gets the list of root nodes (ie. nodes with no parent)
  33786. */
  33787. rootNodes: Node[];
  33788. /** All of the cameras added to this scene
  33789. * @see http://doc.babylonjs.com/babylon101/cameras
  33790. */
  33791. cameras: Camera[];
  33792. /**
  33793. * All of the lights added to this scene
  33794. * @see http://doc.babylonjs.com/babylon101/lights
  33795. */
  33796. lights: Light[];
  33797. /**
  33798. * All of the (abstract) meshes added to this scene
  33799. */
  33800. meshes: AbstractMesh[];
  33801. /**
  33802. * The list of skeletons added to the scene
  33803. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33804. */
  33805. skeletons: Skeleton[];
  33806. /**
  33807. * All of the particle systems added to this scene
  33808. * @see http://doc.babylonjs.com/babylon101/particles
  33809. */
  33810. particleSystems: IParticleSystem[];
  33811. /**
  33812. * Gets a list of Animations associated with the scene
  33813. */
  33814. animations: Animation[];
  33815. /**
  33816. * All of the animation groups added to this scene
  33817. * @see http://doc.babylonjs.com/how_to/group
  33818. */
  33819. animationGroups: AnimationGroup[];
  33820. /**
  33821. * All of the multi-materials added to this scene
  33822. * @see http://doc.babylonjs.com/how_to/multi_materials
  33823. */
  33824. multiMaterials: MultiMaterial[];
  33825. /**
  33826. * All of the materials added to this scene
  33827. * In the context of a Scene, it is not supposed to be modified manually.
  33828. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33829. * Note also that the order of the Material wihin the array is not significant and might change.
  33830. * @see http://doc.babylonjs.com/babylon101/materials
  33831. */
  33832. materials: Material[];
  33833. /**
  33834. * The list of morph target managers added to the scene
  33835. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33836. */
  33837. morphTargetManagers: MorphTargetManager[];
  33838. /**
  33839. * The list of geometries used in the scene.
  33840. */
  33841. geometries: Geometry[];
  33842. /**
  33843. * All of the tranform nodes added to this scene
  33844. * In the context of a Scene, it is not supposed to be modified manually.
  33845. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33846. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33847. * @see http://doc.babylonjs.com/how_to/transformnode
  33848. */
  33849. transformNodes: TransformNode[];
  33850. /**
  33851. * ActionManagers available on the scene.
  33852. */
  33853. actionManagers: AbstractActionManager[];
  33854. /**
  33855. * Textures to keep.
  33856. */
  33857. textures: BaseTexture[];
  33858. /**
  33859. * Environment texture for the scene
  33860. */
  33861. environmentTexture: Nullable<BaseTexture>;
  33862. }
  33863. }
  33864. declare module BABYLON {
  33865. /**
  33866. * Defines a sound that can be played in the application.
  33867. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33869. */
  33870. export class Sound {
  33871. /**
  33872. * The name of the sound in the scene.
  33873. */
  33874. name: string;
  33875. /**
  33876. * Does the sound autoplay once loaded.
  33877. */
  33878. autoplay: boolean;
  33879. /**
  33880. * Does the sound loop after it finishes playing once.
  33881. */
  33882. loop: boolean;
  33883. /**
  33884. * Does the sound use a custom attenuation curve to simulate the falloff
  33885. * happening when the source gets further away from the camera.
  33886. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33887. */
  33888. useCustomAttenuation: boolean;
  33889. /**
  33890. * The sound track id this sound belongs to.
  33891. */
  33892. soundTrackId: number;
  33893. /**
  33894. * Is this sound currently played.
  33895. */
  33896. isPlaying: boolean;
  33897. /**
  33898. * Is this sound currently paused.
  33899. */
  33900. isPaused: boolean;
  33901. /**
  33902. * Does this sound enables spatial sound.
  33903. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33904. */
  33905. spatialSound: boolean;
  33906. /**
  33907. * Define the reference distance the sound should be heard perfectly.
  33908. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33909. */
  33910. refDistance: number;
  33911. /**
  33912. * Define the roll off factor of spatial sounds.
  33913. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33914. */
  33915. rolloffFactor: number;
  33916. /**
  33917. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33918. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33919. */
  33920. maxDistance: number;
  33921. /**
  33922. * Define the distance attenuation model the sound will follow.
  33923. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33924. */
  33925. distanceModel: string;
  33926. /**
  33927. * @hidden
  33928. * Back Compat
  33929. **/
  33930. onended: () => any;
  33931. /**
  33932. * Observable event when the current playing sound finishes.
  33933. */
  33934. onEndedObservable: Observable<Sound>;
  33935. private _panningModel;
  33936. private _playbackRate;
  33937. private _streaming;
  33938. private _startTime;
  33939. private _startOffset;
  33940. private _position;
  33941. /** @hidden */
  33942. _positionInEmitterSpace: boolean;
  33943. private _localDirection;
  33944. private _volume;
  33945. private _isReadyToPlay;
  33946. private _isDirectional;
  33947. private _readyToPlayCallback;
  33948. private _audioBuffer;
  33949. private _soundSource;
  33950. private _streamingSource;
  33951. private _soundPanner;
  33952. private _soundGain;
  33953. private _inputAudioNode;
  33954. private _outputAudioNode;
  33955. private _coneInnerAngle;
  33956. private _coneOuterAngle;
  33957. private _coneOuterGain;
  33958. private _scene;
  33959. private _connectedTransformNode;
  33960. private _customAttenuationFunction;
  33961. private _registerFunc;
  33962. private _isOutputConnected;
  33963. private _htmlAudioElement;
  33964. private _urlType;
  33965. /** @hidden */
  33966. static _SceneComponentInitialization: (scene: Scene) => void;
  33967. /**
  33968. * Create a sound and attach it to a scene
  33969. * @param name Name of your sound
  33970. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33971. * @param scene defines the scene the sound belongs to
  33972. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33973. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33974. */
  33975. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33976. /**
  33977. * Release the sound and its associated resources
  33978. */
  33979. dispose(): void;
  33980. /**
  33981. * Gets if the sounds is ready to be played or not.
  33982. * @returns true if ready, otherwise false
  33983. */
  33984. isReady(): boolean;
  33985. private _soundLoaded;
  33986. /**
  33987. * Sets the data of the sound from an audiobuffer
  33988. * @param audioBuffer The audioBuffer containing the data
  33989. */
  33990. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33991. /**
  33992. * Updates the current sounds options such as maxdistance, loop...
  33993. * @param options A JSON object containing values named as the object properties
  33994. */
  33995. updateOptions(options: any): void;
  33996. private _createSpatialParameters;
  33997. private _updateSpatialParameters;
  33998. /**
  33999. * Switch the panning model to HRTF:
  34000. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34001. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34002. */
  34003. switchPanningModelToHRTF(): void;
  34004. /**
  34005. * Switch the panning model to Equal Power:
  34006. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34007. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34008. */
  34009. switchPanningModelToEqualPower(): void;
  34010. private _switchPanningModel;
  34011. /**
  34012. * Connect this sound to a sound track audio node like gain...
  34013. * @param soundTrackAudioNode the sound track audio node to connect to
  34014. */
  34015. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34016. /**
  34017. * Transform this sound into a directional source
  34018. * @param coneInnerAngle Size of the inner cone in degree
  34019. * @param coneOuterAngle Size of the outer cone in degree
  34020. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34021. */
  34022. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34023. /**
  34024. * Gets or sets the inner angle for the directional cone.
  34025. */
  34026. /**
  34027. * Gets or sets the inner angle for the directional cone.
  34028. */
  34029. directionalConeInnerAngle: number;
  34030. /**
  34031. * Gets or sets the outer angle for the directional cone.
  34032. */
  34033. /**
  34034. * Gets or sets the outer angle for the directional cone.
  34035. */
  34036. directionalConeOuterAngle: number;
  34037. /**
  34038. * Sets the position of the emitter if spatial sound is enabled
  34039. * @param newPosition Defines the new posisiton
  34040. */
  34041. setPosition(newPosition: Vector3): void;
  34042. /**
  34043. * Sets the local direction of the emitter if spatial sound is enabled
  34044. * @param newLocalDirection Defines the new local direction
  34045. */
  34046. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34047. private _updateDirection;
  34048. /** @hidden */
  34049. updateDistanceFromListener(): void;
  34050. /**
  34051. * Sets a new custom attenuation function for the sound.
  34052. * @param callback Defines the function used for the attenuation
  34053. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34054. */
  34055. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34056. /**
  34057. * Play the sound
  34058. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34059. * @param offset (optional) Start the sound setting it at a specific time
  34060. */
  34061. play(time?: number, offset?: number): void;
  34062. private _onended;
  34063. /**
  34064. * Stop the sound
  34065. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34066. */
  34067. stop(time?: number): void;
  34068. /**
  34069. * Put the sound in pause
  34070. */
  34071. pause(): void;
  34072. /**
  34073. * Sets a dedicated volume for this sounds
  34074. * @param newVolume Define the new volume of the sound
  34075. * @param time Define in how long the sound should be at this value
  34076. */
  34077. setVolume(newVolume: number, time?: number): void;
  34078. /**
  34079. * Set the sound play back rate
  34080. * @param newPlaybackRate Define the playback rate the sound should be played at
  34081. */
  34082. setPlaybackRate(newPlaybackRate: number): void;
  34083. /**
  34084. * Gets the volume of the sound.
  34085. * @returns the volume of the sound
  34086. */
  34087. getVolume(): number;
  34088. /**
  34089. * Attach the sound to a dedicated mesh
  34090. * @param transformNode The transform node to connect the sound with
  34091. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34092. */
  34093. attachToMesh(transformNode: TransformNode): void;
  34094. /**
  34095. * Detach the sound from the previously attached mesh
  34096. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34097. */
  34098. detachFromMesh(): void;
  34099. private _onRegisterAfterWorldMatrixUpdate;
  34100. /**
  34101. * Clone the current sound in the scene.
  34102. * @returns the new sound clone
  34103. */
  34104. clone(): Nullable<Sound>;
  34105. /**
  34106. * Gets the current underlying audio buffer containing the data
  34107. * @returns the audio buffer
  34108. */
  34109. getAudioBuffer(): Nullable<AudioBuffer>;
  34110. /**
  34111. * Serializes the Sound in a JSON representation
  34112. * @returns the JSON representation of the sound
  34113. */
  34114. serialize(): any;
  34115. /**
  34116. * Parse a JSON representation of a sound to innstantiate in a given scene
  34117. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34118. * @param scene Define the scene the new parsed sound should be created in
  34119. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34120. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34121. * @returns the newly parsed sound
  34122. */
  34123. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34124. }
  34125. }
  34126. declare module BABYLON {
  34127. /**
  34128. * This defines an action helpful to play a defined sound on a triggered action.
  34129. */
  34130. export class PlaySoundAction extends Action {
  34131. private _sound;
  34132. /**
  34133. * Instantiate the action
  34134. * @param triggerOptions defines the trigger options
  34135. * @param sound defines the sound to play
  34136. * @param condition defines the trigger related conditions
  34137. */
  34138. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34139. /** @hidden */
  34140. _prepare(): void;
  34141. /**
  34142. * Execute the action and play the sound.
  34143. */
  34144. execute(): void;
  34145. /**
  34146. * Serializes the actions and its related information.
  34147. * @param parent defines the object to serialize in
  34148. * @returns the serialized object
  34149. */
  34150. serialize(parent: any): any;
  34151. }
  34152. /**
  34153. * This defines an action helpful to stop a defined sound on a triggered action.
  34154. */
  34155. export class StopSoundAction extends Action {
  34156. private _sound;
  34157. /**
  34158. * Instantiate the action
  34159. * @param triggerOptions defines the trigger options
  34160. * @param sound defines the sound to stop
  34161. * @param condition defines the trigger related conditions
  34162. */
  34163. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34164. /** @hidden */
  34165. _prepare(): void;
  34166. /**
  34167. * Execute the action and stop the sound.
  34168. */
  34169. execute(): void;
  34170. /**
  34171. * Serializes the actions and its related information.
  34172. * @param parent defines the object to serialize in
  34173. * @returns the serialized object
  34174. */
  34175. serialize(parent: any): any;
  34176. }
  34177. }
  34178. declare module BABYLON {
  34179. /**
  34180. * This defines an action responsible to change the value of a property
  34181. * by interpolating between its current value and the newly set one once triggered.
  34182. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34183. */
  34184. export class InterpolateValueAction extends Action {
  34185. /**
  34186. * Defines the path of the property where the value should be interpolated
  34187. */
  34188. propertyPath: string;
  34189. /**
  34190. * Defines the target value at the end of the interpolation.
  34191. */
  34192. value: any;
  34193. /**
  34194. * Defines the time it will take for the property to interpolate to the value.
  34195. */
  34196. duration: number;
  34197. /**
  34198. * Defines if the other scene animations should be stopped when the action has been triggered
  34199. */
  34200. stopOtherAnimations?: boolean;
  34201. /**
  34202. * Defines a callback raised once the interpolation animation has been done.
  34203. */
  34204. onInterpolationDone?: () => void;
  34205. /**
  34206. * Observable triggered once the interpolation animation has been done.
  34207. */
  34208. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34209. private _target;
  34210. private _effectiveTarget;
  34211. private _property;
  34212. /**
  34213. * Instantiate the action
  34214. * @param triggerOptions defines the trigger options
  34215. * @param target defines the object containing the value to interpolate
  34216. * @param propertyPath defines the path to the property in the target object
  34217. * @param value defines the target value at the end of the interpolation
  34218. * @param duration deines the time it will take for the property to interpolate to the value.
  34219. * @param condition defines the trigger related conditions
  34220. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34221. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34222. */
  34223. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34224. /** @hidden */
  34225. _prepare(): void;
  34226. /**
  34227. * Execute the action starts the value interpolation.
  34228. */
  34229. execute(): void;
  34230. /**
  34231. * Serializes the actions and its related information.
  34232. * @param parent defines the object to serialize in
  34233. * @returns the serialized object
  34234. */
  34235. serialize(parent: any): any;
  34236. }
  34237. }
  34238. declare module BABYLON {
  34239. /**
  34240. * Options allowed during the creation of a sound track.
  34241. */
  34242. export interface ISoundTrackOptions {
  34243. /**
  34244. * The volume the sound track should take during creation
  34245. */
  34246. volume?: number;
  34247. /**
  34248. * Define if the sound track is the main sound track of the scene
  34249. */
  34250. mainTrack?: boolean;
  34251. }
  34252. /**
  34253. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34254. * It will be also used in a future release to apply effects on a specific track.
  34255. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34256. */
  34257. export class SoundTrack {
  34258. /**
  34259. * The unique identifier of the sound track in the scene.
  34260. */
  34261. id: number;
  34262. /**
  34263. * The list of sounds included in the sound track.
  34264. */
  34265. soundCollection: Array<Sound>;
  34266. private _outputAudioNode;
  34267. private _scene;
  34268. private _isMainTrack;
  34269. private _connectedAnalyser;
  34270. private _options;
  34271. private _isInitialized;
  34272. /**
  34273. * Creates a new sound track.
  34274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34275. * @param scene Define the scene the sound track belongs to
  34276. * @param options
  34277. */
  34278. constructor(scene: Scene, options?: ISoundTrackOptions);
  34279. private _initializeSoundTrackAudioGraph;
  34280. /**
  34281. * Release the sound track and its associated resources
  34282. */
  34283. dispose(): void;
  34284. /**
  34285. * Adds a sound to this sound track
  34286. * @param sound define the cound to add
  34287. * @ignoreNaming
  34288. */
  34289. AddSound(sound: Sound): void;
  34290. /**
  34291. * Removes a sound to this sound track
  34292. * @param sound define the cound to remove
  34293. * @ignoreNaming
  34294. */
  34295. RemoveSound(sound: Sound): void;
  34296. /**
  34297. * Set a global volume for the full sound track.
  34298. * @param newVolume Define the new volume of the sound track
  34299. */
  34300. setVolume(newVolume: number): void;
  34301. /**
  34302. * Switch the panning model to HRTF:
  34303. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34304. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34305. */
  34306. switchPanningModelToHRTF(): void;
  34307. /**
  34308. * Switch the panning model to Equal Power:
  34309. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34310. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34311. */
  34312. switchPanningModelToEqualPower(): void;
  34313. /**
  34314. * Connect the sound track to an audio analyser allowing some amazing
  34315. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34316. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34317. * @param analyser The analyser to connect to the engine
  34318. */
  34319. connectToAnalyser(analyser: Analyser): void;
  34320. }
  34321. }
  34322. declare module BABYLON {
  34323. interface AbstractScene {
  34324. /**
  34325. * The list of sounds used in the scene.
  34326. */
  34327. sounds: Nullable<Array<Sound>>;
  34328. }
  34329. interface Scene {
  34330. /**
  34331. * @hidden
  34332. * Backing field
  34333. */
  34334. _mainSoundTrack: SoundTrack;
  34335. /**
  34336. * The main sound track played by the scene.
  34337. * It cotains your primary collection of sounds.
  34338. */
  34339. mainSoundTrack: SoundTrack;
  34340. /**
  34341. * The list of sound tracks added to the scene
  34342. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34343. */
  34344. soundTracks: Nullable<Array<SoundTrack>>;
  34345. /**
  34346. * Gets a sound using a given name
  34347. * @param name defines the name to search for
  34348. * @return the found sound or null if not found at all.
  34349. */
  34350. getSoundByName(name: string): Nullable<Sound>;
  34351. /**
  34352. * Gets or sets if audio support is enabled
  34353. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34354. */
  34355. audioEnabled: boolean;
  34356. /**
  34357. * Gets or sets if audio will be output to headphones
  34358. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34359. */
  34360. headphone: boolean;
  34361. }
  34362. /**
  34363. * Defines the sound scene component responsible to manage any sounds
  34364. * in a given scene.
  34365. */
  34366. export class AudioSceneComponent implements ISceneSerializableComponent {
  34367. /**
  34368. * The component name helpfull to identify the component in the list of scene components.
  34369. */
  34370. readonly name: string;
  34371. /**
  34372. * The scene the component belongs to.
  34373. */
  34374. scene: Scene;
  34375. private _audioEnabled;
  34376. /**
  34377. * Gets whether audio is enabled or not.
  34378. * Please use related enable/disable method to switch state.
  34379. */
  34380. readonly audioEnabled: boolean;
  34381. private _headphone;
  34382. /**
  34383. * Gets whether audio is outputing to headphone or not.
  34384. * Please use the according Switch methods to change output.
  34385. */
  34386. readonly headphone: boolean;
  34387. /**
  34388. * Creates a new instance of the component for the given scene
  34389. * @param scene Defines the scene to register the component in
  34390. */
  34391. constructor(scene: Scene);
  34392. /**
  34393. * Registers the component in a given scene
  34394. */
  34395. register(): void;
  34396. /**
  34397. * Rebuilds the elements related to this component in case of
  34398. * context lost for instance.
  34399. */
  34400. rebuild(): void;
  34401. /**
  34402. * Serializes the component data to the specified json object
  34403. * @param serializationObject The object to serialize to
  34404. */
  34405. serialize(serializationObject: any): void;
  34406. /**
  34407. * Adds all the element from the container to the scene
  34408. * @param container the container holding the elements
  34409. */
  34410. addFromContainer(container: AbstractScene): void;
  34411. /**
  34412. * Removes all the elements in the container from the scene
  34413. * @param container contains the elements to remove
  34414. * @param dispose if the removed element should be disposed (default: false)
  34415. */
  34416. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34417. /**
  34418. * Disposes the component and the associated ressources.
  34419. */
  34420. dispose(): void;
  34421. /**
  34422. * Disables audio in the associated scene.
  34423. */
  34424. disableAudio(): void;
  34425. /**
  34426. * Enables audio in the associated scene.
  34427. */
  34428. enableAudio(): void;
  34429. /**
  34430. * Switch audio to headphone output.
  34431. */
  34432. switchAudioModeForHeadphones(): void;
  34433. /**
  34434. * Switch audio to normal speakers.
  34435. */
  34436. switchAudioModeForNormalSpeakers(): void;
  34437. private _afterRender;
  34438. }
  34439. }
  34440. declare module BABYLON {
  34441. /**
  34442. * Wraps one or more Sound objects and selects one with random weight for playback.
  34443. */
  34444. export class WeightedSound {
  34445. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34446. loop: boolean;
  34447. private _coneInnerAngle;
  34448. private _coneOuterAngle;
  34449. private _volume;
  34450. /** A Sound is currently playing. */
  34451. isPlaying: boolean;
  34452. /** A Sound is currently paused. */
  34453. isPaused: boolean;
  34454. private _sounds;
  34455. private _weights;
  34456. private _currentIndex?;
  34457. /**
  34458. * Creates a new WeightedSound from the list of sounds given.
  34459. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34460. * @param sounds Array of Sounds that will be selected from.
  34461. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34462. */
  34463. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34464. /**
  34465. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34466. */
  34467. /**
  34468. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34469. */
  34470. directionalConeInnerAngle: number;
  34471. /**
  34472. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34473. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34474. */
  34475. /**
  34476. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34477. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34478. */
  34479. directionalConeOuterAngle: number;
  34480. /**
  34481. * Playback volume.
  34482. */
  34483. /**
  34484. * Playback volume.
  34485. */
  34486. volume: number;
  34487. private _onended;
  34488. /**
  34489. * Suspend playback
  34490. */
  34491. pause(): void;
  34492. /**
  34493. * Stop playback
  34494. */
  34495. stop(): void;
  34496. /**
  34497. * Start playback.
  34498. * @param startOffset Position the clip head at a specific time in seconds.
  34499. */
  34500. play(startOffset?: number): void;
  34501. }
  34502. }
  34503. declare module BABYLON {
  34504. /**
  34505. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34506. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34507. */
  34508. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34509. /**
  34510. * Gets the name of the behavior.
  34511. */
  34512. readonly name: string;
  34513. /**
  34514. * The easing function used by animations
  34515. */
  34516. static EasingFunction: BackEase;
  34517. /**
  34518. * The easing mode used by animations
  34519. */
  34520. static EasingMode: number;
  34521. /**
  34522. * The duration of the animation, in milliseconds
  34523. */
  34524. transitionDuration: number;
  34525. /**
  34526. * Length of the distance animated by the transition when lower radius is reached
  34527. */
  34528. lowerRadiusTransitionRange: number;
  34529. /**
  34530. * Length of the distance animated by the transition when upper radius is reached
  34531. */
  34532. upperRadiusTransitionRange: number;
  34533. private _autoTransitionRange;
  34534. /**
  34535. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34536. */
  34537. /**
  34538. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34539. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34540. */
  34541. autoTransitionRange: boolean;
  34542. private _attachedCamera;
  34543. private _onAfterCheckInputsObserver;
  34544. private _onMeshTargetChangedObserver;
  34545. /**
  34546. * Initializes the behavior.
  34547. */
  34548. init(): void;
  34549. /**
  34550. * Attaches the behavior to its arc rotate camera.
  34551. * @param camera Defines the camera to attach the behavior to
  34552. */
  34553. attach(camera: ArcRotateCamera): void;
  34554. /**
  34555. * Detaches the behavior from its current arc rotate camera.
  34556. */
  34557. detach(): void;
  34558. private _radiusIsAnimating;
  34559. private _radiusBounceTransition;
  34560. private _animatables;
  34561. private _cachedWheelPrecision;
  34562. /**
  34563. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34564. * @param radiusLimit The limit to check against.
  34565. * @return Bool to indicate if at limit.
  34566. */
  34567. private _isRadiusAtLimit;
  34568. /**
  34569. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34570. * @param radiusDelta The delta by which to animate to. Can be negative.
  34571. */
  34572. private _applyBoundRadiusAnimation;
  34573. /**
  34574. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34575. */
  34576. protected _clearAnimationLocks(): void;
  34577. /**
  34578. * Stops and removes all animations that have been applied to the camera
  34579. */
  34580. stopAllAnimations(): void;
  34581. }
  34582. }
  34583. declare module BABYLON {
  34584. /**
  34585. * 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.
  34586. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34587. */
  34588. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34589. /**
  34590. * Gets the name of the behavior.
  34591. */
  34592. readonly name: string;
  34593. private _mode;
  34594. private _radiusScale;
  34595. private _positionScale;
  34596. private _defaultElevation;
  34597. private _elevationReturnTime;
  34598. private _elevationReturnWaitTime;
  34599. private _zoomStopsAnimation;
  34600. private _framingTime;
  34601. /**
  34602. * The easing function used by animations
  34603. */
  34604. static EasingFunction: ExponentialEase;
  34605. /**
  34606. * The easing mode used by animations
  34607. */
  34608. static EasingMode: number;
  34609. /**
  34610. * Sets the current mode used by the behavior
  34611. */
  34612. /**
  34613. * Gets current mode used by the behavior.
  34614. */
  34615. mode: number;
  34616. /**
  34617. * Sets the scale applied to the radius (1 by default)
  34618. */
  34619. /**
  34620. * Gets the scale applied to the radius
  34621. */
  34622. radiusScale: number;
  34623. /**
  34624. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34625. */
  34626. /**
  34627. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34628. */
  34629. positionScale: number;
  34630. /**
  34631. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34632. * behaviour is triggered, in radians.
  34633. */
  34634. /**
  34635. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34636. * behaviour is triggered, in radians.
  34637. */
  34638. defaultElevation: number;
  34639. /**
  34640. * Sets the time (in milliseconds) taken to return to the default beta position.
  34641. * Negative value indicates camera should not return to default.
  34642. */
  34643. /**
  34644. * Gets the time (in milliseconds) taken to return to the default beta position.
  34645. * Negative value indicates camera should not return to default.
  34646. */
  34647. elevationReturnTime: number;
  34648. /**
  34649. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34650. */
  34651. /**
  34652. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34653. */
  34654. elevationReturnWaitTime: number;
  34655. /**
  34656. * Sets the flag that indicates if user zooming should stop animation.
  34657. */
  34658. /**
  34659. * Gets the flag that indicates if user zooming should stop animation.
  34660. */
  34661. zoomStopsAnimation: boolean;
  34662. /**
  34663. * Sets the transition time when framing the mesh, in milliseconds
  34664. */
  34665. /**
  34666. * Gets the transition time when framing the mesh, in milliseconds
  34667. */
  34668. framingTime: number;
  34669. /**
  34670. * Define if the behavior should automatically change the configured
  34671. * camera limits and sensibilities.
  34672. */
  34673. autoCorrectCameraLimitsAndSensibility: boolean;
  34674. private _onPrePointerObservableObserver;
  34675. private _onAfterCheckInputsObserver;
  34676. private _onMeshTargetChangedObserver;
  34677. private _attachedCamera;
  34678. private _isPointerDown;
  34679. private _lastInteractionTime;
  34680. /**
  34681. * Initializes the behavior.
  34682. */
  34683. init(): void;
  34684. /**
  34685. * Attaches the behavior to its arc rotate camera.
  34686. * @param camera Defines the camera to attach the behavior to
  34687. */
  34688. attach(camera: ArcRotateCamera): void;
  34689. /**
  34690. * Detaches the behavior from its current arc rotate camera.
  34691. */
  34692. detach(): void;
  34693. private _animatables;
  34694. private _betaIsAnimating;
  34695. private _betaTransition;
  34696. private _radiusTransition;
  34697. private _vectorTransition;
  34698. /**
  34699. * Targets the given mesh and updates zoom level accordingly.
  34700. * @param mesh The mesh to target.
  34701. * @param radius Optional. If a cached radius position already exists, overrides default.
  34702. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34703. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34704. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34705. */
  34706. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34707. /**
  34708. * Targets the given mesh with its children and updates zoom level accordingly.
  34709. * @param mesh The mesh to target.
  34710. * @param radius Optional. If a cached radius position already exists, overrides default.
  34711. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34712. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34713. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34714. */
  34715. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34716. /**
  34717. * Targets the given meshes with their children and updates zoom level accordingly.
  34718. * @param meshes The mesh to target.
  34719. * @param radius Optional. If a cached radius position already exists, overrides default.
  34720. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34721. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34722. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34723. */
  34724. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34725. /**
  34726. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34727. * @param minimumWorld Determines the smaller position of the bounding box extend
  34728. * @param maximumWorld Determines the bigger position of the bounding box extend
  34729. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34730. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34731. */
  34732. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34733. /**
  34734. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34735. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34736. * frustum width.
  34737. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34738. * to fully enclose the mesh in the viewing frustum.
  34739. */
  34740. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34741. /**
  34742. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34743. * is automatically returned to its default position (expected to be above ground plane).
  34744. */
  34745. private _maintainCameraAboveGround;
  34746. /**
  34747. * Returns the frustum slope based on the canvas ratio and camera FOV
  34748. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34749. */
  34750. private _getFrustumSlope;
  34751. /**
  34752. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34753. */
  34754. private _clearAnimationLocks;
  34755. /**
  34756. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34757. */
  34758. private _applyUserInteraction;
  34759. /**
  34760. * Stops and removes all animations that have been applied to the camera
  34761. */
  34762. stopAllAnimations(): void;
  34763. /**
  34764. * Gets a value indicating if the user is moving the camera
  34765. */
  34766. readonly isUserIsMoving: boolean;
  34767. /**
  34768. * The camera can move all the way towards the mesh.
  34769. */
  34770. static IgnoreBoundsSizeMode: number;
  34771. /**
  34772. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34773. */
  34774. static FitFrustumSidesMode: number;
  34775. }
  34776. }
  34777. declare module BABYLON {
  34778. /**
  34779. * Base class for Camera Pointer Inputs.
  34780. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34781. * for example usage.
  34782. */
  34783. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34784. /**
  34785. * Defines the camera the input is attached to.
  34786. */
  34787. abstract camera: Camera;
  34788. /**
  34789. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34790. */
  34791. protected _altKey: boolean;
  34792. protected _ctrlKey: boolean;
  34793. protected _metaKey: boolean;
  34794. protected _shiftKey: boolean;
  34795. /**
  34796. * Which mouse buttons were pressed at time of last mouse event.
  34797. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34798. */
  34799. protected _buttonsPressed: number;
  34800. /**
  34801. * Defines the buttons associated with the input to handle camera move.
  34802. */
  34803. buttons: number[];
  34804. /**
  34805. * Attach the input controls to a specific dom element to get the input from.
  34806. * @param element Defines the element the controls should be listened from
  34807. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34808. */
  34809. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34810. /**
  34811. * Detach the current controls from the specified dom element.
  34812. * @param element Defines the element to stop listening the inputs from
  34813. */
  34814. detachControl(element: Nullable<HTMLElement>): void;
  34815. /**
  34816. * Gets the class name of the current input.
  34817. * @returns the class name
  34818. */
  34819. getClassName(): string;
  34820. /**
  34821. * Get the friendly name associated with the input class.
  34822. * @returns the input friendly name
  34823. */
  34824. getSimpleName(): string;
  34825. /**
  34826. * Called on pointer POINTERDOUBLETAP event.
  34827. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34828. */
  34829. protected onDoubleTap(type: string): void;
  34830. /**
  34831. * Called on pointer POINTERMOVE event if only a single touch is active.
  34832. * Override this method to provide functionality.
  34833. */
  34834. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34835. /**
  34836. * Called on pointer POINTERMOVE event if multiple touches are active.
  34837. * Override this method to provide functionality.
  34838. */
  34839. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34840. /**
  34841. * Called on JS contextmenu event.
  34842. * Override this method to provide functionality.
  34843. */
  34844. protected onContextMenu(evt: PointerEvent): void;
  34845. /**
  34846. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34847. * press.
  34848. * Override this method to provide functionality.
  34849. */
  34850. protected onButtonDown(evt: PointerEvent): void;
  34851. /**
  34852. * Called each time a new POINTERUP event occurs. Ie, for each button
  34853. * release.
  34854. * Override this method to provide functionality.
  34855. */
  34856. protected onButtonUp(evt: PointerEvent): void;
  34857. /**
  34858. * Called when window becomes inactive.
  34859. * Override this method to provide functionality.
  34860. */
  34861. protected onLostFocus(): void;
  34862. private _pointerInput;
  34863. private _observer;
  34864. private _onLostFocus;
  34865. private pointA;
  34866. private pointB;
  34867. }
  34868. }
  34869. declare module BABYLON {
  34870. /**
  34871. * Manage the pointers inputs to control an arc rotate camera.
  34872. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34873. */
  34874. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34875. /**
  34876. * Defines the camera the input is attached to.
  34877. */
  34878. camera: ArcRotateCamera;
  34879. /**
  34880. * Gets the class name of the current input.
  34881. * @returns the class name
  34882. */
  34883. getClassName(): string;
  34884. /**
  34885. * Defines the buttons associated with the input to handle camera move.
  34886. */
  34887. buttons: number[];
  34888. /**
  34889. * Defines the pointer angular sensibility along the X axis or how fast is
  34890. * the camera rotating.
  34891. */
  34892. angularSensibilityX: number;
  34893. /**
  34894. * Defines the pointer angular sensibility along the Y axis or how fast is
  34895. * the camera rotating.
  34896. */
  34897. angularSensibilityY: number;
  34898. /**
  34899. * Defines the pointer pinch precision or how fast is the camera zooming.
  34900. */
  34901. pinchPrecision: number;
  34902. /**
  34903. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34904. * from 0.
  34905. * It defines the percentage of current camera.radius to use as delta when
  34906. * pinch zoom is used.
  34907. */
  34908. pinchDeltaPercentage: number;
  34909. /**
  34910. * Defines the pointer panning sensibility or how fast is the camera moving.
  34911. */
  34912. panningSensibility: number;
  34913. /**
  34914. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34915. */
  34916. multiTouchPanning: boolean;
  34917. /**
  34918. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34919. * zoom (pinch) through multitouch.
  34920. */
  34921. multiTouchPanAndZoom: boolean;
  34922. /**
  34923. * Revers pinch action direction.
  34924. */
  34925. pinchInwards: boolean;
  34926. private _isPanClick;
  34927. private _twoFingerActivityCount;
  34928. private _isPinching;
  34929. /**
  34930. * Called on pointer POINTERMOVE event if only a single touch is active.
  34931. */
  34932. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34933. /**
  34934. * Called on pointer POINTERDOUBLETAP event.
  34935. */
  34936. protected onDoubleTap(type: string): void;
  34937. /**
  34938. * Called on pointer POINTERMOVE event if multiple touches are active.
  34939. */
  34940. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34941. /**
  34942. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34943. * press.
  34944. */
  34945. protected onButtonDown(evt: PointerEvent): void;
  34946. /**
  34947. * Called each time a new POINTERUP event occurs. Ie, for each button
  34948. * release.
  34949. */
  34950. protected onButtonUp(evt: PointerEvent): void;
  34951. /**
  34952. * Called when window becomes inactive.
  34953. */
  34954. protected onLostFocus(): void;
  34955. }
  34956. }
  34957. declare module BABYLON {
  34958. /**
  34959. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34960. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34961. */
  34962. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34963. /**
  34964. * Defines the camera the input is attached to.
  34965. */
  34966. camera: ArcRotateCamera;
  34967. /**
  34968. * Defines the list of key codes associated with the up action (increase alpha)
  34969. */
  34970. keysUp: number[];
  34971. /**
  34972. * Defines the list of key codes associated with the down action (decrease alpha)
  34973. */
  34974. keysDown: number[];
  34975. /**
  34976. * Defines the list of key codes associated with the left action (increase beta)
  34977. */
  34978. keysLeft: number[];
  34979. /**
  34980. * Defines the list of key codes associated with the right action (decrease beta)
  34981. */
  34982. keysRight: number[];
  34983. /**
  34984. * Defines the list of key codes associated with the reset action.
  34985. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34986. */
  34987. keysReset: number[];
  34988. /**
  34989. * Defines the panning sensibility of the inputs.
  34990. * (How fast is the camera paning)
  34991. */
  34992. panningSensibility: number;
  34993. /**
  34994. * Defines the zooming sensibility of the inputs.
  34995. * (How fast is the camera zooming)
  34996. */
  34997. zoomingSensibility: number;
  34998. /**
  34999. * Defines wether maintaining the alt key down switch the movement mode from
  35000. * orientation to zoom.
  35001. */
  35002. useAltToZoom: boolean;
  35003. /**
  35004. * Rotation speed of the camera
  35005. */
  35006. angularSpeed: number;
  35007. private _keys;
  35008. private _ctrlPressed;
  35009. private _altPressed;
  35010. private _onCanvasBlurObserver;
  35011. private _onKeyboardObserver;
  35012. private _engine;
  35013. private _scene;
  35014. /**
  35015. * Attach the input controls to a specific dom element to get the input from.
  35016. * @param element Defines the element the controls should be listened from
  35017. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35018. */
  35019. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35020. /**
  35021. * Detach the current controls from the specified dom element.
  35022. * @param element Defines the element to stop listening the inputs from
  35023. */
  35024. detachControl(element: Nullable<HTMLElement>): void;
  35025. /**
  35026. * Update the current camera state depending on the inputs that have been used this frame.
  35027. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35028. */
  35029. checkInputs(): void;
  35030. /**
  35031. * Gets the class name of the current intput.
  35032. * @returns the class name
  35033. */
  35034. getClassName(): string;
  35035. /**
  35036. * Get the friendly name associated with the input class.
  35037. * @returns the input friendly name
  35038. */
  35039. getSimpleName(): string;
  35040. }
  35041. }
  35042. declare module BABYLON {
  35043. /**
  35044. * Manage the mouse wheel inputs to control an arc rotate camera.
  35045. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35046. */
  35047. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35048. /**
  35049. * Defines the camera the input is attached to.
  35050. */
  35051. camera: ArcRotateCamera;
  35052. /**
  35053. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35054. */
  35055. wheelPrecision: number;
  35056. /**
  35057. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35058. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35059. */
  35060. wheelDeltaPercentage: number;
  35061. private _wheel;
  35062. private _observer;
  35063. private computeDeltaFromMouseWheelLegacyEvent;
  35064. /**
  35065. * Attach the input controls to a specific dom element to get the input from.
  35066. * @param element Defines the element the controls should be listened from
  35067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35068. */
  35069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35070. /**
  35071. * Detach the current controls from the specified dom element.
  35072. * @param element Defines the element to stop listening the inputs from
  35073. */
  35074. detachControl(element: Nullable<HTMLElement>): void;
  35075. /**
  35076. * Gets the class name of the current intput.
  35077. * @returns the class name
  35078. */
  35079. getClassName(): string;
  35080. /**
  35081. * Get the friendly name associated with the input class.
  35082. * @returns the input friendly name
  35083. */
  35084. getSimpleName(): string;
  35085. }
  35086. }
  35087. declare module BABYLON {
  35088. /**
  35089. * Default Inputs manager for the ArcRotateCamera.
  35090. * It groups all the default supported inputs for ease of use.
  35091. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35092. */
  35093. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35094. /**
  35095. * Instantiates a new ArcRotateCameraInputsManager.
  35096. * @param camera Defines the camera the inputs belong to
  35097. */
  35098. constructor(camera: ArcRotateCamera);
  35099. /**
  35100. * Add mouse wheel input support to the input manager.
  35101. * @returns the current input manager
  35102. */
  35103. addMouseWheel(): ArcRotateCameraInputsManager;
  35104. /**
  35105. * Add pointers input support to the input manager.
  35106. * @returns the current input manager
  35107. */
  35108. addPointers(): ArcRotateCameraInputsManager;
  35109. /**
  35110. * Add keyboard input support to the input manager.
  35111. * @returns the current input manager
  35112. */
  35113. addKeyboard(): ArcRotateCameraInputsManager;
  35114. }
  35115. }
  35116. declare module BABYLON {
  35117. /**
  35118. * This represents an orbital type of camera.
  35119. *
  35120. * 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.
  35121. * 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.
  35122. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35123. */
  35124. export class ArcRotateCamera extends TargetCamera {
  35125. /**
  35126. * Defines the rotation angle of the camera along the longitudinal axis.
  35127. */
  35128. alpha: number;
  35129. /**
  35130. * Defines the rotation angle of the camera along the latitudinal axis.
  35131. */
  35132. beta: number;
  35133. /**
  35134. * Defines the radius of the camera from it s target point.
  35135. */
  35136. radius: number;
  35137. protected _target: Vector3;
  35138. protected _targetHost: Nullable<AbstractMesh>;
  35139. /**
  35140. * Defines the target point of the camera.
  35141. * The camera looks towards it form the radius distance.
  35142. */
  35143. target: Vector3;
  35144. /**
  35145. * Define the current local position of the camera in the scene
  35146. */
  35147. position: Vector3;
  35148. protected _upVector: Vector3;
  35149. protected _upToYMatrix: Matrix;
  35150. protected _YToUpMatrix: Matrix;
  35151. /**
  35152. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35153. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35154. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35155. */
  35156. upVector: Vector3;
  35157. /**
  35158. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35159. */
  35160. setMatUp(): void;
  35161. /**
  35162. * Current inertia value on the longitudinal axis.
  35163. * The bigger this number the longer it will take for the camera to stop.
  35164. */
  35165. inertialAlphaOffset: number;
  35166. /**
  35167. * Current inertia value on the latitudinal axis.
  35168. * The bigger this number the longer it will take for the camera to stop.
  35169. */
  35170. inertialBetaOffset: number;
  35171. /**
  35172. * Current inertia value on the radius axis.
  35173. * The bigger this number the longer it will take for the camera to stop.
  35174. */
  35175. inertialRadiusOffset: number;
  35176. /**
  35177. * Minimum allowed angle on the longitudinal axis.
  35178. * This can help limiting how the Camera is able to move in the scene.
  35179. */
  35180. lowerAlphaLimit: Nullable<number>;
  35181. /**
  35182. * Maximum allowed angle on the longitudinal axis.
  35183. * This can help limiting how the Camera is able to move in the scene.
  35184. */
  35185. upperAlphaLimit: Nullable<number>;
  35186. /**
  35187. * Minimum allowed angle on the latitudinal axis.
  35188. * This can help limiting how the Camera is able to move in the scene.
  35189. */
  35190. lowerBetaLimit: number;
  35191. /**
  35192. * Maximum allowed angle on the latitudinal axis.
  35193. * This can help limiting how the Camera is able to move in the scene.
  35194. */
  35195. upperBetaLimit: number;
  35196. /**
  35197. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35198. * This can help limiting how the Camera is able to move in the scene.
  35199. */
  35200. lowerRadiusLimit: Nullable<number>;
  35201. /**
  35202. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35203. * This can help limiting how the Camera is able to move in the scene.
  35204. */
  35205. upperRadiusLimit: Nullable<number>;
  35206. /**
  35207. * Defines the current inertia value used during panning of the camera along the X axis.
  35208. */
  35209. inertialPanningX: number;
  35210. /**
  35211. * Defines the current inertia value used during panning of the camera along the Y axis.
  35212. */
  35213. inertialPanningY: number;
  35214. /**
  35215. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35216. * Basically if your fingers moves away from more than this distance you will be considered
  35217. * in pinch mode.
  35218. */
  35219. pinchToPanMaxDistance: number;
  35220. /**
  35221. * Defines the maximum distance the camera can pan.
  35222. * This could help keeping the cammera always in your scene.
  35223. */
  35224. panningDistanceLimit: Nullable<number>;
  35225. /**
  35226. * Defines the target of the camera before paning.
  35227. */
  35228. panningOriginTarget: Vector3;
  35229. /**
  35230. * Defines the value of the inertia used during panning.
  35231. * 0 would mean stop inertia and one would mean no decelleration at all.
  35232. */
  35233. panningInertia: number;
  35234. /**
  35235. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35236. */
  35237. angularSensibilityX: number;
  35238. /**
  35239. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35240. */
  35241. angularSensibilityY: number;
  35242. /**
  35243. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35244. */
  35245. pinchPrecision: number;
  35246. /**
  35247. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35248. * It will be used instead of pinchDeltaPrecision if different from 0.
  35249. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35250. */
  35251. pinchDeltaPercentage: number;
  35252. /**
  35253. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35254. */
  35255. panningSensibility: number;
  35256. /**
  35257. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35258. */
  35259. keysUp: number[];
  35260. /**
  35261. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35262. */
  35263. keysDown: number[];
  35264. /**
  35265. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35266. */
  35267. keysLeft: number[];
  35268. /**
  35269. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35270. */
  35271. keysRight: number[];
  35272. /**
  35273. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35274. */
  35275. wheelPrecision: number;
  35276. /**
  35277. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35278. * It will be used instead of pinchDeltaPrecision if different from 0.
  35279. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35280. */
  35281. wheelDeltaPercentage: number;
  35282. /**
  35283. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35284. */
  35285. zoomOnFactor: number;
  35286. /**
  35287. * Defines a screen offset for the camera position.
  35288. */
  35289. targetScreenOffset: Vector2;
  35290. /**
  35291. * Allows the camera to be completely reversed.
  35292. * If false the camera can not arrive upside down.
  35293. */
  35294. allowUpsideDown: boolean;
  35295. /**
  35296. * Define if double tap/click is used to restore the previously saved state of the camera.
  35297. */
  35298. useInputToRestoreState: boolean;
  35299. /** @hidden */
  35300. _viewMatrix: Matrix;
  35301. /** @hidden */
  35302. _useCtrlForPanning: boolean;
  35303. /** @hidden */
  35304. _panningMouseButton: number;
  35305. /**
  35306. * Defines the input associated to the camera.
  35307. */
  35308. inputs: ArcRotateCameraInputsManager;
  35309. /** @hidden */
  35310. _reset: () => void;
  35311. /**
  35312. * Defines the allowed panning axis.
  35313. */
  35314. panningAxis: Vector3;
  35315. protected _localDirection: Vector3;
  35316. protected _transformedDirection: Vector3;
  35317. private _bouncingBehavior;
  35318. /**
  35319. * Gets the bouncing behavior of the camera if it has been enabled.
  35320. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35321. */
  35322. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35323. /**
  35324. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35325. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35326. */
  35327. useBouncingBehavior: boolean;
  35328. private _framingBehavior;
  35329. /**
  35330. * Gets the framing behavior of the camera if it has been enabled.
  35331. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35332. */
  35333. readonly framingBehavior: Nullable<FramingBehavior>;
  35334. /**
  35335. * Defines if the framing behavior of the camera is enabled on the camera.
  35336. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35337. */
  35338. useFramingBehavior: boolean;
  35339. private _autoRotationBehavior;
  35340. /**
  35341. * Gets the auto rotation behavior of the camera if it has been enabled.
  35342. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35343. */
  35344. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35345. /**
  35346. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35347. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35348. */
  35349. useAutoRotationBehavior: boolean;
  35350. /**
  35351. * Observable triggered when the mesh target has been changed on the camera.
  35352. */
  35353. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35354. /**
  35355. * Event raised when the camera is colliding with a mesh.
  35356. */
  35357. onCollide: (collidedMesh: AbstractMesh) => void;
  35358. /**
  35359. * Defines whether the camera should check collision with the objects oh the scene.
  35360. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35361. */
  35362. checkCollisions: boolean;
  35363. /**
  35364. * Defines the collision radius of the camera.
  35365. * This simulates a sphere around the camera.
  35366. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35367. */
  35368. collisionRadius: Vector3;
  35369. protected _collider: Collider;
  35370. protected _previousPosition: Vector3;
  35371. protected _collisionVelocity: Vector3;
  35372. protected _newPosition: Vector3;
  35373. protected _previousAlpha: number;
  35374. protected _previousBeta: number;
  35375. protected _previousRadius: number;
  35376. protected _collisionTriggered: boolean;
  35377. protected _targetBoundingCenter: Nullable<Vector3>;
  35378. private _computationVector;
  35379. /**
  35380. * Instantiates a new ArcRotateCamera in a given scene
  35381. * @param name Defines the name of the camera
  35382. * @param alpha Defines the camera rotation along the logitudinal axis
  35383. * @param beta Defines the camera rotation along the latitudinal axis
  35384. * @param radius Defines the camera distance from its target
  35385. * @param target Defines the camera target
  35386. * @param scene Defines the scene the camera belongs to
  35387. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35388. */
  35389. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35390. /** @hidden */
  35391. _initCache(): void;
  35392. /** @hidden */
  35393. _updateCache(ignoreParentClass?: boolean): void;
  35394. protected _getTargetPosition(): Vector3;
  35395. private _storedAlpha;
  35396. private _storedBeta;
  35397. private _storedRadius;
  35398. private _storedTarget;
  35399. /**
  35400. * Stores the current state of the camera (alpha, beta, radius and target)
  35401. * @returns the camera itself
  35402. */
  35403. storeState(): Camera;
  35404. /**
  35405. * @hidden
  35406. * Restored camera state. You must call storeState() first
  35407. */
  35408. _restoreStateValues(): boolean;
  35409. /** @hidden */
  35410. _isSynchronizedViewMatrix(): boolean;
  35411. /**
  35412. * Attached controls to the current camera.
  35413. * @param element Defines the element the controls should be listened from
  35414. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35415. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35416. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35417. */
  35418. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35419. /**
  35420. * Detach the current controls from the camera.
  35421. * The camera will stop reacting to inputs.
  35422. * @param element Defines the element to stop listening the inputs from
  35423. */
  35424. detachControl(element: HTMLElement): void;
  35425. /** @hidden */
  35426. _checkInputs(): void;
  35427. protected _checkLimits(): void;
  35428. /**
  35429. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35430. */
  35431. rebuildAnglesAndRadius(): void;
  35432. /**
  35433. * Use a position to define the current camera related information like aplha, beta and radius
  35434. * @param position Defines the position to set the camera at
  35435. */
  35436. setPosition(position: Vector3): void;
  35437. /**
  35438. * Defines the target the camera should look at.
  35439. * This will automatically adapt alpha beta and radius to fit within the new target.
  35440. * @param target Defines the new target as a Vector or a mesh
  35441. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35442. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35443. */
  35444. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35445. /** @hidden */
  35446. _getViewMatrix(): Matrix;
  35447. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35448. /**
  35449. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35450. * @param meshes Defines the mesh to zoom on
  35451. * @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)
  35452. */
  35453. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35454. /**
  35455. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35456. * The target will be changed but the radius
  35457. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35458. * @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)
  35459. */
  35460. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35461. min: Vector3;
  35462. max: Vector3;
  35463. distance: number;
  35464. }, doNotUpdateMaxZ?: boolean): void;
  35465. /**
  35466. * @override
  35467. * Override Camera.createRigCamera
  35468. */
  35469. createRigCamera(name: string, cameraIndex: number): Camera;
  35470. /**
  35471. * @hidden
  35472. * @override
  35473. * Override Camera._updateRigCameras
  35474. */
  35475. _updateRigCameras(): void;
  35476. /**
  35477. * Destroy the camera and release the current resources hold by it.
  35478. */
  35479. dispose(): void;
  35480. /**
  35481. * Gets the current object class name.
  35482. * @return the class name
  35483. */
  35484. getClassName(): string;
  35485. }
  35486. }
  35487. declare module BABYLON {
  35488. /**
  35489. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35490. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35491. */
  35492. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35493. /**
  35494. * Gets the name of the behavior.
  35495. */
  35496. readonly name: string;
  35497. private _zoomStopsAnimation;
  35498. private _idleRotationSpeed;
  35499. private _idleRotationWaitTime;
  35500. private _idleRotationSpinupTime;
  35501. /**
  35502. * Sets the flag that indicates if user zooming should stop animation.
  35503. */
  35504. /**
  35505. * Gets the flag that indicates if user zooming should stop animation.
  35506. */
  35507. zoomStopsAnimation: boolean;
  35508. /**
  35509. * Sets the default speed at which the camera rotates around the model.
  35510. */
  35511. /**
  35512. * Gets the default speed at which the camera rotates around the model.
  35513. */
  35514. idleRotationSpeed: number;
  35515. /**
  35516. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35517. */
  35518. /**
  35519. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35520. */
  35521. idleRotationWaitTime: number;
  35522. /**
  35523. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35524. */
  35525. /**
  35526. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35527. */
  35528. idleRotationSpinupTime: number;
  35529. /**
  35530. * Gets a value indicating if the camera is currently rotating because of this behavior
  35531. */
  35532. readonly rotationInProgress: boolean;
  35533. private _onPrePointerObservableObserver;
  35534. private _onAfterCheckInputsObserver;
  35535. private _attachedCamera;
  35536. private _isPointerDown;
  35537. private _lastFrameTime;
  35538. private _lastInteractionTime;
  35539. private _cameraRotationSpeed;
  35540. /**
  35541. * Initializes the behavior.
  35542. */
  35543. init(): void;
  35544. /**
  35545. * Attaches the behavior to its arc rotate camera.
  35546. * @param camera Defines the camera to attach the behavior to
  35547. */
  35548. attach(camera: ArcRotateCamera): void;
  35549. /**
  35550. * Detaches the behavior from its current arc rotate camera.
  35551. */
  35552. detach(): void;
  35553. /**
  35554. * Returns true if user is scrolling.
  35555. * @return true if user is scrolling.
  35556. */
  35557. private _userIsZooming;
  35558. private _lastFrameRadius;
  35559. private _shouldAnimationStopForInteraction;
  35560. /**
  35561. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35562. */
  35563. private _applyUserInteraction;
  35564. private _userIsMoving;
  35565. }
  35566. }
  35567. declare module BABYLON {
  35568. /**
  35569. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35570. */
  35571. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35572. private ui;
  35573. /**
  35574. * The name of the behavior
  35575. */
  35576. name: string;
  35577. /**
  35578. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35579. */
  35580. distanceAwayFromFace: number;
  35581. /**
  35582. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35583. */
  35584. distanceAwayFromBottomOfFace: number;
  35585. private _faceVectors;
  35586. private _target;
  35587. private _scene;
  35588. private _onRenderObserver;
  35589. private _tmpMatrix;
  35590. private _tmpVector;
  35591. /**
  35592. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35593. * @param ui The transform node that should be attched to the mesh
  35594. */
  35595. constructor(ui: TransformNode);
  35596. /**
  35597. * Initializes the behavior
  35598. */
  35599. init(): void;
  35600. private _closestFace;
  35601. private _zeroVector;
  35602. private _lookAtTmpMatrix;
  35603. private _lookAtToRef;
  35604. /**
  35605. * Attaches the AttachToBoxBehavior to the passed in mesh
  35606. * @param target The mesh that the specified node will be attached to
  35607. */
  35608. attach(target: Mesh): void;
  35609. /**
  35610. * Detaches the behavior from the mesh
  35611. */
  35612. detach(): void;
  35613. }
  35614. }
  35615. declare module BABYLON {
  35616. /**
  35617. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35618. */
  35619. export class FadeInOutBehavior implements Behavior<Mesh> {
  35620. /**
  35621. * Time in milliseconds to delay before fading in (Default: 0)
  35622. */
  35623. delay: number;
  35624. /**
  35625. * Time in milliseconds for the mesh to fade in (Default: 300)
  35626. */
  35627. fadeInTime: number;
  35628. private _millisecondsPerFrame;
  35629. private _hovered;
  35630. private _hoverValue;
  35631. private _ownerNode;
  35632. /**
  35633. * Instatiates the FadeInOutBehavior
  35634. */
  35635. constructor();
  35636. /**
  35637. * The name of the behavior
  35638. */
  35639. readonly name: string;
  35640. /**
  35641. * Initializes the behavior
  35642. */
  35643. init(): void;
  35644. /**
  35645. * Attaches the fade behavior on the passed in mesh
  35646. * @param ownerNode The mesh that will be faded in/out once attached
  35647. */
  35648. attach(ownerNode: Mesh): void;
  35649. /**
  35650. * Detaches the behavior from the mesh
  35651. */
  35652. detach(): void;
  35653. /**
  35654. * Triggers the mesh to begin fading in or out
  35655. * @param value if the object should fade in or out (true to fade in)
  35656. */
  35657. fadeIn(value: boolean): void;
  35658. private _update;
  35659. private _setAllVisibility;
  35660. }
  35661. }
  35662. declare module BABYLON {
  35663. /**
  35664. * Class containing a set of static utilities functions for managing Pivots
  35665. * @hidden
  35666. */
  35667. export class PivotTools {
  35668. private static _PivotCached;
  35669. private static _OldPivotPoint;
  35670. private static _PivotTranslation;
  35671. private static _PivotTmpVector;
  35672. /** @hidden */
  35673. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35674. /** @hidden */
  35675. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35676. }
  35677. }
  35678. declare module BABYLON {
  35679. /**
  35680. * Class containing static functions to help procedurally build meshes
  35681. */
  35682. export class PlaneBuilder {
  35683. /**
  35684. * Creates a plane mesh
  35685. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35686. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35687. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35689. * * 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
  35690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35691. * @param name defines the name of the mesh
  35692. * @param options defines the options used to create the mesh
  35693. * @param scene defines the hosting scene
  35694. * @returns the plane mesh
  35695. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35696. */
  35697. static CreatePlane(name: string, options: {
  35698. size?: number;
  35699. width?: number;
  35700. height?: number;
  35701. sideOrientation?: number;
  35702. frontUVs?: Vector4;
  35703. backUVs?: Vector4;
  35704. updatable?: boolean;
  35705. sourcePlane?: Plane;
  35706. }, scene?: Nullable<Scene>): Mesh;
  35707. }
  35708. }
  35709. declare module BABYLON {
  35710. /**
  35711. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35712. */
  35713. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35714. private static _AnyMouseID;
  35715. private _attachedNode;
  35716. private _dragPlane;
  35717. private _scene;
  35718. private _pointerObserver;
  35719. private _beforeRenderObserver;
  35720. private static _planeScene;
  35721. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35722. /**
  35723. * 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)
  35724. */
  35725. maxDragAngle: number;
  35726. /**
  35727. * @hidden
  35728. */
  35729. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35730. /**
  35731. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35732. */
  35733. currentDraggingPointerID: number;
  35734. /**
  35735. * The last position where the pointer hit the drag plane in world space
  35736. */
  35737. lastDragPosition: Vector3;
  35738. /**
  35739. * If the behavior is currently in a dragging state
  35740. */
  35741. dragging: boolean;
  35742. /**
  35743. * 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)
  35744. */
  35745. dragDeltaRatio: number;
  35746. /**
  35747. * If the drag plane orientation should be updated during the dragging (Default: true)
  35748. */
  35749. updateDragPlane: boolean;
  35750. private _debugMode;
  35751. private _moving;
  35752. /**
  35753. * Fires each time the attached mesh is dragged with the pointer
  35754. * * delta between last drag position and current drag position in world space
  35755. * * dragDistance along the drag axis
  35756. * * dragPlaneNormal normal of the current drag plane used during the drag
  35757. * * dragPlanePoint in world space where the drag intersects the drag plane
  35758. */
  35759. onDragObservable: Observable<{
  35760. delta: Vector3;
  35761. dragPlanePoint: Vector3;
  35762. dragPlaneNormal: Vector3;
  35763. dragDistance: number;
  35764. pointerId: number;
  35765. }>;
  35766. /**
  35767. * Fires each time a drag begins (eg. mouse down on mesh)
  35768. */
  35769. onDragStartObservable: Observable<{
  35770. dragPlanePoint: Vector3;
  35771. pointerId: number;
  35772. }>;
  35773. /**
  35774. * Fires each time a drag ends (eg. mouse release after drag)
  35775. */
  35776. onDragEndObservable: Observable<{
  35777. dragPlanePoint: Vector3;
  35778. pointerId: number;
  35779. }>;
  35780. /**
  35781. * If the attached mesh should be moved when dragged
  35782. */
  35783. moveAttached: boolean;
  35784. /**
  35785. * If the drag behavior will react to drag events (Default: true)
  35786. */
  35787. enabled: boolean;
  35788. /**
  35789. * If camera controls should be detached during the drag
  35790. */
  35791. detachCameraControls: boolean;
  35792. /**
  35793. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35794. */
  35795. useObjectOrienationForDragging: boolean;
  35796. private _options;
  35797. /**
  35798. * Creates a pointer drag behavior that can be attached to a mesh
  35799. * @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)
  35800. */
  35801. constructor(options?: {
  35802. dragAxis?: Vector3;
  35803. dragPlaneNormal?: Vector3;
  35804. });
  35805. /**
  35806. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35807. */
  35808. validateDrag: (targetPosition: Vector3) => boolean;
  35809. /**
  35810. * The name of the behavior
  35811. */
  35812. readonly name: string;
  35813. /**
  35814. * Initializes the behavior
  35815. */
  35816. init(): void;
  35817. private _tmpVector;
  35818. private _alternatePickedPoint;
  35819. private _worldDragAxis;
  35820. private _targetPosition;
  35821. private _attachedElement;
  35822. /**
  35823. * Attaches the drag behavior the passed in mesh
  35824. * @param ownerNode The mesh that will be dragged around once attached
  35825. */
  35826. attach(ownerNode: AbstractMesh): void;
  35827. /**
  35828. * Force relase the drag action by code.
  35829. */
  35830. releaseDrag(): void;
  35831. private _startDragRay;
  35832. private _lastPointerRay;
  35833. /**
  35834. * Simulates the start of a pointer drag event on the behavior
  35835. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35836. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35837. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35838. */
  35839. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35840. private _startDrag;
  35841. private _dragDelta;
  35842. private _moveDrag;
  35843. private _pickWithRayOnDragPlane;
  35844. private _pointA;
  35845. private _pointB;
  35846. private _pointC;
  35847. private _lineA;
  35848. private _lineB;
  35849. private _localAxis;
  35850. private _lookAt;
  35851. private _updateDragPlanePosition;
  35852. /**
  35853. * Detaches the behavior from the mesh
  35854. */
  35855. detach(): void;
  35856. }
  35857. }
  35858. declare module BABYLON {
  35859. /**
  35860. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35861. */
  35862. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35863. private _dragBehaviorA;
  35864. private _dragBehaviorB;
  35865. private _startDistance;
  35866. private _initialScale;
  35867. private _targetScale;
  35868. private _ownerNode;
  35869. private _sceneRenderObserver;
  35870. /**
  35871. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35872. */
  35873. constructor();
  35874. /**
  35875. * The name of the behavior
  35876. */
  35877. readonly name: string;
  35878. /**
  35879. * Initializes the behavior
  35880. */
  35881. init(): void;
  35882. private _getCurrentDistance;
  35883. /**
  35884. * Attaches the scale behavior the passed in mesh
  35885. * @param ownerNode The mesh that will be scaled around once attached
  35886. */
  35887. attach(ownerNode: Mesh): void;
  35888. /**
  35889. * Detaches the behavior from the mesh
  35890. */
  35891. detach(): void;
  35892. }
  35893. }
  35894. declare module BABYLON {
  35895. /**
  35896. * 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
  35897. */
  35898. export class SixDofDragBehavior implements Behavior<Mesh> {
  35899. private static _virtualScene;
  35900. private _ownerNode;
  35901. private _sceneRenderObserver;
  35902. private _scene;
  35903. private _targetPosition;
  35904. private _virtualOriginMesh;
  35905. private _virtualDragMesh;
  35906. private _pointerObserver;
  35907. private _moving;
  35908. private _startingOrientation;
  35909. /**
  35910. * 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)
  35911. */
  35912. private zDragFactor;
  35913. /**
  35914. * If the object should rotate to face the drag origin
  35915. */
  35916. rotateDraggedObject: boolean;
  35917. /**
  35918. * If the behavior is currently in a dragging state
  35919. */
  35920. dragging: boolean;
  35921. /**
  35922. * 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)
  35923. */
  35924. dragDeltaRatio: number;
  35925. /**
  35926. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35927. */
  35928. currentDraggingPointerID: number;
  35929. /**
  35930. * If camera controls should be detached during the drag
  35931. */
  35932. detachCameraControls: boolean;
  35933. /**
  35934. * Fires each time a drag starts
  35935. */
  35936. onDragStartObservable: Observable<{}>;
  35937. /**
  35938. * Fires each time a drag ends (eg. mouse release after drag)
  35939. */
  35940. onDragEndObservable: Observable<{}>;
  35941. /**
  35942. * 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
  35943. */
  35944. constructor();
  35945. /**
  35946. * The name of the behavior
  35947. */
  35948. readonly name: string;
  35949. /**
  35950. * Initializes the behavior
  35951. */
  35952. init(): void;
  35953. /**
  35954. * Attaches the scale behavior the passed in mesh
  35955. * @param ownerNode The mesh that will be scaled around once attached
  35956. */
  35957. attach(ownerNode: Mesh): void;
  35958. /**
  35959. * Detaches the behavior from the mesh
  35960. */
  35961. detach(): void;
  35962. }
  35963. }
  35964. declare module BABYLON {
  35965. /**
  35966. * Class used to apply inverse kinematics to bones
  35967. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35968. */
  35969. export class BoneIKController {
  35970. private static _tmpVecs;
  35971. private static _tmpQuat;
  35972. private static _tmpMats;
  35973. /**
  35974. * Gets or sets the target mesh
  35975. */
  35976. targetMesh: AbstractMesh;
  35977. /** Gets or sets the mesh used as pole */
  35978. poleTargetMesh: AbstractMesh;
  35979. /**
  35980. * Gets or sets the bone used as pole
  35981. */
  35982. poleTargetBone: Nullable<Bone>;
  35983. /**
  35984. * Gets or sets the target position
  35985. */
  35986. targetPosition: Vector3;
  35987. /**
  35988. * Gets or sets the pole target position
  35989. */
  35990. poleTargetPosition: Vector3;
  35991. /**
  35992. * Gets or sets the pole target local offset
  35993. */
  35994. poleTargetLocalOffset: Vector3;
  35995. /**
  35996. * Gets or sets the pole angle
  35997. */
  35998. poleAngle: number;
  35999. /**
  36000. * Gets or sets the mesh associated with the controller
  36001. */
  36002. mesh: AbstractMesh;
  36003. /**
  36004. * 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)
  36005. */
  36006. slerpAmount: number;
  36007. private _bone1Quat;
  36008. private _bone1Mat;
  36009. private _bone2Ang;
  36010. private _bone1;
  36011. private _bone2;
  36012. private _bone1Length;
  36013. private _bone2Length;
  36014. private _maxAngle;
  36015. private _maxReach;
  36016. private _rightHandedSystem;
  36017. private _bendAxis;
  36018. private _slerping;
  36019. private _adjustRoll;
  36020. /**
  36021. * Gets or sets maximum allowed angle
  36022. */
  36023. maxAngle: number;
  36024. /**
  36025. * Creates a new BoneIKController
  36026. * @param mesh defines the mesh to control
  36027. * @param bone defines the bone to control
  36028. * @param options defines options to set up the controller
  36029. */
  36030. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36031. targetMesh?: AbstractMesh;
  36032. poleTargetMesh?: AbstractMesh;
  36033. poleTargetBone?: Bone;
  36034. poleTargetLocalOffset?: Vector3;
  36035. poleAngle?: number;
  36036. bendAxis?: Vector3;
  36037. maxAngle?: number;
  36038. slerpAmount?: number;
  36039. });
  36040. private _setMaxAngle;
  36041. /**
  36042. * Force the controller to update the bones
  36043. */
  36044. update(): void;
  36045. }
  36046. }
  36047. declare module BABYLON {
  36048. /**
  36049. * Class used to make a bone look toward a point in space
  36050. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36051. */
  36052. export class BoneLookController {
  36053. private static _tmpVecs;
  36054. private static _tmpQuat;
  36055. private static _tmpMats;
  36056. /**
  36057. * The target Vector3 that the bone will look at
  36058. */
  36059. target: Vector3;
  36060. /**
  36061. * The mesh that the bone is attached to
  36062. */
  36063. mesh: AbstractMesh;
  36064. /**
  36065. * The bone that will be looking to the target
  36066. */
  36067. bone: Bone;
  36068. /**
  36069. * The up axis of the coordinate system that is used when the bone is rotated
  36070. */
  36071. upAxis: Vector3;
  36072. /**
  36073. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36074. */
  36075. upAxisSpace: Space;
  36076. /**
  36077. * Used to make an adjustment to the yaw of the bone
  36078. */
  36079. adjustYaw: number;
  36080. /**
  36081. * Used to make an adjustment to the pitch of the bone
  36082. */
  36083. adjustPitch: number;
  36084. /**
  36085. * Used to make an adjustment to the roll of the bone
  36086. */
  36087. adjustRoll: number;
  36088. /**
  36089. * 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)
  36090. */
  36091. slerpAmount: number;
  36092. private _minYaw;
  36093. private _maxYaw;
  36094. private _minPitch;
  36095. private _maxPitch;
  36096. private _minYawSin;
  36097. private _minYawCos;
  36098. private _maxYawSin;
  36099. private _maxYawCos;
  36100. private _midYawConstraint;
  36101. private _minPitchTan;
  36102. private _maxPitchTan;
  36103. private _boneQuat;
  36104. private _slerping;
  36105. private _transformYawPitch;
  36106. private _transformYawPitchInv;
  36107. private _firstFrameSkipped;
  36108. private _yawRange;
  36109. private _fowardAxis;
  36110. /**
  36111. * Gets or sets the minimum yaw angle that the bone can look to
  36112. */
  36113. minYaw: number;
  36114. /**
  36115. * Gets or sets the maximum yaw angle that the bone can look to
  36116. */
  36117. maxYaw: number;
  36118. /**
  36119. * Gets or sets the minimum pitch angle that the bone can look to
  36120. */
  36121. minPitch: number;
  36122. /**
  36123. * Gets or sets the maximum pitch angle that the bone can look to
  36124. */
  36125. maxPitch: number;
  36126. /**
  36127. * Create a BoneLookController
  36128. * @param mesh the mesh that the bone belongs to
  36129. * @param bone the bone that will be looking to the target
  36130. * @param target the target Vector3 to look at
  36131. * @param options optional settings:
  36132. * * maxYaw: the maximum angle the bone will yaw to
  36133. * * minYaw: the minimum angle the bone will yaw to
  36134. * * maxPitch: the maximum angle the bone will pitch to
  36135. * * minPitch: the minimum angle the bone will yaw to
  36136. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36137. * * upAxis: the up axis of the coordinate system
  36138. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36139. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36140. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36141. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36142. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36143. * * adjustRoll: used to make an adjustment to the roll of the bone
  36144. **/
  36145. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36146. maxYaw?: number;
  36147. minYaw?: number;
  36148. maxPitch?: number;
  36149. minPitch?: number;
  36150. slerpAmount?: number;
  36151. upAxis?: Vector3;
  36152. upAxisSpace?: Space;
  36153. yawAxis?: Vector3;
  36154. pitchAxis?: Vector3;
  36155. adjustYaw?: number;
  36156. adjustPitch?: number;
  36157. adjustRoll?: number;
  36158. });
  36159. /**
  36160. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36161. */
  36162. update(): void;
  36163. private _getAngleDiff;
  36164. private _getAngleBetween;
  36165. private _isAngleBetween;
  36166. }
  36167. }
  36168. declare module BABYLON {
  36169. /**
  36170. * Manage the gamepad inputs to control an arc rotate camera.
  36171. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36172. */
  36173. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36174. /**
  36175. * Defines the camera the input is attached to.
  36176. */
  36177. camera: ArcRotateCamera;
  36178. /**
  36179. * Defines the gamepad the input is gathering event from.
  36180. */
  36181. gamepad: Nullable<Gamepad>;
  36182. /**
  36183. * Defines the gamepad rotation sensiblity.
  36184. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36185. */
  36186. gamepadRotationSensibility: number;
  36187. /**
  36188. * Defines the gamepad move sensiblity.
  36189. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36190. */
  36191. gamepadMoveSensibility: number;
  36192. private _onGamepadConnectedObserver;
  36193. private _onGamepadDisconnectedObserver;
  36194. /**
  36195. * Attach the input controls to a specific dom element to get the input from.
  36196. * @param element Defines the element the controls should be listened from
  36197. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36198. */
  36199. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36200. /**
  36201. * Detach the current controls from the specified dom element.
  36202. * @param element Defines the element to stop listening the inputs from
  36203. */
  36204. detachControl(element: Nullable<HTMLElement>): void;
  36205. /**
  36206. * Update the current camera state depending on the inputs that have been used this frame.
  36207. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36208. */
  36209. checkInputs(): void;
  36210. /**
  36211. * Gets the class name of the current intput.
  36212. * @returns the class name
  36213. */
  36214. getClassName(): string;
  36215. /**
  36216. * Get the friendly name associated with the input class.
  36217. * @returns the input friendly name
  36218. */
  36219. getSimpleName(): string;
  36220. }
  36221. }
  36222. declare module BABYLON {
  36223. interface ArcRotateCameraInputsManager {
  36224. /**
  36225. * Add orientation input support to the input manager.
  36226. * @returns the current input manager
  36227. */
  36228. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36229. }
  36230. /**
  36231. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36232. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36233. */
  36234. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36235. /**
  36236. * Defines the camera the input is attached to.
  36237. */
  36238. camera: ArcRotateCamera;
  36239. /**
  36240. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36241. */
  36242. alphaCorrection: number;
  36243. /**
  36244. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36245. */
  36246. gammaCorrection: number;
  36247. private _alpha;
  36248. private _gamma;
  36249. private _dirty;
  36250. private _deviceOrientationHandler;
  36251. /**
  36252. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36253. */
  36254. constructor();
  36255. /**
  36256. * Attach the input controls to a specific dom element to get the input from.
  36257. * @param element Defines the element the controls should be listened from
  36258. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36259. */
  36260. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36261. /** @hidden */
  36262. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36263. /**
  36264. * Update the current camera state depending on the inputs that have been used this frame.
  36265. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36266. */
  36267. checkInputs(): void;
  36268. /**
  36269. * Detach the current controls from the specified dom element.
  36270. * @param element Defines the element to stop listening the inputs from
  36271. */
  36272. detachControl(element: Nullable<HTMLElement>): void;
  36273. /**
  36274. * Gets the class name of the current intput.
  36275. * @returns the class name
  36276. */
  36277. getClassName(): string;
  36278. /**
  36279. * Get the friendly name associated with the input class.
  36280. * @returns the input friendly name
  36281. */
  36282. getSimpleName(): string;
  36283. }
  36284. }
  36285. declare module BABYLON {
  36286. /**
  36287. * Listen to mouse events to control the camera.
  36288. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36289. */
  36290. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36291. /**
  36292. * Defines the camera the input is attached to.
  36293. */
  36294. camera: FlyCamera;
  36295. /**
  36296. * Defines if touch is enabled. (Default is true.)
  36297. */
  36298. touchEnabled: boolean;
  36299. /**
  36300. * Defines the buttons associated with the input to handle camera rotation.
  36301. */
  36302. buttons: number[];
  36303. /**
  36304. * Assign buttons for Yaw control.
  36305. */
  36306. buttonsYaw: number[];
  36307. /**
  36308. * Assign buttons for Pitch control.
  36309. */
  36310. buttonsPitch: number[];
  36311. /**
  36312. * Assign buttons for Roll control.
  36313. */
  36314. buttonsRoll: number[];
  36315. /**
  36316. * Detect if any button is being pressed while mouse is moved.
  36317. * -1 = Mouse locked.
  36318. * 0 = Left button.
  36319. * 1 = Middle Button.
  36320. * 2 = Right Button.
  36321. */
  36322. activeButton: number;
  36323. /**
  36324. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36325. * Higher values reduce its sensitivity.
  36326. */
  36327. angularSensibility: number;
  36328. private _mousemoveCallback;
  36329. private _observer;
  36330. private _rollObserver;
  36331. private previousPosition;
  36332. private noPreventDefault;
  36333. private element;
  36334. /**
  36335. * Listen to mouse events to control the camera.
  36336. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36338. */
  36339. constructor(touchEnabled?: boolean);
  36340. /**
  36341. * Attach the mouse control to the HTML DOM element.
  36342. * @param element Defines the element that listens to the input events.
  36343. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36344. */
  36345. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36346. /**
  36347. * Detach the current controls from the specified dom element.
  36348. * @param element Defines the element to stop listening the inputs from
  36349. */
  36350. detachControl(element: Nullable<HTMLElement>): void;
  36351. /**
  36352. * Gets the class name of the current input.
  36353. * @returns the class name.
  36354. */
  36355. getClassName(): string;
  36356. /**
  36357. * Get the friendly name associated with the input class.
  36358. * @returns the input's friendly name.
  36359. */
  36360. getSimpleName(): string;
  36361. private _pointerInput;
  36362. private _onMouseMove;
  36363. /**
  36364. * Rotate camera by mouse offset.
  36365. */
  36366. private rotateCamera;
  36367. }
  36368. }
  36369. declare module BABYLON {
  36370. /**
  36371. * Default Inputs manager for the FlyCamera.
  36372. * It groups all the default supported inputs for ease of use.
  36373. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36374. */
  36375. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36376. /**
  36377. * Instantiates a new FlyCameraInputsManager.
  36378. * @param camera Defines the camera the inputs belong to.
  36379. */
  36380. constructor(camera: FlyCamera);
  36381. /**
  36382. * Add keyboard input support to the input manager.
  36383. * @returns the new FlyCameraKeyboardMoveInput().
  36384. */
  36385. addKeyboard(): FlyCameraInputsManager;
  36386. /**
  36387. * Add mouse input support to the input manager.
  36388. * @param touchEnabled Enable touch screen support.
  36389. * @returns the new FlyCameraMouseInput().
  36390. */
  36391. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36392. }
  36393. }
  36394. declare module BABYLON {
  36395. /**
  36396. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36397. * such as in a 3D Space Shooter or a Flight Simulator.
  36398. */
  36399. export class FlyCamera extends TargetCamera {
  36400. /**
  36401. * Define the collision ellipsoid of the camera.
  36402. * This is helpful for simulating a camera body, like a player's body.
  36403. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36404. */
  36405. ellipsoid: Vector3;
  36406. /**
  36407. * Define an offset for the position of the ellipsoid around the camera.
  36408. * This can be helpful if the camera is attached away from the player's body center,
  36409. * such as at its head.
  36410. */
  36411. ellipsoidOffset: Vector3;
  36412. /**
  36413. * Enable or disable collisions of the camera with the rest of the scene objects.
  36414. */
  36415. checkCollisions: boolean;
  36416. /**
  36417. * Enable or disable gravity on the camera.
  36418. */
  36419. applyGravity: boolean;
  36420. /**
  36421. * Define the current direction the camera is moving to.
  36422. */
  36423. cameraDirection: Vector3;
  36424. /**
  36425. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36426. * This overrides and empties cameraRotation.
  36427. */
  36428. rotationQuaternion: Quaternion;
  36429. /**
  36430. * Track Roll to maintain the wanted Rolling when looking around.
  36431. */
  36432. _trackRoll: number;
  36433. /**
  36434. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36435. */
  36436. rollCorrect: number;
  36437. /**
  36438. * Mimic a banked turn, Rolling the camera when Yawing.
  36439. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36440. */
  36441. bankedTurn: boolean;
  36442. /**
  36443. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36444. */
  36445. bankedTurnLimit: number;
  36446. /**
  36447. * Value of 0 disables the banked Roll.
  36448. * Value of 1 is equal to the Yaw angle in radians.
  36449. */
  36450. bankedTurnMultiplier: number;
  36451. /**
  36452. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36453. */
  36454. inputs: FlyCameraInputsManager;
  36455. /**
  36456. * Gets the input sensibility for mouse input.
  36457. * Higher values reduce sensitivity.
  36458. */
  36459. /**
  36460. * Sets the input sensibility for a mouse input.
  36461. * Higher values reduce sensitivity.
  36462. */
  36463. angularSensibility: number;
  36464. /**
  36465. * Get the keys for camera movement forward.
  36466. */
  36467. /**
  36468. * Set the keys for camera movement forward.
  36469. */
  36470. keysForward: number[];
  36471. /**
  36472. * Get the keys for camera movement backward.
  36473. */
  36474. keysBackward: number[];
  36475. /**
  36476. * Get the keys for camera movement up.
  36477. */
  36478. /**
  36479. * Set the keys for camera movement up.
  36480. */
  36481. keysUp: number[];
  36482. /**
  36483. * Get the keys for camera movement down.
  36484. */
  36485. /**
  36486. * Set the keys for camera movement down.
  36487. */
  36488. keysDown: number[];
  36489. /**
  36490. * Get the keys for camera movement left.
  36491. */
  36492. /**
  36493. * Set the keys for camera movement left.
  36494. */
  36495. keysLeft: number[];
  36496. /**
  36497. * Set the keys for camera movement right.
  36498. */
  36499. /**
  36500. * Set the keys for camera movement right.
  36501. */
  36502. keysRight: number[];
  36503. /**
  36504. * Event raised when the camera collides with a mesh in the scene.
  36505. */
  36506. onCollide: (collidedMesh: AbstractMesh) => void;
  36507. private _collider;
  36508. private _needMoveForGravity;
  36509. private _oldPosition;
  36510. private _diffPosition;
  36511. private _newPosition;
  36512. /** @hidden */
  36513. _localDirection: Vector3;
  36514. /** @hidden */
  36515. _transformedDirection: Vector3;
  36516. /**
  36517. * Instantiates a FlyCamera.
  36518. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36519. * such as in a 3D Space Shooter or a Flight Simulator.
  36520. * @param name Define the name of the camera in the scene.
  36521. * @param position Define the starting position of the camera in the scene.
  36522. * @param scene Define the scene the camera belongs to.
  36523. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36524. */
  36525. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36526. /**
  36527. * Attach a control to the HTML DOM element.
  36528. * @param element Defines the element that listens to the input events.
  36529. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36530. */
  36531. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36532. /**
  36533. * Detach a control from the HTML DOM element.
  36534. * The camera will stop reacting to that input.
  36535. * @param element Defines the element that listens to the input events.
  36536. */
  36537. detachControl(element: HTMLElement): void;
  36538. private _collisionMask;
  36539. /**
  36540. * Get the mask that the camera ignores in collision events.
  36541. */
  36542. /**
  36543. * Set the mask that the camera ignores in collision events.
  36544. */
  36545. collisionMask: number;
  36546. /** @hidden */
  36547. _collideWithWorld(displacement: Vector3): void;
  36548. /** @hidden */
  36549. private _onCollisionPositionChange;
  36550. /** @hidden */
  36551. _checkInputs(): void;
  36552. /** @hidden */
  36553. _decideIfNeedsToMove(): boolean;
  36554. /** @hidden */
  36555. _updatePosition(): void;
  36556. /**
  36557. * Restore the Roll to its target value at the rate specified.
  36558. * @param rate - Higher means slower restoring.
  36559. * @hidden
  36560. */
  36561. restoreRoll(rate: number): void;
  36562. /**
  36563. * Destroy the camera and release the current resources held by it.
  36564. */
  36565. dispose(): void;
  36566. /**
  36567. * Get the current object class name.
  36568. * @returns the class name.
  36569. */
  36570. getClassName(): string;
  36571. }
  36572. }
  36573. declare module BABYLON {
  36574. /**
  36575. * Listen to keyboard events to control the camera.
  36576. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36577. */
  36578. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36579. /**
  36580. * Defines the camera the input is attached to.
  36581. */
  36582. camera: FlyCamera;
  36583. /**
  36584. * The list of keyboard keys used to control the forward move of the camera.
  36585. */
  36586. keysForward: number[];
  36587. /**
  36588. * The list of keyboard keys used to control the backward move of the camera.
  36589. */
  36590. keysBackward: number[];
  36591. /**
  36592. * The list of keyboard keys used to control the forward move of the camera.
  36593. */
  36594. keysUp: number[];
  36595. /**
  36596. * The list of keyboard keys used to control the backward move of the camera.
  36597. */
  36598. keysDown: number[];
  36599. /**
  36600. * The list of keyboard keys used to control the right strafe move of the camera.
  36601. */
  36602. keysRight: number[];
  36603. /**
  36604. * The list of keyboard keys used to control the left strafe move of the camera.
  36605. */
  36606. keysLeft: number[];
  36607. private _keys;
  36608. private _onCanvasBlurObserver;
  36609. private _onKeyboardObserver;
  36610. private _engine;
  36611. private _scene;
  36612. /**
  36613. * Attach the input controls to a specific dom element to get the input from.
  36614. * @param element Defines the element the controls should be listened from
  36615. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36616. */
  36617. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36618. /**
  36619. * Detach the current controls from the specified dom element.
  36620. * @param element Defines the element to stop listening the inputs from
  36621. */
  36622. detachControl(element: Nullable<HTMLElement>): void;
  36623. /**
  36624. * Gets the class name of the current intput.
  36625. * @returns the class name
  36626. */
  36627. getClassName(): string;
  36628. /** @hidden */
  36629. _onLostFocus(e: FocusEvent): void;
  36630. /**
  36631. * Get the friendly name associated with the input class.
  36632. * @returns the input friendly name
  36633. */
  36634. getSimpleName(): string;
  36635. /**
  36636. * Update the current camera state depending on the inputs that have been used this frame.
  36637. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36638. */
  36639. checkInputs(): void;
  36640. }
  36641. }
  36642. declare module BABYLON {
  36643. /**
  36644. * Manage the mouse wheel inputs to control a follow camera.
  36645. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36646. */
  36647. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36648. /**
  36649. * Defines the camera the input is attached to.
  36650. */
  36651. camera: FollowCamera;
  36652. /**
  36653. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36654. */
  36655. axisControlRadius: boolean;
  36656. /**
  36657. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36658. */
  36659. axisControlHeight: boolean;
  36660. /**
  36661. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36662. */
  36663. axisControlRotation: boolean;
  36664. /**
  36665. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36666. * relation to mouseWheel events.
  36667. */
  36668. wheelPrecision: number;
  36669. /**
  36670. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36671. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36672. */
  36673. wheelDeltaPercentage: number;
  36674. private _wheel;
  36675. private _observer;
  36676. /**
  36677. * Attach the input controls to a specific dom element to get the input from.
  36678. * @param element Defines the element the controls should be listened from
  36679. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36680. */
  36681. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36682. /**
  36683. * Detach the current controls from the specified dom element.
  36684. * @param element Defines the element to stop listening the inputs from
  36685. */
  36686. detachControl(element: Nullable<HTMLElement>): void;
  36687. /**
  36688. * Gets the class name of the current intput.
  36689. * @returns the class name
  36690. */
  36691. getClassName(): string;
  36692. /**
  36693. * Get the friendly name associated with the input class.
  36694. * @returns the input friendly name
  36695. */
  36696. getSimpleName(): string;
  36697. }
  36698. }
  36699. declare module BABYLON {
  36700. /**
  36701. * Manage the pointers inputs to control an follow camera.
  36702. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36703. */
  36704. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36705. /**
  36706. * Defines the camera the input is attached to.
  36707. */
  36708. camera: FollowCamera;
  36709. /**
  36710. * Gets the class name of the current input.
  36711. * @returns the class name
  36712. */
  36713. getClassName(): string;
  36714. /**
  36715. * Defines the pointer angular sensibility along the X axis or how fast is
  36716. * the camera rotating.
  36717. * A negative number will reverse the axis direction.
  36718. */
  36719. angularSensibilityX: number;
  36720. /**
  36721. * Defines the pointer angular sensibility along the Y axis or how fast is
  36722. * the camera rotating.
  36723. * A negative number will reverse the axis direction.
  36724. */
  36725. angularSensibilityY: number;
  36726. /**
  36727. * Defines the pointer pinch precision or how fast is the camera zooming.
  36728. * A negative number will reverse the axis direction.
  36729. */
  36730. pinchPrecision: number;
  36731. /**
  36732. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36733. * from 0.
  36734. * It defines the percentage of current camera.radius to use as delta when
  36735. * pinch zoom is used.
  36736. */
  36737. pinchDeltaPercentage: number;
  36738. /**
  36739. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36740. */
  36741. axisXControlRadius: boolean;
  36742. /**
  36743. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36744. */
  36745. axisXControlHeight: boolean;
  36746. /**
  36747. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36748. */
  36749. axisXControlRotation: boolean;
  36750. /**
  36751. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36752. */
  36753. axisYControlRadius: boolean;
  36754. /**
  36755. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36756. */
  36757. axisYControlHeight: boolean;
  36758. /**
  36759. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36760. */
  36761. axisYControlRotation: boolean;
  36762. /**
  36763. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36764. */
  36765. axisPinchControlRadius: boolean;
  36766. /**
  36767. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36768. */
  36769. axisPinchControlHeight: boolean;
  36770. /**
  36771. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36772. */
  36773. axisPinchControlRotation: boolean;
  36774. /**
  36775. * Log error messages if basic misconfiguration has occurred.
  36776. */
  36777. warningEnable: boolean;
  36778. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36779. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36780. private _warningCounter;
  36781. private _warning;
  36782. }
  36783. }
  36784. declare module BABYLON {
  36785. /**
  36786. * Default Inputs manager for the FollowCamera.
  36787. * It groups all the default supported inputs for ease of use.
  36788. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36789. */
  36790. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36791. /**
  36792. * Instantiates a new FollowCameraInputsManager.
  36793. * @param camera Defines the camera the inputs belong to
  36794. */
  36795. constructor(camera: FollowCamera);
  36796. /**
  36797. * Add keyboard input support to the input manager.
  36798. * @returns the current input manager
  36799. */
  36800. addKeyboard(): FollowCameraInputsManager;
  36801. /**
  36802. * Add mouse wheel input support to the input manager.
  36803. * @returns the current input manager
  36804. */
  36805. addMouseWheel(): FollowCameraInputsManager;
  36806. /**
  36807. * Add pointers input support to the input manager.
  36808. * @returns the current input manager
  36809. */
  36810. addPointers(): FollowCameraInputsManager;
  36811. /**
  36812. * Add orientation input support to the input manager.
  36813. * @returns the current input manager
  36814. */
  36815. addVRDeviceOrientation(): FollowCameraInputsManager;
  36816. }
  36817. }
  36818. declare module BABYLON {
  36819. /**
  36820. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36821. * an arc rotate version arcFollowCamera are available.
  36822. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36823. */
  36824. export class FollowCamera extends TargetCamera {
  36825. /**
  36826. * Distance the follow camera should follow an object at
  36827. */
  36828. radius: number;
  36829. /**
  36830. * Minimum allowed distance of the camera to the axis of rotation
  36831. * (The camera can not get closer).
  36832. * This can help limiting how the Camera is able to move in the scene.
  36833. */
  36834. lowerRadiusLimit: Nullable<number>;
  36835. /**
  36836. * Maximum allowed distance of the camera to the axis of rotation
  36837. * (The camera can not get further).
  36838. * This can help limiting how the Camera is able to move in the scene.
  36839. */
  36840. upperRadiusLimit: Nullable<number>;
  36841. /**
  36842. * Define a rotation offset between the camera and the object it follows
  36843. */
  36844. rotationOffset: number;
  36845. /**
  36846. * Minimum allowed angle to camera position relative to target object.
  36847. * This can help limiting how the Camera is able to move in the scene.
  36848. */
  36849. lowerRotationOffsetLimit: Nullable<number>;
  36850. /**
  36851. * Maximum 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. upperRotationOffsetLimit: Nullable<number>;
  36855. /**
  36856. * Define a height offset between the camera and the object it follows.
  36857. * It can help following an object from the top (like a car chaing a plane)
  36858. */
  36859. heightOffset: number;
  36860. /**
  36861. * Minimum allowed height of camera position relative to target object.
  36862. * This can help limiting how the Camera is able to move in the scene.
  36863. */
  36864. lowerHeightOffsetLimit: Nullable<number>;
  36865. /**
  36866. * Maximum 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. upperHeightOffsetLimit: Nullable<number>;
  36870. /**
  36871. * Define how fast the camera can accelerate to follow it s target.
  36872. */
  36873. cameraAcceleration: number;
  36874. /**
  36875. * Define the speed limit of the camera following an object.
  36876. */
  36877. maxCameraSpeed: number;
  36878. /**
  36879. * Define the target of the camera.
  36880. */
  36881. lockedTarget: Nullable<AbstractMesh>;
  36882. /**
  36883. * Defines the input associated with the camera.
  36884. */
  36885. inputs: FollowCameraInputsManager;
  36886. /**
  36887. * Instantiates the follow camera.
  36888. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36889. * @param name Define the name of the camera in the scene
  36890. * @param position Define the position of the camera
  36891. * @param scene Define the scene the camera belong to
  36892. * @param lockedTarget Define the target of the camera
  36893. */
  36894. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36895. private _follow;
  36896. /**
  36897. * Attached controls to the current camera.
  36898. * @param element Defines the element the controls should be listened from
  36899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36900. */
  36901. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36902. /**
  36903. * Detach the current controls from the camera.
  36904. * The camera will stop reacting to inputs.
  36905. * @param element Defines the element to stop listening the inputs from
  36906. */
  36907. detachControl(element: HTMLElement): void;
  36908. /** @hidden */
  36909. _checkInputs(): void;
  36910. private _checkLimits;
  36911. /**
  36912. * Gets the camera class name.
  36913. * @returns the class name
  36914. */
  36915. getClassName(): string;
  36916. }
  36917. /**
  36918. * Arc Rotate version of the follow camera.
  36919. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36920. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36921. */
  36922. export class ArcFollowCamera extends TargetCamera {
  36923. /** The longitudinal angle of the camera */
  36924. alpha: number;
  36925. /** The latitudinal angle of the camera */
  36926. beta: number;
  36927. /** The radius of the camera from its target */
  36928. radius: number;
  36929. /** Define the camera target (the messh it should follow) */
  36930. target: Nullable<AbstractMesh>;
  36931. private _cartesianCoordinates;
  36932. /**
  36933. * Instantiates a new ArcFollowCamera
  36934. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36935. * @param name Define the name of the camera
  36936. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36937. * @param beta Define the rotation angle of the camera around the elevation axis
  36938. * @param radius Define the radius of the camera from its target point
  36939. * @param target Define the target of the camera
  36940. * @param scene Define the scene the camera belongs to
  36941. */
  36942. constructor(name: string,
  36943. /** The longitudinal angle of the camera */
  36944. alpha: number,
  36945. /** The latitudinal angle of the camera */
  36946. beta: number,
  36947. /** The radius of the camera from its target */
  36948. radius: number,
  36949. /** Define the camera target (the messh it should follow) */
  36950. target: Nullable<AbstractMesh>, scene: Scene);
  36951. private _follow;
  36952. /** @hidden */
  36953. _checkInputs(): void;
  36954. /**
  36955. * Returns the class name of the object.
  36956. * It is mostly used internally for serialization purposes.
  36957. */
  36958. getClassName(): string;
  36959. }
  36960. }
  36961. declare module BABYLON {
  36962. /**
  36963. * Manage the keyboard inputs to control the movement of a follow camera.
  36964. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36965. */
  36966. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36967. /**
  36968. * Defines the camera the input is attached to.
  36969. */
  36970. camera: FollowCamera;
  36971. /**
  36972. * Defines the list of key codes associated with the up action (increase heightOffset)
  36973. */
  36974. keysHeightOffsetIncr: number[];
  36975. /**
  36976. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36977. */
  36978. keysHeightOffsetDecr: number[];
  36979. /**
  36980. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36981. */
  36982. keysHeightOffsetModifierAlt: boolean;
  36983. /**
  36984. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36985. */
  36986. keysHeightOffsetModifierCtrl: boolean;
  36987. /**
  36988. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36989. */
  36990. keysHeightOffsetModifierShift: boolean;
  36991. /**
  36992. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36993. */
  36994. keysRotationOffsetIncr: number[];
  36995. /**
  36996. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36997. */
  36998. keysRotationOffsetDecr: number[];
  36999. /**
  37000. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37001. */
  37002. keysRotationOffsetModifierAlt: boolean;
  37003. /**
  37004. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37005. */
  37006. keysRotationOffsetModifierCtrl: boolean;
  37007. /**
  37008. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37009. */
  37010. keysRotationOffsetModifierShift: boolean;
  37011. /**
  37012. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37013. */
  37014. keysRadiusIncr: number[];
  37015. /**
  37016. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37017. */
  37018. keysRadiusDecr: number[];
  37019. /**
  37020. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37021. */
  37022. keysRadiusModifierAlt: boolean;
  37023. /**
  37024. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37025. */
  37026. keysRadiusModifierCtrl: boolean;
  37027. /**
  37028. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37029. */
  37030. keysRadiusModifierShift: boolean;
  37031. /**
  37032. * Defines the rate of change of heightOffset.
  37033. */
  37034. heightSensibility: number;
  37035. /**
  37036. * Defines the rate of change of rotationOffset.
  37037. */
  37038. rotationSensibility: number;
  37039. /**
  37040. * Defines the rate of change of radius.
  37041. */
  37042. radiusSensibility: number;
  37043. private _keys;
  37044. private _ctrlPressed;
  37045. private _altPressed;
  37046. private _shiftPressed;
  37047. private _onCanvasBlurObserver;
  37048. private _onKeyboardObserver;
  37049. private _engine;
  37050. private _scene;
  37051. /**
  37052. * Attach the input controls to a specific dom element to get the input from.
  37053. * @param element Defines the element the controls should be listened from
  37054. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37055. */
  37056. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37057. /**
  37058. * Detach the current controls from the specified dom element.
  37059. * @param element Defines the element to stop listening the inputs from
  37060. */
  37061. detachControl(element: Nullable<HTMLElement>): void;
  37062. /**
  37063. * Update the current camera state depending on the inputs that have been used this frame.
  37064. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37065. */
  37066. checkInputs(): void;
  37067. /**
  37068. * Gets the class name of the current input.
  37069. * @returns the class name
  37070. */
  37071. getClassName(): string;
  37072. /**
  37073. * Get the friendly name associated with the input class.
  37074. * @returns the input friendly name
  37075. */
  37076. getSimpleName(): string;
  37077. /**
  37078. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37079. * allow modification of the heightOffset value.
  37080. */
  37081. private _modifierHeightOffset;
  37082. /**
  37083. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37084. * allow modification of the rotationOffset value.
  37085. */
  37086. private _modifierRotationOffset;
  37087. /**
  37088. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37089. * allow modification of the radius value.
  37090. */
  37091. private _modifierRadius;
  37092. }
  37093. }
  37094. declare module BABYLON {
  37095. interface FreeCameraInputsManager {
  37096. /**
  37097. * @hidden
  37098. */
  37099. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37100. /**
  37101. * Add orientation input support to the input manager.
  37102. * @returns the current input manager
  37103. */
  37104. addDeviceOrientation(): FreeCameraInputsManager;
  37105. }
  37106. /**
  37107. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37108. * Screen rotation is taken into account.
  37109. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37110. */
  37111. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37112. private _camera;
  37113. private _screenOrientationAngle;
  37114. private _constantTranform;
  37115. private _screenQuaternion;
  37116. private _alpha;
  37117. private _beta;
  37118. private _gamma;
  37119. /**
  37120. * @hidden
  37121. */
  37122. _onDeviceOrientationChangedObservable: Observable<void>;
  37123. /**
  37124. * Instantiates a new input
  37125. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37126. */
  37127. constructor();
  37128. /**
  37129. * Define the camera controlled by the input.
  37130. */
  37131. camera: FreeCamera;
  37132. /**
  37133. * Attach the input controls to a specific dom element to get the input from.
  37134. * @param element Defines the element the controls should be listened from
  37135. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37136. */
  37137. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37138. private _orientationChanged;
  37139. private _deviceOrientation;
  37140. /**
  37141. * Detach the current controls from the specified dom element.
  37142. * @param element Defines the element to stop listening the inputs from
  37143. */
  37144. detachControl(element: Nullable<HTMLElement>): void;
  37145. /**
  37146. * Update the current camera state depending on the inputs that have been used this frame.
  37147. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37148. */
  37149. checkInputs(): void;
  37150. /**
  37151. * Gets the class name of the current intput.
  37152. * @returns the class name
  37153. */
  37154. getClassName(): string;
  37155. /**
  37156. * Get the friendly name associated with the input class.
  37157. * @returns the input friendly name
  37158. */
  37159. getSimpleName(): string;
  37160. }
  37161. }
  37162. declare module BABYLON {
  37163. /**
  37164. * Manage the gamepad inputs to control a free camera.
  37165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37166. */
  37167. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37168. /**
  37169. * Define the camera the input is attached to.
  37170. */
  37171. camera: FreeCamera;
  37172. /**
  37173. * Define the Gamepad controlling the input
  37174. */
  37175. gamepad: Nullable<Gamepad>;
  37176. /**
  37177. * Defines the gamepad rotation sensiblity.
  37178. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37179. */
  37180. gamepadAngularSensibility: number;
  37181. /**
  37182. * Defines the gamepad move sensiblity.
  37183. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37184. */
  37185. gamepadMoveSensibility: number;
  37186. private _onGamepadConnectedObserver;
  37187. private _onGamepadDisconnectedObserver;
  37188. private _cameraTransform;
  37189. private _deltaTransform;
  37190. private _vector3;
  37191. private _vector2;
  37192. /**
  37193. * Attach the input controls to a specific dom element to get the input from.
  37194. * @param element Defines the element the controls should be listened from
  37195. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37196. */
  37197. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37198. /**
  37199. * Detach the current controls from the specified dom element.
  37200. * @param element Defines the element to stop listening the inputs from
  37201. */
  37202. detachControl(element: Nullable<HTMLElement>): void;
  37203. /**
  37204. * Update the current camera state depending on the inputs that have been used this frame.
  37205. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37206. */
  37207. checkInputs(): void;
  37208. /**
  37209. * Gets the class name of the current intput.
  37210. * @returns the class name
  37211. */
  37212. getClassName(): string;
  37213. /**
  37214. * Get the friendly name associated with the input class.
  37215. * @returns the input friendly name
  37216. */
  37217. getSimpleName(): string;
  37218. }
  37219. }
  37220. declare module BABYLON {
  37221. /**
  37222. * Defines the potential axis of a Joystick
  37223. */
  37224. export enum JoystickAxis {
  37225. /** X axis */
  37226. X = 0,
  37227. /** Y axis */
  37228. Y = 1,
  37229. /** Z axis */
  37230. Z = 2
  37231. }
  37232. /**
  37233. * Class used to define virtual joystick (used in touch mode)
  37234. */
  37235. export class VirtualJoystick {
  37236. /**
  37237. * Gets or sets a boolean indicating that left and right values must be inverted
  37238. */
  37239. reverseLeftRight: boolean;
  37240. /**
  37241. * Gets or sets a boolean indicating that up and down values must be inverted
  37242. */
  37243. reverseUpDown: boolean;
  37244. /**
  37245. * Gets the offset value for the position (ie. the change of the position value)
  37246. */
  37247. deltaPosition: Vector3;
  37248. /**
  37249. * Gets a boolean indicating if the virtual joystick was pressed
  37250. */
  37251. pressed: boolean;
  37252. /**
  37253. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37254. */
  37255. static Canvas: Nullable<HTMLCanvasElement>;
  37256. private static _globalJoystickIndex;
  37257. private static vjCanvasContext;
  37258. private static vjCanvasWidth;
  37259. private static vjCanvasHeight;
  37260. private static halfWidth;
  37261. private _action;
  37262. private _axisTargetedByLeftAndRight;
  37263. private _axisTargetedByUpAndDown;
  37264. private _joystickSensibility;
  37265. private _inversedSensibility;
  37266. private _joystickPointerID;
  37267. private _joystickColor;
  37268. private _joystickPointerPos;
  37269. private _joystickPreviousPointerPos;
  37270. private _joystickPointerStartPos;
  37271. private _deltaJoystickVector;
  37272. private _leftJoystick;
  37273. private _touches;
  37274. private _onPointerDownHandlerRef;
  37275. private _onPointerMoveHandlerRef;
  37276. private _onPointerUpHandlerRef;
  37277. private _onResize;
  37278. /**
  37279. * Creates a new virtual joystick
  37280. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37281. */
  37282. constructor(leftJoystick?: boolean);
  37283. /**
  37284. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37285. * @param newJoystickSensibility defines the new sensibility
  37286. */
  37287. setJoystickSensibility(newJoystickSensibility: number): void;
  37288. private _onPointerDown;
  37289. private _onPointerMove;
  37290. private _onPointerUp;
  37291. /**
  37292. * Change the color of the virtual joystick
  37293. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37294. */
  37295. setJoystickColor(newColor: string): void;
  37296. /**
  37297. * Defines a callback to call when the joystick is touched
  37298. * @param action defines the callback
  37299. */
  37300. setActionOnTouch(action: () => any): void;
  37301. /**
  37302. * Defines which axis you'd like to control for left & right
  37303. * @param axis defines the axis to use
  37304. */
  37305. setAxisForLeftRight(axis: JoystickAxis): void;
  37306. /**
  37307. * Defines which axis you'd like to control for up & down
  37308. * @param axis defines the axis to use
  37309. */
  37310. setAxisForUpDown(axis: JoystickAxis): void;
  37311. private _drawVirtualJoystick;
  37312. /**
  37313. * Release internal HTML canvas
  37314. */
  37315. releaseCanvas(): void;
  37316. }
  37317. }
  37318. declare module BABYLON {
  37319. interface FreeCameraInputsManager {
  37320. /**
  37321. * Add virtual joystick input support to the input manager.
  37322. * @returns the current input manager
  37323. */
  37324. addVirtualJoystick(): FreeCameraInputsManager;
  37325. }
  37326. /**
  37327. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37328. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37329. */
  37330. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37331. /**
  37332. * Defines the camera the input is attached to.
  37333. */
  37334. camera: FreeCamera;
  37335. private _leftjoystick;
  37336. private _rightjoystick;
  37337. /**
  37338. * Gets the left stick of the virtual joystick.
  37339. * @returns The virtual Joystick
  37340. */
  37341. getLeftJoystick(): VirtualJoystick;
  37342. /**
  37343. * Gets the right stick of the virtual joystick.
  37344. * @returns The virtual Joystick
  37345. */
  37346. getRightJoystick(): VirtualJoystick;
  37347. /**
  37348. * Update the current camera state depending on the inputs that have been used this frame.
  37349. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37350. */
  37351. checkInputs(): void;
  37352. /**
  37353. * Attach the input controls to a specific dom element to get the input from.
  37354. * @param element Defines the element the controls should be listened from
  37355. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37356. */
  37357. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37358. /**
  37359. * Detach the current controls from the specified dom element.
  37360. * @param element Defines the element to stop listening the inputs from
  37361. */
  37362. detachControl(element: Nullable<HTMLElement>): void;
  37363. /**
  37364. * Gets the class name of the current intput.
  37365. * @returns the class name
  37366. */
  37367. getClassName(): string;
  37368. /**
  37369. * Get the friendly name associated with the input class.
  37370. * @returns the input friendly name
  37371. */
  37372. getSimpleName(): string;
  37373. }
  37374. }
  37375. declare module BABYLON {
  37376. /**
  37377. * This represents a FPS type of camera controlled by touch.
  37378. * This is like a universal camera minus the Gamepad controls.
  37379. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37380. */
  37381. export class TouchCamera extends FreeCamera {
  37382. /**
  37383. * Defines the touch sensibility for rotation.
  37384. * The higher the faster.
  37385. */
  37386. touchAngularSensibility: number;
  37387. /**
  37388. * Defines the touch sensibility for move.
  37389. * The higher the faster.
  37390. */
  37391. touchMoveSensibility: number;
  37392. /**
  37393. * Instantiates a new touch camera.
  37394. * This represents a FPS type of camera controlled by touch.
  37395. * This is like a universal camera minus the Gamepad controls.
  37396. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37397. * @param name Define the name of the camera in the scene
  37398. * @param position Define the start position of the camera in the scene
  37399. * @param scene Define the scene the camera belongs to
  37400. */
  37401. constructor(name: string, position: Vector3, scene: Scene);
  37402. /**
  37403. * Gets the current object class name.
  37404. * @return the class name
  37405. */
  37406. getClassName(): string;
  37407. /** @hidden */
  37408. _setupInputs(): void;
  37409. }
  37410. }
  37411. declare module BABYLON {
  37412. /**
  37413. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37414. * being tilted forward or back and left or right.
  37415. */
  37416. export class DeviceOrientationCamera extends FreeCamera {
  37417. private _initialQuaternion;
  37418. private _quaternionCache;
  37419. private _tmpDragQuaternion;
  37420. /**
  37421. * Creates a new device orientation camera
  37422. * @param name The name of the camera
  37423. * @param position The start position camera
  37424. * @param scene The scene the camera belongs to
  37425. */
  37426. constructor(name: string, position: Vector3, scene: Scene);
  37427. /**
  37428. * @hidden
  37429. * Disabled pointer input on first orientation sensor update (Default: true)
  37430. */
  37431. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37432. private _dragFactor;
  37433. /**
  37434. * Enabled turning on the y axis when the orientation sensor is active
  37435. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37436. */
  37437. enableHorizontalDragging(dragFactor?: number): void;
  37438. /**
  37439. * Gets the current instance class name ("DeviceOrientationCamera").
  37440. * This helps avoiding instanceof at run time.
  37441. * @returns the class name
  37442. */
  37443. getClassName(): string;
  37444. /**
  37445. * @hidden
  37446. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37447. */
  37448. _checkInputs(): void;
  37449. /**
  37450. * Reset the camera to its default orientation on the specified axis only.
  37451. * @param axis The axis to reset
  37452. */
  37453. resetToCurrentRotation(axis?: Axis): void;
  37454. }
  37455. }
  37456. declare module BABYLON {
  37457. /**
  37458. * Defines supported buttons for XBox360 compatible gamepads
  37459. */
  37460. export enum Xbox360Button {
  37461. /** A */
  37462. A = 0,
  37463. /** B */
  37464. B = 1,
  37465. /** X */
  37466. X = 2,
  37467. /** Y */
  37468. Y = 3,
  37469. /** Start */
  37470. Start = 4,
  37471. /** Back */
  37472. Back = 5,
  37473. /** Left button */
  37474. LB = 6,
  37475. /** Right button */
  37476. RB = 7,
  37477. /** Left stick */
  37478. LeftStick = 8,
  37479. /** Right stick */
  37480. RightStick = 9
  37481. }
  37482. /** Defines values for XBox360 DPad */
  37483. export enum Xbox360Dpad {
  37484. /** Up */
  37485. Up = 0,
  37486. /** Down */
  37487. Down = 1,
  37488. /** Left */
  37489. Left = 2,
  37490. /** Right */
  37491. Right = 3
  37492. }
  37493. /**
  37494. * Defines a XBox360 gamepad
  37495. */
  37496. export class Xbox360Pad extends Gamepad {
  37497. private _leftTrigger;
  37498. private _rightTrigger;
  37499. private _onlefttriggerchanged;
  37500. private _onrighttriggerchanged;
  37501. private _onbuttondown;
  37502. private _onbuttonup;
  37503. private _ondpaddown;
  37504. private _ondpadup;
  37505. /** Observable raised when a button is pressed */
  37506. onButtonDownObservable: Observable<Xbox360Button>;
  37507. /** Observable raised when a button is released */
  37508. onButtonUpObservable: Observable<Xbox360Button>;
  37509. /** Observable raised when a pad is pressed */
  37510. onPadDownObservable: Observable<Xbox360Dpad>;
  37511. /** Observable raised when a pad is released */
  37512. onPadUpObservable: Observable<Xbox360Dpad>;
  37513. private _buttonA;
  37514. private _buttonB;
  37515. private _buttonX;
  37516. private _buttonY;
  37517. private _buttonBack;
  37518. private _buttonStart;
  37519. private _buttonLB;
  37520. private _buttonRB;
  37521. private _buttonLeftStick;
  37522. private _buttonRightStick;
  37523. private _dPadUp;
  37524. private _dPadDown;
  37525. private _dPadLeft;
  37526. private _dPadRight;
  37527. private _isXboxOnePad;
  37528. /**
  37529. * Creates a new XBox360 gamepad object
  37530. * @param id defines the id of this gamepad
  37531. * @param index defines its index
  37532. * @param gamepad defines the internal HTML gamepad object
  37533. * @param xboxOne defines if it is a XBox One gamepad
  37534. */
  37535. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37536. /**
  37537. * Defines the callback to call when left trigger is pressed
  37538. * @param callback defines the callback to use
  37539. */
  37540. onlefttriggerchanged(callback: (value: number) => void): void;
  37541. /**
  37542. * Defines the callback to call when right trigger is pressed
  37543. * @param callback defines the callback to use
  37544. */
  37545. onrighttriggerchanged(callback: (value: number) => void): void;
  37546. /**
  37547. * Gets the left trigger value
  37548. */
  37549. /**
  37550. * Sets the left trigger value
  37551. */
  37552. leftTrigger: number;
  37553. /**
  37554. * Gets the right trigger value
  37555. */
  37556. /**
  37557. * Sets the right trigger value
  37558. */
  37559. rightTrigger: number;
  37560. /**
  37561. * Defines the callback to call when a button is pressed
  37562. * @param callback defines the callback to use
  37563. */
  37564. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37565. /**
  37566. * Defines the callback to call when a button is released
  37567. * @param callback defines the callback to use
  37568. */
  37569. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37570. /**
  37571. * Defines the callback to call when a pad is pressed
  37572. * @param callback defines the callback to use
  37573. */
  37574. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37575. /**
  37576. * Defines the callback to call when a pad is released
  37577. * @param callback defines the callback to use
  37578. */
  37579. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37580. private _setButtonValue;
  37581. private _setDPadValue;
  37582. /**
  37583. * Gets the value of the `A` button
  37584. */
  37585. /**
  37586. * Sets the value of the `A` button
  37587. */
  37588. buttonA: number;
  37589. /**
  37590. * Gets the value of the `B` button
  37591. */
  37592. /**
  37593. * Sets the value of the `B` button
  37594. */
  37595. buttonB: number;
  37596. /**
  37597. * Gets the value of the `X` button
  37598. */
  37599. /**
  37600. * Sets the value of the `X` button
  37601. */
  37602. buttonX: number;
  37603. /**
  37604. * Gets the value of the `Y` button
  37605. */
  37606. /**
  37607. * Sets the value of the `Y` button
  37608. */
  37609. buttonY: number;
  37610. /**
  37611. * Gets the value of the `Start` button
  37612. */
  37613. /**
  37614. * Sets the value of the `Start` button
  37615. */
  37616. buttonStart: number;
  37617. /**
  37618. * Gets the value of the `Back` button
  37619. */
  37620. /**
  37621. * Sets the value of the `Back` button
  37622. */
  37623. buttonBack: number;
  37624. /**
  37625. * Gets the value of the `Left` button
  37626. */
  37627. /**
  37628. * Sets the value of the `Left` button
  37629. */
  37630. buttonLB: number;
  37631. /**
  37632. * Gets the value of the `Right` button
  37633. */
  37634. /**
  37635. * Sets the value of the `Right` button
  37636. */
  37637. buttonRB: number;
  37638. /**
  37639. * Gets the value of the Left joystick
  37640. */
  37641. /**
  37642. * Sets the value of the Left joystick
  37643. */
  37644. buttonLeftStick: number;
  37645. /**
  37646. * Gets the value of the Right joystick
  37647. */
  37648. /**
  37649. * Sets the value of the Right joystick
  37650. */
  37651. buttonRightStick: number;
  37652. /**
  37653. * Gets the value of D-pad up
  37654. */
  37655. /**
  37656. * Sets the value of D-pad up
  37657. */
  37658. dPadUp: number;
  37659. /**
  37660. * Gets the value of D-pad down
  37661. */
  37662. /**
  37663. * Sets the value of D-pad down
  37664. */
  37665. dPadDown: number;
  37666. /**
  37667. * Gets the value of D-pad left
  37668. */
  37669. /**
  37670. * Sets the value of D-pad left
  37671. */
  37672. dPadLeft: number;
  37673. /**
  37674. * Gets the value of D-pad right
  37675. */
  37676. /**
  37677. * Sets the value of D-pad right
  37678. */
  37679. dPadRight: number;
  37680. /**
  37681. * Force the gamepad to synchronize with device values
  37682. */
  37683. update(): void;
  37684. /**
  37685. * Disposes the gamepad
  37686. */
  37687. dispose(): void;
  37688. }
  37689. }
  37690. declare module BABYLON {
  37691. /**
  37692. * Manager for handling gamepads
  37693. */
  37694. export class GamepadManager {
  37695. private _scene?;
  37696. private _babylonGamepads;
  37697. private _oneGamepadConnected;
  37698. /** @hidden */
  37699. _isMonitoring: boolean;
  37700. private _gamepadEventSupported;
  37701. private _gamepadSupport;
  37702. /**
  37703. * observable to be triggered when the gamepad controller has been connected
  37704. */
  37705. onGamepadConnectedObservable: Observable<Gamepad>;
  37706. /**
  37707. * observable to be triggered when the gamepad controller has been disconnected
  37708. */
  37709. onGamepadDisconnectedObservable: Observable<Gamepad>;
  37710. private _onGamepadConnectedEvent;
  37711. private _onGamepadDisconnectedEvent;
  37712. /**
  37713. * Initializes the gamepad manager
  37714. * @param _scene BabylonJS scene
  37715. */
  37716. constructor(_scene?: Scene | undefined);
  37717. /**
  37718. * The gamepads in the game pad manager
  37719. */
  37720. readonly gamepads: Gamepad[];
  37721. /**
  37722. * Get the gamepad controllers based on type
  37723. * @param type The type of gamepad controller
  37724. * @returns Nullable gamepad
  37725. */
  37726. getGamepadByType(type?: number): Nullable<Gamepad>;
  37727. /**
  37728. * Disposes the gamepad manager
  37729. */
  37730. dispose(): void;
  37731. private _addNewGamepad;
  37732. private _startMonitoringGamepads;
  37733. private _stopMonitoringGamepads;
  37734. /** @hidden */
  37735. _checkGamepadsStatus(): void;
  37736. private _updateGamepadObjects;
  37737. }
  37738. }
  37739. declare module BABYLON {
  37740. interface Scene {
  37741. /** @hidden */
  37742. _gamepadManager: Nullable<GamepadManager>;
  37743. /**
  37744. * Gets the gamepad manager associated with the scene
  37745. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  37746. */
  37747. gamepadManager: GamepadManager;
  37748. }
  37749. /**
  37750. * Interface representing a free camera inputs manager
  37751. */
  37752. interface FreeCameraInputsManager {
  37753. /**
  37754. * Adds gamepad input support to the FreeCameraInputsManager.
  37755. * @returns the FreeCameraInputsManager
  37756. */
  37757. addGamepad(): FreeCameraInputsManager;
  37758. }
  37759. /**
  37760. * Interface representing an arc rotate camera inputs manager
  37761. */
  37762. interface ArcRotateCameraInputsManager {
  37763. /**
  37764. * Adds gamepad input support to the ArcRotateCamera InputManager.
  37765. * @returns the camera inputs manager
  37766. */
  37767. addGamepad(): ArcRotateCameraInputsManager;
  37768. }
  37769. /**
  37770. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  37771. */
  37772. export class GamepadSystemSceneComponent implements ISceneComponent {
  37773. /**
  37774. * The component name helpfull to identify the component in the list of scene components.
  37775. */
  37776. readonly name: string;
  37777. /**
  37778. * The scene the component belongs to.
  37779. */
  37780. scene: Scene;
  37781. /**
  37782. * Creates a new instance of the component for the given scene
  37783. * @param scene Defines the scene to register the component in
  37784. */
  37785. constructor(scene: Scene);
  37786. /**
  37787. * Registers the component in a given scene
  37788. */
  37789. register(): void;
  37790. /**
  37791. * Rebuilds the elements related to this component in case of
  37792. * context lost for instance.
  37793. */
  37794. rebuild(): void;
  37795. /**
  37796. * Disposes the component and the associated ressources
  37797. */
  37798. dispose(): void;
  37799. private _beforeCameraUpdate;
  37800. }
  37801. }
  37802. declare module BABYLON {
  37803. /**
  37804. * 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,
  37805. * which still works and will still be found in many Playgrounds.
  37806. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37807. */
  37808. export class UniversalCamera extends TouchCamera {
  37809. /**
  37810. * Defines the gamepad rotation sensiblity.
  37811. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37812. */
  37813. gamepadAngularSensibility: number;
  37814. /**
  37815. * Defines the gamepad move sensiblity.
  37816. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37817. */
  37818. gamepadMoveSensibility: number;
  37819. /**
  37820. * 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,
  37821. * which still works and will still be found in many Playgrounds.
  37822. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37823. * @param name Define the name of the camera in the scene
  37824. * @param position Define the start position of the camera in the scene
  37825. * @param scene Define the scene the camera belongs to
  37826. */
  37827. constructor(name: string, position: Vector3, scene: Scene);
  37828. /**
  37829. * Gets the current object class name.
  37830. * @return the class name
  37831. */
  37832. getClassName(): string;
  37833. }
  37834. }
  37835. declare module BABYLON {
  37836. /**
  37837. * This represents a FPS type of camera. This is only here for back compat purpose.
  37838. * Please use the UniversalCamera instead as both are identical.
  37839. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37840. */
  37841. export class GamepadCamera extends UniversalCamera {
  37842. /**
  37843. * Instantiates a new Gamepad Camera
  37844. * This represents a FPS type of camera. This is only here for back compat purpose.
  37845. * Please use the UniversalCamera instead as both are identical.
  37846. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37847. * @param name Define the name of the camera in the scene
  37848. * @param position Define the start position of the camera in the scene
  37849. * @param scene Define the scene the camera belongs to
  37850. */
  37851. constructor(name: string, position: Vector3, scene: Scene);
  37852. /**
  37853. * Gets the current object class name.
  37854. * @return the class name
  37855. */
  37856. getClassName(): string;
  37857. }
  37858. }
  37859. declare module BABYLON {
  37860. /** @hidden */
  37861. export var passPixelShader: {
  37862. name: string;
  37863. shader: string;
  37864. };
  37865. }
  37866. declare module BABYLON {
  37867. /** @hidden */
  37868. export var passCubePixelShader: {
  37869. name: string;
  37870. shader: string;
  37871. };
  37872. }
  37873. declare module BABYLON {
  37874. /**
  37875. * PassPostProcess which produces an output the same as it's input
  37876. */
  37877. export class PassPostProcess extends PostProcess {
  37878. /**
  37879. * Creates the PassPostProcess
  37880. * @param name The name of the effect.
  37881. * @param options The required width/height ratio to downsize to before computing the render pass.
  37882. * @param camera The camera to apply the render pass to.
  37883. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37884. * @param engine The engine which the post process will be applied. (default: current engine)
  37885. * @param reusable If the post process can be reused on the same frame. (default: false)
  37886. * @param textureType The type of texture to be used when performing the post processing.
  37887. * @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)
  37888. */
  37889. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37890. }
  37891. /**
  37892. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37893. */
  37894. export class PassCubePostProcess extends PostProcess {
  37895. private _face;
  37896. /**
  37897. * Gets or sets the cube face to display.
  37898. * * 0 is +X
  37899. * * 1 is -X
  37900. * * 2 is +Y
  37901. * * 3 is -Y
  37902. * * 4 is +Z
  37903. * * 5 is -Z
  37904. */
  37905. face: number;
  37906. /**
  37907. * Creates the PassCubePostProcess
  37908. * @param name The name of the effect.
  37909. * @param options The required width/height ratio to downsize to before computing the render pass.
  37910. * @param camera The camera to apply the render pass to.
  37911. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37912. * @param engine The engine which the post process will be applied. (default: current engine)
  37913. * @param reusable If the post process can be reused on the same frame. (default: false)
  37914. * @param textureType The type of texture to be used when performing the post processing.
  37915. * @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)
  37916. */
  37917. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37918. }
  37919. }
  37920. declare module BABYLON {
  37921. /** @hidden */
  37922. export var anaglyphPixelShader: {
  37923. name: string;
  37924. shader: string;
  37925. };
  37926. }
  37927. declare module BABYLON {
  37928. /**
  37929. * Postprocess used to generate anaglyphic rendering
  37930. */
  37931. export class AnaglyphPostProcess extends PostProcess {
  37932. private _passedProcess;
  37933. /**
  37934. * Creates a new AnaglyphPostProcess
  37935. * @param name defines postprocess name
  37936. * @param options defines creation options or target ratio scale
  37937. * @param rigCameras defines cameras using this postprocess
  37938. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37939. * @param engine defines hosting engine
  37940. * @param reusable defines if the postprocess will be reused multiple times per frame
  37941. */
  37942. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37943. }
  37944. }
  37945. declare module BABYLON {
  37946. /**
  37947. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37948. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37949. */
  37950. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37951. /**
  37952. * Creates a new AnaglyphArcRotateCamera
  37953. * @param name defines camera name
  37954. * @param alpha defines alpha angle (in radians)
  37955. * @param beta defines beta angle (in radians)
  37956. * @param radius defines radius
  37957. * @param target defines camera target
  37958. * @param interaxialDistance defines distance between each color axis
  37959. * @param scene defines the hosting scene
  37960. */
  37961. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37962. /**
  37963. * Gets camera class name
  37964. * @returns AnaglyphArcRotateCamera
  37965. */
  37966. getClassName(): string;
  37967. }
  37968. }
  37969. declare module BABYLON {
  37970. /**
  37971. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37972. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37973. */
  37974. export class AnaglyphFreeCamera extends FreeCamera {
  37975. /**
  37976. * Creates a new AnaglyphFreeCamera
  37977. * @param name defines camera name
  37978. * @param position defines initial position
  37979. * @param interaxialDistance defines distance between each color axis
  37980. * @param scene defines the hosting scene
  37981. */
  37982. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37983. /**
  37984. * Gets camera class name
  37985. * @returns AnaglyphFreeCamera
  37986. */
  37987. getClassName(): string;
  37988. }
  37989. }
  37990. declare module BABYLON {
  37991. /**
  37992. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37993. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37994. */
  37995. export class AnaglyphGamepadCamera extends GamepadCamera {
  37996. /**
  37997. * Creates a new AnaglyphGamepadCamera
  37998. * @param name defines camera name
  37999. * @param position defines initial position
  38000. * @param interaxialDistance defines distance between each color axis
  38001. * @param scene defines the hosting scene
  38002. */
  38003. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38004. /**
  38005. * Gets camera class name
  38006. * @returns AnaglyphGamepadCamera
  38007. */
  38008. getClassName(): string;
  38009. }
  38010. }
  38011. declare module BABYLON {
  38012. /**
  38013. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38014. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38015. */
  38016. export class AnaglyphUniversalCamera extends UniversalCamera {
  38017. /**
  38018. * Creates a new AnaglyphUniversalCamera
  38019. * @param name defines camera name
  38020. * @param position defines initial position
  38021. * @param interaxialDistance defines distance between each color axis
  38022. * @param scene defines the hosting scene
  38023. */
  38024. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38025. /**
  38026. * Gets camera class name
  38027. * @returns AnaglyphUniversalCamera
  38028. */
  38029. getClassName(): string;
  38030. }
  38031. }
  38032. declare module BABYLON {
  38033. /** @hidden */
  38034. export var stereoscopicInterlacePixelShader: {
  38035. name: string;
  38036. shader: string;
  38037. };
  38038. }
  38039. declare module BABYLON {
  38040. /**
  38041. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38042. */
  38043. export class StereoscopicInterlacePostProcess extends PostProcess {
  38044. private _stepSize;
  38045. private _passedProcess;
  38046. /**
  38047. * Initializes a StereoscopicInterlacePostProcess
  38048. * @param name The name of the effect.
  38049. * @param rigCameras The rig cameras to be appled to the post process
  38050. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38051. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38052. * @param engine The engine which the post process will be applied. (default: current engine)
  38053. * @param reusable If the post process can be reused on the same frame. (default: false)
  38054. */
  38055. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38056. }
  38057. }
  38058. declare module BABYLON {
  38059. /**
  38060. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38061. * @see http://doc.babylonjs.com/features/cameras
  38062. */
  38063. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38064. /**
  38065. * Creates a new StereoscopicArcRotateCamera
  38066. * @param name defines camera name
  38067. * @param alpha defines alpha angle (in radians)
  38068. * @param beta defines beta angle (in radians)
  38069. * @param radius defines radius
  38070. * @param target defines camera target
  38071. * @param interaxialDistance defines distance between each color axis
  38072. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38073. * @param scene defines the hosting scene
  38074. */
  38075. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38076. /**
  38077. * Gets camera class name
  38078. * @returns StereoscopicArcRotateCamera
  38079. */
  38080. getClassName(): string;
  38081. }
  38082. }
  38083. declare module BABYLON {
  38084. /**
  38085. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38086. * @see http://doc.babylonjs.com/features/cameras
  38087. */
  38088. export class StereoscopicFreeCamera extends FreeCamera {
  38089. /**
  38090. * Creates a new StereoscopicFreeCamera
  38091. * @param name defines camera name
  38092. * @param position defines initial position
  38093. * @param interaxialDistance defines distance between each color axis
  38094. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38095. * @param scene defines the hosting scene
  38096. */
  38097. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38098. /**
  38099. * Gets camera class name
  38100. * @returns StereoscopicFreeCamera
  38101. */
  38102. getClassName(): string;
  38103. }
  38104. }
  38105. declare module BABYLON {
  38106. /**
  38107. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38108. * @see http://doc.babylonjs.com/features/cameras
  38109. */
  38110. export class StereoscopicGamepadCamera extends GamepadCamera {
  38111. /**
  38112. * Creates a new StereoscopicGamepadCamera
  38113. * @param name defines camera name
  38114. * @param position defines initial position
  38115. * @param interaxialDistance defines distance between each color axis
  38116. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38117. * @param scene defines the hosting scene
  38118. */
  38119. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38120. /**
  38121. * Gets camera class name
  38122. * @returns StereoscopicGamepadCamera
  38123. */
  38124. getClassName(): string;
  38125. }
  38126. }
  38127. declare module BABYLON {
  38128. /**
  38129. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38130. * @see http://doc.babylonjs.com/features/cameras
  38131. */
  38132. export class StereoscopicUniversalCamera extends UniversalCamera {
  38133. /**
  38134. * Creates a new StereoscopicUniversalCamera
  38135. * @param name defines camera name
  38136. * @param position defines initial position
  38137. * @param interaxialDistance defines distance between each color axis
  38138. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38139. * @param scene defines the hosting scene
  38140. */
  38141. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38142. /**
  38143. * Gets camera class name
  38144. * @returns StereoscopicUniversalCamera
  38145. */
  38146. getClassName(): string;
  38147. }
  38148. }
  38149. declare module BABYLON {
  38150. /**
  38151. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38152. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38153. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38154. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38155. */
  38156. export class VirtualJoysticksCamera extends FreeCamera {
  38157. /**
  38158. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38159. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38160. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38161. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38162. * @param name Define the name of the camera in the scene
  38163. * @param position Define the start position of the camera in the scene
  38164. * @param scene Define the scene the camera belongs to
  38165. */
  38166. constructor(name: string, position: Vector3, scene: Scene);
  38167. /**
  38168. * Gets the current object class name.
  38169. * @return the class name
  38170. */
  38171. getClassName(): string;
  38172. }
  38173. }
  38174. declare module BABYLON {
  38175. /**
  38176. * This represents all the required metrics to create a VR camera.
  38177. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38178. */
  38179. export class VRCameraMetrics {
  38180. /**
  38181. * Define the horizontal resolution off the screen.
  38182. */
  38183. hResolution: number;
  38184. /**
  38185. * Define the vertical resolution off the screen.
  38186. */
  38187. vResolution: number;
  38188. /**
  38189. * Define the horizontal screen size.
  38190. */
  38191. hScreenSize: number;
  38192. /**
  38193. * Define the vertical screen size.
  38194. */
  38195. vScreenSize: number;
  38196. /**
  38197. * Define the vertical screen center position.
  38198. */
  38199. vScreenCenter: number;
  38200. /**
  38201. * Define the distance of the eyes to the screen.
  38202. */
  38203. eyeToScreenDistance: number;
  38204. /**
  38205. * Define the distance between both lenses
  38206. */
  38207. lensSeparationDistance: number;
  38208. /**
  38209. * Define the distance between both viewer's eyes.
  38210. */
  38211. interpupillaryDistance: number;
  38212. /**
  38213. * Define the distortion factor of the VR postprocess.
  38214. * Please, touch with care.
  38215. */
  38216. distortionK: number[];
  38217. /**
  38218. * Define the chromatic aberration correction factors for the VR post process.
  38219. */
  38220. chromaAbCorrection: number[];
  38221. /**
  38222. * Define the scale factor of the post process.
  38223. * The smaller the better but the slower.
  38224. */
  38225. postProcessScaleFactor: number;
  38226. /**
  38227. * Define an offset for the lens center.
  38228. */
  38229. lensCenterOffset: number;
  38230. /**
  38231. * Define if the current vr camera should compensate the distortion of the lense or not.
  38232. */
  38233. compensateDistortion: boolean;
  38234. /**
  38235. * Defines if multiview should be enabled when rendering (Default: false)
  38236. */
  38237. multiviewEnabled: boolean;
  38238. /**
  38239. * Gets the rendering aspect ratio based on the provided resolutions.
  38240. */
  38241. readonly aspectRatio: number;
  38242. /**
  38243. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38244. */
  38245. readonly aspectRatioFov: number;
  38246. /**
  38247. * @hidden
  38248. */
  38249. readonly leftHMatrix: Matrix;
  38250. /**
  38251. * @hidden
  38252. */
  38253. readonly rightHMatrix: Matrix;
  38254. /**
  38255. * @hidden
  38256. */
  38257. readonly leftPreViewMatrix: Matrix;
  38258. /**
  38259. * @hidden
  38260. */
  38261. readonly rightPreViewMatrix: Matrix;
  38262. /**
  38263. * Get the default VRMetrics based on the most generic setup.
  38264. * @returns the default vr metrics
  38265. */
  38266. static GetDefault(): VRCameraMetrics;
  38267. }
  38268. }
  38269. declare module BABYLON {
  38270. /** @hidden */
  38271. export var vrDistortionCorrectionPixelShader: {
  38272. name: string;
  38273. shader: string;
  38274. };
  38275. }
  38276. declare module BABYLON {
  38277. /**
  38278. * VRDistortionCorrectionPostProcess used for mobile VR
  38279. */
  38280. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38281. private _isRightEye;
  38282. private _distortionFactors;
  38283. private _postProcessScaleFactor;
  38284. private _lensCenterOffset;
  38285. private _scaleIn;
  38286. private _scaleFactor;
  38287. private _lensCenter;
  38288. /**
  38289. * Initializes the VRDistortionCorrectionPostProcess
  38290. * @param name The name of the effect.
  38291. * @param camera The camera to apply the render pass to.
  38292. * @param isRightEye If this is for the right eye distortion
  38293. * @param vrMetrics All the required metrics for the VR camera
  38294. */
  38295. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38296. }
  38297. }
  38298. declare module BABYLON {
  38299. /**
  38300. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38301. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38302. */
  38303. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38304. /**
  38305. * Creates a new VRDeviceOrientationArcRotateCamera
  38306. * @param name defines camera name
  38307. * @param alpha defines the camera rotation along the logitudinal axis
  38308. * @param beta defines the camera rotation along the latitudinal axis
  38309. * @param radius defines the camera distance from its target
  38310. * @param target defines the camera target
  38311. * @param scene defines the scene the camera belongs to
  38312. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38313. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38314. */
  38315. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38316. /**
  38317. * Gets camera class name
  38318. * @returns VRDeviceOrientationArcRotateCamera
  38319. */
  38320. getClassName(): string;
  38321. }
  38322. }
  38323. declare module BABYLON {
  38324. /**
  38325. * Camera used to simulate VR rendering (based on FreeCamera)
  38326. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38327. */
  38328. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38329. /**
  38330. * Creates a new VRDeviceOrientationFreeCamera
  38331. * @param name defines camera name
  38332. * @param position defines the start position of the camera
  38333. * @param scene defines the scene the camera belongs to
  38334. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38335. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38336. */
  38337. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38338. /**
  38339. * Gets camera class name
  38340. * @returns VRDeviceOrientationFreeCamera
  38341. */
  38342. getClassName(): string;
  38343. }
  38344. }
  38345. declare module BABYLON {
  38346. /**
  38347. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38348. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38349. */
  38350. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38351. /**
  38352. * Creates a new VRDeviceOrientationGamepadCamera
  38353. * @param name defines camera name
  38354. * @param position defines the start position of the camera
  38355. * @param scene defines the scene the camera belongs to
  38356. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38357. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38358. */
  38359. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38360. /**
  38361. * Gets camera class name
  38362. * @returns VRDeviceOrientationGamepadCamera
  38363. */
  38364. getClassName(): string;
  38365. }
  38366. }
  38367. declare module BABYLON {
  38368. /**
  38369. * Base class of materials working in push mode in babylon JS
  38370. * @hidden
  38371. */
  38372. export class PushMaterial extends Material {
  38373. protected _activeEffect: Effect;
  38374. protected _normalMatrix: Matrix;
  38375. /**
  38376. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38377. * This means that the material can keep using a previous shader while a new one is being compiled.
  38378. * This is mostly used when shader parallel compilation is supported (true by default)
  38379. */
  38380. allowShaderHotSwapping: boolean;
  38381. constructor(name: string, scene: Scene);
  38382. getEffect(): Effect;
  38383. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38384. /**
  38385. * Binds the given world matrix to the active effect
  38386. *
  38387. * @param world the matrix to bind
  38388. */
  38389. bindOnlyWorldMatrix(world: Matrix): void;
  38390. /**
  38391. * Binds the given normal matrix to the active effect
  38392. *
  38393. * @param normalMatrix the matrix to bind
  38394. */
  38395. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38396. bind(world: Matrix, mesh?: Mesh): void;
  38397. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38398. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38399. }
  38400. }
  38401. declare module BABYLON {
  38402. /**
  38403. * This groups all the flags used to control the materials channel.
  38404. */
  38405. export class MaterialFlags {
  38406. private static _DiffuseTextureEnabled;
  38407. /**
  38408. * Are diffuse textures enabled in the application.
  38409. */
  38410. static DiffuseTextureEnabled: boolean;
  38411. private static _AmbientTextureEnabled;
  38412. /**
  38413. * Are ambient textures enabled in the application.
  38414. */
  38415. static AmbientTextureEnabled: boolean;
  38416. private static _OpacityTextureEnabled;
  38417. /**
  38418. * Are opacity textures enabled in the application.
  38419. */
  38420. static OpacityTextureEnabled: boolean;
  38421. private static _ReflectionTextureEnabled;
  38422. /**
  38423. * Are reflection textures enabled in the application.
  38424. */
  38425. static ReflectionTextureEnabled: boolean;
  38426. private static _EmissiveTextureEnabled;
  38427. /**
  38428. * Are emissive textures enabled in the application.
  38429. */
  38430. static EmissiveTextureEnabled: boolean;
  38431. private static _SpecularTextureEnabled;
  38432. /**
  38433. * Are specular textures enabled in the application.
  38434. */
  38435. static SpecularTextureEnabled: boolean;
  38436. private static _BumpTextureEnabled;
  38437. /**
  38438. * Are bump textures enabled in the application.
  38439. */
  38440. static BumpTextureEnabled: boolean;
  38441. private static _LightmapTextureEnabled;
  38442. /**
  38443. * Are lightmap textures enabled in the application.
  38444. */
  38445. static LightmapTextureEnabled: boolean;
  38446. private static _RefractionTextureEnabled;
  38447. /**
  38448. * Are refraction textures enabled in the application.
  38449. */
  38450. static RefractionTextureEnabled: boolean;
  38451. private static _ColorGradingTextureEnabled;
  38452. /**
  38453. * Are color grading textures enabled in the application.
  38454. */
  38455. static ColorGradingTextureEnabled: boolean;
  38456. private static _FresnelEnabled;
  38457. /**
  38458. * Are fresnels enabled in the application.
  38459. */
  38460. static FresnelEnabled: boolean;
  38461. private static _ClearCoatTextureEnabled;
  38462. /**
  38463. * Are clear coat textures enabled in the application.
  38464. */
  38465. static ClearCoatTextureEnabled: boolean;
  38466. private static _ClearCoatBumpTextureEnabled;
  38467. /**
  38468. * Are clear coat bump textures enabled in the application.
  38469. */
  38470. static ClearCoatBumpTextureEnabled: boolean;
  38471. private static _ClearCoatTintTextureEnabled;
  38472. /**
  38473. * Are clear coat tint textures enabled in the application.
  38474. */
  38475. static ClearCoatTintTextureEnabled: boolean;
  38476. private static _SheenTextureEnabled;
  38477. /**
  38478. * Are sheen textures enabled in the application.
  38479. */
  38480. static SheenTextureEnabled: boolean;
  38481. private static _AnisotropicTextureEnabled;
  38482. /**
  38483. * Are anisotropic textures enabled in the application.
  38484. */
  38485. static AnisotropicTextureEnabled: boolean;
  38486. private static _ThicknessTextureEnabled;
  38487. /**
  38488. * Are thickness textures enabled in the application.
  38489. */
  38490. static ThicknessTextureEnabled: boolean;
  38491. }
  38492. }
  38493. declare module BABYLON {
  38494. /** @hidden */
  38495. export var defaultFragmentDeclaration: {
  38496. name: string;
  38497. shader: string;
  38498. };
  38499. }
  38500. declare module BABYLON {
  38501. /** @hidden */
  38502. export var defaultUboDeclaration: {
  38503. name: string;
  38504. shader: string;
  38505. };
  38506. }
  38507. declare module BABYLON {
  38508. /** @hidden */
  38509. export var lightFragmentDeclaration: {
  38510. name: string;
  38511. shader: string;
  38512. };
  38513. }
  38514. declare module BABYLON {
  38515. /** @hidden */
  38516. export var lightUboDeclaration: {
  38517. name: string;
  38518. shader: string;
  38519. };
  38520. }
  38521. declare module BABYLON {
  38522. /** @hidden */
  38523. export var lightsFragmentFunctions: {
  38524. name: string;
  38525. shader: string;
  38526. };
  38527. }
  38528. declare module BABYLON {
  38529. /** @hidden */
  38530. export var shadowsFragmentFunctions: {
  38531. name: string;
  38532. shader: string;
  38533. };
  38534. }
  38535. declare module BABYLON {
  38536. /** @hidden */
  38537. export var fresnelFunction: {
  38538. name: string;
  38539. shader: string;
  38540. };
  38541. }
  38542. declare module BABYLON {
  38543. /** @hidden */
  38544. export var reflectionFunction: {
  38545. name: string;
  38546. shader: string;
  38547. };
  38548. }
  38549. declare module BABYLON {
  38550. /** @hidden */
  38551. export var bumpFragmentFunctions: {
  38552. name: string;
  38553. shader: string;
  38554. };
  38555. }
  38556. declare module BABYLON {
  38557. /** @hidden */
  38558. export var logDepthDeclaration: {
  38559. name: string;
  38560. shader: string;
  38561. };
  38562. }
  38563. declare module BABYLON {
  38564. /** @hidden */
  38565. export var bumpFragment: {
  38566. name: string;
  38567. shader: string;
  38568. };
  38569. }
  38570. declare module BABYLON {
  38571. /** @hidden */
  38572. export var depthPrePass: {
  38573. name: string;
  38574. shader: string;
  38575. };
  38576. }
  38577. declare module BABYLON {
  38578. /** @hidden */
  38579. export var lightFragment: {
  38580. name: string;
  38581. shader: string;
  38582. };
  38583. }
  38584. declare module BABYLON {
  38585. /** @hidden */
  38586. export var logDepthFragment: {
  38587. name: string;
  38588. shader: string;
  38589. };
  38590. }
  38591. declare module BABYLON {
  38592. /** @hidden */
  38593. export var defaultPixelShader: {
  38594. name: string;
  38595. shader: string;
  38596. };
  38597. }
  38598. declare module BABYLON {
  38599. /** @hidden */
  38600. export var defaultVertexDeclaration: {
  38601. name: string;
  38602. shader: string;
  38603. };
  38604. }
  38605. declare module BABYLON {
  38606. /** @hidden */
  38607. export var bumpVertexDeclaration: {
  38608. name: string;
  38609. shader: string;
  38610. };
  38611. }
  38612. declare module BABYLON {
  38613. /** @hidden */
  38614. export var bumpVertex: {
  38615. name: string;
  38616. shader: string;
  38617. };
  38618. }
  38619. declare module BABYLON {
  38620. /** @hidden */
  38621. export var fogVertex: {
  38622. name: string;
  38623. shader: string;
  38624. };
  38625. }
  38626. declare module BABYLON {
  38627. /** @hidden */
  38628. export var shadowsVertex: {
  38629. name: string;
  38630. shader: string;
  38631. };
  38632. }
  38633. declare module BABYLON {
  38634. /** @hidden */
  38635. export var pointCloudVertex: {
  38636. name: string;
  38637. shader: string;
  38638. };
  38639. }
  38640. declare module BABYLON {
  38641. /** @hidden */
  38642. export var logDepthVertex: {
  38643. name: string;
  38644. shader: string;
  38645. };
  38646. }
  38647. declare module BABYLON {
  38648. /** @hidden */
  38649. export var defaultVertexShader: {
  38650. name: string;
  38651. shader: string;
  38652. };
  38653. }
  38654. declare module BABYLON {
  38655. /** @hidden */
  38656. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38657. MAINUV1: boolean;
  38658. MAINUV2: boolean;
  38659. DIFFUSE: boolean;
  38660. DIFFUSEDIRECTUV: number;
  38661. AMBIENT: boolean;
  38662. AMBIENTDIRECTUV: number;
  38663. OPACITY: boolean;
  38664. OPACITYDIRECTUV: number;
  38665. OPACITYRGB: boolean;
  38666. REFLECTION: boolean;
  38667. EMISSIVE: boolean;
  38668. EMISSIVEDIRECTUV: number;
  38669. SPECULAR: boolean;
  38670. SPECULARDIRECTUV: number;
  38671. BUMP: boolean;
  38672. BUMPDIRECTUV: number;
  38673. PARALLAX: boolean;
  38674. PARALLAXOCCLUSION: boolean;
  38675. SPECULAROVERALPHA: boolean;
  38676. CLIPPLANE: boolean;
  38677. CLIPPLANE2: boolean;
  38678. CLIPPLANE3: boolean;
  38679. CLIPPLANE4: boolean;
  38680. ALPHATEST: boolean;
  38681. DEPTHPREPASS: boolean;
  38682. ALPHAFROMDIFFUSE: boolean;
  38683. POINTSIZE: boolean;
  38684. FOG: boolean;
  38685. SPECULARTERM: boolean;
  38686. DIFFUSEFRESNEL: boolean;
  38687. OPACITYFRESNEL: boolean;
  38688. REFLECTIONFRESNEL: boolean;
  38689. REFRACTIONFRESNEL: boolean;
  38690. EMISSIVEFRESNEL: boolean;
  38691. FRESNEL: boolean;
  38692. NORMAL: boolean;
  38693. UV1: boolean;
  38694. UV2: boolean;
  38695. VERTEXCOLOR: boolean;
  38696. VERTEXALPHA: boolean;
  38697. NUM_BONE_INFLUENCERS: number;
  38698. BonesPerMesh: number;
  38699. BONETEXTURE: boolean;
  38700. INSTANCES: boolean;
  38701. GLOSSINESS: boolean;
  38702. ROUGHNESS: boolean;
  38703. EMISSIVEASILLUMINATION: boolean;
  38704. LINKEMISSIVEWITHDIFFUSE: boolean;
  38705. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38706. LIGHTMAP: boolean;
  38707. LIGHTMAPDIRECTUV: number;
  38708. OBJECTSPACE_NORMALMAP: boolean;
  38709. USELIGHTMAPASSHADOWMAP: boolean;
  38710. REFLECTIONMAP_3D: boolean;
  38711. REFLECTIONMAP_SPHERICAL: boolean;
  38712. REFLECTIONMAP_PLANAR: boolean;
  38713. REFLECTIONMAP_CUBIC: boolean;
  38714. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38715. REFLECTIONMAP_PROJECTION: boolean;
  38716. REFLECTIONMAP_SKYBOX: boolean;
  38717. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38718. REFLECTIONMAP_EXPLICIT: boolean;
  38719. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38720. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38721. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38722. INVERTCUBICMAP: boolean;
  38723. LOGARITHMICDEPTH: boolean;
  38724. REFRACTION: boolean;
  38725. REFRACTIONMAP_3D: boolean;
  38726. REFLECTIONOVERALPHA: boolean;
  38727. TWOSIDEDLIGHTING: boolean;
  38728. SHADOWFLOAT: boolean;
  38729. MORPHTARGETS: boolean;
  38730. MORPHTARGETS_NORMAL: boolean;
  38731. MORPHTARGETS_TANGENT: boolean;
  38732. NUM_MORPH_INFLUENCERS: number;
  38733. NONUNIFORMSCALING: boolean;
  38734. PREMULTIPLYALPHA: boolean;
  38735. IMAGEPROCESSING: boolean;
  38736. VIGNETTE: boolean;
  38737. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38738. VIGNETTEBLENDMODEOPAQUE: boolean;
  38739. TONEMAPPING: boolean;
  38740. TONEMAPPING_ACES: boolean;
  38741. CONTRAST: boolean;
  38742. COLORCURVES: boolean;
  38743. COLORGRADING: boolean;
  38744. COLORGRADING3D: boolean;
  38745. SAMPLER3DGREENDEPTH: boolean;
  38746. SAMPLER3DBGRMAP: boolean;
  38747. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38748. MULTIVIEW: boolean;
  38749. /**
  38750. * If the reflection texture on this material is in linear color space
  38751. * @hidden
  38752. */
  38753. IS_REFLECTION_LINEAR: boolean;
  38754. /**
  38755. * If the refraction texture on this material is in linear color space
  38756. * @hidden
  38757. */
  38758. IS_REFRACTION_LINEAR: boolean;
  38759. EXPOSURE: boolean;
  38760. constructor();
  38761. setReflectionMode(modeToEnable: string): void;
  38762. }
  38763. /**
  38764. * This is the default material used in Babylon. It is the best trade off between quality
  38765. * and performances.
  38766. * @see http://doc.babylonjs.com/babylon101/materials
  38767. */
  38768. export class StandardMaterial extends PushMaterial {
  38769. private _diffuseTexture;
  38770. /**
  38771. * The basic texture of the material as viewed under a light.
  38772. */
  38773. diffuseTexture: Nullable<BaseTexture>;
  38774. private _ambientTexture;
  38775. /**
  38776. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38777. */
  38778. ambientTexture: Nullable<BaseTexture>;
  38779. private _opacityTexture;
  38780. /**
  38781. * Define the transparency of the material from a texture.
  38782. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38783. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38784. */
  38785. opacityTexture: Nullable<BaseTexture>;
  38786. private _reflectionTexture;
  38787. /**
  38788. * Define the texture used to display the reflection.
  38789. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38790. */
  38791. reflectionTexture: Nullable<BaseTexture>;
  38792. private _emissiveTexture;
  38793. /**
  38794. * Define texture of the material as if self lit.
  38795. * This will be mixed in the final result even in the absence of light.
  38796. */
  38797. emissiveTexture: Nullable<BaseTexture>;
  38798. private _specularTexture;
  38799. /**
  38800. * Define how the color and intensity of the highlight given by the light in the material.
  38801. */
  38802. specularTexture: Nullable<BaseTexture>;
  38803. private _bumpTexture;
  38804. /**
  38805. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38806. * 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.
  38807. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38808. */
  38809. bumpTexture: Nullable<BaseTexture>;
  38810. private _lightmapTexture;
  38811. /**
  38812. * Complex lighting can be computationally expensive to compute at runtime.
  38813. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38814. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38815. */
  38816. lightmapTexture: Nullable<BaseTexture>;
  38817. private _refractionTexture;
  38818. /**
  38819. * Define the texture used to display the refraction.
  38820. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38821. */
  38822. refractionTexture: Nullable<BaseTexture>;
  38823. /**
  38824. * The color of the material lit by the environmental background lighting.
  38825. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38826. */
  38827. ambientColor: Color3;
  38828. /**
  38829. * The basic color of the material as viewed under a light.
  38830. */
  38831. diffuseColor: Color3;
  38832. /**
  38833. * Define how the color and intensity of the highlight given by the light in the material.
  38834. */
  38835. specularColor: Color3;
  38836. /**
  38837. * Define the color of the material as if self lit.
  38838. * This will be mixed in the final result even in the absence of light.
  38839. */
  38840. emissiveColor: Color3;
  38841. /**
  38842. * Defines how sharp are the highlights in the material.
  38843. * The bigger the value the sharper giving a more glossy feeling to the result.
  38844. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38845. */
  38846. specularPower: number;
  38847. private _useAlphaFromDiffuseTexture;
  38848. /**
  38849. * Does the transparency come from the diffuse texture alpha channel.
  38850. */
  38851. useAlphaFromDiffuseTexture: boolean;
  38852. private _useEmissiveAsIllumination;
  38853. /**
  38854. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38855. */
  38856. useEmissiveAsIllumination: boolean;
  38857. private _linkEmissiveWithDiffuse;
  38858. /**
  38859. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38860. * the emissive level when the final color is close to one.
  38861. */
  38862. linkEmissiveWithDiffuse: boolean;
  38863. private _useSpecularOverAlpha;
  38864. /**
  38865. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38866. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38867. */
  38868. useSpecularOverAlpha: boolean;
  38869. private _useReflectionOverAlpha;
  38870. /**
  38871. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38872. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38873. */
  38874. useReflectionOverAlpha: boolean;
  38875. private _disableLighting;
  38876. /**
  38877. * Does lights from the scene impacts this material.
  38878. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38879. */
  38880. disableLighting: boolean;
  38881. private _useObjectSpaceNormalMap;
  38882. /**
  38883. * Allows using an object space normal map (instead of tangent space).
  38884. */
  38885. useObjectSpaceNormalMap: boolean;
  38886. private _useParallax;
  38887. /**
  38888. * Is parallax enabled or not.
  38889. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38890. */
  38891. useParallax: boolean;
  38892. private _useParallaxOcclusion;
  38893. /**
  38894. * Is parallax occlusion enabled or not.
  38895. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38896. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38897. */
  38898. useParallaxOcclusion: boolean;
  38899. /**
  38900. * 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.
  38901. */
  38902. parallaxScaleBias: number;
  38903. private _roughness;
  38904. /**
  38905. * Helps to define how blurry the reflections should appears in the material.
  38906. */
  38907. roughness: number;
  38908. /**
  38909. * In case of refraction, define the value of the indice of refraction.
  38910. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38911. */
  38912. indexOfRefraction: number;
  38913. /**
  38914. * Invert the refraction texture alongside the y axis.
  38915. * It can be useful with procedural textures or probe for instance.
  38916. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38917. */
  38918. invertRefractionY: boolean;
  38919. /**
  38920. * Defines the alpha limits in alpha test mode.
  38921. */
  38922. alphaCutOff: number;
  38923. private _useLightmapAsShadowmap;
  38924. /**
  38925. * In case of light mapping, define whether the map contains light or shadow informations.
  38926. */
  38927. useLightmapAsShadowmap: boolean;
  38928. private _diffuseFresnelParameters;
  38929. /**
  38930. * Define the diffuse fresnel parameters of the material.
  38931. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38932. */
  38933. diffuseFresnelParameters: FresnelParameters;
  38934. private _opacityFresnelParameters;
  38935. /**
  38936. * Define the opacity fresnel parameters of the material.
  38937. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38938. */
  38939. opacityFresnelParameters: FresnelParameters;
  38940. private _reflectionFresnelParameters;
  38941. /**
  38942. * Define the reflection fresnel parameters of the material.
  38943. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38944. */
  38945. reflectionFresnelParameters: FresnelParameters;
  38946. private _refractionFresnelParameters;
  38947. /**
  38948. * Define the refraction fresnel parameters of the material.
  38949. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38950. */
  38951. refractionFresnelParameters: FresnelParameters;
  38952. private _emissiveFresnelParameters;
  38953. /**
  38954. * Define the emissive fresnel parameters of the material.
  38955. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38956. */
  38957. emissiveFresnelParameters: FresnelParameters;
  38958. private _useReflectionFresnelFromSpecular;
  38959. /**
  38960. * If true automatically deducts the fresnels values from the material specularity.
  38961. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38962. */
  38963. useReflectionFresnelFromSpecular: boolean;
  38964. private _useGlossinessFromSpecularMapAlpha;
  38965. /**
  38966. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38967. */
  38968. useGlossinessFromSpecularMapAlpha: boolean;
  38969. private _maxSimultaneousLights;
  38970. /**
  38971. * Defines the maximum number of lights that can be used in the material
  38972. */
  38973. maxSimultaneousLights: number;
  38974. private _invertNormalMapX;
  38975. /**
  38976. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38977. */
  38978. invertNormalMapX: boolean;
  38979. private _invertNormalMapY;
  38980. /**
  38981. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38982. */
  38983. invertNormalMapY: boolean;
  38984. private _twoSidedLighting;
  38985. /**
  38986. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38987. */
  38988. twoSidedLighting: boolean;
  38989. /**
  38990. * Default configuration related to image processing available in the standard Material.
  38991. */
  38992. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38993. /**
  38994. * Gets the image processing configuration used either in this material.
  38995. */
  38996. /**
  38997. * Sets the Default image processing configuration used either in the this material.
  38998. *
  38999. * If sets to null, the scene one is in use.
  39000. */
  39001. imageProcessingConfiguration: ImageProcessingConfiguration;
  39002. /**
  39003. * Keep track of the image processing observer to allow dispose and replace.
  39004. */
  39005. private _imageProcessingObserver;
  39006. /**
  39007. * Attaches a new image processing configuration to the Standard Material.
  39008. * @param configuration
  39009. */
  39010. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39011. /**
  39012. * Gets wether the color curves effect is enabled.
  39013. */
  39014. /**
  39015. * Sets wether the color curves effect is enabled.
  39016. */
  39017. cameraColorCurvesEnabled: boolean;
  39018. /**
  39019. * Gets wether the color grading effect is enabled.
  39020. */
  39021. /**
  39022. * Gets wether the color grading effect is enabled.
  39023. */
  39024. cameraColorGradingEnabled: boolean;
  39025. /**
  39026. * Gets wether tonemapping is enabled or not.
  39027. */
  39028. /**
  39029. * Sets wether tonemapping is enabled or not
  39030. */
  39031. cameraToneMappingEnabled: boolean;
  39032. /**
  39033. * The camera exposure used on this material.
  39034. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39035. * This corresponds to a photographic exposure.
  39036. */
  39037. /**
  39038. * The camera exposure used on this material.
  39039. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39040. * This corresponds to a photographic exposure.
  39041. */
  39042. cameraExposure: number;
  39043. /**
  39044. * Gets The camera contrast used on this material.
  39045. */
  39046. /**
  39047. * Sets The camera contrast used on this material.
  39048. */
  39049. cameraContrast: number;
  39050. /**
  39051. * Gets the Color Grading 2D Lookup Texture.
  39052. */
  39053. /**
  39054. * Sets the Color Grading 2D Lookup Texture.
  39055. */
  39056. cameraColorGradingTexture: Nullable<BaseTexture>;
  39057. /**
  39058. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39059. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39060. * 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;
  39061. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39062. */
  39063. /**
  39064. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39065. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39066. * 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;
  39067. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39068. */
  39069. cameraColorCurves: Nullable<ColorCurves>;
  39070. /**
  39071. * Custom callback helping to override the default shader used in the material.
  39072. */
  39073. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39074. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39075. protected _worldViewProjectionMatrix: Matrix;
  39076. protected _globalAmbientColor: Color3;
  39077. protected _useLogarithmicDepth: boolean;
  39078. /**
  39079. * Instantiates a new standard material.
  39080. * This is the default material used in Babylon. It is the best trade off between quality
  39081. * and performances.
  39082. * @see http://doc.babylonjs.com/babylon101/materials
  39083. * @param name Define the name of the material in the scene
  39084. * @param scene Define the scene the material belong to
  39085. */
  39086. constructor(name: string, scene: Scene);
  39087. /**
  39088. * Gets a boolean indicating that current material needs to register RTT
  39089. */
  39090. readonly hasRenderTargetTextures: boolean;
  39091. /**
  39092. * Gets the current class name of the material e.g. "StandardMaterial"
  39093. * Mainly use in serialization.
  39094. * @returns the class name
  39095. */
  39096. getClassName(): string;
  39097. /**
  39098. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39099. * You can try switching to logarithmic depth.
  39100. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39101. */
  39102. useLogarithmicDepth: boolean;
  39103. /**
  39104. * Specifies if the material will require alpha blending
  39105. * @returns a boolean specifying if alpha blending is needed
  39106. */
  39107. needAlphaBlending(): boolean;
  39108. /**
  39109. * Specifies if this material should be rendered in alpha test mode
  39110. * @returns a boolean specifying if an alpha test is needed.
  39111. */
  39112. needAlphaTesting(): boolean;
  39113. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39114. /**
  39115. * Get the texture used for alpha test purpose.
  39116. * @returns the diffuse texture in case of the standard material.
  39117. */
  39118. getAlphaTestTexture(): Nullable<BaseTexture>;
  39119. /**
  39120. * Get if the submesh is ready to be used and all its information available.
  39121. * Child classes can use it to update shaders
  39122. * @param mesh defines the mesh to check
  39123. * @param subMesh defines which submesh to check
  39124. * @param useInstances specifies that instances should be used
  39125. * @returns a boolean indicating that the submesh is ready or not
  39126. */
  39127. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39128. /**
  39129. * Builds the material UBO layouts.
  39130. * Used internally during the effect preparation.
  39131. */
  39132. buildUniformLayout(): void;
  39133. /**
  39134. * Unbinds the material from the mesh
  39135. */
  39136. unbind(): void;
  39137. /**
  39138. * Binds the submesh to this material by preparing the effect and shader to draw
  39139. * @param world defines the world transformation matrix
  39140. * @param mesh defines the mesh containing the submesh
  39141. * @param subMesh defines the submesh to bind the material to
  39142. */
  39143. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39144. /**
  39145. * Get the list of animatables in the material.
  39146. * @returns the list of animatables object used in the material
  39147. */
  39148. getAnimatables(): IAnimatable[];
  39149. /**
  39150. * Gets the active textures from the material
  39151. * @returns an array of textures
  39152. */
  39153. getActiveTextures(): BaseTexture[];
  39154. /**
  39155. * Specifies if the material uses a texture
  39156. * @param texture defines the texture to check against the material
  39157. * @returns a boolean specifying if the material uses the texture
  39158. */
  39159. hasTexture(texture: BaseTexture): boolean;
  39160. /**
  39161. * Disposes the material
  39162. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39163. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39164. */
  39165. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39166. /**
  39167. * Makes a duplicate of the material, and gives it a new name
  39168. * @param name defines the new name for the duplicated material
  39169. * @returns the cloned material
  39170. */
  39171. clone(name: string): StandardMaterial;
  39172. /**
  39173. * Serializes this material in a JSON representation
  39174. * @returns the serialized material object
  39175. */
  39176. serialize(): any;
  39177. /**
  39178. * Creates a standard material from parsed material data
  39179. * @param source defines the JSON representation of the material
  39180. * @param scene defines the hosting scene
  39181. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39182. * @returns a new standard material
  39183. */
  39184. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39185. /**
  39186. * Are diffuse textures enabled in the application.
  39187. */
  39188. static DiffuseTextureEnabled: boolean;
  39189. /**
  39190. * Are ambient textures enabled in the application.
  39191. */
  39192. static AmbientTextureEnabled: boolean;
  39193. /**
  39194. * Are opacity textures enabled in the application.
  39195. */
  39196. static OpacityTextureEnabled: boolean;
  39197. /**
  39198. * Are reflection textures enabled in the application.
  39199. */
  39200. static ReflectionTextureEnabled: boolean;
  39201. /**
  39202. * Are emissive textures enabled in the application.
  39203. */
  39204. static EmissiveTextureEnabled: boolean;
  39205. /**
  39206. * Are specular textures enabled in the application.
  39207. */
  39208. static SpecularTextureEnabled: boolean;
  39209. /**
  39210. * Are bump textures enabled in the application.
  39211. */
  39212. static BumpTextureEnabled: boolean;
  39213. /**
  39214. * Are lightmap textures enabled in the application.
  39215. */
  39216. static LightmapTextureEnabled: boolean;
  39217. /**
  39218. * Are refraction textures enabled in the application.
  39219. */
  39220. static RefractionTextureEnabled: boolean;
  39221. /**
  39222. * Are color grading textures enabled in the application.
  39223. */
  39224. static ColorGradingTextureEnabled: boolean;
  39225. /**
  39226. * Are fresnels enabled in the application.
  39227. */
  39228. static FresnelEnabled: boolean;
  39229. }
  39230. }
  39231. declare module BABYLON {
  39232. /**
  39233. * A class extending Texture allowing drawing on a texture
  39234. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39235. */
  39236. export class DynamicTexture extends Texture {
  39237. private _generateMipMaps;
  39238. private _canvas;
  39239. private _context;
  39240. private _engine;
  39241. /**
  39242. * Creates a DynamicTexture
  39243. * @param name defines the name of the texture
  39244. * @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
  39245. * @param scene defines the scene where you want the texture
  39246. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39247. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39248. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39249. */
  39250. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39251. /**
  39252. * Get the current class name of the texture useful for serialization or dynamic coding.
  39253. * @returns "DynamicTexture"
  39254. */
  39255. getClassName(): string;
  39256. /**
  39257. * Gets the current state of canRescale
  39258. */
  39259. readonly canRescale: boolean;
  39260. private _recreate;
  39261. /**
  39262. * Scales the texture
  39263. * @param ratio the scale factor to apply to both width and height
  39264. */
  39265. scale(ratio: number): void;
  39266. /**
  39267. * Resizes the texture
  39268. * @param width the new width
  39269. * @param height the new height
  39270. */
  39271. scaleTo(width: number, height: number): void;
  39272. /**
  39273. * Gets the context of the canvas used by the texture
  39274. * @returns the canvas context of the dynamic texture
  39275. */
  39276. getContext(): CanvasRenderingContext2D;
  39277. /**
  39278. * Clears the texture
  39279. */
  39280. clear(): void;
  39281. /**
  39282. * Updates the texture
  39283. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39284. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39285. */
  39286. update(invertY?: boolean, premulAlpha?: boolean): void;
  39287. /**
  39288. * Draws text onto the texture
  39289. * @param text defines the text to be drawn
  39290. * @param x defines the placement of the text from the left
  39291. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39292. * @param font defines the font to be used with font-style, font-size, font-name
  39293. * @param color defines the color used for the text
  39294. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39295. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39296. * @param update defines whether texture is immediately update (default is true)
  39297. */
  39298. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39299. /**
  39300. * Clones the texture
  39301. * @returns the clone of the texture.
  39302. */
  39303. clone(): DynamicTexture;
  39304. /**
  39305. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39306. * @returns a serialized dynamic texture object
  39307. */
  39308. serialize(): any;
  39309. /** @hidden */
  39310. _rebuild(): void;
  39311. }
  39312. }
  39313. declare module BABYLON {
  39314. /** @hidden */
  39315. export var imageProcessingPixelShader: {
  39316. name: string;
  39317. shader: string;
  39318. };
  39319. }
  39320. declare module BABYLON {
  39321. /**
  39322. * ImageProcessingPostProcess
  39323. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39324. */
  39325. export class ImageProcessingPostProcess extends PostProcess {
  39326. /**
  39327. * Default configuration related to image processing available in the PBR Material.
  39328. */
  39329. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39330. /**
  39331. * Gets the image processing configuration used either in this material.
  39332. */
  39333. /**
  39334. * Sets the Default image processing configuration used either in the this material.
  39335. *
  39336. * If sets to null, the scene one is in use.
  39337. */
  39338. imageProcessingConfiguration: ImageProcessingConfiguration;
  39339. /**
  39340. * Keep track of the image processing observer to allow dispose and replace.
  39341. */
  39342. private _imageProcessingObserver;
  39343. /**
  39344. * Attaches a new image processing configuration to the PBR Material.
  39345. * @param configuration
  39346. */
  39347. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39348. /**
  39349. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39350. */
  39351. /**
  39352. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39353. */
  39354. colorCurves: Nullable<ColorCurves>;
  39355. /**
  39356. * Gets wether the color curves effect is enabled.
  39357. */
  39358. /**
  39359. * Sets wether the color curves effect is enabled.
  39360. */
  39361. colorCurvesEnabled: boolean;
  39362. /**
  39363. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39364. */
  39365. /**
  39366. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39367. */
  39368. colorGradingTexture: Nullable<BaseTexture>;
  39369. /**
  39370. * Gets wether the color grading effect is enabled.
  39371. */
  39372. /**
  39373. * Gets wether the color grading effect is enabled.
  39374. */
  39375. colorGradingEnabled: boolean;
  39376. /**
  39377. * Gets exposure used in the effect.
  39378. */
  39379. /**
  39380. * Sets exposure used in the effect.
  39381. */
  39382. exposure: number;
  39383. /**
  39384. * Gets wether tonemapping is enabled or not.
  39385. */
  39386. /**
  39387. * Sets wether tonemapping is enabled or not
  39388. */
  39389. toneMappingEnabled: boolean;
  39390. /**
  39391. * Gets the type of tone mapping effect.
  39392. */
  39393. /**
  39394. * Sets the type of tone mapping effect.
  39395. */
  39396. toneMappingType: number;
  39397. /**
  39398. * Gets contrast used in the effect.
  39399. */
  39400. /**
  39401. * Sets contrast used in the effect.
  39402. */
  39403. contrast: number;
  39404. /**
  39405. * Gets Vignette stretch size.
  39406. */
  39407. /**
  39408. * Sets Vignette stretch size.
  39409. */
  39410. vignetteStretch: number;
  39411. /**
  39412. * Gets Vignette centre X Offset.
  39413. */
  39414. /**
  39415. * Sets Vignette centre X Offset.
  39416. */
  39417. vignetteCentreX: number;
  39418. /**
  39419. * Gets Vignette centre Y Offset.
  39420. */
  39421. /**
  39422. * Sets Vignette centre Y Offset.
  39423. */
  39424. vignetteCentreY: number;
  39425. /**
  39426. * Gets Vignette weight or intensity of the vignette effect.
  39427. */
  39428. /**
  39429. * Sets Vignette weight or intensity of the vignette effect.
  39430. */
  39431. vignetteWeight: number;
  39432. /**
  39433. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39434. * if vignetteEnabled is set to true.
  39435. */
  39436. /**
  39437. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39438. * if vignetteEnabled is set to true.
  39439. */
  39440. vignetteColor: Color4;
  39441. /**
  39442. * Gets Camera field of view used by the Vignette effect.
  39443. */
  39444. /**
  39445. * Sets Camera field of view used by the Vignette effect.
  39446. */
  39447. vignetteCameraFov: number;
  39448. /**
  39449. * Gets the vignette blend mode allowing different kind of effect.
  39450. */
  39451. /**
  39452. * Sets the vignette blend mode allowing different kind of effect.
  39453. */
  39454. vignetteBlendMode: number;
  39455. /**
  39456. * Gets wether the vignette effect is enabled.
  39457. */
  39458. /**
  39459. * Sets wether the vignette effect is enabled.
  39460. */
  39461. vignetteEnabled: boolean;
  39462. private _fromLinearSpace;
  39463. /**
  39464. * Gets wether the input of the processing is in Gamma or Linear Space.
  39465. */
  39466. /**
  39467. * Sets wether the input of the processing is in Gamma or Linear Space.
  39468. */
  39469. fromLinearSpace: boolean;
  39470. /**
  39471. * Defines cache preventing GC.
  39472. */
  39473. private _defines;
  39474. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39475. /**
  39476. * "ImageProcessingPostProcess"
  39477. * @returns "ImageProcessingPostProcess"
  39478. */
  39479. getClassName(): string;
  39480. protected _updateParameters(): void;
  39481. dispose(camera?: Camera): void;
  39482. }
  39483. }
  39484. declare module BABYLON {
  39485. /**
  39486. * Class containing static functions to help procedurally build meshes
  39487. */
  39488. export class GroundBuilder {
  39489. /**
  39490. * Creates a ground mesh
  39491. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39492. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39494. * @param name defines the name of the mesh
  39495. * @param options defines the options used to create the mesh
  39496. * @param scene defines the hosting scene
  39497. * @returns the ground mesh
  39498. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39499. */
  39500. static CreateGround(name: string, options: {
  39501. width?: number;
  39502. height?: number;
  39503. subdivisions?: number;
  39504. subdivisionsX?: number;
  39505. subdivisionsY?: number;
  39506. updatable?: boolean;
  39507. }, scene: any): Mesh;
  39508. /**
  39509. * Creates a tiled ground mesh
  39510. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39511. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39512. * * 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
  39513. * * 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
  39514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39515. * @param name defines the name of the mesh
  39516. * @param options defines the options used to create the mesh
  39517. * @param scene defines the hosting scene
  39518. * @returns the tiled ground mesh
  39519. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39520. */
  39521. static CreateTiledGround(name: string, options: {
  39522. xmin: number;
  39523. zmin: number;
  39524. xmax: number;
  39525. zmax: number;
  39526. subdivisions?: {
  39527. w: number;
  39528. h: number;
  39529. };
  39530. precision?: {
  39531. w: number;
  39532. h: number;
  39533. };
  39534. updatable?: boolean;
  39535. }, scene?: Nullable<Scene>): Mesh;
  39536. /**
  39537. * Creates a ground mesh from a height map
  39538. * * The parameter `url` sets the URL of the height map image resource.
  39539. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39540. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39541. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39542. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39543. * * 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.
  39544. * * 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).
  39545. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39547. * @param name defines the name of the mesh
  39548. * @param url defines the url to the height map
  39549. * @param options defines the options used to create the mesh
  39550. * @param scene defines the hosting scene
  39551. * @returns the ground mesh
  39552. * @see https://doc.babylonjs.com/babylon101/height_map
  39553. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39554. */
  39555. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39556. width?: number;
  39557. height?: number;
  39558. subdivisions?: number;
  39559. minHeight?: number;
  39560. maxHeight?: number;
  39561. colorFilter?: Color3;
  39562. alphaFilter?: number;
  39563. updatable?: boolean;
  39564. onReady?: (mesh: GroundMesh) => void;
  39565. }, scene?: Nullable<Scene>): GroundMesh;
  39566. }
  39567. }
  39568. declare module BABYLON {
  39569. /**
  39570. * Class containing static functions to help procedurally build meshes
  39571. */
  39572. export class TorusBuilder {
  39573. /**
  39574. * Creates a torus mesh
  39575. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39576. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39577. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39579. * * 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
  39580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39581. * @param name defines the name of the mesh
  39582. * @param options defines the options used to create the mesh
  39583. * @param scene defines the hosting scene
  39584. * @returns the torus mesh
  39585. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39586. */
  39587. static CreateTorus(name: string, options: {
  39588. diameter?: number;
  39589. thickness?: number;
  39590. tessellation?: number;
  39591. updatable?: boolean;
  39592. sideOrientation?: number;
  39593. frontUVs?: Vector4;
  39594. backUVs?: Vector4;
  39595. }, scene: any): Mesh;
  39596. }
  39597. }
  39598. declare module BABYLON {
  39599. /**
  39600. * Class containing static functions to help procedurally build meshes
  39601. */
  39602. export class CylinderBuilder {
  39603. /**
  39604. * Creates a cylinder or a cone mesh
  39605. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39606. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39607. * * 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.
  39608. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39609. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39610. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39611. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39612. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39613. * * 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).
  39614. * * 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
  39615. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39616. * * 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
  39617. * * 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.
  39618. * * If `enclose` is false, a ring surface is one element.
  39619. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39620. * * 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
  39621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39622. * * 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
  39623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39624. * @param name defines the name of the mesh
  39625. * @param options defines the options used to create the mesh
  39626. * @param scene defines the hosting scene
  39627. * @returns the cylinder mesh
  39628. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39629. */
  39630. static CreateCylinder(name: string, options: {
  39631. height?: number;
  39632. diameterTop?: number;
  39633. diameterBottom?: number;
  39634. diameter?: number;
  39635. tessellation?: number;
  39636. subdivisions?: number;
  39637. arc?: number;
  39638. faceColors?: Color4[];
  39639. faceUV?: Vector4[];
  39640. updatable?: boolean;
  39641. hasRings?: boolean;
  39642. enclose?: boolean;
  39643. sideOrientation?: number;
  39644. frontUVs?: Vector4;
  39645. backUVs?: Vector4;
  39646. }, scene: any): Mesh;
  39647. }
  39648. }
  39649. declare module BABYLON {
  39650. /**
  39651. * Options to modify the vr teleportation behavior.
  39652. */
  39653. export interface VRTeleportationOptions {
  39654. /**
  39655. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39656. */
  39657. floorMeshName?: string;
  39658. /**
  39659. * A list of meshes to be used as the teleportation floor. (default: empty)
  39660. */
  39661. floorMeshes?: Mesh[];
  39662. }
  39663. /**
  39664. * Options to modify the vr experience helper's behavior.
  39665. */
  39666. export interface VRExperienceHelperOptions extends WebVROptions {
  39667. /**
  39668. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39669. */
  39670. createDeviceOrientationCamera?: boolean;
  39671. /**
  39672. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39673. */
  39674. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39675. /**
  39676. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39677. */
  39678. laserToggle?: boolean;
  39679. /**
  39680. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39681. */
  39682. floorMeshes?: Mesh[];
  39683. /**
  39684. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39685. */
  39686. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39687. }
  39688. /**
  39689. * Event containing information after VR has been entered
  39690. */
  39691. export class OnAfterEnteringVRObservableEvent {
  39692. /**
  39693. * If entering vr was successful
  39694. */
  39695. success: boolean;
  39696. }
  39697. /**
  39698. * Helps to quickly add VR support to an existing scene.
  39699. * See http://doc.babylonjs.com/how_to/webvr_helper
  39700. */
  39701. export class VRExperienceHelper {
  39702. /** Options to modify the vr experience helper's behavior. */
  39703. webVROptions: VRExperienceHelperOptions;
  39704. private _scene;
  39705. private _position;
  39706. private _btnVR;
  39707. private _btnVRDisplayed;
  39708. private _webVRsupported;
  39709. private _webVRready;
  39710. private _webVRrequesting;
  39711. private _webVRpresenting;
  39712. private _hasEnteredVR;
  39713. private _fullscreenVRpresenting;
  39714. private _canvas;
  39715. private _webVRCamera;
  39716. private _vrDeviceOrientationCamera;
  39717. private _deviceOrientationCamera;
  39718. private _existingCamera;
  39719. private _onKeyDown;
  39720. private _onVrDisplayPresentChange;
  39721. private _onVRDisplayChanged;
  39722. private _onVRRequestPresentStart;
  39723. private _onVRRequestPresentComplete;
  39724. /**
  39725. * Observable raised right before entering VR.
  39726. */
  39727. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39728. /**
  39729. * Observable raised when entering VR has completed.
  39730. */
  39731. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39732. /**
  39733. * Observable raised when exiting VR.
  39734. */
  39735. onExitingVRObservable: Observable<VRExperienceHelper>;
  39736. /**
  39737. * Observable raised when controller mesh is loaded.
  39738. */
  39739. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39740. /** Return this.onEnteringVRObservable
  39741. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39742. */
  39743. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39744. /** Return this.onExitingVRObservable
  39745. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39746. */
  39747. readonly onExitingVR: Observable<VRExperienceHelper>;
  39748. /** Return this.onControllerMeshLoadedObservable
  39749. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39750. */
  39751. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39752. private _rayLength;
  39753. private _useCustomVRButton;
  39754. private _teleportationRequested;
  39755. private _teleportActive;
  39756. private _floorMeshName;
  39757. private _floorMeshesCollection;
  39758. private _rotationAllowed;
  39759. private _teleportBackwardsVector;
  39760. private _teleportationTarget;
  39761. private _isDefaultTeleportationTarget;
  39762. private _postProcessMove;
  39763. private _teleportationFillColor;
  39764. private _teleportationBorderColor;
  39765. private _rotationAngle;
  39766. private _haloCenter;
  39767. private _cameraGazer;
  39768. private _padSensibilityUp;
  39769. private _padSensibilityDown;
  39770. private _leftController;
  39771. private _rightController;
  39772. /**
  39773. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39774. */
  39775. onNewMeshSelected: Observable<AbstractMesh>;
  39776. /**
  39777. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39778. */
  39779. onNewMeshPicked: Observable<PickingInfo>;
  39780. private _circleEase;
  39781. /**
  39782. * Observable raised before camera teleportation
  39783. */
  39784. onBeforeCameraTeleport: Observable<Vector3>;
  39785. /**
  39786. * Observable raised after camera teleportation
  39787. */
  39788. onAfterCameraTeleport: Observable<Vector3>;
  39789. /**
  39790. * Observable raised when current selected mesh gets unselected
  39791. */
  39792. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39793. private _raySelectionPredicate;
  39794. /**
  39795. * To be optionaly changed by user to define custom ray selection
  39796. */
  39797. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39798. /**
  39799. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39800. */
  39801. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39802. /**
  39803. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39804. */
  39805. teleportationEnabled: boolean;
  39806. private _defaultHeight;
  39807. private _teleportationInitialized;
  39808. private _interactionsEnabled;
  39809. private _interactionsRequested;
  39810. private _displayGaze;
  39811. private _displayLaserPointer;
  39812. /**
  39813. * The mesh used to display where the user is going to teleport.
  39814. */
  39815. /**
  39816. * Sets the mesh to be used to display where the user is going to teleport.
  39817. */
  39818. teleportationTarget: Mesh;
  39819. /**
  39820. * 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
  39821. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39822. * See http://doc.babylonjs.com/resources/baking_transformations
  39823. */
  39824. gazeTrackerMesh: Mesh;
  39825. /**
  39826. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39827. */
  39828. updateGazeTrackerScale: boolean;
  39829. /**
  39830. * If the gaze trackers color should be updated when selecting meshes
  39831. */
  39832. updateGazeTrackerColor: boolean;
  39833. /**
  39834. * The gaze tracking mesh corresponding to the left controller
  39835. */
  39836. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39837. /**
  39838. * The gaze tracking mesh corresponding to the right controller
  39839. */
  39840. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39841. /**
  39842. * If the ray of the gaze should be displayed.
  39843. */
  39844. /**
  39845. * Sets if the ray of the gaze should be displayed.
  39846. */
  39847. displayGaze: boolean;
  39848. /**
  39849. * If the ray of the LaserPointer should be displayed.
  39850. */
  39851. /**
  39852. * Sets if the ray of the LaserPointer should be displayed.
  39853. */
  39854. displayLaserPointer: boolean;
  39855. /**
  39856. * The deviceOrientationCamera used as the camera when not in VR.
  39857. */
  39858. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39859. /**
  39860. * Based on the current WebVR support, returns the current VR camera used.
  39861. */
  39862. readonly currentVRCamera: Nullable<Camera>;
  39863. /**
  39864. * The webVRCamera which is used when in VR.
  39865. */
  39866. readonly webVRCamera: WebVRFreeCamera;
  39867. /**
  39868. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39869. */
  39870. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39871. private readonly _teleportationRequestInitiated;
  39872. /**
  39873. * Defines wether or not Pointer lock should be requested when switching to
  39874. * full screen.
  39875. */
  39876. requestPointerLockOnFullScreen: boolean;
  39877. /**
  39878. * Instantiates a VRExperienceHelper.
  39879. * Helps to quickly add VR support to an existing scene.
  39880. * @param scene The scene the VRExperienceHelper belongs to.
  39881. * @param webVROptions Options to modify the vr experience helper's behavior.
  39882. */
  39883. constructor(scene: Scene,
  39884. /** Options to modify the vr experience helper's behavior. */
  39885. webVROptions?: VRExperienceHelperOptions);
  39886. private _onDefaultMeshLoaded;
  39887. private _onResize;
  39888. private _onFullscreenChange;
  39889. /**
  39890. * Gets a value indicating if we are currently in VR mode.
  39891. */
  39892. readonly isInVRMode: boolean;
  39893. private onVrDisplayPresentChange;
  39894. private onVRDisplayChanged;
  39895. private moveButtonToBottomRight;
  39896. private displayVRButton;
  39897. private updateButtonVisibility;
  39898. private _cachedAngularSensibility;
  39899. /**
  39900. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39901. * Otherwise, will use the fullscreen API.
  39902. */
  39903. enterVR(): void;
  39904. /**
  39905. * Attempt to exit VR, or fullscreen.
  39906. */
  39907. exitVR(): void;
  39908. /**
  39909. * The position of the vr experience helper.
  39910. */
  39911. /**
  39912. * Sets the position of the vr experience helper.
  39913. */
  39914. position: Vector3;
  39915. /**
  39916. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39917. */
  39918. enableInteractions(): void;
  39919. private readonly _noControllerIsActive;
  39920. private beforeRender;
  39921. private _isTeleportationFloor;
  39922. /**
  39923. * Adds a floor mesh to be used for teleportation.
  39924. * @param floorMesh the mesh to be used for teleportation.
  39925. */
  39926. addFloorMesh(floorMesh: Mesh): void;
  39927. /**
  39928. * Removes a floor mesh from being used for teleportation.
  39929. * @param floorMesh the mesh to be removed.
  39930. */
  39931. removeFloorMesh(floorMesh: Mesh): void;
  39932. /**
  39933. * Enables interactions and teleportation using the VR controllers and gaze.
  39934. * @param vrTeleportationOptions options to modify teleportation behavior.
  39935. */
  39936. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39937. private _onNewGamepadConnected;
  39938. private _tryEnableInteractionOnController;
  39939. private _onNewGamepadDisconnected;
  39940. private _enableInteractionOnController;
  39941. private _checkTeleportWithRay;
  39942. private _checkRotate;
  39943. private _checkTeleportBackwards;
  39944. private _enableTeleportationOnController;
  39945. private _createTeleportationCircles;
  39946. private _displayTeleportationTarget;
  39947. private _hideTeleportationTarget;
  39948. private _rotateCamera;
  39949. private _moveTeleportationSelectorTo;
  39950. private _workingVector;
  39951. private _workingQuaternion;
  39952. private _workingMatrix;
  39953. /**
  39954. * Teleports the users feet to the desired location
  39955. * @param location The location where the user's feet should be placed
  39956. */
  39957. teleportCamera(location: Vector3): void;
  39958. private _convertNormalToDirectionOfRay;
  39959. private _castRayAndSelectObject;
  39960. private _notifySelectedMeshUnselected;
  39961. /**
  39962. * Sets the color of the laser ray from the vr controllers.
  39963. * @param color new color for the ray.
  39964. */
  39965. changeLaserColor(color: Color3): void;
  39966. /**
  39967. * Sets the color of the ray from the vr headsets gaze.
  39968. * @param color new color for the ray.
  39969. */
  39970. changeGazeColor(color: Color3): void;
  39971. /**
  39972. * Exits VR and disposes of the vr experience helper
  39973. */
  39974. dispose(): void;
  39975. /**
  39976. * Gets the name of the VRExperienceHelper class
  39977. * @returns "VRExperienceHelper"
  39978. */
  39979. getClassName(): string;
  39980. }
  39981. }
  39982. declare module BABYLON {
  39983. /**
  39984. * Manages an XRSession
  39985. * @see https://doc.babylonjs.com/how_to/webxr
  39986. */
  39987. export class WebXRSessionManager implements IDisposable {
  39988. private scene;
  39989. /**
  39990. * Fires every time a new xrFrame arrives which can be used to update the camera
  39991. */
  39992. onXRFrameObservable: Observable<any>;
  39993. /**
  39994. * Fires when the xr session is ended either by the device or manually done
  39995. */
  39996. onXRSessionEnded: Observable<any>;
  39997. /** @hidden */
  39998. _xrSession: XRSession;
  39999. /** @hidden */
  40000. _frameOfReference: XRFrameOfReference;
  40001. /** @hidden */
  40002. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40003. /** @hidden */
  40004. _currentXRFrame: Nullable<XRFrame>;
  40005. private _xrNavigator;
  40006. private _xrDevice;
  40007. private _tmpMatrix;
  40008. /**
  40009. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40010. * @param scene The scene which the session should be created for
  40011. */
  40012. constructor(scene: Scene);
  40013. /**
  40014. * Initializes the manager
  40015. * After initialization enterXR can be called to start an XR session
  40016. * @returns Promise which resolves after it is initialized
  40017. */
  40018. initializeAsync(): Promise<void>;
  40019. /**
  40020. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40021. * @param sessionCreationOptions xr options to create the session with
  40022. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40023. * @returns Promise which resolves after it enters XR
  40024. */
  40025. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40026. /**
  40027. * Stops the xrSession and restores the renderloop
  40028. * @returns Promise which resolves after it exits XR
  40029. */
  40030. exitXRAsync(): Promise<void>;
  40031. /**
  40032. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40033. * @param ray ray to cast into the environment
  40034. * @returns Promise which resolves with a collision point in the environment if it exists
  40035. */
  40036. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40037. /**
  40038. * Checks if a session would be supported for the creation options specified
  40039. * @param options creation options to check if they are supported
  40040. * @returns true if supported
  40041. */
  40042. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40043. /**
  40044. * @hidden
  40045. * Converts the render layer of xrSession to a render target
  40046. * @param session session to create render target for
  40047. * @param scene scene the new render target should be created for
  40048. */
  40049. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40050. /**
  40051. * Disposes of the session manager
  40052. */
  40053. dispose(): void;
  40054. }
  40055. }
  40056. declare module BABYLON {
  40057. /**
  40058. * WebXR Camera which holds the views for the xrSession
  40059. * @see https://doc.babylonjs.com/how_to/webxr
  40060. */
  40061. export class WebXRCamera extends FreeCamera {
  40062. private static _TmpMatrix;
  40063. /**
  40064. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40065. * @param name the name of the camera
  40066. * @param scene the scene to add the camera to
  40067. */
  40068. constructor(name: string, scene: Scene);
  40069. private _updateNumberOfRigCameras;
  40070. /** @hidden */
  40071. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40072. /**
  40073. * Updates the cameras position from the current pose information of the XR session
  40074. * @param xrSessionManager the session containing pose information
  40075. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40076. */
  40077. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40078. }
  40079. }
  40080. declare module BABYLON {
  40081. /**
  40082. * States of the webXR experience
  40083. */
  40084. export enum WebXRState {
  40085. /**
  40086. * Transitioning to being in XR mode
  40087. */
  40088. ENTERING_XR = 0,
  40089. /**
  40090. * Transitioning to non XR mode
  40091. */
  40092. EXITING_XR = 1,
  40093. /**
  40094. * In XR mode and presenting
  40095. */
  40096. IN_XR = 2,
  40097. /**
  40098. * Not entered XR mode
  40099. */
  40100. NOT_IN_XR = 3
  40101. }
  40102. /**
  40103. * Helper class used to enable XR
  40104. * @see https://doc.babylonjs.com/how_to/webxr
  40105. */
  40106. export class WebXRExperienceHelper implements IDisposable {
  40107. private scene;
  40108. /**
  40109. * 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
  40110. */
  40111. container: AbstractMesh;
  40112. /**
  40113. * Camera used to render xr content
  40114. */
  40115. camera: WebXRCamera;
  40116. /**
  40117. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40118. */
  40119. state: WebXRState;
  40120. private _setState;
  40121. private static _TmpVector;
  40122. /**
  40123. * Fires when the state of the experience helper has changed
  40124. */
  40125. onStateChangedObservable: Observable<WebXRState>;
  40126. /** @hidden */
  40127. _sessionManager: WebXRSessionManager;
  40128. private _nonVRCamera;
  40129. private _originalSceneAutoClear;
  40130. private _supported;
  40131. /**
  40132. * Creates the experience helper
  40133. * @param scene the scene to attach the experience helper to
  40134. * @returns a promise for the experience helper
  40135. */
  40136. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40137. /**
  40138. * Creates a WebXRExperienceHelper
  40139. * @param scene The scene the helper should be created in
  40140. */
  40141. private constructor();
  40142. /**
  40143. * Exits XR mode and returns the scene to its original state
  40144. * @returns promise that resolves after xr mode has exited
  40145. */
  40146. exitXRAsync(): Promise<void>;
  40147. /**
  40148. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40149. * @param sessionCreationOptions options for the XR session
  40150. * @param frameOfReference frame of reference of the XR session
  40151. * @returns promise that resolves after xr mode has entered
  40152. */
  40153. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40154. /**
  40155. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40156. * @param ray ray to cast into the environment
  40157. * @returns Promise which resolves with a collision point in the environment if it exists
  40158. */
  40159. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40160. /**
  40161. * Updates the global position of the camera by moving the camera's container
  40162. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40163. * @param position The desired global position of the camera
  40164. */
  40165. setPositionOfCameraUsingContainer(position: Vector3): void;
  40166. /**
  40167. * Rotates the xr camera by rotating the camera's container around the camera's position
  40168. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40169. * @param rotation the desired quaternion rotation to apply to the camera
  40170. */
  40171. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40172. /**
  40173. * Checks if the creation options are supported by the xr session
  40174. * @param options creation options
  40175. * @returns true if supported
  40176. */
  40177. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40178. /**
  40179. * Disposes of the experience helper
  40180. */
  40181. dispose(): void;
  40182. }
  40183. }
  40184. declare module BABYLON {
  40185. /**
  40186. * Button which can be used to enter a different mode of XR
  40187. */
  40188. export class WebXREnterExitUIButton {
  40189. /** button element */
  40190. element: HTMLElement;
  40191. /** XR initialization options for the button */
  40192. initializationOptions: XRSessionCreationOptions;
  40193. /**
  40194. * Creates a WebXREnterExitUIButton
  40195. * @param element button element
  40196. * @param initializationOptions XR initialization options for the button
  40197. */
  40198. constructor(
  40199. /** button element */
  40200. element: HTMLElement,
  40201. /** XR initialization options for the button */
  40202. initializationOptions: XRSessionCreationOptions);
  40203. /**
  40204. * Overwritable function which can be used to update the button's visuals when the state changes
  40205. * @param activeButton the current active button in the UI
  40206. */
  40207. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40208. }
  40209. /**
  40210. * Options to create the webXR UI
  40211. */
  40212. export class WebXREnterExitUIOptions {
  40213. /**
  40214. * Context to enter xr with
  40215. */
  40216. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40217. /**
  40218. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40219. */
  40220. customButtons?: Array<WebXREnterExitUIButton>;
  40221. }
  40222. /**
  40223. * UI to allow the user to enter/exit XR mode
  40224. */
  40225. export class WebXREnterExitUI implements IDisposable {
  40226. private scene;
  40227. private _overlay;
  40228. private _buttons;
  40229. private _activeButton;
  40230. /**
  40231. * Fired every time the active button is changed.
  40232. *
  40233. * When xr is entered via a button that launches xr that button will be the callback parameter
  40234. *
  40235. * When exiting xr the callback parameter will be null)
  40236. */
  40237. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40238. /**
  40239. * Creates UI to allow the user to enter/exit XR mode
  40240. * @param scene the scene to add the ui to
  40241. * @param helper the xr experience helper to enter/exit xr with
  40242. * @param options options to configure the UI
  40243. * @returns the created ui
  40244. */
  40245. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40246. private constructor();
  40247. private _updateButtons;
  40248. /**
  40249. * Disposes of the object
  40250. */
  40251. dispose(): void;
  40252. }
  40253. }
  40254. declare module BABYLON {
  40255. /**
  40256. * Represents an XR input
  40257. */
  40258. export class WebXRController {
  40259. /**
  40260. * 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
  40261. */
  40262. grip?: AbstractMesh;
  40263. /**
  40264. * Pointer which can be used to select objects or attach a visible laser to
  40265. */
  40266. pointer: AbstractMesh;
  40267. /**
  40268. * Creates the controller
  40269. * @see https://doc.babylonjs.com/how_to/webxr
  40270. * @param scene the scene which the controller should be associated to
  40271. */
  40272. constructor(scene: Scene);
  40273. /**
  40274. * Disposes of the object
  40275. */
  40276. dispose(): void;
  40277. }
  40278. /**
  40279. * XR input used to track XR inputs such as controllers/rays
  40280. */
  40281. export class WebXRInput implements IDisposable {
  40282. private helper;
  40283. /**
  40284. * XR controllers being tracked
  40285. */
  40286. controllers: Array<WebXRController>;
  40287. private _tmpMatrix;
  40288. private _frameObserver;
  40289. /**
  40290. * Initializes the WebXRInput
  40291. * @param helper experience helper which the input should be created for
  40292. */
  40293. constructor(helper: WebXRExperienceHelper);
  40294. /**
  40295. * Disposes of the object
  40296. */
  40297. dispose(): void;
  40298. }
  40299. }
  40300. declare module BABYLON {
  40301. /**
  40302. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40303. */
  40304. export class WebXRManagedOutputCanvas implements IDisposable {
  40305. private _canvas;
  40306. /**
  40307. * xrpresent context of the canvas which can be used to display/mirror xr content
  40308. */
  40309. canvasContext: Nullable<WebGLRenderingContext>;
  40310. /**
  40311. * Initializes the canvas to be added/removed upon entering/exiting xr
  40312. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40313. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40314. */
  40315. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40316. /**
  40317. * Disposes of the object
  40318. */
  40319. dispose(): void;
  40320. private _setManagedOutputCanvas;
  40321. private _addCanvas;
  40322. private _removeCanvas;
  40323. }
  40324. }
  40325. declare module BABYLON {
  40326. /**
  40327. * Contains an array of blocks representing the octree
  40328. */
  40329. export interface IOctreeContainer<T> {
  40330. /**
  40331. * Blocks within the octree
  40332. */
  40333. blocks: Array<OctreeBlock<T>>;
  40334. }
  40335. /**
  40336. * Class used to store a cell in an octree
  40337. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40338. */
  40339. export class OctreeBlock<T> {
  40340. /**
  40341. * Gets the content of the current block
  40342. */
  40343. entries: T[];
  40344. /**
  40345. * Gets the list of block children
  40346. */
  40347. blocks: Array<OctreeBlock<T>>;
  40348. private _depth;
  40349. private _maxDepth;
  40350. private _capacity;
  40351. private _minPoint;
  40352. private _maxPoint;
  40353. private _boundingVectors;
  40354. private _creationFunc;
  40355. /**
  40356. * Creates a new block
  40357. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40358. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40359. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40360. * @param depth defines the current depth of this block in the octree
  40361. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40362. * @param creationFunc defines a callback to call when an element is added to the block
  40363. */
  40364. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40365. /**
  40366. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40367. */
  40368. readonly capacity: number;
  40369. /**
  40370. * Gets the minimum vector (in world space) of the block's bounding box
  40371. */
  40372. readonly minPoint: Vector3;
  40373. /**
  40374. * Gets the maximum vector (in world space) of the block's bounding box
  40375. */
  40376. readonly maxPoint: Vector3;
  40377. /**
  40378. * Add a new element to this block
  40379. * @param entry defines the element to add
  40380. */
  40381. addEntry(entry: T): void;
  40382. /**
  40383. * Remove an element from this block
  40384. * @param entry defines the element to remove
  40385. */
  40386. removeEntry(entry: T): void;
  40387. /**
  40388. * Add an array of elements to this block
  40389. * @param entries defines the array of elements to add
  40390. */
  40391. addEntries(entries: T[]): void;
  40392. /**
  40393. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40394. * @param frustumPlanes defines the frustum planes to test
  40395. * @param selection defines the array to store current content if selection is positive
  40396. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40397. */
  40398. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40399. /**
  40400. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40401. * @param sphereCenter defines the bounding sphere center
  40402. * @param sphereRadius defines the bounding sphere radius
  40403. * @param selection defines the array to store current content if selection is positive
  40404. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40405. */
  40406. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40407. /**
  40408. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40409. * @param ray defines the ray to test with
  40410. * @param selection defines the array to store current content if selection is positive
  40411. */
  40412. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40413. /**
  40414. * Subdivide the content into child blocks (this block will then be empty)
  40415. */
  40416. createInnerBlocks(): void;
  40417. /**
  40418. * @hidden
  40419. */
  40420. 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;
  40421. }
  40422. }
  40423. declare module BABYLON {
  40424. /**
  40425. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40426. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40427. */
  40428. export class Octree<T> {
  40429. /** 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.) */
  40430. maxDepth: number;
  40431. /**
  40432. * Blocks within the octree containing objects
  40433. */
  40434. blocks: Array<OctreeBlock<T>>;
  40435. /**
  40436. * Content stored in the octree
  40437. */
  40438. dynamicContent: T[];
  40439. private _maxBlockCapacity;
  40440. private _selectionContent;
  40441. private _creationFunc;
  40442. /**
  40443. * Creates a octree
  40444. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40445. * @param creationFunc function to be used to instatiate the octree
  40446. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40447. * @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.)
  40448. */
  40449. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40450. /** 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.) */
  40451. maxDepth?: number);
  40452. /**
  40453. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40454. * @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);
  40455. * @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);
  40456. * @param entries meshes to be added to the octree blocks
  40457. */
  40458. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40459. /**
  40460. * Adds a mesh to the octree
  40461. * @param entry Mesh to add to the octree
  40462. */
  40463. addMesh(entry: T): void;
  40464. /**
  40465. * Remove an element from the octree
  40466. * @param entry defines the element to remove
  40467. */
  40468. removeMesh(entry: T): void;
  40469. /**
  40470. * Selects an array of meshes within the frustum
  40471. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40472. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40473. * @returns array of meshes within the frustum
  40474. */
  40475. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40476. /**
  40477. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40478. * @param sphereCenter defines the bounding sphere center
  40479. * @param sphereRadius defines the bounding sphere radius
  40480. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40481. * @returns an array of objects that intersect the sphere
  40482. */
  40483. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40484. /**
  40485. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40486. * @param ray defines the ray to test with
  40487. * @returns array of intersected objects
  40488. */
  40489. intersectsRay(ray: Ray): SmartArray<T>;
  40490. /**
  40491. * Adds a mesh into the octree block if it intersects the block
  40492. */
  40493. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40494. /**
  40495. * Adds a submesh into the octree block if it intersects the block
  40496. */
  40497. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40498. }
  40499. }
  40500. declare module BABYLON {
  40501. interface Scene {
  40502. /**
  40503. * @hidden
  40504. * Backing Filed
  40505. */
  40506. _selectionOctree: Octree<AbstractMesh>;
  40507. /**
  40508. * Gets the octree used to boost mesh selection (picking)
  40509. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40510. */
  40511. selectionOctree: Octree<AbstractMesh>;
  40512. /**
  40513. * Creates or updates the octree used to boost selection (picking)
  40514. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40515. * @param maxCapacity defines the maximum capacity per leaf
  40516. * @param maxDepth defines the maximum depth of the octree
  40517. * @returns an octree of AbstractMesh
  40518. */
  40519. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40520. }
  40521. interface AbstractMesh {
  40522. /**
  40523. * @hidden
  40524. * Backing Field
  40525. */
  40526. _submeshesOctree: Octree<SubMesh>;
  40527. /**
  40528. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40529. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40530. * @param maxCapacity defines the maximum size of each block (64 by default)
  40531. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40532. * @returns the new octree
  40533. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40534. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40535. */
  40536. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40537. }
  40538. /**
  40539. * Defines the octree scene component responsible to manage any octrees
  40540. * in a given scene.
  40541. */
  40542. export class OctreeSceneComponent {
  40543. /**
  40544. * The component name help to identify the component in the list of scene components.
  40545. */
  40546. readonly name: string;
  40547. /**
  40548. * The scene the component belongs to.
  40549. */
  40550. scene: Scene;
  40551. /**
  40552. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40553. */
  40554. readonly checksIsEnabled: boolean;
  40555. /**
  40556. * Creates a new instance of the component for the given scene
  40557. * @param scene Defines the scene to register the component in
  40558. */
  40559. constructor(scene: Scene);
  40560. /**
  40561. * Registers the component in a given scene
  40562. */
  40563. register(): void;
  40564. /**
  40565. * Return the list of active meshes
  40566. * @returns the list of active meshes
  40567. */
  40568. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40569. /**
  40570. * Return the list of active sub meshes
  40571. * @param mesh The mesh to get the candidates sub meshes from
  40572. * @returns the list of active sub meshes
  40573. */
  40574. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40575. private _tempRay;
  40576. /**
  40577. * Return the list of sub meshes intersecting with a given local ray
  40578. * @param mesh defines the mesh to find the submesh for
  40579. * @param localRay defines the ray in local space
  40580. * @returns the list of intersecting sub meshes
  40581. */
  40582. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40583. /**
  40584. * Return the list of sub meshes colliding with a collider
  40585. * @param mesh defines the mesh to find the submesh for
  40586. * @param collider defines the collider to evaluate the collision against
  40587. * @returns the list of colliding sub meshes
  40588. */
  40589. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40590. /**
  40591. * Rebuilds the elements related to this component in case of
  40592. * context lost for instance.
  40593. */
  40594. rebuild(): void;
  40595. /**
  40596. * Disposes the component and the associated ressources.
  40597. */
  40598. dispose(): void;
  40599. }
  40600. }
  40601. declare module BABYLON {
  40602. /**
  40603. * Renders a layer on top of an existing scene
  40604. */
  40605. export class UtilityLayerRenderer implements IDisposable {
  40606. /** the original scene that will be rendered on top of */
  40607. originalScene: Scene;
  40608. private _pointerCaptures;
  40609. private _lastPointerEvents;
  40610. private static _DefaultUtilityLayer;
  40611. private static _DefaultKeepDepthUtilityLayer;
  40612. private _sharedGizmoLight;
  40613. /**
  40614. * @hidden
  40615. * Light which used by gizmos to get light shading
  40616. */
  40617. _getSharedGizmoLight(): HemisphericLight;
  40618. /**
  40619. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40620. */
  40621. pickUtilitySceneFirst: boolean;
  40622. /**
  40623. * 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)
  40624. */
  40625. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40626. /**
  40627. * 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)
  40628. */
  40629. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40630. /**
  40631. * The scene that is rendered on top of the original scene
  40632. */
  40633. utilityLayerScene: Scene;
  40634. /**
  40635. * If the utility layer should automatically be rendered on top of existing scene
  40636. */
  40637. shouldRender: boolean;
  40638. /**
  40639. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40640. */
  40641. onlyCheckPointerDownEvents: boolean;
  40642. /**
  40643. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40644. */
  40645. processAllEvents: boolean;
  40646. /**
  40647. * Observable raised when the pointer move from the utility layer scene to the main scene
  40648. */
  40649. onPointerOutObservable: Observable<number>;
  40650. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40651. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40652. private _afterRenderObserver;
  40653. private _sceneDisposeObserver;
  40654. private _originalPointerObserver;
  40655. /**
  40656. * Instantiates a UtilityLayerRenderer
  40657. * @param originalScene the original scene that will be rendered on top of
  40658. * @param handleEvents boolean indicating if the utility layer should handle events
  40659. */
  40660. constructor(
  40661. /** the original scene that will be rendered on top of */
  40662. originalScene: Scene, handleEvents?: boolean);
  40663. private _notifyObservers;
  40664. /**
  40665. * Renders the utility layers scene on top of the original scene
  40666. */
  40667. render(): void;
  40668. /**
  40669. * Disposes of the renderer
  40670. */
  40671. dispose(): void;
  40672. private _updateCamera;
  40673. }
  40674. }
  40675. declare module BABYLON {
  40676. /**
  40677. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40678. */
  40679. export class Gizmo implements IDisposable {
  40680. /** The utility layer the gizmo will be added to */
  40681. gizmoLayer: UtilityLayerRenderer;
  40682. /**
  40683. * The root mesh of the gizmo
  40684. */
  40685. _rootMesh: Mesh;
  40686. private _attachedMesh;
  40687. /**
  40688. * Ratio for the scale of the gizmo (Default: 1)
  40689. */
  40690. scaleRatio: number;
  40691. /**
  40692. * If a custom mesh has been set (Default: false)
  40693. */
  40694. protected _customMeshSet: boolean;
  40695. /**
  40696. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40697. * * When set, interactions will be enabled
  40698. */
  40699. attachedMesh: Nullable<AbstractMesh>;
  40700. /**
  40701. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40702. * @param mesh The mesh to replace the default mesh of the gizmo
  40703. */
  40704. setCustomMesh(mesh: Mesh): void;
  40705. /**
  40706. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40707. */
  40708. updateGizmoRotationToMatchAttachedMesh: boolean;
  40709. /**
  40710. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40711. */
  40712. updateGizmoPositionToMatchAttachedMesh: boolean;
  40713. /**
  40714. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40715. */
  40716. protected _updateScale: boolean;
  40717. protected _interactionsEnabled: boolean;
  40718. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40719. private _beforeRenderObserver;
  40720. private _tempVector;
  40721. /**
  40722. * Creates a gizmo
  40723. * @param gizmoLayer The utility layer the gizmo will be added to
  40724. */
  40725. constructor(
  40726. /** The utility layer the gizmo will be added to */
  40727. gizmoLayer?: UtilityLayerRenderer);
  40728. /**
  40729. * Updates the gizmo to match the attached mesh's position/rotation
  40730. */
  40731. protected _update(): void;
  40732. /**
  40733. * Disposes of the gizmo
  40734. */
  40735. dispose(): void;
  40736. }
  40737. }
  40738. declare module BABYLON {
  40739. /**
  40740. * Single axis drag gizmo
  40741. */
  40742. export class AxisDragGizmo extends Gizmo {
  40743. /**
  40744. * Drag behavior responsible for the gizmos dragging interactions
  40745. */
  40746. dragBehavior: PointerDragBehavior;
  40747. private _pointerObserver;
  40748. /**
  40749. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40750. */
  40751. snapDistance: number;
  40752. /**
  40753. * Event that fires each time the gizmo snaps to a new location.
  40754. * * snapDistance is the the change in distance
  40755. */
  40756. onSnapObservable: Observable<{
  40757. snapDistance: number;
  40758. }>;
  40759. /** @hidden */
  40760. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40761. /** @hidden */
  40762. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40763. /**
  40764. * Creates an AxisDragGizmo
  40765. * @param gizmoLayer The utility layer the gizmo will be added to
  40766. * @param dragAxis The axis which the gizmo will be able to drag on
  40767. * @param color The color of the gizmo
  40768. */
  40769. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40770. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40771. /**
  40772. * Disposes of the gizmo
  40773. */
  40774. dispose(): void;
  40775. }
  40776. }
  40777. declare module BABYLON.Debug {
  40778. /**
  40779. * The Axes viewer will show 3 axes in a specific point in space
  40780. */
  40781. export class AxesViewer {
  40782. private _xAxis;
  40783. private _yAxis;
  40784. private _zAxis;
  40785. private _scaleLinesFactor;
  40786. private _instanced;
  40787. /**
  40788. * Gets the hosting scene
  40789. */
  40790. scene: Scene;
  40791. /**
  40792. * Gets or sets a number used to scale line length
  40793. */
  40794. scaleLines: number;
  40795. /** Gets the node hierarchy used to render x-axis */
  40796. readonly xAxis: TransformNode;
  40797. /** Gets the node hierarchy used to render y-axis */
  40798. readonly yAxis: TransformNode;
  40799. /** Gets the node hierarchy used to render z-axis */
  40800. readonly zAxis: TransformNode;
  40801. /**
  40802. * Creates a new AxesViewer
  40803. * @param scene defines the hosting scene
  40804. * @param scaleLines defines a number used to scale line length (1 by default)
  40805. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40806. * @param xAxis defines the node hierarchy used to render the x-axis
  40807. * @param yAxis defines the node hierarchy used to render the y-axis
  40808. * @param zAxis defines the node hierarchy used to render the z-axis
  40809. */
  40810. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40811. /**
  40812. * Force the viewer to update
  40813. * @param position defines the position of the viewer
  40814. * @param xaxis defines the x axis of the viewer
  40815. * @param yaxis defines the y axis of the viewer
  40816. * @param zaxis defines the z axis of the viewer
  40817. */
  40818. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40819. /**
  40820. * Creates an instance of this axes viewer.
  40821. * @returns a new axes viewer with instanced meshes
  40822. */
  40823. createInstance(): AxesViewer;
  40824. /** Releases resources */
  40825. dispose(): void;
  40826. private static _SetRenderingGroupId;
  40827. }
  40828. }
  40829. declare module BABYLON.Debug {
  40830. /**
  40831. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40832. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40833. */
  40834. export class BoneAxesViewer extends AxesViewer {
  40835. /**
  40836. * Gets or sets the target mesh where to display the axes viewer
  40837. */
  40838. mesh: Nullable<Mesh>;
  40839. /**
  40840. * Gets or sets the target bone where to display the axes viewer
  40841. */
  40842. bone: Nullable<Bone>;
  40843. /** Gets current position */
  40844. pos: Vector3;
  40845. /** Gets direction of X axis */
  40846. xaxis: Vector3;
  40847. /** Gets direction of Y axis */
  40848. yaxis: Vector3;
  40849. /** Gets direction of Z axis */
  40850. zaxis: Vector3;
  40851. /**
  40852. * Creates a new BoneAxesViewer
  40853. * @param scene defines the hosting scene
  40854. * @param bone defines the target bone
  40855. * @param mesh defines the target mesh
  40856. * @param scaleLines defines a scaling factor for line length (1 by default)
  40857. */
  40858. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40859. /**
  40860. * Force the viewer to update
  40861. */
  40862. update(): void;
  40863. /** Releases resources */
  40864. dispose(): void;
  40865. }
  40866. }
  40867. declare module BABYLON {
  40868. /**
  40869. * Interface used to define scene explorer extensibility option
  40870. */
  40871. export interface IExplorerExtensibilityOption {
  40872. /**
  40873. * Define the option label
  40874. */
  40875. label: string;
  40876. /**
  40877. * Defines the action to execute on click
  40878. */
  40879. action: (entity: any) => void;
  40880. }
  40881. /**
  40882. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40883. */
  40884. export interface IExplorerExtensibilityGroup {
  40885. /**
  40886. * Defines a predicate to test if a given type mut be extended
  40887. */
  40888. predicate: (entity: any) => boolean;
  40889. /**
  40890. * Gets the list of options added to a type
  40891. */
  40892. entries: IExplorerExtensibilityOption[];
  40893. }
  40894. /**
  40895. * Interface used to define the options to use to create the Inspector
  40896. */
  40897. export interface IInspectorOptions {
  40898. /**
  40899. * Display in overlay mode (default: false)
  40900. */
  40901. overlay?: boolean;
  40902. /**
  40903. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40904. */
  40905. globalRoot?: HTMLElement;
  40906. /**
  40907. * Display the Scene explorer
  40908. */
  40909. showExplorer?: boolean;
  40910. /**
  40911. * Display the property inspector
  40912. */
  40913. showInspector?: boolean;
  40914. /**
  40915. * Display in embed mode (both panes on the right)
  40916. */
  40917. embedMode?: boolean;
  40918. /**
  40919. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40920. */
  40921. handleResize?: boolean;
  40922. /**
  40923. * Allow the panes to popup (default: true)
  40924. */
  40925. enablePopup?: boolean;
  40926. /**
  40927. * Allow the panes to be closed by users (default: true)
  40928. */
  40929. enableClose?: boolean;
  40930. /**
  40931. * Optional list of extensibility entries
  40932. */
  40933. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40934. /**
  40935. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40936. */
  40937. inspectorURL?: string;
  40938. }
  40939. interface Scene {
  40940. /**
  40941. * @hidden
  40942. * Backing field
  40943. */
  40944. _debugLayer: DebugLayer;
  40945. /**
  40946. * Gets the debug layer (aka Inspector) associated with the scene
  40947. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40948. */
  40949. debugLayer: DebugLayer;
  40950. }
  40951. /**
  40952. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40953. * what is happening in your scene
  40954. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40955. */
  40956. export class DebugLayer {
  40957. /**
  40958. * Define the url to get the inspector script from.
  40959. * By default it uses the babylonjs CDN.
  40960. * @ignoreNaming
  40961. */
  40962. static InspectorURL: string;
  40963. private _scene;
  40964. private BJSINSPECTOR;
  40965. /**
  40966. * Observable triggered when a property is changed through the inspector.
  40967. */
  40968. onPropertyChangedObservable: Observable<{
  40969. object: any;
  40970. property: string;
  40971. value: any;
  40972. initialValue: any;
  40973. }>;
  40974. /**
  40975. * Instantiates a new debug layer.
  40976. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40977. * what is happening in your scene
  40978. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40979. * @param scene Defines the scene to inspect
  40980. */
  40981. constructor(scene: Scene);
  40982. /** Creates the inspector window. */
  40983. private _createInspector;
  40984. /**
  40985. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40986. * @param entity defines the entity to select
  40987. * @param lineContainerTitle defines the specific block to highlight
  40988. */
  40989. select(entity: any, lineContainerTitle?: string): void;
  40990. /** Get the inspector from bundle or global */
  40991. private _getGlobalInspector;
  40992. /**
  40993. * Get if the inspector is visible or not.
  40994. * @returns true if visible otherwise, false
  40995. */
  40996. isVisible(): boolean;
  40997. /**
  40998. * Hide the inspector and close its window.
  40999. */
  41000. hide(): void;
  41001. /**
  41002. * Launch the debugLayer.
  41003. * @param config Define the configuration of the inspector
  41004. * @return a promise fulfilled when the debug layer is visible
  41005. */
  41006. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41007. }
  41008. }
  41009. declare module BABYLON {
  41010. /**
  41011. * Class containing static functions to help procedurally build meshes
  41012. */
  41013. export class BoxBuilder {
  41014. /**
  41015. * Creates a box mesh
  41016. * * The parameter `size` sets the size (float) of each box side (default 1)
  41017. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41018. * * 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)
  41019. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41021. * * 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
  41022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41023. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41024. * @param name defines the name of the mesh
  41025. * @param options defines the options used to create the mesh
  41026. * @param scene defines the hosting scene
  41027. * @returns the box mesh
  41028. */
  41029. static CreateBox(name: string, options: {
  41030. size?: number;
  41031. width?: number;
  41032. height?: number;
  41033. depth?: number;
  41034. faceUV?: Vector4[];
  41035. faceColors?: Color4[];
  41036. sideOrientation?: number;
  41037. frontUVs?: Vector4;
  41038. backUVs?: Vector4;
  41039. wrap?: boolean;
  41040. topBaseAt?: number;
  41041. bottomBaseAt?: number;
  41042. updatable?: boolean;
  41043. }, scene?: Nullable<Scene>): Mesh;
  41044. }
  41045. }
  41046. declare module BABYLON {
  41047. /**
  41048. * Class containing static functions to help procedurally build meshes
  41049. */
  41050. export class SphereBuilder {
  41051. /**
  41052. * Creates a sphere mesh
  41053. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41054. * * 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`)
  41055. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41056. * * 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
  41057. * * 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)
  41058. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41059. * * 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
  41060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41061. * @param name defines the name of the mesh
  41062. * @param options defines the options used to create the mesh
  41063. * @param scene defines the hosting scene
  41064. * @returns the sphere mesh
  41065. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41066. */
  41067. static CreateSphere(name: string, options: {
  41068. segments?: number;
  41069. diameter?: number;
  41070. diameterX?: number;
  41071. diameterY?: number;
  41072. diameterZ?: number;
  41073. arc?: number;
  41074. slice?: number;
  41075. sideOrientation?: number;
  41076. frontUVs?: Vector4;
  41077. backUVs?: Vector4;
  41078. updatable?: boolean;
  41079. }, scene: any): Mesh;
  41080. }
  41081. }
  41082. declare module BABYLON.Debug {
  41083. /**
  41084. * Used to show the physics impostor around the specific mesh
  41085. */
  41086. export class PhysicsViewer {
  41087. /** @hidden */
  41088. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41089. /** @hidden */
  41090. protected _meshes: Array<Nullable<AbstractMesh>>;
  41091. /** @hidden */
  41092. protected _scene: Nullable<Scene>;
  41093. /** @hidden */
  41094. protected _numMeshes: number;
  41095. /** @hidden */
  41096. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41097. private _renderFunction;
  41098. private _utilityLayer;
  41099. private _debugBoxMesh;
  41100. private _debugSphereMesh;
  41101. private _debugCylinderMesh;
  41102. private _debugMaterial;
  41103. private _debugMeshMeshes;
  41104. /**
  41105. * Creates a new PhysicsViewer
  41106. * @param scene defines the hosting scene
  41107. */
  41108. constructor(scene: Scene);
  41109. /** @hidden */
  41110. protected _updateDebugMeshes(): void;
  41111. /**
  41112. * Renders a specified physic impostor
  41113. * @param impostor defines the impostor to render
  41114. * @param targetMesh defines the mesh represented by the impostor
  41115. * @returns the new debug mesh used to render the impostor
  41116. */
  41117. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  41118. /**
  41119. * Hides a specified physic impostor
  41120. * @param impostor defines the impostor to hide
  41121. */
  41122. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41123. private _getDebugMaterial;
  41124. private _getDebugBoxMesh;
  41125. private _getDebugSphereMesh;
  41126. private _getDebugCylinderMesh;
  41127. private _getDebugMeshMesh;
  41128. private _getDebugMesh;
  41129. /** Releases all resources */
  41130. dispose(): void;
  41131. }
  41132. }
  41133. declare module BABYLON {
  41134. /**
  41135. * Class containing static functions to help procedurally build meshes
  41136. */
  41137. export class LinesBuilder {
  41138. /**
  41139. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41140. * * 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
  41141. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41142. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41143. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41144. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41145. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41146. * * 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
  41147. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41149. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41150. * @param name defines the name of the new line system
  41151. * @param options defines the options used to create the line system
  41152. * @param scene defines the hosting scene
  41153. * @returns a new line system mesh
  41154. */
  41155. static CreateLineSystem(name: string, options: {
  41156. lines: Vector3[][];
  41157. updatable?: boolean;
  41158. instance?: Nullable<LinesMesh>;
  41159. colors?: Nullable<Color4[][]>;
  41160. useVertexAlpha?: boolean;
  41161. }, scene: Nullable<Scene>): LinesMesh;
  41162. /**
  41163. * Creates a line mesh
  41164. * 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
  41165. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41166. * * The parameter `points` is an array successive Vector3
  41167. * * 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
  41168. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41169. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41170. * * When updating an instance, remember that only point positions can change, not the number of points
  41171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41172. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41173. * @param name defines the name of the new line system
  41174. * @param options defines the options used to create the line system
  41175. * @param scene defines the hosting scene
  41176. * @returns a new line mesh
  41177. */
  41178. static CreateLines(name: string, options: {
  41179. points: Vector3[];
  41180. updatable?: boolean;
  41181. instance?: Nullable<LinesMesh>;
  41182. colors?: Color4[];
  41183. useVertexAlpha?: boolean;
  41184. }, scene?: Nullable<Scene>): LinesMesh;
  41185. /**
  41186. * Creates a dashed line mesh
  41187. * * 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
  41188. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41189. * * The parameter `points` is an array successive Vector3
  41190. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41191. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41192. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41193. * * 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
  41194. * * When updating an instance, remember that only point positions can change, not the number of points
  41195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41196. * @param name defines the name of the mesh
  41197. * @param options defines the options used to create the mesh
  41198. * @param scene defines the hosting scene
  41199. * @returns the dashed line mesh
  41200. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41201. */
  41202. static CreateDashedLines(name: string, options: {
  41203. points: Vector3[];
  41204. dashSize?: number;
  41205. gapSize?: number;
  41206. dashNb?: number;
  41207. updatable?: boolean;
  41208. instance?: LinesMesh;
  41209. }, scene?: Nullable<Scene>): LinesMesh;
  41210. }
  41211. }
  41212. declare module BABYLON {
  41213. /**
  41214. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41215. * in order to better appreciate the issue one might have.
  41216. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41217. */
  41218. export class RayHelper {
  41219. /**
  41220. * Defines the ray we are currently tryin to visualize.
  41221. */
  41222. ray: Nullable<Ray>;
  41223. private _renderPoints;
  41224. private _renderLine;
  41225. private _renderFunction;
  41226. private _scene;
  41227. private _updateToMeshFunction;
  41228. private _attachedToMesh;
  41229. private _meshSpaceDirection;
  41230. private _meshSpaceOrigin;
  41231. /**
  41232. * Helper function to create a colored helper in a scene in one line.
  41233. * @param ray Defines the ray we are currently tryin to visualize
  41234. * @param scene Defines the scene the ray is used in
  41235. * @param color Defines the color we want to see the ray in
  41236. * @returns The newly created ray helper.
  41237. */
  41238. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41239. /**
  41240. * Instantiate a new ray helper.
  41241. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41242. * in order to better appreciate the issue one might have.
  41243. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41244. * @param ray Defines the ray we are currently tryin to visualize
  41245. */
  41246. constructor(ray: Ray);
  41247. /**
  41248. * Shows the ray we are willing to debug.
  41249. * @param scene Defines the scene the ray needs to be rendered in
  41250. * @param color Defines the color the ray needs to be rendered in
  41251. */
  41252. show(scene: Scene, color?: Color3): void;
  41253. /**
  41254. * Hides the ray we are debugging.
  41255. */
  41256. hide(): void;
  41257. private _render;
  41258. /**
  41259. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41260. * @param mesh Defines the mesh we want the helper attached to
  41261. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41262. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41263. * @param length Defines the length of the ray
  41264. */
  41265. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41266. /**
  41267. * Detach the ray helper from the mesh it has previously been attached to.
  41268. */
  41269. detachFromMesh(): void;
  41270. private _updateToMesh;
  41271. /**
  41272. * Dispose the helper and release its associated resources.
  41273. */
  41274. dispose(): void;
  41275. }
  41276. }
  41277. declare module BABYLON.Debug {
  41278. /**
  41279. * Class used to render a debug view of a given skeleton
  41280. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41281. */
  41282. export class SkeletonViewer {
  41283. /** defines the skeleton to render */
  41284. skeleton: Skeleton;
  41285. /** defines the mesh attached to the skeleton */
  41286. mesh: AbstractMesh;
  41287. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41288. autoUpdateBonesMatrices: boolean;
  41289. /** defines the rendering group id to use with the viewer */
  41290. renderingGroupId: number;
  41291. /** Gets or sets the color used to render the skeleton */
  41292. color: Color3;
  41293. private _scene;
  41294. private _debugLines;
  41295. private _debugMesh;
  41296. private _isEnabled;
  41297. private _renderFunction;
  41298. private _utilityLayer;
  41299. /**
  41300. * Returns the mesh used to render the bones
  41301. */
  41302. readonly debugMesh: Nullable<LinesMesh>;
  41303. /**
  41304. * Creates a new SkeletonViewer
  41305. * @param skeleton defines the skeleton to render
  41306. * @param mesh defines the mesh attached to the skeleton
  41307. * @param scene defines the hosting scene
  41308. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41309. * @param renderingGroupId defines the rendering group id to use with the viewer
  41310. */
  41311. constructor(
  41312. /** defines the skeleton to render */
  41313. skeleton: Skeleton,
  41314. /** defines the mesh attached to the skeleton */
  41315. mesh: AbstractMesh, scene: Scene,
  41316. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41317. autoUpdateBonesMatrices?: boolean,
  41318. /** defines the rendering group id to use with the viewer */
  41319. renderingGroupId?: number);
  41320. /** Gets or sets a boolean indicating if the viewer is enabled */
  41321. isEnabled: boolean;
  41322. private _getBonePosition;
  41323. private _getLinesForBonesWithLength;
  41324. private _getLinesForBonesNoLength;
  41325. /** Update the viewer to sync with current skeleton state */
  41326. update(): void;
  41327. /** Release associated resources */
  41328. dispose(): void;
  41329. }
  41330. }
  41331. declare module BABYLON {
  41332. /**
  41333. * Options to create the null engine
  41334. */
  41335. export class NullEngineOptions {
  41336. /**
  41337. * Render width (Default: 512)
  41338. */
  41339. renderWidth: number;
  41340. /**
  41341. * Render height (Default: 256)
  41342. */
  41343. renderHeight: number;
  41344. /**
  41345. * Texture size (Default: 512)
  41346. */
  41347. textureSize: number;
  41348. /**
  41349. * If delta time between frames should be constant
  41350. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41351. */
  41352. deterministicLockstep: boolean;
  41353. /**
  41354. * Maximum about of steps between frames (Default: 4)
  41355. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41356. */
  41357. lockstepMaxSteps: number;
  41358. }
  41359. /**
  41360. * The null engine class provides support for headless version of babylon.js.
  41361. * This can be used in server side scenario or for testing purposes
  41362. */
  41363. export class NullEngine extends Engine {
  41364. private _options;
  41365. /**
  41366. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41367. */
  41368. isDeterministicLockStep(): boolean;
  41369. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41370. getLockstepMaxSteps(): number;
  41371. /**
  41372. * Sets hardware scaling, used to save performance if needed
  41373. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41374. */
  41375. getHardwareScalingLevel(): number;
  41376. constructor(options?: NullEngineOptions);
  41377. createVertexBuffer(vertices: FloatArray): DataBuffer;
  41378. createIndexBuffer(indices: IndicesArray): DataBuffer;
  41379. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41380. getRenderWidth(useScreen?: boolean): number;
  41381. getRenderHeight(useScreen?: boolean): number;
  41382. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41383. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41384. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41385. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41386. bindSamplers(effect: Effect): void;
  41387. enableEffect(effect: Effect): void;
  41388. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41389. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41390. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41391. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41392. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41393. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41394. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41395. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41396. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41397. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41398. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41399. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41400. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41401. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41402. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41403. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41404. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41405. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41406. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41407. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41408. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41409. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41410. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41411. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41412. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41413. bindBuffers(vertexBuffers: {
  41414. [key: string]: VertexBuffer;
  41415. }, indexBuffer: DataBuffer, effect: Effect): void;
  41416. wipeCaches(bruteForce?: boolean): void;
  41417. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41418. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41419. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41420. /** @hidden */
  41421. _createTexture(): WebGLTexture;
  41422. /** @hidden */
  41423. _releaseTexture(texture: InternalTexture): void;
  41424. 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;
  41425. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41426. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41427. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41428. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41429. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  41430. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41431. areAllEffectsReady(): boolean;
  41432. /**
  41433. * @hidden
  41434. * Get the current error code of the webGL context
  41435. * @returns the error code
  41436. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41437. */
  41438. getError(): number;
  41439. /** @hidden */
  41440. _getUnpackAlignement(): number;
  41441. /** @hidden */
  41442. _unpackFlipY(value: boolean): void;
  41443. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41444. /**
  41445. * Updates a dynamic vertex buffer.
  41446. * @param vertexBuffer the vertex buffer to update
  41447. * @param data the data used to update the vertex buffer
  41448. * @param byteOffset the byte offset of the data (optional)
  41449. * @param byteLength the byte length of the data (optional)
  41450. */
  41451. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41452. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41453. /** @hidden */
  41454. _bindTexture(channel: number, texture: InternalTexture): void;
  41455. /** @hidden */
  41456. _releaseBuffer(buffer: DataBuffer): boolean;
  41457. releaseEffects(): void;
  41458. displayLoadingUI(): void;
  41459. hideLoadingUI(): void;
  41460. /** @hidden */
  41461. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41462. /** @hidden */
  41463. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41464. /** @hidden */
  41465. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41466. /** @hidden */
  41467. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41468. }
  41469. }
  41470. declare module BABYLON {
  41471. /** @hidden */
  41472. export class _OcclusionDataStorage {
  41473. /** @hidden */
  41474. occlusionInternalRetryCounter: number;
  41475. /** @hidden */
  41476. isOcclusionQueryInProgress: boolean;
  41477. /** @hidden */
  41478. isOccluded: boolean;
  41479. /** @hidden */
  41480. occlusionRetryCount: number;
  41481. /** @hidden */
  41482. occlusionType: number;
  41483. /** @hidden */
  41484. occlusionQueryAlgorithmType: number;
  41485. }
  41486. interface Engine {
  41487. /**
  41488. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41489. * @return the new query
  41490. */
  41491. createQuery(): WebGLQuery;
  41492. /**
  41493. * Delete and release a webGL query
  41494. * @param query defines the query to delete
  41495. * @return the current engine
  41496. */
  41497. deleteQuery(query: WebGLQuery): Engine;
  41498. /**
  41499. * Check if a given query has resolved and got its value
  41500. * @param query defines the query to check
  41501. * @returns true if the query got its value
  41502. */
  41503. isQueryResultAvailable(query: WebGLQuery): boolean;
  41504. /**
  41505. * Gets the value of a given query
  41506. * @param query defines the query to check
  41507. * @returns the value of the query
  41508. */
  41509. getQueryResult(query: WebGLQuery): number;
  41510. /**
  41511. * Initiates an occlusion query
  41512. * @param algorithmType defines the algorithm to use
  41513. * @param query defines the query to use
  41514. * @returns the current engine
  41515. * @see http://doc.babylonjs.com/features/occlusionquery
  41516. */
  41517. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41518. /**
  41519. * Ends an occlusion query
  41520. * @see http://doc.babylonjs.com/features/occlusionquery
  41521. * @param algorithmType defines the algorithm to use
  41522. * @returns the current engine
  41523. */
  41524. endOcclusionQuery(algorithmType: number): Engine;
  41525. /**
  41526. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41527. * Please note that only one query can be issued at a time
  41528. * @returns a time token used to track the time span
  41529. */
  41530. startTimeQuery(): Nullable<_TimeToken>;
  41531. /**
  41532. * Ends a time query
  41533. * @param token defines the token used to measure the time span
  41534. * @returns the time spent (in ns)
  41535. */
  41536. endTimeQuery(token: _TimeToken): int;
  41537. /** @hidden */
  41538. _currentNonTimestampToken: Nullable<_TimeToken>;
  41539. /** @hidden */
  41540. _createTimeQuery(): WebGLQuery;
  41541. /** @hidden */
  41542. _deleteTimeQuery(query: WebGLQuery): void;
  41543. /** @hidden */
  41544. _getGlAlgorithmType(algorithmType: number): number;
  41545. /** @hidden */
  41546. _getTimeQueryResult(query: WebGLQuery): any;
  41547. /** @hidden */
  41548. _getTimeQueryAvailability(query: WebGLQuery): any;
  41549. }
  41550. interface AbstractMesh {
  41551. /**
  41552. * Backing filed
  41553. * @hidden
  41554. */
  41555. __occlusionDataStorage: _OcclusionDataStorage;
  41556. /**
  41557. * Access property
  41558. * @hidden
  41559. */
  41560. _occlusionDataStorage: _OcclusionDataStorage;
  41561. /**
  41562. * 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.
  41563. * The default value is -1 which means don't break the query and wait till the result
  41564. * @see http://doc.babylonjs.com/features/occlusionquery
  41565. */
  41566. occlusionRetryCount: number;
  41567. /**
  41568. * 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:
  41569. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41570. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41571. * * 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.
  41572. * @see http://doc.babylonjs.com/features/occlusionquery
  41573. */
  41574. occlusionType: number;
  41575. /**
  41576. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41577. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41578. * * 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.
  41579. * @see http://doc.babylonjs.com/features/occlusionquery
  41580. */
  41581. occlusionQueryAlgorithmType: number;
  41582. /**
  41583. * 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
  41584. * @see http://doc.babylonjs.com/features/occlusionquery
  41585. */
  41586. isOccluded: boolean;
  41587. /**
  41588. * Flag to check the progress status of the query
  41589. * @see http://doc.babylonjs.com/features/occlusionquery
  41590. */
  41591. isOcclusionQueryInProgress: boolean;
  41592. }
  41593. }
  41594. declare module BABYLON {
  41595. /** @hidden */
  41596. export var _forceTransformFeedbackToBundle: boolean;
  41597. interface Engine {
  41598. /**
  41599. * Creates a webGL transform feedback object
  41600. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41601. * @returns the webGL transform feedback object
  41602. */
  41603. createTransformFeedback(): WebGLTransformFeedback;
  41604. /**
  41605. * Delete a webGL transform feedback object
  41606. * @param value defines the webGL transform feedback object to delete
  41607. */
  41608. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41609. /**
  41610. * Bind a webGL transform feedback object to the webgl context
  41611. * @param value defines the webGL transform feedback object to bind
  41612. */
  41613. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41614. /**
  41615. * Begins a transform feedback operation
  41616. * @param usePoints defines if points or triangles must be used
  41617. */
  41618. beginTransformFeedback(usePoints: boolean): void;
  41619. /**
  41620. * Ends a transform feedback operation
  41621. */
  41622. endTransformFeedback(): void;
  41623. /**
  41624. * Specify the varyings to use with transform feedback
  41625. * @param program defines the associated webGL program
  41626. * @param value defines the list of strings representing the varying names
  41627. */
  41628. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41629. /**
  41630. * Bind a webGL buffer for a transform feedback operation
  41631. * @param value defines the webGL buffer to bind
  41632. */
  41633. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  41634. }
  41635. }
  41636. declare module BABYLON {
  41637. /**
  41638. * Creation options of the multi render target texture.
  41639. */
  41640. export interface IMultiRenderTargetOptions {
  41641. /**
  41642. * Define if the texture needs to create mip maps after render.
  41643. */
  41644. generateMipMaps?: boolean;
  41645. /**
  41646. * Define the types of all the draw buffers we want to create
  41647. */
  41648. types?: number[];
  41649. /**
  41650. * Define the sampling modes of all the draw buffers we want to create
  41651. */
  41652. samplingModes?: number[];
  41653. /**
  41654. * Define if a depth buffer is required
  41655. */
  41656. generateDepthBuffer?: boolean;
  41657. /**
  41658. * Define if a stencil buffer is required
  41659. */
  41660. generateStencilBuffer?: boolean;
  41661. /**
  41662. * Define if a depth texture is required instead of a depth buffer
  41663. */
  41664. generateDepthTexture?: boolean;
  41665. /**
  41666. * Define the number of desired draw buffers
  41667. */
  41668. textureCount?: number;
  41669. /**
  41670. * Define if aspect ratio should be adapted to the texture or stay the scene one
  41671. */
  41672. doNotChangeAspectRatio?: boolean;
  41673. /**
  41674. * Define the default type of the buffers we are creating
  41675. */
  41676. defaultType?: number;
  41677. }
  41678. /**
  41679. * A multi render target, like a render target provides the ability to render to a texture.
  41680. * Unlike the render target, it can render to several draw buffers in one draw.
  41681. * This is specially interesting in deferred rendering or for any effects requiring more than
  41682. * just one color from a single pass.
  41683. */
  41684. export class MultiRenderTarget extends RenderTargetTexture {
  41685. private _internalTextures;
  41686. private _textures;
  41687. private _multiRenderTargetOptions;
  41688. /**
  41689. * Get if draw buffers are currently supported by the used hardware and browser.
  41690. */
  41691. readonly isSupported: boolean;
  41692. /**
  41693. * Get the list of textures generated by the multi render target.
  41694. */
  41695. readonly textures: Texture[];
  41696. /**
  41697. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  41698. */
  41699. readonly depthTexture: Texture;
  41700. /**
  41701. * Set the wrapping mode on U of all the textures we are rendering to.
  41702. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41703. */
  41704. wrapU: number;
  41705. /**
  41706. * Set the wrapping mode on V of all the textures we are rendering to.
  41707. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41708. */
  41709. wrapV: number;
  41710. /**
  41711. * Instantiate a new multi render target texture.
  41712. * A multi render target, like a render target provides the ability to render to a texture.
  41713. * Unlike the render target, it can render to several draw buffers in one draw.
  41714. * This is specially interesting in deferred rendering or for any effects requiring more than
  41715. * just one color from a single pass.
  41716. * @param name Define the name of the texture
  41717. * @param size Define the size of the buffers to render to
  41718. * @param count Define the number of target we are rendering into
  41719. * @param scene Define the scene the texture belongs to
  41720. * @param options Define the options used to create the multi render target
  41721. */
  41722. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  41723. /** @hidden */
  41724. _rebuild(): void;
  41725. private _createInternalTextures;
  41726. private _createTextures;
  41727. /**
  41728. * Define the number of samples used if MSAA is enabled.
  41729. */
  41730. samples: number;
  41731. /**
  41732. * Resize all the textures in the multi render target.
  41733. * Be carrefull as it will recreate all the data in the new texture.
  41734. * @param size Define the new size
  41735. */
  41736. resize(size: any): void;
  41737. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  41738. /**
  41739. * Dispose the render targets and their associated resources
  41740. */
  41741. dispose(): void;
  41742. /**
  41743. * Release all the underlying texture used as draw buffers.
  41744. */
  41745. releaseInternalTextures(): void;
  41746. }
  41747. }
  41748. declare module BABYLON {
  41749. interface Engine {
  41750. /**
  41751. * Unbind a list of render target textures from the webGL context
  41752. * This is used only when drawBuffer extension or webGL2 are active
  41753. * @param textures defines the render target textures to unbind
  41754. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41755. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41756. */
  41757. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  41758. /**
  41759. * Create a multi render target texture
  41760. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  41761. * @param size defines the size of the texture
  41762. * @param options defines the creation options
  41763. * @returns the cube texture as an InternalTexture
  41764. */
  41765. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  41766. /**
  41767. * Update the sample count for a given multiple render target texture
  41768. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41769. * @param textures defines the textures to update
  41770. * @param samples defines the sample count to set
  41771. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41772. */
  41773. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  41774. }
  41775. }
  41776. declare module BABYLON {
  41777. /**
  41778. * Gather the list of clipboard event types as constants.
  41779. */
  41780. export class ClipboardEventTypes {
  41781. /**
  41782. * The clipboard event is fired when a copy command is active (pressed).
  41783. */
  41784. static readonly COPY: number;
  41785. /**
  41786. * The clipboard event is fired when a cut command is active (pressed).
  41787. */
  41788. static readonly CUT: number;
  41789. /**
  41790. * The clipboard event is fired when a paste command is active (pressed).
  41791. */
  41792. static readonly PASTE: number;
  41793. }
  41794. /**
  41795. * This class is used to store clipboard related info for the onClipboardObservable event.
  41796. */
  41797. export class ClipboardInfo {
  41798. /**
  41799. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41800. */
  41801. type: number;
  41802. /**
  41803. * Defines the related dom event
  41804. */
  41805. event: ClipboardEvent;
  41806. /**
  41807. *Creates an instance of ClipboardInfo.
  41808. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41809. * @param event Defines the related dom event
  41810. */
  41811. constructor(
  41812. /**
  41813. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41814. */
  41815. type: number,
  41816. /**
  41817. * Defines the related dom event
  41818. */
  41819. event: ClipboardEvent);
  41820. /**
  41821. * Get the clipboard event's type from the keycode.
  41822. * @param keyCode Defines the keyCode for the current keyboard event.
  41823. * @return {number}
  41824. */
  41825. static GetTypeFromCharacter(keyCode: number): number;
  41826. }
  41827. }
  41828. declare module BABYLON {
  41829. /**
  41830. * Class used to represent data loading progression
  41831. */
  41832. export class SceneLoaderProgressEvent {
  41833. /** defines if data length to load can be evaluated */
  41834. readonly lengthComputable: boolean;
  41835. /** defines the loaded data length */
  41836. readonly loaded: number;
  41837. /** defines the data length to load */
  41838. readonly total: number;
  41839. /**
  41840. * Create a new progress event
  41841. * @param lengthComputable defines if data length to load can be evaluated
  41842. * @param loaded defines the loaded data length
  41843. * @param total defines the data length to load
  41844. */
  41845. constructor(
  41846. /** defines if data length to load can be evaluated */
  41847. lengthComputable: boolean,
  41848. /** defines the loaded data length */
  41849. loaded: number,
  41850. /** defines the data length to load */
  41851. total: number);
  41852. /**
  41853. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41854. * @param event defines the source event
  41855. * @returns a new SceneLoaderProgressEvent
  41856. */
  41857. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41858. }
  41859. /**
  41860. * Interface used by SceneLoader plugins to define supported file extensions
  41861. */
  41862. export interface ISceneLoaderPluginExtensions {
  41863. /**
  41864. * Defines the list of supported extensions
  41865. */
  41866. [extension: string]: {
  41867. isBinary: boolean;
  41868. };
  41869. }
  41870. /**
  41871. * Interface used by SceneLoader plugin factory
  41872. */
  41873. export interface ISceneLoaderPluginFactory {
  41874. /**
  41875. * Defines the name of the factory
  41876. */
  41877. name: string;
  41878. /**
  41879. * Function called to create a new plugin
  41880. * @return the new plugin
  41881. */
  41882. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41883. /**
  41884. * Boolean indicating if the plugin can direct load specific data
  41885. */
  41886. canDirectLoad?: (data: string) => boolean;
  41887. }
  41888. /**
  41889. * Interface used to define a SceneLoader plugin
  41890. */
  41891. export interface ISceneLoaderPlugin {
  41892. /**
  41893. * The friendly name of this plugin.
  41894. */
  41895. name: string;
  41896. /**
  41897. * The file extensions supported by this plugin.
  41898. */
  41899. extensions: string | ISceneLoaderPluginExtensions;
  41900. /**
  41901. * Import meshes into a scene.
  41902. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41903. * @param scene The scene to import into
  41904. * @param data The data to import
  41905. * @param rootUrl The root url for scene and resources
  41906. * @param meshes The meshes array to import into
  41907. * @param particleSystems The particle systems array to import into
  41908. * @param skeletons The skeletons array to import into
  41909. * @param onError The callback when import fails
  41910. * @returns True if successful or false otherwise
  41911. */
  41912. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41913. /**
  41914. * Load into a scene.
  41915. * @param scene The scene to load into
  41916. * @param data The data to import
  41917. * @param rootUrl The root url for scene and resources
  41918. * @param onError The callback when import fails
  41919. * @returns true if successful or false otherwise
  41920. */
  41921. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41922. /**
  41923. * The callback that returns true if the data can be directly loaded.
  41924. */
  41925. canDirectLoad?: (data: string) => boolean;
  41926. /**
  41927. * The callback that allows custom handling of the root url based on the response url.
  41928. */
  41929. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41930. /**
  41931. * Load into an asset container.
  41932. * @param scene The scene to load into
  41933. * @param data The data to import
  41934. * @param rootUrl The root url for scene and resources
  41935. * @param onError The callback when import fails
  41936. * @returns The loaded asset container
  41937. */
  41938. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41939. }
  41940. /**
  41941. * Interface used to define an async SceneLoader plugin
  41942. */
  41943. export interface ISceneLoaderPluginAsync {
  41944. /**
  41945. * The friendly name of this plugin.
  41946. */
  41947. name: string;
  41948. /**
  41949. * The file extensions supported by this plugin.
  41950. */
  41951. extensions: string | ISceneLoaderPluginExtensions;
  41952. /**
  41953. * Import meshes into a scene.
  41954. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41955. * @param scene The scene to import into
  41956. * @param data The data to import
  41957. * @param rootUrl The root url for scene and resources
  41958. * @param onProgress The callback when the load progresses
  41959. * @param fileName Defines the name of the file to load
  41960. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41961. */
  41962. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41963. meshes: AbstractMesh[];
  41964. particleSystems: IParticleSystem[];
  41965. skeletons: Skeleton[];
  41966. animationGroups: AnimationGroup[];
  41967. }>;
  41968. /**
  41969. * Load into a scene.
  41970. * @param scene The scene to load into
  41971. * @param data The data to import
  41972. * @param rootUrl The root url for scene and resources
  41973. * @param onProgress The callback when the load progresses
  41974. * @param fileName Defines the name of the file to load
  41975. * @returns Nothing
  41976. */
  41977. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41978. /**
  41979. * The callback that returns true if the data can be directly loaded.
  41980. */
  41981. canDirectLoad?: (data: string) => boolean;
  41982. /**
  41983. * The callback that allows custom handling of the root url based on the response url.
  41984. */
  41985. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41986. /**
  41987. * Load into an asset container.
  41988. * @param scene The scene to load into
  41989. * @param data The data to import
  41990. * @param rootUrl The root url for scene and resources
  41991. * @param onProgress The callback when the load progresses
  41992. * @param fileName Defines the name of the file to load
  41993. * @returns The loaded asset container
  41994. */
  41995. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41996. }
  41997. /**
  41998. * Class used to load scene from various file formats using registered plugins
  41999. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42000. */
  42001. export class SceneLoader {
  42002. /**
  42003. * No logging while loading
  42004. */
  42005. static readonly NO_LOGGING: number;
  42006. /**
  42007. * Minimal logging while loading
  42008. */
  42009. static readonly MINIMAL_LOGGING: number;
  42010. /**
  42011. * Summary logging while loading
  42012. */
  42013. static readonly SUMMARY_LOGGING: number;
  42014. /**
  42015. * Detailled logging while loading
  42016. */
  42017. static readonly DETAILED_LOGGING: number;
  42018. /**
  42019. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42020. */
  42021. static ForceFullSceneLoadingForIncremental: boolean;
  42022. /**
  42023. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42024. */
  42025. static ShowLoadingScreen: boolean;
  42026. /**
  42027. * Defines the current logging level (while loading the scene)
  42028. * @ignorenaming
  42029. */
  42030. static loggingLevel: number;
  42031. /**
  42032. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42033. */
  42034. static CleanBoneMatrixWeights: boolean;
  42035. /**
  42036. * Event raised when a plugin is used to load a scene
  42037. */
  42038. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42039. private static _registeredPlugins;
  42040. private static _getDefaultPlugin;
  42041. private static _getPluginForExtension;
  42042. private static _getPluginForDirectLoad;
  42043. private static _getPluginForFilename;
  42044. private static _getDirectLoad;
  42045. private static _loadData;
  42046. private static _getFileInfo;
  42047. /**
  42048. * Gets a plugin that can load the given extension
  42049. * @param extension defines the extension to load
  42050. * @returns a plugin or null if none works
  42051. */
  42052. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42053. /**
  42054. * Gets a boolean indicating that the given extension can be loaded
  42055. * @param extension defines the extension to load
  42056. * @returns true if the extension is supported
  42057. */
  42058. static IsPluginForExtensionAvailable(extension: string): boolean;
  42059. /**
  42060. * Adds a new plugin to the list of registered plugins
  42061. * @param plugin defines the plugin to add
  42062. */
  42063. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42064. /**
  42065. * Import meshes into a scene
  42066. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42067. * @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)
  42068. * @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)
  42069. * @param scene the instance of BABYLON.Scene to append to
  42070. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42071. * @param onProgress a callback with a progress event for each file being loaded
  42072. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42073. * @param pluginExtension the extension used to determine the plugin
  42074. * @returns The loaded plugin
  42075. */
  42076. 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>;
  42077. /**
  42078. * Import meshes into a scene
  42079. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42080. * @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)
  42081. * @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)
  42082. * @param scene the instance of BABYLON.Scene to append to
  42083. * @param onProgress a callback with a progress event for each file being loaded
  42084. * @param pluginExtension the extension used to determine the plugin
  42085. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42086. */
  42087. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42088. meshes: AbstractMesh[];
  42089. particleSystems: IParticleSystem[];
  42090. skeletons: Skeleton[];
  42091. animationGroups: AnimationGroup[];
  42092. }>;
  42093. /**
  42094. * Load a scene
  42095. * @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)
  42096. * @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)
  42097. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42098. * @param onSuccess a callback with the scene when import succeeds
  42099. * @param onProgress a callback with a progress event for each file being loaded
  42100. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42101. * @param pluginExtension the extension used to determine the plugin
  42102. * @returns The loaded plugin
  42103. */
  42104. 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>;
  42105. /**
  42106. * Load a scene
  42107. * @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)
  42108. * @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)
  42109. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42110. * @param onProgress a callback with a progress event for each file being loaded
  42111. * @param pluginExtension the extension used to determine the plugin
  42112. * @returns The loaded scene
  42113. */
  42114. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42115. /**
  42116. * Append a scene
  42117. * @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)
  42118. * @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)
  42119. * @param scene is the instance of BABYLON.Scene to append to
  42120. * @param onSuccess a callback with the scene when import succeeds
  42121. * @param onProgress a callback with a progress event for each file being loaded
  42122. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42123. * @param pluginExtension the extension used to determine the plugin
  42124. * @returns The loaded plugin
  42125. */
  42126. 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>;
  42127. /**
  42128. * Append a scene
  42129. * @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)
  42130. * @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)
  42131. * @param scene is the instance of BABYLON.Scene to append to
  42132. * @param onProgress a callback with a progress event for each file being loaded
  42133. * @param pluginExtension the extension used to determine the plugin
  42134. * @returns The given scene
  42135. */
  42136. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42137. /**
  42138. * Load a scene into an asset container
  42139. * @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)
  42140. * @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)
  42141. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42142. * @param onSuccess a callback with the scene when import succeeds
  42143. * @param onProgress a callback with a progress event for each file being loaded
  42144. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42145. * @param pluginExtension the extension used to determine the plugin
  42146. * @returns The loaded plugin
  42147. */
  42148. 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>;
  42149. /**
  42150. * Load a scene into an asset container
  42151. * @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)
  42152. * @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)
  42153. * @param scene is the instance of Scene to append to
  42154. * @param onProgress a callback with a progress event for each file being loaded
  42155. * @param pluginExtension the extension used to determine the plugin
  42156. * @returns The loaded asset container
  42157. */
  42158. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42159. }
  42160. }
  42161. declare module BABYLON {
  42162. /**
  42163. * Google Daydream controller
  42164. */
  42165. export class DaydreamController extends WebVRController {
  42166. /**
  42167. * Base Url for the controller model.
  42168. */
  42169. static MODEL_BASE_URL: string;
  42170. /**
  42171. * File name for the controller model.
  42172. */
  42173. static MODEL_FILENAME: string;
  42174. /**
  42175. * Gamepad Id prefix used to identify Daydream Controller.
  42176. */
  42177. static readonly GAMEPAD_ID_PREFIX: string;
  42178. /**
  42179. * Creates a new DaydreamController from a gamepad
  42180. * @param vrGamepad the gamepad that the controller should be created from
  42181. */
  42182. constructor(vrGamepad: any);
  42183. /**
  42184. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42185. * @param scene scene in which to add meshes
  42186. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42187. */
  42188. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42189. /**
  42190. * Called once for each button that changed state since the last frame
  42191. * @param buttonIdx Which button index changed
  42192. * @param state New state of the button
  42193. * @param changes Which properties on the state changed since last frame
  42194. */
  42195. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42196. }
  42197. }
  42198. declare module BABYLON {
  42199. /**
  42200. * Gear VR Controller
  42201. */
  42202. export class GearVRController extends WebVRController {
  42203. /**
  42204. * Base Url for the controller model.
  42205. */
  42206. static MODEL_BASE_URL: string;
  42207. /**
  42208. * File name for the controller model.
  42209. */
  42210. static MODEL_FILENAME: string;
  42211. /**
  42212. * Gamepad Id prefix used to identify this controller.
  42213. */
  42214. static readonly GAMEPAD_ID_PREFIX: string;
  42215. private readonly _buttonIndexToObservableNameMap;
  42216. /**
  42217. * Creates a new GearVRController from a gamepad
  42218. * @param vrGamepad the gamepad that the controller should be created from
  42219. */
  42220. constructor(vrGamepad: any);
  42221. /**
  42222. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42223. * @param scene scene in which to add meshes
  42224. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42225. */
  42226. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42227. /**
  42228. * Called once for each button that changed state since the last frame
  42229. * @param buttonIdx Which button index changed
  42230. * @param state New state of the button
  42231. * @param changes Which properties on the state changed since last frame
  42232. */
  42233. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42234. }
  42235. }
  42236. declare module BABYLON {
  42237. /**
  42238. * Generic Controller
  42239. */
  42240. export class GenericController extends WebVRController {
  42241. /**
  42242. * Base Url for the controller model.
  42243. */
  42244. static readonly MODEL_BASE_URL: string;
  42245. /**
  42246. * File name for the controller model.
  42247. */
  42248. static readonly MODEL_FILENAME: string;
  42249. /**
  42250. * Creates a new GenericController from a gamepad
  42251. * @param vrGamepad the gamepad that the controller should be created from
  42252. */
  42253. constructor(vrGamepad: any);
  42254. /**
  42255. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42256. * @param scene scene in which to add meshes
  42257. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42258. */
  42259. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42260. /**
  42261. * Called once for each button that changed state since the last frame
  42262. * @param buttonIdx Which button index changed
  42263. * @param state New state of the button
  42264. * @param changes Which properties on the state changed since last frame
  42265. */
  42266. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42267. }
  42268. }
  42269. declare module BABYLON {
  42270. /**
  42271. * Oculus Touch Controller
  42272. */
  42273. export class OculusTouchController extends WebVRController {
  42274. /**
  42275. * Base Url for the controller model.
  42276. */
  42277. static MODEL_BASE_URL: string;
  42278. /**
  42279. * File name for the left controller model.
  42280. */
  42281. static MODEL_LEFT_FILENAME: string;
  42282. /**
  42283. * File name for the right controller model.
  42284. */
  42285. static MODEL_RIGHT_FILENAME: string;
  42286. /**
  42287. * Fired when the secondary trigger on this controller is modified
  42288. */
  42289. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42290. /**
  42291. * Fired when the thumb rest on this controller is modified
  42292. */
  42293. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42294. /**
  42295. * Creates a new OculusTouchController from a gamepad
  42296. * @param vrGamepad the gamepad that the controller should be created from
  42297. */
  42298. constructor(vrGamepad: any);
  42299. /**
  42300. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42301. * @param scene scene in which to add meshes
  42302. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42303. */
  42304. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42305. /**
  42306. * Fired when the A button on this controller is modified
  42307. */
  42308. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42309. /**
  42310. * Fired when the B button on this controller is modified
  42311. */
  42312. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42313. /**
  42314. * Fired when the X button on this controller is modified
  42315. */
  42316. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42317. /**
  42318. * Fired when the Y button on this controller is modified
  42319. */
  42320. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42321. /**
  42322. * Called once for each button that changed state since the last frame
  42323. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42324. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42325. * 2) secondary trigger (same)
  42326. * 3) A (right) X (left), touch, pressed = value
  42327. * 4) B / Y
  42328. * 5) thumb rest
  42329. * @param buttonIdx Which button index changed
  42330. * @param state New state of the button
  42331. * @param changes Which properties on the state changed since last frame
  42332. */
  42333. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42334. }
  42335. }
  42336. declare module BABYLON {
  42337. /**
  42338. * Vive Controller
  42339. */
  42340. export class ViveController extends WebVRController {
  42341. /**
  42342. * Base Url for the controller model.
  42343. */
  42344. static MODEL_BASE_URL: string;
  42345. /**
  42346. * File name for the controller model.
  42347. */
  42348. static MODEL_FILENAME: string;
  42349. /**
  42350. * Creates a new ViveController from a gamepad
  42351. * @param vrGamepad the gamepad that the controller should be created from
  42352. */
  42353. constructor(vrGamepad: any);
  42354. /**
  42355. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42356. * @param scene scene in which to add meshes
  42357. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42358. */
  42359. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42360. /**
  42361. * Fired when the left button on this controller is modified
  42362. */
  42363. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42364. /**
  42365. * Fired when the right button on this controller is modified
  42366. */
  42367. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42368. /**
  42369. * Fired when the menu button on this controller is modified
  42370. */
  42371. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42372. /**
  42373. * Called once for each button that changed state since the last frame
  42374. * Vive mapping:
  42375. * 0: touchpad
  42376. * 1: trigger
  42377. * 2: left AND right buttons
  42378. * 3: menu button
  42379. * @param buttonIdx Which button index changed
  42380. * @param state New state of the button
  42381. * @param changes Which properties on the state changed since last frame
  42382. */
  42383. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42384. }
  42385. }
  42386. declare module BABYLON {
  42387. /**
  42388. * Defines the WindowsMotionController object that the state of the windows motion controller
  42389. */
  42390. export class WindowsMotionController extends WebVRController {
  42391. /**
  42392. * The base url used to load the left and right controller models
  42393. */
  42394. static MODEL_BASE_URL: string;
  42395. /**
  42396. * The name of the left controller model file
  42397. */
  42398. static MODEL_LEFT_FILENAME: string;
  42399. /**
  42400. * The name of the right controller model file
  42401. */
  42402. static MODEL_RIGHT_FILENAME: string;
  42403. /**
  42404. * The controller name prefix for this controller type
  42405. */
  42406. static readonly GAMEPAD_ID_PREFIX: string;
  42407. /**
  42408. * The controller id pattern for this controller type
  42409. */
  42410. private static readonly GAMEPAD_ID_PATTERN;
  42411. private _loadedMeshInfo;
  42412. private readonly _mapping;
  42413. /**
  42414. * Fired when the trackpad on this controller is clicked
  42415. */
  42416. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42417. /**
  42418. * Fired when the trackpad on this controller is modified
  42419. */
  42420. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42421. /**
  42422. * The current x and y values of this controller's trackpad
  42423. */
  42424. trackpad: StickValues;
  42425. /**
  42426. * Creates a new WindowsMotionController from a gamepad
  42427. * @param vrGamepad the gamepad that the controller should be created from
  42428. */
  42429. constructor(vrGamepad: any);
  42430. /**
  42431. * Fired when the trigger on this controller is modified
  42432. */
  42433. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42434. /**
  42435. * Fired when the menu button on this controller is modified
  42436. */
  42437. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42438. /**
  42439. * Fired when the grip button on this controller is modified
  42440. */
  42441. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42442. /**
  42443. * Fired when the thumbstick button on this controller is modified
  42444. */
  42445. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42446. /**
  42447. * Fired when the touchpad button on this controller is modified
  42448. */
  42449. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42450. /**
  42451. * Fired when the touchpad values on this controller are modified
  42452. */
  42453. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42454. private _updateTrackpad;
  42455. /**
  42456. * Called once per frame by the engine.
  42457. */
  42458. update(): void;
  42459. /**
  42460. * Called once for each button that changed state since the last frame
  42461. * @param buttonIdx Which button index changed
  42462. * @param state New state of the button
  42463. * @param changes Which properties on the state changed since last frame
  42464. */
  42465. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42466. /**
  42467. * Moves the buttons on the controller mesh based on their current state
  42468. * @param buttonName the name of the button to move
  42469. * @param buttonValue the value of the button which determines the buttons new position
  42470. */
  42471. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42472. /**
  42473. * Moves the axis on the controller mesh based on its current state
  42474. * @param axis the index of the axis
  42475. * @param axisValue the value of the axis which determines the meshes new position
  42476. * @hidden
  42477. */
  42478. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42479. /**
  42480. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42481. * @param scene scene in which to add meshes
  42482. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42483. */
  42484. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42485. /**
  42486. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42487. * can be transformed by button presses and axes values, based on this._mapping.
  42488. *
  42489. * @param scene scene in which the meshes exist
  42490. * @param meshes list of meshes that make up the controller model to process
  42491. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42492. */
  42493. private processModel;
  42494. private createMeshInfo;
  42495. /**
  42496. * Gets the ray of the controller in the direction the controller is pointing
  42497. * @param length the length the resulting ray should be
  42498. * @returns a ray in the direction the controller is pointing
  42499. */
  42500. getForwardRay(length?: number): Ray;
  42501. /**
  42502. * Disposes of the controller
  42503. */
  42504. dispose(): void;
  42505. }
  42506. }
  42507. declare module BABYLON {
  42508. /**
  42509. * Single axis scale gizmo
  42510. */
  42511. export class AxisScaleGizmo extends Gizmo {
  42512. private _coloredMaterial;
  42513. /**
  42514. * Drag behavior responsible for the gizmos dragging interactions
  42515. */
  42516. dragBehavior: PointerDragBehavior;
  42517. private _pointerObserver;
  42518. /**
  42519. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42520. */
  42521. snapDistance: number;
  42522. /**
  42523. * Event that fires each time the gizmo snaps to a new location.
  42524. * * snapDistance is the the change in distance
  42525. */
  42526. onSnapObservable: Observable<{
  42527. snapDistance: number;
  42528. }>;
  42529. /**
  42530. * If the scaling operation should be done on all axis (default: false)
  42531. */
  42532. uniformScaling: boolean;
  42533. /**
  42534. * Creates an AxisScaleGizmo
  42535. * @param gizmoLayer The utility layer the gizmo will be added to
  42536. * @param dragAxis The axis which the gizmo will be able to scale on
  42537. * @param color The color of the gizmo
  42538. */
  42539. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42540. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42541. /**
  42542. * Disposes of the gizmo
  42543. */
  42544. dispose(): void;
  42545. /**
  42546. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42547. * @param mesh The mesh to replace the default mesh of the gizmo
  42548. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42549. */
  42550. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42551. }
  42552. }
  42553. declare module BABYLON {
  42554. /**
  42555. * Bounding box gizmo
  42556. */
  42557. export class BoundingBoxGizmo extends Gizmo {
  42558. private _lineBoundingBox;
  42559. private _rotateSpheresParent;
  42560. private _scaleBoxesParent;
  42561. private _boundingDimensions;
  42562. private _renderObserver;
  42563. private _pointerObserver;
  42564. private _scaleDragSpeed;
  42565. private _tmpQuaternion;
  42566. private _tmpVector;
  42567. private _tmpRotationMatrix;
  42568. /**
  42569. * 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)
  42570. */
  42571. ignoreChildren: boolean;
  42572. /**
  42573. * 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)
  42574. */
  42575. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42576. /**
  42577. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42578. */
  42579. rotationSphereSize: number;
  42580. /**
  42581. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42582. */
  42583. scaleBoxSize: number;
  42584. /**
  42585. * 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)
  42586. */
  42587. fixedDragMeshScreenSize: boolean;
  42588. /**
  42589. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42590. */
  42591. fixedDragMeshScreenSizeDistanceFactor: number;
  42592. /**
  42593. * Fired when a rotation sphere or scale box is dragged
  42594. */
  42595. onDragStartObservable: Observable<{}>;
  42596. /**
  42597. * Fired when a scale box is dragged
  42598. */
  42599. onScaleBoxDragObservable: Observable<{}>;
  42600. /**
  42601. * Fired when a scale box drag is ended
  42602. */
  42603. onScaleBoxDragEndObservable: Observable<{}>;
  42604. /**
  42605. * Fired when a rotation sphere is dragged
  42606. */
  42607. onRotationSphereDragObservable: Observable<{}>;
  42608. /**
  42609. * Fired when a rotation sphere drag is ended
  42610. */
  42611. onRotationSphereDragEndObservable: Observable<{}>;
  42612. /**
  42613. * 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)
  42614. */
  42615. scalePivot: Nullable<Vector3>;
  42616. /**
  42617. * Mesh used as a pivot to rotate the attached mesh
  42618. */
  42619. private _anchorMesh;
  42620. private _existingMeshScale;
  42621. private _dragMesh;
  42622. private pointerDragBehavior;
  42623. private coloredMaterial;
  42624. private hoverColoredMaterial;
  42625. /**
  42626. * Sets the color of the bounding box gizmo
  42627. * @param color the color to set
  42628. */
  42629. setColor(color: Color3): void;
  42630. /**
  42631. * Creates an BoundingBoxGizmo
  42632. * @param gizmoLayer The utility layer the gizmo will be added to
  42633. * @param color The color of the gizmo
  42634. */
  42635. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42636. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42637. private _selectNode;
  42638. /**
  42639. * Updates the bounding box information for the Gizmo
  42640. */
  42641. updateBoundingBox(): void;
  42642. private _updateRotationSpheres;
  42643. private _updateScaleBoxes;
  42644. /**
  42645. * Enables rotation on the specified axis and disables rotation on the others
  42646. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42647. */
  42648. setEnabledRotationAxis(axis: string): void;
  42649. /**
  42650. * Enables/disables scaling
  42651. * @param enable if scaling should be enabled
  42652. */
  42653. setEnabledScaling(enable: boolean): void;
  42654. private _updateDummy;
  42655. /**
  42656. * Enables a pointer drag behavior on the bounding box of the gizmo
  42657. */
  42658. enableDragBehavior(): void;
  42659. /**
  42660. * Disposes of the gizmo
  42661. */
  42662. dispose(): void;
  42663. /**
  42664. * 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)
  42665. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42666. * @returns the bounding box mesh with the passed in mesh as a child
  42667. */
  42668. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42669. /**
  42670. * CustomMeshes are not supported by this gizmo
  42671. * @param mesh The mesh to replace the default mesh of the gizmo
  42672. */
  42673. setCustomMesh(mesh: Mesh): void;
  42674. }
  42675. }
  42676. declare module BABYLON {
  42677. /**
  42678. * Single plane rotation gizmo
  42679. */
  42680. export class PlaneRotationGizmo extends Gizmo {
  42681. /**
  42682. * Drag behavior responsible for the gizmos dragging interactions
  42683. */
  42684. dragBehavior: PointerDragBehavior;
  42685. private _pointerObserver;
  42686. /**
  42687. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42688. */
  42689. snapDistance: number;
  42690. /**
  42691. * Event that fires each time the gizmo snaps to a new location.
  42692. * * snapDistance is the the change in distance
  42693. */
  42694. onSnapObservable: Observable<{
  42695. snapDistance: number;
  42696. }>;
  42697. /**
  42698. * Creates a PlaneRotationGizmo
  42699. * @param gizmoLayer The utility layer the gizmo will be added to
  42700. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42701. * @param color The color of the gizmo
  42702. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42703. */
  42704. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42705. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42706. /**
  42707. * Disposes of the gizmo
  42708. */
  42709. dispose(): void;
  42710. }
  42711. }
  42712. declare module BABYLON {
  42713. /**
  42714. * Gizmo that enables rotating a mesh along 3 axis
  42715. */
  42716. export class RotationGizmo extends Gizmo {
  42717. /**
  42718. * Internal gizmo used for interactions on the x axis
  42719. */
  42720. xGizmo: PlaneRotationGizmo;
  42721. /**
  42722. * Internal gizmo used for interactions on the y axis
  42723. */
  42724. yGizmo: PlaneRotationGizmo;
  42725. /**
  42726. * Internal gizmo used for interactions on the z axis
  42727. */
  42728. zGizmo: PlaneRotationGizmo;
  42729. /** Fires an event when any of it's sub gizmos are dragged */
  42730. onDragStartObservable: Observable<{}>;
  42731. /** Fires an event when any of it's sub gizmos are released from dragging */
  42732. onDragEndObservable: Observable<{}>;
  42733. attachedMesh: Nullable<AbstractMesh>;
  42734. /**
  42735. * Creates a RotationGizmo
  42736. * @param gizmoLayer The utility layer the gizmo will be added to
  42737. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42738. */
  42739. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42740. updateGizmoRotationToMatchAttachedMesh: boolean;
  42741. /**
  42742. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42743. */
  42744. snapDistance: number;
  42745. /**
  42746. * Ratio for the scale of the gizmo (Default: 1)
  42747. */
  42748. scaleRatio: number;
  42749. /**
  42750. * Disposes of the gizmo
  42751. */
  42752. dispose(): void;
  42753. /**
  42754. * CustomMeshes are not supported by this gizmo
  42755. * @param mesh The mesh to replace the default mesh of the gizmo
  42756. */
  42757. setCustomMesh(mesh: Mesh): void;
  42758. }
  42759. }
  42760. declare module BABYLON {
  42761. /**
  42762. * Gizmo that enables dragging a mesh along 3 axis
  42763. */
  42764. export class PositionGizmo extends Gizmo {
  42765. /**
  42766. * Internal gizmo used for interactions on the x axis
  42767. */
  42768. xGizmo: AxisDragGizmo;
  42769. /**
  42770. * Internal gizmo used for interactions on the y axis
  42771. */
  42772. yGizmo: AxisDragGizmo;
  42773. /**
  42774. * Internal gizmo used for interactions on the z axis
  42775. */
  42776. zGizmo: AxisDragGizmo;
  42777. /** Fires an event when any of it's sub gizmos are dragged */
  42778. onDragStartObservable: Observable<{}>;
  42779. /** Fires an event when any of it's sub gizmos are released from dragging */
  42780. onDragEndObservable: Observable<{}>;
  42781. attachedMesh: Nullable<AbstractMesh>;
  42782. /**
  42783. * Creates a PositionGizmo
  42784. * @param gizmoLayer The utility layer the gizmo will be added to
  42785. */
  42786. constructor(gizmoLayer?: UtilityLayerRenderer);
  42787. updateGizmoRotationToMatchAttachedMesh: boolean;
  42788. /**
  42789. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42790. */
  42791. snapDistance: number;
  42792. /**
  42793. * Ratio for the scale of the gizmo (Default: 1)
  42794. */
  42795. scaleRatio: number;
  42796. /**
  42797. * Disposes of the gizmo
  42798. */
  42799. dispose(): void;
  42800. /**
  42801. * CustomMeshes are not supported by this gizmo
  42802. * @param mesh The mesh to replace the default mesh of the gizmo
  42803. */
  42804. setCustomMesh(mesh: Mesh): void;
  42805. }
  42806. }
  42807. declare module BABYLON {
  42808. /**
  42809. * Class containing static functions to help procedurally build meshes
  42810. */
  42811. export class PolyhedronBuilder {
  42812. /**
  42813. * Creates a polyhedron mesh
  42814. * * 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
  42815. * * The parameter `size` (positive float, default 1) sets the polygon size
  42816. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42817. * * 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`
  42818. * * 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
  42819. * * 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)`)
  42820. * * 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
  42821. * * 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
  42822. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42823. * * 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
  42824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42825. * @param name defines the name of the mesh
  42826. * @param options defines the options used to create the mesh
  42827. * @param scene defines the hosting scene
  42828. * @returns the polyhedron mesh
  42829. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42830. */
  42831. static CreatePolyhedron(name: string, options: {
  42832. type?: number;
  42833. size?: number;
  42834. sizeX?: number;
  42835. sizeY?: number;
  42836. sizeZ?: number;
  42837. custom?: any;
  42838. faceUV?: Vector4[];
  42839. faceColors?: Color4[];
  42840. flat?: boolean;
  42841. updatable?: boolean;
  42842. sideOrientation?: number;
  42843. frontUVs?: Vector4;
  42844. backUVs?: Vector4;
  42845. }, scene?: Nullable<Scene>): Mesh;
  42846. }
  42847. }
  42848. declare module BABYLON {
  42849. /**
  42850. * Gizmo that enables scaling a mesh along 3 axis
  42851. */
  42852. export class ScaleGizmo extends Gizmo {
  42853. /**
  42854. * Internal gizmo used for interactions on the x axis
  42855. */
  42856. xGizmo: AxisScaleGizmo;
  42857. /**
  42858. * Internal gizmo used for interactions on the y axis
  42859. */
  42860. yGizmo: AxisScaleGizmo;
  42861. /**
  42862. * Internal gizmo used for interactions on the z axis
  42863. */
  42864. zGizmo: AxisScaleGizmo;
  42865. /**
  42866. * Internal gizmo used to scale all axis equally
  42867. */
  42868. uniformScaleGizmo: AxisScaleGizmo;
  42869. /** Fires an event when any of it's sub gizmos are dragged */
  42870. onDragStartObservable: Observable<{}>;
  42871. /** Fires an event when any of it's sub gizmos are released from dragging */
  42872. onDragEndObservable: Observable<{}>;
  42873. attachedMesh: Nullable<AbstractMesh>;
  42874. /**
  42875. * Creates a ScaleGizmo
  42876. * @param gizmoLayer The utility layer the gizmo will be added to
  42877. */
  42878. constructor(gizmoLayer?: UtilityLayerRenderer);
  42879. updateGizmoRotationToMatchAttachedMesh: boolean;
  42880. /**
  42881. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42882. */
  42883. snapDistance: number;
  42884. /**
  42885. * Ratio for the scale of the gizmo (Default: 1)
  42886. */
  42887. scaleRatio: number;
  42888. /**
  42889. * Disposes of the gizmo
  42890. */
  42891. dispose(): void;
  42892. }
  42893. }
  42894. declare module BABYLON {
  42895. /**
  42896. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42897. */
  42898. export class GizmoManager implements IDisposable {
  42899. private scene;
  42900. /**
  42901. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42902. */
  42903. gizmos: {
  42904. positionGizmo: Nullable<PositionGizmo>;
  42905. rotationGizmo: Nullable<RotationGizmo>;
  42906. scaleGizmo: Nullable<ScaleGizmo>;
  42907. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42908. };
  42909. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42910. clearGizmoOnEmptyPointerEvent: boolean;
  42911. /** Fires an event when the manager is attached to a mesh */
  42912. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42913. private _gizmosEnabled;
  42914. private _pointerObserver;
  42915. private _attachedMesh;
  42916. private _boundingBoxColor;
  42917. private _defaultUtilityLayer;
  42918. private _defaultKeepDepthUtilityLayer;
  42919. /**
  42920. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42921. */
  42922. boundingBoxDragBehavior: SixDofDragBehavior;
  42923. /**
  42924. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42925. */
  42926. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42927. /**
  42928. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42929. */
  42930. usePointerToAttachGizmos: boolean;
  42931. /**
  42932. * Instatiates a gizmo manager
  42933. * @param scene the scene to overlay the gizmos on top of
  42934. */
  42935. constructor(scene: Scene);
  42936. /**
  42937. * Attaches a set of gizmos to the specified mesh
  42938. * @param mesh The mesh the gizmo's should be attached to
  42939. */
  42940. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42941. /**
  42942. * If the position gizmo is enabled
  42943. */
  42944. positionGizmoEnabled: boolean;
  42945. /**
  42946. * If the rotation gizmo is enabled
  42947. */
  42948. rotationGizmoEnabled: boolean;
  42949. /**
  42950. * If the scale gizmo is enabled
  42951. */
  42952. scaleGizmoEnabled: boolean;
  42953. /**
  42954. * If the boundingBox gizmo is enabled
  42955. */
  42956. boundingBoxGizmoEnabled: boolean;
  42957. /**
  42958. * Disposes of the gizmo manager
  42959. */
  42960. dispose(): void;
  42961. }
  42962. }
  42963. declare module BABYLON {
  42964. /**
  42965. * A directional light is defined by a direction (what a surprise!).
  42966. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  42967. * 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.
  42968. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42969. */
  42970. export class DirectionalLight extends ShadowLight {
  42971. private _shadowFrustumSize;
  42972. /**
  42973. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  42974. */
  42975. /**
  42976. * Specifies a fix frustum size for the shadow generation.
  42977. */
  42978. shadowFrustumSize: number;
  42979. private _shadowOrthoScale;
  42980. /**
  42981. * Gets the shadow projection scale against the optimal computed one.
  42982. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42983. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42984. */
  42985. /**
  42986. * Sets 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. shadowOrthoScale: number;
  42991. /**
  42992. * Automatically compute the projection matrix to best fit (including all the casters)
  42993. * on each frame.
  42994. */
  42995. autoUpdateExtends: boolean;
  42996. private _orthoLeft;
  42997. private _orthoRight;
  42998. private _orthoTop;
  42999. private _orthoBottom;
  43000. /**
  43001. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  43002. * The directional light is emitted from everywhere in the given direction.
  43003. * It can cast shadows.
  43004. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43005. * @param name The friendly name of the light
  43006. * @param direction The direction of the light
  43007. * @param scene The scene the light belongs to
  43008. */
  43009. constructor(name: string, direction: Vector3, scene: Scene);
  43010. /**
  43011. * Returns the string "DirectionalLight".
  43012. * @return The class name
  43013. */
  43014. getClassName(): string;
  43015. /**
  43016. * Returns the integer 1.
  43017. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43018. */
  43019. getTypeID(): number;
  43020. /**
  43021. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  43022. * Returns the DirectionalLight Shadow projection matrix.
  43023. */
  43024. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43025. /**
  43026. * Sets the passed matrix "matrix" as fixed frustum 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 _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  43030. /**
  43031. * Sets the passed matrix "matrix" as auto extend 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 _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43035. protected _buildUniformLayout(): void;
  43036. /**
  43037. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  43038. * @param effect The effect to update
  43039. * @param lightIndex The index of the light in the effect to update
  43040. * @returns The directional light
  43041. */
  43042. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  43043. /**
  43044. * Gets the minZ used for shadow according to both the scene and the light.
  43045. *
  43046. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43047. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43048. * @param activeCamera The camera we are returning the min for
  43049. * @returns the depth min z
  43050. */
  43051. getDepthMinZ(activeCamera: Camera): number;
  43052. /**
  43053. * Gets the maxZ used for shadow according to both the scene and the light.
  43054. *
  43055. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43056. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43057. * @param activeCamera The camera we are returning the max for
  43058. * @returns the depth max z
  43059. */
  43060. getDepthMaxZ(activeCamera: Camera): number;
  43061. /**
  43062. * Prepares the list of defines specific to the light type.
  43063. * @param defines the list of defines
  43064. * @param lightIndex defines the index of the light for the effect
  43065. */
  43066. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43067. }
  43068. }
  43069. declare module BABYLON {
  43070. /**
  43071. * Class containing static functions to help procedurally build meshes
  43072. */
  43073. export class HemisphereBuilder {
  43074. /**
  43075. * Creates a hemisphere mesh
  43076. * @param name defines the name of the mesh
  43077. * @param options defines the options used to create the mesh
  43078. * @param scene defines the hosting scene
  43079. * @returns the hemisphere mesh
  43080. */
  43081. static CreateHemisphere(name: string, options: {
  43082. segments?: number;
  43083. diameter?: number;
  43084. sideOrientation?: number;
  43085. }, scene: any): Mesh;
  43086. }
  43087. }
  43088. declare module BABYLON {
  43089. /**
  43090. * A spot light is defined by a position, a direction, an angle, and an exponent.
  43091. * These values define a cone of light starting from the position, emitting toward the direction.
  43092. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  43093. * and the exponent defines the speed of the decay of the light with distance (reach).
  43094. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43095. */
  43096. export class SpotLight extends ShadowLight {
  43097. private _angle;
  43098. private _innerAngle;
  43099. private _cosHalfAngle;
  43100. private _lightAngleScale;
  43101. private _lightAngleOffset;
  43102. /**
  43103. * Gets the cone angle of the spot light in Radians.
  43104. */
  43105. /**
  43106. * Sets the cone angle of the spot light in Radians.
  43107. */
  43108. angle: number;
  43109. /**
  43110. * Only used in gltf falloff mode, this defines the angle where
  43111. * the directional falloff will start before cutting at angle which could be seen
  43112. * as outer angle.
  43113. */
  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. innerAngle: number;
  43120. private _shadowAngleScale;
  43121. /**
  43122. * Allows scaling the angle of the light for shadow generation only.
  43123. */
  43124. /**
  43125. * Allows scaling the angle of the light for shadow generation only.
  43126. */
  43127. shadowAngleScale: number;
  43128. /**
  43129. * The light decay speed with the distance from the emission spot.
  43130. */
  43131. exponent: number;
  43132. private _projectionTextureMatrix;
  43133. /**
  43134. * Allows reading the projecton texture
  43135. */
  43136. readonly projectionTextureMatrix: Matrix;
  43137. protected _projectionTextureLightNear: number;
  43138. /**
  43139. * Gets the near clip of the Spotlight for texture projection.
  43140. */
  43141. /**
  43142. * Sets the near clip of the Spotlight for texture projection.
  43143. */
  43144. projectionTextureLightNear: number;
  43145. protected _projectionTextureLightFar: number;
  43146. /**
  43147. * Gets the far clip of the Spotlight for texture projection.
  43148. */
  43149. /**
  43150. * Sets the far clip of the Spotlight for texture projection.
  43151. */
  43152. projectionTextureLightFar: number;
  43153. protected _projectionTextureUpDirection: Vector3;
  43154. /**
  43155. * Gets the Up vector of the Spotlight for texture projection.
  43156. */
  43157. /**
  43158. * Sets the Up vector of the Spotlight for texture projection.
  43159. */
  43160. projectionTextureUpDirection: Vector3;
  43161. private _projectionTexture;
  43162. /**
  43163. * Gets the projection texture of the light.
  43164. */
  43165. /**
  43166. * Sets the projection texture of the light.
  43167. */
  43168. projectionTexture: Nullable<BaseTexture>;
  43169. private _projectionTextureViewLightDirty;
  43170. private _projectionTextureProjectionLightDirty;
  43171. private _projectionTextureDirty;
  43172. private _projectionTextureViewTargetVector;
  43173. private _projectionTextureViewLightMatrix;
  43174. private _projectionTextureProjectionLightMatrix;
  43175. private _projectionTextureScalingMatrix;
  43176. /**
  43177. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  43178. * It can cast shadows.
  43179. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43180. * @param name The light friendly name
  43181. * @param position The position of the spot light in the scene
  43182. * @param direction The direction of the light in the scene
  43183. * @param angle The cone angle of the light in Radians
  43184. * @param exponent The light decay speed with the distance from the emission spot
  43185. * @param scene The scene the lights belongs to
  43186. */
  43187. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  43188. /**
  43189. * Returns the string "SpotLight".
  43190. * @returns the class name
  43191. */
  43192. getClassName(): string;
  43193. /**
  43194. * Returns the integer 2.
  43195. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43196. */
  43197. getTypeID(): number;
  43198. /**
  43199. * Overrides the direction setter to recompute the projection texture view light Matrix.
  43200. */
  43201. protected _setDirection(value: Vector3): void;
  43202. /**
  43203. * Overrides the position setter to recompute the projection texture view light Matrix.
  43204. */
  43205. protected _setPosition(value: Vector3): void;
  43206. /**
  43207. * 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.
  43208. * Returns the SpotLight.
  43209. */
  43210. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43211. protected _computeProjectionTextureViewLightMatrix(): void;
  43212. protected _computeProjectionTextureProjectionLightMatrix(): void;
  43213. /**
  43214. * Main function for light texture projection matrix computing.
  43215. */
  43216. protected _computeProjectionTextureMatrix(): void;
  43217. protected _buildUniformLayout(): void;
  43218. private _computeAngleValues;
  43219. /**
  43220. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  43221. * @param effect The effect to update
  43222. * @param lightIndex The index of the light in the effect to update
  43223. * @returns The spot light
  43224. */
  43225. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  43226. /**
  43227. * Disposes the light and the associated resources.
  43228. */
  43229. dispose(): void;
  43230. /**
  43231. * Prepares the list of defines specific to the light type.
  43232. * @param defines the list of defines
  43233. * @param lightIndex defines the index of the light for the effect
  43234. */
  43235. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43236. }
  43237. }
  43238. declare module BABYLON {
  43239. /**
  43240. * Gizmo that enables viewing a light
  43241. */
  43242. export class LightGizmo extends Gizmo {
  43243. private _lightMesh;
  43244. private _material;
  43245. private cachedPosition;
  43246. private cachedForward;
  43247. /**
  43248. * Creates a LightGizmo
  43249. * @param gizmoLayer The utility layer the gizmo will be added to
  43250. */
  43251. constructor(gizmoLayer?: UtilityLayerRenderer);
  43252. private _light;
  43253. /**
  43254. * The light that the gizmo is attached to
  43255. */
  43256. light: Nullable<Light>;
  43257. /**
  43258. * @hidden
  43259. * Updates the gizmo to match the attached mesh's position/rotation
  43260. */
  43261. protected _update(): void;
  43262. private static _Scale;
  43263. /**
  43264. * Creates the lines for a light mesh
  43265. */
  43266. private static _createLightLines;
  43267. private static _CreateHemisphericLightMesh;
  43268. private static _CreatePointLightMesh;
  43269. private static _CreateSpotLightMesh;
  43270. private static _CreateDirectionalLightMesh;
  43271. }
  43272. }
  43273. declare module BABYLON {
  43274. /** @hidden */
  43275. export var backgroundFragmentDeclaration: {
  43276. name: string;
  43277. shader: string;
  43278. };
  43279. }
  43280. declare module BABYLON {
  43281. /** @hidden */
  43282. export var backgroundUboDeclaration: {
  43283. name: string;
  43284. shader: string;
  43285. };
  43286. }
  43287. declare module BABYLON {
  43288. /** @hidden */
  43289. export var backgroundPixelShader: {
  43290. name: string;
  43291. shader: string;
  43292. };
  43293. }
  43294. declare module BABYLON {
  43295. /** @hidden */
  43296. export var backgroundVertexDeclaration: {
  43297. name: string;
  43298. shader: string;
  43299. };
  43300. }
  43301. declare module BABYLON {
  43302. /** @hidden */
  43303. export var backgroundVertexShader: {
  43304. name: string;
  43305. shader: string;
  43306. };
  43307. }
  43308. declare module BABYLON {
  43309. /**
  43310. * Background material used to create an efficient environement around your scene.
  43311. */
  43312. export class BackgroundMaterial extends PushMaterial {
  43313. /**
  43314. * Standard reflectance value at parallel view angle.
  43315. */
  43316. static StandardReflectance0: number;
  43317. /**
  43318. * Standard reflectance value at grazing angle.
  43319. */
  43320. static StandardReflectance90: number;
  43321. protected _primaryColor: Color3;
  43322. /**
  43323. * Key light Color (multiply against the environement texture)
  43324. */
  43325. primaryColor: Color3;
  43326. protected __perceptualColor: Nullable<Color3>;
  43327. /**
  43328. * Experimental Internal Use Only.
  43329. *
  43330. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43331. * This acts as a helper to set the primary color to a more "human friendly" value.
  43332. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43333. * output color as close as possible from the chosen value.
  43334. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43335. * part of lighting setup.)
  43336. */
  43337. _perceptualColor: Nullable<Color3>;
  43338. protected _primaryColorShadowLevel: float;
  43339. /**
  43340. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43341. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43342. */
  43343. primaryColorShadowLevel: float;
  43344. protected _primaryColorHighlightLevel: float;
  43345. /**
  43346. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43347. * The primary color is used at the level chosen to define what the white area would look.
  43348. */
  43349. primaryColorHighlightLevel: float;
  43350. protected _reflectionTexture: Nullable<BaseTexture>;
  43351. /**
  43352. * Reflection Texture used in the material.
  43353. * Should be author in a specific way for the best result (refer to the documentation).
  43354. */
  43355. reflectionTexture: Nullable<BaseTexture>;
  43356. protected _reflectionBlur: float;
  43357. /**
  43358. * Reflection Texture level of blur.
  43359. *
  43360. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43361. * texture twice.
  43362. */
  43363. reflectionBlur: float;
  43364. protected _diffuseTexture: Nullable<BaseTexture>;
  43365. /**
  43366. * Diffuse Texture used in the material.
  43367. * Should be author in a specific way for the best result (refer to the documentation).
  43368. */
  43369. diffuseTexture: Nullable<BaseTexture>;
  43370. protected _shadowLights: Nullable<IShadowLight[]>;
  43371. /**
  43372. * Specify the list of lights casting shadow on the material.
  43373. * All scene shadow lights will be included if null.
  43374. */
  43375. shadowLights: Nullable<IShadowLight[]>;
  43376. protected _shadowLevel: float;
  43377. /**
  43378. * Helps adjusting the shadow to a softer level if required.
  43379. * 0 means black shadows and 1 means no shadows.
  43380. */
  43381. shadowLevel: float;
  43382. protected _sceneCenter: Vector3;
  43383. /**
  43384. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43385. * It is usually zero but might be interesting to modify according to your setup.
  43386. */
  43387. sceneCenter: Vector3;
  43388. protected _opacityFresnel: boolean;
  43389. /**
  43390. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43391. * This helps ensuring a nice transition when the camera goes under the ground.
  43392. */
  43393. opacityFresnel: boolean;
  43394. protected _reflectionFresnel: boolean;
  43395. /**
  43396. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43397. * This helps adding a mirror texture on the ground.
  43398. */
  43399. reflectionFresnel: boolean;
  43400. protected _reflectionFalloffDistance: number;
  43401. /**
  43402. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43403. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43404. */
  43405. reflectionFalloffDistance: number;
  43406. protected _reflectionAmount: number;
  43407. /**
  43408. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43409. */
  43410. reflectionAmount: number;
  43411. protected _reflectionReflectance0: number;
  43412. /**
  43413. * This specifies the weight of the reflection at grazing angle.
  43414. */
  43415. reflectionReflectance0: number;
  43416. protected _reflectionReflectance90: number;
  43417. /**
  43418. * This specifies the weight of the reflection at a perpendicular point of view.
  43419. */
  43420. reflectionReflectance90: number;
  43421. /**
  43422. * Sets the reflection reflectance fresnel values according to the default standard
  43423. * empirically know to work well :-)
  43424. */
  43425. reflectionStandardFresnelWeight: number;
  43426. protected _useRGBColor: boolean;
  43427. /**
  43428. * Helps to directly use the maps channels instead of their level.
  43429. */
  43430. useRGBColor: boolean;
  43431. protected _enableNoise: boolean;
  43432. /**
  43433. * This helps reducing the banding effect that could occur on the background.
  43434. */
  43435. enableNoise: boolean;
  43436. /**
  43437. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43438. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43439. * Recommended to be keep at 1.0 except for special cases.
  43440. */
  43441. fovMultiplier: number;
  43442. private _fovMultiplier;
  43443. /**
  43444. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43445. */
  43446. useEquirectangularFOV: boolean;
  43447. private _maxSimultaneousLights;
  43448. /**
  43449. * Number of Simultaneous lights allowed on the material.
  43450. */
  43451. maxSimultaneousLights: int;
  43452. /**
  43453. * Default configuration related to image processing available in the Background Material.
  43454. */
  43455. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43456. /**
  43457. * Keep track of the image processing observer to allow dispose and replace.
  43458. */
  43459. private _imageProcessingObserver;
  43460. /**
  43461. * Attaches a new image processing configuration to the PBR Material.
  43462. * @param configuration (if null the scene configuration will be use)
  43463. */
  43464. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43465. /**
  43466. * Gets the image processing configuration used either in this material.
  43467. */
  43468. /**
  43469. * Sets the Default image processing configuration used either in the this material.
  43470. *
  43471. * If sets to null, the scene one is in use.
  43472. */
  43473. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43474. /**
  43475. * Gets wether the color curves effect is enabled.
  43476. */
  43477. /**
  43478. * Sets wether the color curves effect is enabled.
  43479. */
  43480. cameraColorCurvesEnabled: boolean;
  43481. /**
  43482. * Gets wether the color grading effect is enabled.
  43483. */
  43484. /**
  43485. * Gets wether the color grading effect is enabled.
  43486. */
  43487. cameraColorGradingEnabled: boolean;
  43488. /**
  43489. * Gets wether tonemapping is enabled or not.
  43490. */
  43491. /**
  43492. * Sets wether tonemapping is enabled or not
  43493. */
  43494. cameraToneMappingEnabled: boolean;
  43495. /**
  43496. * The camera exposure used on this material.
  43497. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43498. * This corresponds to a photographic exposure.
  43499. */
  43500. /**
  43501. * The camera exposure used on this material.
  43502. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43503. * This corresponds to a photographic exposure.
  43504. */
  43505. cameraExposure: float;
  43506. /**
  43507. * Gets The camera contrast used on this material.
  43508. */
  43509. /**
  43510. * Sets The camera contrast used on this material.
  43511. */
  43512. cameraContrast: float;
  43513. /**
  43514. * Gets the Color Grading 2D Lookup Texture.
  43515. */
  43516. /**
  43517. * Sets the Color Grading 2D Lookup Texture.
  43518. */
  43519. cameraColorGradingTexture: Nullable<BaseTexture>;
  43520. /**
  43521. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43522. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43523. * 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;
  43524. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43525. */
  43526. /**
  43527. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43528. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43529. * 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;
  43530. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43531. */
  43532. cameraColorCurves: Nullable<ColorCurves>;
  43533. /**
  43534. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43535. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43536. */
  43537. switchToBGR: boolean;
  43538. private _renderTargets;
  43539. private _reflectionControls;
  43540. private _white;
  43541. private _primaryShadowColor;
  43542. private _primaryHighlightColor;
  43543. /**
  43544. * Instantiates a Background Material in the given scene
  43545. * @param name The friendly name of the material
  43546. * @param scene The scene to add the material to
  43547. */
  43548. constructor(name: string, scene: Scene);
  43549. /**
  43550. * Gets a boolean indicating that current material needs to register RTT
  43551. */
  43552. readonly hasRenderTargetTextures: boolean;
  43553. /**
  43554. * The entire material has been created in order to prevent overdraw.
  43555. * @returns false
  43556. */
  43557. needAlphaTesting(): boolean;
  43558. /**
  43559. * The entire material has been created in order to prevent overdraw.
  43560. * @returns true if blending is enable
  43561. */
  43562. needAlphaBlending(): boolean;
  43563. /**
  43564. * Checks wether the material is ready to be rendered for a given mesh.
  43565. * @param mesh The mesh to render
  43566. * @param subMesh The submesh to check against
  43567. * @param useInstances Specify wether or not the material is used with instances
  43568. * @returns true if all the dependencies are ready (Textures, Effects...)
  43569. */
  43570. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43571. /**
  43572. * Compute the primary color according to the chosen perceptual color.
  43573. */
  43574. private _computePrimaryColorFromPerceptualColor;
  43575. /**
  43576. * Compute the highlights and shadow colors according to their chosen levels.
  43577. */
  43578. private _computePrimaryColors;
  43579. /**
  43580. * Build the uniform buffer used in the material.
  43581. */
  43582. buildUniformLayout(): void;
  43583. /**
  43584. * Unbind the material.
  43585. */
  43586. unbind(): void;
  43587. /**
  43588. * Bind only the world matrix to the material.
  43589. * @param world The world matrix to bind.
  43590. */
  43591. bindOnlyWorldMatrix(world: Matrix): void;
  43592. /**
  43593. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43594. * @param world The world matrix to bind.
  43595. * @param subMesh The submesh to bind for.
  43596. */
  43597. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43598. /**
  43599. * Dispose the material.
  43600. * @param forceDisposeEffect Force disposal of the associated effect.
  43601. * @param forceDisposeTextures Force disposal of the associated textures.
  43602. */
  43603. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43604. /**
  43605. * Clones the material.
  43606. * @param name The cloned name.
  43607. * @returns The cloned material.
  43608. */
  43609. clone(name: string): BackgroundMaterial;
  43610. /**
  43611. * Serializes the current material to its JSON representation.
  43612. * @returns The JSON representation.
  43613. */
  43614. serialize(): any;
  43615. /**
  43616. * Gets the class name of the material
  43617. * @returns "BackgroundMaterial"
  43618. */
  43619. getClassName(): string;
  43620. /**
  43621. * Parse a JSON input to create back a background material.
  43622. * @param source The JSON data to parse
  43623. * @param scene The scene to create the parsed material in
  43624. * @param rootUrl The root url of the assets the material depends upon
  43625. * @returns the instantiated BackgroundMaterial.
  43626. */
  43627. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43628. }
  43629. }
  43630. declare module BABYLON {
  43631. /**
  43632. * Represents the different options available during the creation of
  43633. * a Environment helper.
  43634. *
  43635. * This can control the default ground, skybox and image processing setup of your scene.
  43636. */
  43637. export interface IEnvironmentHelperOptions {
  43638. /**
  43639. * Specifies wether or not to create a ground.
  43640. * True by default.
  43641. */
  43642. createGround: boolean;
  43643. /**
  43644. * Specifies the ground size.
  43645. * 15 by default.
  43646. */
  43647. groundSize: number;
  43648. /**
  43649. * The texture used on the ground for the main color.
  43650. * Comes from the BabylonJS CDN by default.
  43651. *
  43652. * Remarks: Can be either a texture or a url.
  43653. */
  43654. groundTexture: string | BaseTexture;
  43655. /**
  43656. * The color mixed in the ground texture by default.
  43657. * BabylonJS clearColor by default.
  43658. */
  43659. groundColor: Color3;
  43660. /**
  43661. * Specifies the ground opacity.
  43662. * 1 by default.
  43663. */
  43664. groundOpacity: number;
  43665. /**
  43666. * Enables the ground to receive shadows.
  43667. * True by default.
  43668. */
  43669. enableGroundShadow: boolean;
  43670. /**
  43671. * Helps preventing the shadow to be fully black on the ground.
  43672. * 0.5 by default.
  43673. */
  43674. groundShadowLevel: number;
  43675. /**
  43676. * Creates a mirror texture attach to the ground.
  43677. * false by default.
  43678. */
  43679. enableGroundMirror: boolean;
  43680. /**
  43681. * Specifies the ground mirror size ratio.
  43682. * 0.3 by default as the default kernel is 64.
  43683. */
  43684. groundMirrorSizeRatio: number;
  43685. /**
  43686. * Specifies the ground mirror blur kernel size.
  43687. * 64 by default.
  43688. */
  43689. groundMirrorBlurKernel: number;
  43690. /**
  43691. * Specifies the ground mirror visibility amount.
  43692. * 1 by default
  43693. */
  43694. groundMirrorAmount: number;
  43695. /**
  43696. * Specifies the ground mirror reflectance weight.
  43697. * This uses the standard weight of the background material to setup the fresnel effect
  43698. * of the mirror.
  43699. * 1 by default.
  43700. */
  43701. groundMirrorFresnelWeight: number;
  43702. /**
  43703. * Specifies the ground mirror Falloff distance.
  43704. * This can helps reducing the size of the reflection.
  43705. * 0 by Default.
  43706. */
  43707. groundMirrorFallOffDistance: number;
  43708. /**
  43709. * Specifies the ground mirror texture type.
  43710. * Unsigned Int by Default.
  43711. */
  43712. groundMirrorTextureType: number;
  43713. /**
  43714. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43715. * the shown objects.
  43716. */
  43717. groundYBias: number;
  43718. /**
  43719. * Specifies wether or not to create a skybox.
  43720. * True by default.
  43721. */
  43722. createSkybox: boolean;
  43723. /**
  43724. * Specifies the skybox size.
  43725. * 20 by default.
  43726. */
  43727. skyboxSize: number;
  43728. /**
  43729. * The texture used on the skybox for the main color.
  43730. * Comes from the BabylonJS CDN by default.
  43731. *
  43732. * Remarks: Can be either a texture or a url.
  43733. */
  43734. skyboxTexture: string | BaseTexture;
  43735. /**
  43736. * The color mixed in the skybox texture by default.
  43737. * BabylonJS clearColor by default.
  43738. */
  43739. skyboxColor: Color3;
  43740. /**
  43741. * The background rotation around the Y axis of the scene.
  43742. * This helps aligning the key lights of your scene with the background.
  43743. * 0 by default.
  43744. */
  43745. backgroundYRotation: number;
  43746. /**
  43747. * Compute automatically the size of the elements to best fit with the scene.
  43748. */
  43749. sizeAuto: boolean;
  43750. /**
  43751. * Default position of the rootMesh if autoSize is not true.
  43752. */
  43753. rootPosition: Vector3;
  43754. /**
  43755. * Sets up the image processing in the scene.
  43756. * true by default.
  43757. */
  43758. setupImageProcessing: boolean;
  43759. /**
  43760. * The texture used as your environment texture in the scene.
  43761. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43762. *
  43763. * Remarks: Can be either a texture or a url.
  43764. */
  43765. environmentTexture: string | BaseTexture;
  43766. /**
  43767. * The value of the exposure to apply to the scene.
  43768. * 0.6 by default if setupImageProcessing is true.
  43769. */
  43770. cameraExposure: number;
  43771. /**
  43772. * The value of the contrast to apply to the scene.
  43773. * 1.6 by default if setupImageProcessing is true.
  43774. */
  43775. cameraContrast: number;
  43776. /**
  43777. * Specifies wether or not tonemapping should be enabled in the scene.
  43778. * true by default if setupImageProcessing is true.
  43779. */
  43780. toneMappingEnabled: boolean;
  43781. }
  43782. /**
  43783. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43784. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43785. * It also helps with the default setup of your imageProcessing configuration.
  43786. */
  43787. export class EnvironmentHelper {
  43788. /**
  43789. * Default ground texture URL.
  43790. */
  43791. private static _groundTextureCDNUrl;
  43792. /**
  43793. * Default skybox texture URL.
  43794. */
  43795. private static _skyboxTextureCDNUrl;
  43796. /**
  43797. * Default environment texture URL.
  43798. */
  43799. private static _environmentTextureCDNUrl;
  43800. /**
  43801. * Creates the default options for the helper.
  43802. */
  43803. private static _getDefaultOptions;
  43804. private _rootMesh;
  43805. /**
  43806. * Gets the root mesh created by the helper.
  43807. */
  43808. readonly rootMesh: Mesh;
  43809. private _skybox;
  43810. /**
  43811. * Gets the skybox created by the helper.
  43812. */
  43813. readonly skybox: Nullable<Mesh>;
  43814. private _skyboxTexture;
  43815. /**
  43816. * Gets the skybox texture created by the helper.
  43817. */
  43818. readonly skyboxTexture: Nullable<BaseTexture>;
  43819. private _skyboxMaterial;
  43820. /**
  43821. * Gets the skybox material created by the helper.
  43822. */
  43823. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43824. private _ground;
  43825. /**
  43826. * Gets the ground mesh created by the helper.
  43827. */
  43828. readonly ground: Nullable<Mesh>;
  43829. private _groundTexture;
  43830. /**
  43831. * Gets the ground texture created by the helper.
  43832. */
  43833. readonly groundTexture: Nullable<BaseTexture>;
  43834. private _groundMirror;
  43835. /**
  43836. * Gets the ground mirror created by the helper.
  43837. */
  43838. readonly groundMirror: Nullable<MirrorTexture>;
  43839. /**
  43840. * Gets the ground mirror render list to helps pushing the meshes
  43841. * you wish in the ground reflection.
  43842. */
  43843. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43844. private _groundMaterial;
  43845. /**
  43846. * Gets the ground material created by the helper.
  43847. */
  43848. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43849. /**
  43850. * Stores the creation options.
  43851. */
  43852. private readonly _scene;
  43853. private _options;
  43854. /**
  43855. * This observable will be notified with any error during the creation of the environment,
  43856. * mainly texture creation errors.
  43857. */
  43858. onErrorObservable: Observable<{
  43859. message?: string;
  43860. exception?: any;
  43861. }>;
  43862. /**
  43863. * constructor
  43864. * @param options Defines the options we want to customize the helper
  43865. * @param scene The scene to add the material to
  43866. */
  43867. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43868. /**
  43869. * Updates the background according to the new options
  43870. * @param options
  43871. */
  43872. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43873. /**
  43874. * Sets the primary color of all the available elements.
  43875. * @param color the main color to affect to the ground and the background
  43876. */
  43877. setMainColor(color: Color3): void;
  43878. /**
  43879. * Setup the image processing according to the specified options.
  43880. */
  43881. private _setupImageProcessing;
  43882. /**
  43883. * Setup the environment texture according to the specified options.
  43884. */
  43885. private _setupEnvironmentTexture;
  43886. /**
  43887. * Setup the background according to the specified options.
  43888. */
  43889. private _setupBackground;
  43890. /**
  43891. * Get the scene sizes according to the setup.
  43892. */
  43893. private _getSceneSize;
  43894. /**
  43895. * Setup the ground according to the specified options.
  43896. */
  43897. private _setupGround;
  43898. /**
  43899. * Setup the ground material according to the specified options.
  43900. */
  43901. private _setupGroundMaterial;
  43902. /**
  43903. * Setup the ground diffuse texture according to the specified options.
  43904. */
  43905. private _setupGroundDiffuseTexture;
  43906. /**
  43907. * Setup the ground mirror texture according to the specified options.
  43908. */
  43909. private _setupGroundMirrorTexture;
  43910. /**
  43911. * Setup the ground to receive the mirror texture.
  43912. */
  43913. private _setupMirrorInGroundMaterial;
  43914. /**
  43915. * Setup the skybox according to the specified options.
  43916. */
  43917. private _setupSkybox;
  43918. /**
  43919. * Setup the skybox material according to the specified options.
  43920. */
  43921. private _setupSkyboxMaterial;
  43922. /**
  43923. * Setup the skybox reflection texture according to the specified options.
  43924. */
  43925. private _setupSkyboxReflectionTexture;
  43926. private _errorHandler;
  43927. /**
  43928. * Dispose all the elements created by the Helper.
  43929. */
  43930. dispose(): void;
  43931. }
  43932. }
  43933. declare module BABYLON {
  43934. /**
  43935. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43936. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43937. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43938. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43939. */
  43940. export class PhotoDome extends TransformNode {
  43941. private _useDirectMapping;
  43942. /**
  43943. * The texture being displayed on the sphere
  43944. */
  43945. protected _photoTexture: Texture;
  43946. /**
  43947. * Gets or sets the texture being displayed on the sphere
  43948. */
  43949. photoTexture: Texture;
  43950. /**
  43951. * Observable raised when an error occured while loading the 360 image
  43952. */
  43953. onLoadErrorObservable: Observable<string>;
  43954. /**
  43955. * The skybox material
  43956. */
  43957. protected _material: BackgroundMaterial;
  43958. /**
  43959. * The surface used for the skybox
  43960. */
  43961. protected _mesh: Mesh;
  43962. /**
  43963. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43964. * Also see the options.resolution property.
  43965. */
  43966. fovMultiplier: number;
  43967. /**
  43968. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43969. * @param name Element's name, child elements will append suffixes for their own names.
  43970. * @param urlsOfPhoto defines the url of the photo to display
  43971. * @param options defines an object containing optional or exposed sub element properties
  43972. * @param onError defines a callback called when an error occured while loading the texture
  43973. */
  43974. constructor(name: string, urlOfPhoto: string, options: {
  43975. resolution?: number;
  43976. size?: number;
  43977. useDirectMapping?: boolean;
  43978. faceForward?: boolean;
  43979. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43980. /**
  43981. * Releases resources associated with this node.
  43982. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43983. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43984. */
  43985. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43986. }
  43987. }
  43988. declare module BABYLON {
  43989. /** @hidden */
  43990. export var rgbdDecodePixelShader: {
  43991. name: string;
  43992. shader: string;
  43993. };
  43994. }
  43995. declare module BABYLON {
  43996. /**
  43997. * Class used to host texture specific utilities
  43998. */
  43999. export class BRDFTextureTools {
  44000. /**
  44001. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  44002. * @param texture the texture to expand.
  44003. */
  44004. private static _ExpandDefaultBRDFTexture;
  44005. /**
  44006. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44007. * @param scene defines the hosting scene
  44008. * @returns the environment BRDF texture
  44009. */
  44010. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44011. private static _environmentBRDFBase64Texture;
  44012. }
  44013. }
  44014. declare module BABYLON {
  44015. /**
  44016. * @hidden
  44017. */
  44018. export interface IMaterialClearCoatDefines {
  44019. CLEARCOAT: boolean;
  44020. CLEARCOAT_DEFAULTIOR: boolean;
  44021. CLEARCOAT_TEXTURE: boolean;
  44022. CLEARCOAT_TEXTUREDIRECTUV: number;
  44023. CLEARCOAT_BUMP: boolean;
  44024. CLEARCOAT_BUMPDIRECTUV: number;
  44025. CLEARCOAT_TINT: boolean;
  44026. CLEARCOAT_TINT_TEXTURE: boolean;
  44027. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44028. /** @hidden */
  44029. _areTexturesDirty: boolean;
  44030. }
  44031. /**
  44032. * Define the code related to the clear coat parameters of the pbr material.
  44033. */
  44034. export class PBRClearCoatConfiguration {
  44035. /**
  44036. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44037. * The default fits with a polyurethane material.
  44038. */
  44039. private static readonly _DefaultIndiceOfRefraction;
  44040. private _isEnabled;
  44041. /**
  44042. * Defines if the clear coat is enabled in the material.
  44043. */
  44044. isEnabled: boolean;
  44045. /**
  44046. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44047. */
  44048. intensity: number;
  44049. /**
  44050. * Defines the clear coat layer roughness.
  44051. */
  44052. roughness: number;
  44053. private _indiceOfRefraction;
  44054. /**
  44055. * Defines the indice of refraction of the clear coat.
  44056. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44057. * The default fits with a polyurethane material.
  44058. * Changing the default value is more performance intensive.
  44059. */
  44060. indiceOfRefraction: number;
  44061. private _texture;
  44062. /**
  44063. * Stores the clear coat values in a texture.
  44064. */
  44065. texture: Nullable<BaseTexture>;
  44066. private _bumpTexture;
  44067. /**
  44068. * Define the clear coat specific bump texture.
  44069. */
  44070. bumpTexture: Nullable<BaseTexture>;
  44071. private _isTintEnabled;
  44072. /**
  44073. * Defines if the clear coat tint is enabled in the material.
  44074. */
  44075. isTintEnabled: boolean;
  44076. /**
  44077. * Defines the clear coat tint of the material.
  44078. * This is only use if tint is enabled
  44079. */
  44080. tintColor: Color3;
  44081. /**
  44082. * Defines the distance at which the tint color should be found in the
  44083. * clear coat media.
  44084. * This is only use if tint is enabled
  44085. */
  44086. tintColorAtDistance: number;
  44087. /**
  44088. * Defines the clear coat layer thickness.
  44089. * This is only use if tint is enabled
  44090. */
  44091. tintThickness: number;
  44092. private _tintTexture;
  44093. /**
  44094. * Stores the clear tint values in a texture.
  44095. * rgb is tint
  44096. * a is a thickness factor
  44097. */
  44098. tintTexture: Nullable<BaseTexture>;
  44099. /** @hidden */
  44100. private _internalMarkAllSubMeshesAsTexturesDirty;
  44101. /** @hidden */
  44102. _markAllSubMeshesAsTexturesDirty(): void;
  44103. /**
  44104. * Instantiate a new istance of clear coat configuration.
  44105. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44106. */
  44107. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44108. /**
  44109. * Gets wehter the submesh is ready to be used or not.
  44110. * @param defines the list of "defines" to update.
  44111. * @param scene defines the scene the material belongs to.
  44112. * @param engine defines the engine the material belongs to.
  44113. * @param disableBumpMap defines wether the material disables bump or not.
  44114. * @returns - boolean indicating that the submesh is ready or not.
  44115. */
  44116. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44117. /**
  44118. * Checks to see if a texture is used in the material.
  44119. * @param defines the list of "defines" to update.
  44120. * @param scene defines the scene to the material belongs to.
  44121. */
  44122. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44123. /**
  44124. * Binds the material data.
  44125. * @param uniformBuffer defines the Uniform buffer to fill in.
  44126. * @param scene defines the scene the material belongs to.
  44127. * @param engine defines the engine the material belongs to.
  44128. * @param disableBumpMap defines wether the material disables bump or not.
  44129. * @param isFrozen defines wether the material is frozen or not.
  44130. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44131. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44132. */
  44133. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44134. /**
  44135. * Checks to see if a texture is used in the material.
  44136. * @param texture - Base texture to use.
  44137. * @returns - Boolean specifying if a texture is used in the material.
  44138. */
  44139. hasTexture(texture: BaseTexture): boolean;
  44140. /**
  44141. * Returns an array of the actively used textures.
  44142. * @param activeTextures Array of BaseTextures
  44143. */
  44144. getActiveTextures(activeTextures: BaseTexture[]): void;
  44145. /**
  44146. * Returns the animatable textures.
  44147. * @param animatables Array of animatable textures.
  44148. */
  44149. getAnimatables(animatables: IAnimatable[]): void;
  44150. /**
  44151. * Disposes the resources of the material.
  44152. * @param forceDisposeTextures - Forces the disposal of all textures.
  44153. */
  44154. dispose(forceDisposeTextures?: boolean): void;
  44155. /**
  44156. * Get the current class name of the texture useful for serialization or dynamic coding.
  44157. * @returns "PBRClearCoatConfiguration"
  44158. */
  44159. getClassName(): string;
  44160. /**
  44161. * Add fallbacks to the effect fallbacks list.
  44162. * @param defines defines the Base texture to use.
  44163. * @param fallbacks defines the current fallback list.
  44164. * @param currentRank defines the current fallback rank.
  44165. * @returns the new fallback rank.
  44166. */
  44167. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44168. /**
  44169. * Add the required uniforms to the current list.
  44170. * @param uniforms defines the current uniform list.
  44171. */
  44172. static AddUniforms(uniforms: string[]): void;
  44173. /**
  44174. * Add the required samplers to the current list.
  44175. * @param samplers defines the current sampler list.
  44176. */
  44177. static AddSamplers(samplers: string[]): void;
  44178. /**
  44179. * Add the required uniforms to the current buffer.
  44180. * @param uniformBuffer defines the current uniform buffer.
  44181. */
  44182. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44183. /**
  44184. * Makes a duplicate of the current configuration into another one.
  44185. * @param clearCoatConfiguration define the config where to copy the info
  44186. */
  44187. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44188. /**
  44189. * Serializes this clear coat configuration.
  44190. * @returns - An object with the serialized config.
  44191. */
  44192. serialize(): any;
  44193. /**
  44194. * Parses a Clear Coat Configuration from a serialized object.
  44195. * @param source - Serialized object.
  44196. */
  44197. parse(source: any): void;
  44198. }
  44199. }
  44200. declare module BABYLON {
  44201. /**
  44202. * @hidden
  44203. */
  44204. export interface IMaterialAnisotropicDefines {
  44205. ANISOTROPIC: boolean;
  44206. ANISOTROPIC_TEXTURE: boolean;
  44207. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44208. MAINUV1: boolean;
  44209. _areTexturesDirty: boolean;
  44210. _needUVs: boolean;
  44211. }
  44212. /**
  44213. * Define the code related to the anisotropic parameters of the pbr material.
  44214. */
  44215. export class PBRAnisotropicConfiguration {
  44216. private _isEnabled;
  44217. /**
  44218. * Defines if the anisotropy is enabled in the material.
  44219. */
  44220. isEnabled: boolean;
  44221. /**
  44222. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44223. */
  44224. intensity: number;
  44225. /**
  44226. * Defines if the effect is along the tangents, bitangents or in between.
  44227. * By default, the effect is "strectching" the highlights along the tangents.
  44228. */
  44229. direction: Vector2;
  44230. private _texture;
  44231. /**
  44232. * Stores the anisotropy values in a texture.
  44233. * rg is direction (like normal from -1 to 1)
  44234. * b is a intensity
  44235. */
  44236. texture: Nullable<BaseTexture>;
  44237. /** @hidden */
  44238. private _internalMarkAllSubMeshesAsTexturesDirty;
  44239. /** @hidden */
  44240. _markAllSubMeshesAsTexturesDirty(): void;
  44241. /**
  44242. * Instantiate a new istance of anisotropy configuration.
  44243. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44244. */
  44245. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44246. /**
  44247. * Specifies that the submesh is ready to be used.
  44248. * @param defines the list of "defines" to update.
  44249. * @param scene defines the scene the material belongs to.
  44250. * @returns - boolean indicating that the submesh is ready or not.
  44251. */
  44252. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44253. /**
  44254. * Checks to see if a texture is used in the material.
  44255. * @param defines the list of "defines" to update.
  44256. * @param mesh the mesh we are preparing the defines for.
  44257. * @param scene defines the scene the material belongs to.
  44258. */
  44259. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44260. /**
  44261. * Binds the material data.
  44262. * @param uniformBuffer defines the Uniform buffer to fill in.
  44263. * @param scene defines the scene the material belongs to.
  44264. * @param isFrozen defines wether the material is frozen or not.
  44265. */
  44266. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44267. /**
  44268. * Checks to see if a texture is used in the material.
  44269. * @param texture - Base texture to use.
  44270. * @returns - Boolean specifying if a texture is used in the material.
  44271. */
  44272. hasTexture(texture: BaseTexture): boolean;
  44273. /**
  44274. * Returns an array of the actively used textures.
  44275. * @param activeTextures Array of BaseTextures
  44276. */
  44277. getActiveTextures(activeTextures: BaseTexture[]): void;
  44278. /**
  44279. * Returns the animatable textures.
  44280. * @param animatables Array of animatable textures.
  44281. */
  44282. getAnimatables(animatables: IAnimatable[]): void;
  44283. /**
  44284. * Disposes the resources of the material.
  44285. * @param forceDisposeTextures - Forces the disposal of all textures.
  44286. */
  44287. dispose(forceDisposeTextures?: boolean): void;
  44288. /**
  44289. * Get the current class name of the texture useful for serialization or dynamic coding.
  44290. * @returns "PBRAnisotropicConfiguration"
  44291. */
  44292. getClassName(): string;
  44293. /**
  44294. * Add fallbacks to the effect fallbacks list.
  44295. * @param defines defines the Base texture to use.
  44296. * @param fallbacks defines the current fallback list.
  44297. * @param currentRank defines the current fallback rank.
  44298. * @returns the new fallback rank.
  44299. */
  44300. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44301. /**
  44302. * Add the required uniforms to the current list.
  44303. * @param uniforms defines the current uniform list.
  44304. */
  44305. static AddUniforms(uniforms: string[]): void;
  44306. /**
  44307. * Add the required uniforms to the current buffer.
  44308. * @param uniformBuffer defines the current uniform buffer.
  44309. */
  44310. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44311. /**
  44312. * Add the required samplers to the current list.
  44313. * @param samplers defines the current sampler list.
  44314. */
  44315. static AddSamplers(samplers: string[]): void;
  44316. /**
  44317. * Makes a duplicate of the current configuration into another one.
  44318. * @param anisotropicConfiguration define the config where to copy the info
  44319. */
  44320. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44321. /**
  44322. * Serializes this anisotropy configuration.
  44323. * @returns - An object with the serialized config.
  44324. */
  44325. serialize(): any;
  44326. /**
  44327. * Parses a anisotropy Configuration from a serialized object.
  44328. * @param source - Serialized object.
  44329. */
  44330. parse(source: any): void;
  44331. }
  44332. }
  44333. declare module BABYLON {
  44334. /**
  44335. * @hidden
  44336. */
  44337. export interface IMaterialBRDFDefines {
  44338. BRDF_V_HEIGHT_CORRELATED: boolean;
  44339. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44340. SPHERICAL_HARMONICS: boolean;
  44341. /** @hidden */
  44342. _areMiscDirty: boolean;
  44343. }
  44344. /**
  44345. * Define the code related to the BRDF parameters of the pbr material.
  44346. */
  44347. export class PBRBRDFConfiguration {
  44348. /**
  44349. * Default value used for the energy conservation.
  44350. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44351. */
  44352. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  44353. /**
  44354. * Default value used for the Smith Visibility Height Correlated mode.
  44355. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44356. */
  44357. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  44358. /**
  44359. * Default value used for the IBL diffuse part.
  44360. * This can help switching back to the polynomials mode globally which is a tiny bit
  44361. * less GPU intensive at the drawback of a lower quality.
  44362. */
  44363. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  44364. private _useEnergyConservation;
  44365. /**
  44366. * Defines if the material uses energy conservation.
  44367. */
  44368. useEnergyConservation: boolean;
  44369. private _useSmithVisibilityHeightCorrelated;
  44370. /**
  44371. * LEGACY Mode set to false
  44372. * Defines if the material uses height smith correlated visibility term.
  44373. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44374. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44375. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44376. * Not relying on height correlated will also disable energy conservation.
  44377. */
  44378. useSmithVisibilityHeightCorrelated: boolean;
  44379. private _useSphericalHarmonics;
  44380. /**
  44381. * LEGACY Mode set to false
  44382. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  44383. * diffuse part of the IBL.
  44384. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  44385. * to the ground truth.
  44386. */
  44387. useSphericalHarmonics: boolean;
  44388. /** @hidden */
  44389. private _internalMarkAllSubMeshesAsMiscDirty;
  44390. /** @hidden */
  44391. _markAllSubMeshesAsMiscDirty(): void;
  44392. /**
  44393. * Instantiate a new istance of clear coat configuration.
  44394. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44395. */
  44396. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44397. /**
  44398. * Checks to see if a texture is used in the material.
  44399. * @param defines the list of "defines" to update.
  44400. */
  44401. prepareDefines(defines: IMaterialBRDFDefines): void;
  44402. /**
  44403. * Get the current class name of the texture useful for serialization or dynamic coding.
  44404. * @returns "PBRClearCoatConfiguration"
  44405. */
  44406. getClassName(): string;
  44407. /**
  44408. * Makes a duplicate of the current configuration into another one.
  44409. * @param brdfConfiguration define the config where to copy the info
  44410. */
  44411. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44412. /**
  44413. * Serializes this BRDF configuration.
  44414. * @returns - An object with the serialized config.
  44415. */
  44416. serialize(): any;
  44417. /**
  44418. * Parses a BRDF Configuration from a serialized object.
  44419. * @param source - Serialized object.
  44420. */
  44421. parse(source: any): void;
  44422. }
  44423. }
  44424. declare module BABYLON {
  44425. /**
  44426. * @hidden
  44427. */
  44428. export interface IMaterialSheenDefines {
  44429. SHEEN: boolean;
  44430. SHEEN_TEXTURE: boolean;
  44431. SHEEN_TEXTUREDIRECTUV: number;
  44432. SHEEN_LINKWITHALBEDO: boolean;
  44433. /** @hidden */
  44434. _areTexturesDirty: boolean;
  44435. }
  44436. /**
  44437. * Define the code related to the Sheen parameters of the pbr material.
  44438. */
  44439. export class PBRSheenConfiguration {
  44440. private _isEnabled;
  44441. /**
  44442. * Defines if the material uses sheen.
  44443. */
  44444. isEnabled: boolean;
  44445. private _linkSheenWithAlbedo;
  44446. /**
  44447. * Defines if the sheen is linked to the sheen color.
  44448. */
  44449. linkSheenWithAlbedo: boolean;
  44450. /**
  44451. * Defines the sheen intensity.
  44452. */
  44453. intensity: number;
  44454. /**
  44455. * Defines the sheen color.
  44456. */
  44457. color: Color3;
  44458. private _texture;
  44459. /**
  44460. * Stores the sheen tint values in a texture.
  44461. * rgb is tint
  44462. * a is a intensity
  44463. */
  44464. texture: Nullable<BaseTexture>;
  44465. /** @hidden */
  44466. private _internalMarkAllSubMeshesAsTexturesDirty;
  44467. /** @hidden */
  44468. _markAllSubMeshesAsTexturesDirty(): void;
  44469. /**
  44470. * Instantiate a new istance of clear coat configuration.
  44471. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44472. */
  44473. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44474. /**
  44475. * Specifies that the submesh is ready to be used.
  44476. * @param defines the list of "defines" to update.
  44477. * @param scene defines the scene the material belongs to.
  44478. * @returns - boolean indicating that the submesh is ready or not.
  44479. */
  44480. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44481. /**
  44482. * Checks to see if a texture is used in the material.
  44483. * @param defines the list of "defines" to update.
  44484. * @param scene defines the scene the material belongs to.
  44485. */
  44486. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44487. /**
  44488. * Binds the material data.
  44489. * @param uniformBuffer defines the Uniform buffer to fill in.
  44490. * @param scene defines the scene the material belongs to.
  44491. * @param isFrozen defines wether the material is frozen or not.
  44492. */
  44493. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44494. /**
  44495. * Checks to see if a texture is used in the material.
  44496. * @param texture - Base texture to use.
  44497. * @returns - Boolean specifying if a texture is used in the material.
  44498. */
  44499. hasTexture(texture: BaseTexture): boolean;
  44500. /**
  44501. * Returns an array of the actively used textures.
  44502. * @param activeTextures Array of BaseTextures
  44503. */
  44504. getActiveTextures(activeTextures: BaseTexture[]): void;
  44505. /**
  44506. * Returns the animatable textures.
  44507. * @param animatables Array of animatable textures.
  44508. */
  44509. getAnimatables(animatables: IAnimatable[]): void;
  44510. /**
  44511. * Disposes the resources of the material.
  44512. * @param forceDisposeTextures - Forces the disposal of all textures.
  44513. */
  44514. dispose(forceDisposeTextures?: boolean): void;
  44515. /**
  44516. * Get the current class name of the texture useful for serialization or dynamic coding.
  44517. * @returns "PBRSheenConfiguration"
  44518. */
  44519. getClassName(): string;
  44520. /**
  44521. * Add fallbacks to the effect fallbacks list.
  44522. * @param defines defines the Base texture to use.
  44523. * @param fallbacks defines the current fallback list.
  44524. * @param currentRank defines the current fallback rank.
  44525. * @returns the new fallback rank.
  44526. */
  44527. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44528. /**
  44529. * Add the required uniforms to the current list.
  44530. * @param uniforms defines the current uniform list.
  44531. */
  44532. static AddUniforms(uniforms: string[]): void;
  44533. /**
  44534. * Add the required uniforms to the current buffer.
  44535. * @param uniformBuffer defines the current uniform buffer.
  44536. */
  44537. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44538. /**
  44539. * Add the required samplers to the current list.
  44540. * @param samplers defines the current sampler list.
  44541. */
  44542. static AddSamplers(samplers: string[]): void;
  44543. /**
  44544. * Makes a duplicate of the current configuration into another one.
  44545. * @param sheenConfiguration define the config where to copy the info
  44546. */
  44547. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44548. /**
  44549. * Serializes this BRDF configuration.
  44550. * @returns - An object with the serialized config.
  44551. */
  44552. serialize(): any;
  44553. /**
  44554. * Parses a Sheen Configuration from a serialized object.
  44555. * @param source - Serialized object.
  44556. */
  44557. parse(source: any): void;
  44558. }
  44559. }
  44560. declare module BABYLON {
  44561. /**
  44562. * @hidden
  44563. */
  44564. export interface IMaterialSubSurfaceDefines {
  44565. SUBSURFACE: boolean;
  44566. SS_REFRACTION: boolean;
  44567. SS_TRANSLUCENCY: boolean;
  44568. SS_SCATERRING: boolean;
  44569. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44570. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44571. SS_REFRACTIONMAP_3D: boolean;
  44572. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44573. SS_LODINREFRACTIONALPHA: boolean;
  44574. SS_GAMMAREFRACTION: boolean;
  44575. SS_RGBDREFRACTION: boolean;
  44576. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44577. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44578. /** @hidden */
  44579. _areTexturesDirty: boolean;
  44580. }
  44581. /**
  44582. * Define the code related to the sub surface parameters of the pbr material.
  44583. */
  44584. export class PBRSubSurfaceConfiguration {
  44585. private _isRefractionEnabled;
  44586. /**
  44587. * Defines if the refraction is enabled in the material.
  44588. */
  44589. isRefractionEnabled: boolean;
  44590. private _isTranslucencyEnabled;
  44591. /**
  44592. * Defines if the translucency is enabled in the material.
  44593. */
  44594. isTranslucencyEnabled: boolean;
  44595. private _isScatteringEnabled;
  44596. /**
  44597. * Defines the refraction intensity of the material.
  44598. * The refraction when enabled replaces the Diffuse part of the material.
  44599. * The intensity helps transitionning between diffuse and refraction.
  44600. */
  44601. refractionIntensity: number;
  44602. /**
  44603. * Defines the translucency intensity of the material.
  44604. * When translucency has been enabled, this defines how much of the "translucency"
  44605. * is addded to the diffuse part of the material.
  44606. */
  44607. translucencyIntensity: number;
  44608. /**
  44609. * Defines the scattering intensity of the material.
  44610. * When scattering has been enabled, this defines how much of the "scattered light"
  44611. * is addded to the diffuse part of the material.
  44612. */
  44613. scatteringIntensity: number;
  44614. private _thicknessTexture;
  44615. /**
  44616. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  44617. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  44618. * 0 would mean minimumThickness
  44619. * 1 would mean maximumThickness
  44620. * The other channels might be use as a mask to vary the different effects intensity.
  44621. */
  44622. thicknessTexture: Nullable<BaseTexture>;
  44623. private _refractionTexture;
  44624. /**
  44625. * Defines the texture to use for refraction.
  44626. */
  44627. refractionTexture: Nullable<BaseTexture>;
  44628. private _indexOfRefraction;
  44629. /**
  44630. * Defines the indice of refraction used in the material.
  44631. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  44632. */
  44633. indexOfRefraction: number;
  44634. private _invertRefractionY;
  44635. /**
  44636. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44637. */
  44638. invertRefractionY: boolean;
  44639. private _linkRefractionWithTransparency;
  44640. /**
  44641. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44642. * Materials half opaque for instance using refraction could benefit from this control.
  44643. */
  44644. linkRefractionWithTransparency: boolean;
  44645. /**
  44646. * Defines the minimum thickness stored in the thickness map.
  44647. * If no thickness map is defined, this value will be used to simulate thickness.
  44648. */
  44649. minimumThickness: number;
  44650. /**
  44651. * Defines the maximum thickness stored in the thickness map.
  44652. */
  44653. maximumThickness: number;
  44654. /**
  44655. * Defines the volume tint of the material.
  44656. * This is used for both translucency and scattering.
  44657. */
  44658. tintColor: Color3;
  44659. /**
  44660. * Defines the distance at which the tint color should be found in the media.
  44661. * This is used for refraction only.
  44662. */
  44663. tintColorAtDistance: number;
  44664. /**
  44665. * Defines how far each channel transmit through the media.
  44666. * It is defined as a color to simplify it selection.
  44667. */
  44668. diffusionDistance: Color3;
  44669. private _useMaskFromThicknessTexture;
  44670. /**
  44671. * Stores the intensity of the different subsurface effects in the thickness texture.
  44672. * * the green channel is the translucency intensity.
  44673. * * the blue channel is the scattering intensity.
  44674. * * the alpha channel is the refraction intensity.
  44675. */
  44676. useMaskFromThicknessTexture: boolean;
  44677. /** @hidden */
  44678. private _internalMarkAllSubMeshesAsTexturesDirty;
  44679. /** @hidden */
  44680. _markAllSubMeshesAsTexturesDirty(): void;
  44681. /**
  44682. * Instantiate a new istance of sub surface configuration.
  44683. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44684. */
  44685. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44686. /**
  44687. * Gets wehter the submesh is ready to be used or not.
  44688. * @param defines the list of "defines" to update.
  44689. * @param scene defines the scene the material belongs to.
  44690. * @returns - boolean indicating that the submesh is ready or not.
  44691. */
  44692. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  44693. /**
  44694. * Checks to see if a texture is used in the material.
  44695. * @param defines the list of "defines" to update.
  44696. * @param scene defines the scene to the material belongs to.
  44697. */
  44698. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  44699. /**
  44700. * Binds the material data.
  44701. * @param uniformBuffer defines the Uniform buffer to fill in.
  44702. * @param scene defines the scene the material belongs to.
  44703. * @param engine defines the engine the material belongs to.
  44704. * @param isFrozen defines wether the material is frozen or not.
  44705. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  44706. */
  44707. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  44708. /**
  44709. * Unbinds the material from the mesh.
  44710. * @param activeEffect defines the effect that should be unbound from.
  44711. * @returns true if unbound, otherwise false
  44712. */
  44713. unbind(activeEffect: Effect): boolean;
  44714. /**
  44715. * Returns the texture used for refraction or null if none is used.
  44716. * @param scene defines the scene the material belongs to.
  44717. * @returns - Refraction texture if present. If no refraction texture and refraction
  44718. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44719. */
  44720. private _getRefractionTexture;
  44721. /**
  44722. * Returns true if alpha blending should be disabled.
  44723. */
  44724. readonly disableAlphaBlending: boolean;
  44725. /**
  44726. * Fills the list of render target textures.
  44727. * @param renderTargets the list of render targets to update
  44728. */
  44729. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  44730. /**
  44731. * Checks to see if a texture is used in the material.
  44732. * @param texture - Base texture to use.
  44733. * @returns - Boolean specifying if a texture is used in the material.
  44734. */
  44735. hasTexture(texture: BaseTexture): boolean;
  44736. /**
  44737. * Gets a boolean indicating that current material needs to register RTT
  44738. * @returns true if this uses a render target otherwise false.
  44739. */
  44740. hasRenderTargetTextures(): boolean;
  44741. /**
  44742. * Returns an array of the actively used textures.
  44743. * @param activeTextures Array of BaseTextures
  44744. */
  44745. getActiveTextures(activeTextures: BaseTexture[]): void;
  44746. /**
  44747. * Returns the animatable textures.
  44748. * @param animatables Array of animatable textures.
  44749. */
  44750. getAnimatables(animatables: IAnimatable[]): void;
  44751. /**
  44752. * Disposes the resources of the material.
  44753. * @param forceDisposeTextures - Forces the disposal of all textures.
  44754. */
  44755. dispose(forceDisposeTextures?: boolean): void;
  44756. /**
  44757. * Get the current class name of the texture useful for serialization or dynamic coding.
  44758. * @returns "PBRSubSurfaceConfiguration"
  44759. */
  44760. getClassName(): string;
  44761. /**
  44762. * Add fallbacks to the effect fallbacks list.
  44763. * @param defines defines the Base texture to use.
  44764. * @param fallbacks defines the current fallback list.
  44765. * @param currentRank defines the current fallback rank.
  44766. * @returns the new fallback rank.
  44767. */
  44768. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44769. /**
  44770. * Add the required uniforms to the current list.
  44771. * @param uniforms defines the current uniform list.
  44772. */
  44773. static AddUniforms(uniforms: string[]): void;
  44774. /**
  44775. * Add the required samplers to the current list.
  44776. * @param samplers defines the current sampler list.
  44777. */
  44778. static AddSamplers(samplers: string[]): void;
  44779. /**
  44780. * Add the required uniforms to the current buffer.
  44781. * @param uniformBuffer defines the current uniform buffer.
  44782. */
  44783. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44784. /**
  44785. * Makes a duplicate of the current configuration into another one.
  44786. * @param configuration define the config where to copy the info
  44787. */
  44788. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  44789. /**
  44790. * Serializes this Sub Surface configuration.
  44791. * @returns - An object with the serialized config.
  44792. */
  44793. serialize(): any;
  44794. /**
  44795. * Parses a Sub Surface Configuration from a serialized object.
  44796. * @param source - Serialized object.
  44797. */
  44798. parse(source: any): void;
  44799. }
  44800. }
  44801. declare module BABYLON {
  44802. /** @hidden */
  44803. export var pbrFragmentDeclaration: {
  44804. name: string;
  44805. shader: string;
  44806. };
  44807. }
  44808. declare module BABYLON {
  44809. /** @hidden */
  44810. export var pbrUboDeclaration: {
  44811. name: string;
  44812. shader: string;
  44813. };
  44814. }
  44815. declare module BABYLON {
  44816. /** @hidden */
  44817. export var pbrFragmentExtraDeclaration: {
  44818. name: string;
  44819. shader: string;
  44820. };
  44821. }
  44822. declare module BABYLON {
  44823. /** @hidden */
  44824. export var pbrFragmentSamplersDeclaration: {
  44825. name: string;
  44826. shader: string;
  44827. };
  44828. }
  44829. declare module BABYLON {
  44830. /** @hidden */
  44831. export var pbrHelperFunctions: {
  44832. name: string;
  44833. shader: string;
  44834. };
  44835. }
  44836. declare module BABYLON {
  44837. /** @hidden */
  44838. export var harmonicsFunctions: {
  44839. name: string;
  44840. shader: string;
  44841. };
  44842. }
  44843. declare module BABYLON {
  44844. /** @hidden */
  44845. export var pbrDirectLightingSetupFunctions: {
  44846. name: string;
  44847. shader: string;
  44848. };
  44849. }
  44850. declare module BABYLON {
  44851. /** @hidden */
  44852. export var pbrDirectLightingFalloffFunctions: {
  44853. name: string;
  44854. shader: string;
  44855. };
  44856. }
  44857. declare module BABYLON {
  44858. /** @hidden */
  44859. export var pbrBRDFFunctions: {
  44860. name: string;
  44861. shader: string;
  44862. };
  44863. }
  44864. declare module BABYLON {
  44865. /** @hidden */
  44866. export var pbrDirectLightingFunctions: {
  44867. name: string;
  44868. shader: string;
  44869. };
  44870. }
  44871. declare module BABYLON {
  44872. /** @hidden */
  44873. export var pbrIBLFunctions: {
  44874. name: string;
  44875. shader: string;
  44876. };
  44877. }
  44878. declare module BABYLON {
  44879. /** @hidden */
  44880. export var pbrDebug: {
  44881. name: string;
  44882. shader: string;
  44883. };
  44884. }
  44885. declare module BABYLON {
  44886. /** @hidden */
  44887. export var pbrPixelShader: {
  44888. name: string;
  44889. shader: string;
  44890. };
  44891. }
  44892. declare module BABYLON {
  44893. /** @hidden */
  44894. export var pbrVertexDeclaration: {
  44895. name: string;
  44896. shader: string;
  44897. };
  44898. }
  44899. declare module BABYLON {
  44900. /** @hidden */
  44901. export var pbrVertexShader: {
  44902. name: string;
  44903. shader: string;
  44904. };
  44905. }
  44906. declare module BABYLON {
  44907. /**
  44908. * Manages the defines for the PBR Material.
  44909. * @hidden
  44910. */
  44911. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  44912. PBR: boolean;
  44913. MAINUV1: boolean;
  44914. MAINUV2: boolean;
  44915. UV1: boolean;
  44916. UV2: boolean;
  44917. ALBEDO: boolean;
  44918. ALBEDODIRECTUV: number;
  44919. VERTEXCOLOR: boolean;
  44920. AMBIENT: boolean;
  44921. AMBIENTDIRECTUV: number;
  44922. AMBIENTINGRAYSCALE: boolean;
  44923. OPACITY: boolean;
  44924. VERTEXALPHA: boolean;
  44925. OPACITYDIRECTUV: number;
  44926. OPACITYRGB: boolean;
  44927. ALPHATEST: boolean;
  44928. DEPTHPREPASS: boolean;
  44929. ALPHABLEND: boolean;
  44930. ALPHAFROMALBEDO: boolean;
  44931. ALPHATESTVALUE: string;
  44932. SPECULAROVERALPHA: boolean;
  44933. RADIANCEOVERALPHA: boolean;
  44934. ALPHAFRESNEL: boolean;
  44935. LINEARALPHAFRESNEL: boolean;
  44936. PREMULTIPLYALPHA: boolean;
  44937. EMISSIVE: boolean;
  44938. EMISSIVEDIRECTUV: number;
  44939. REFLECTIVITY: boolean;
  44940. REFLECTIVITYDIRECTUV: number;
  44941. SPECULARTERM: boolean;
  44942. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  44943. MICROSURFACEAUTOMATIC: boolean;
  44944. LODBASEDMICROSFURACE: boolean;
  44945. MICROSURFACEMAP: boolean;
  44946. MICROSURFACEMAPDIRECTUV: number;
  44947. METALLICWORKFLOW: boolean;
  44948. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  44949. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  44950. METALLNESSSTOREINMETALMAPBLUE: boolean;
  44951. AOSTOREINMETALMAPRED: boolean;
  44952. ENVIRONMENTBRDF: boolean;
  44953. ENVIRONMENTBRDF_RGBD: boolean;
  44954. NORMAL: boolean;
  44955. TANGENT: boolean;
  44956. BUMP: boolean;
  44957. BUMPDIRECTUV: number;
  44958. OBJECTSPACE_NORMALMAP: boolean;
  44959. PARALLAX: boolean;
  44960. PARALLAXOCCLUSION: boolean;
  44961. NORMALXYSCALE: boolean;
  44962. LIGHTMAP: boolean;
  44963. LIGHTMAPDIRECTUV: number;
  44964. USELIGHTMAPASSHADOWMAP: boolean;
  44965. GAMMALIGHTMAP: boolean;
  44966. REFLECTION: boolean;
  44967. REFLECTIONMAP_3D: boolean;
  44968. REFLECTIONMAP_SPHERICAL: boolean;
  44969. REFLECTIONMAP_PLANAR: boolean;
  44970. REFLECTIONMAP_CUBIC: boolean;
  44971. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  44972. REFLECTIONMAP_PROJECTION: boolean;
  44973. REFLECTIONMAP_SKYBOX: boolean;
  44974. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  44975. REFLECTIONMAP_EXPLICIT: boolean;
  44976. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  44977. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  44978. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  44979. INVERTCUBICMAP: boolean;
  44980. USESPHERICALFROMREFLECTIONMAP: boolean;
  44981. SPHERICAL_HARMONICS: boolean;
  44982. USESPHERICALINVERTEX: boolean;
  44983. REFLECTIONMAP_OPPOSITEZ: boolean;
  44984. LODINREFLECTIONALPHA: boolean;
  44985. GAMMAREFLECTION: boolean;
  44986. RGBDREFLECTION: boolean;
  44987. RADIANCEOCCLUSION: boolean;
  44988. HORIZONOCCLUSION: boolean;
  44989. INSTANCES: boolean;
  44990. NUM_BONE_INFLUENCERS: number;
  44991. BonesPerMesh: number;
  44992. BONETEXTURE: boolean;
  44993. NONUNIFORMSCALING: boolean;
  44994. MORPHTARGETS: boolean;
  44995. MORPHTARGETS_NORMAL: boolean;
  44996. MORPHTARGETS_TANGENT: boolean;
  44997. NUM_MORPH_INFLUENCERS: number;
  44998. IMAGEPROCESSING: boolean;
  44999. VIGNETTE: boolean;
  45000. VIGNETTEBLENDMODEMULTIPLY: boolean;
  45001. VIGNETTEBLENDMODEOPAQUE: boolean;
  45002. TONEMAPPING: boolean;
  45003. TONEMAPPING_ACES: boolean;
  45004. CONTRAST: boolean;
  45005. COLORCURVES: boolean;
  45006. COLORGRADING: boolean;
  45007. COLORGRADING3D: boolean;
  45008. SAMPLER3DGREENDEPTH: boolean;
  45009. SAMPLER3DBGRMAP: boolean;
  45010. IMAGEPROCESSINGPOSTPROCESS: boolean;
  45011. EXPOSURE: boolean;
  45012. MULTIVIEW: boolean;
  45013. USEPHYSICALLIGHTFALLOFF: boolean;
  45014. USEGLTFLIGHTFALLOFF: boolean;
  45015. TWOSIDEDLIGHTING: boolean;
  45016. SHADOWFLOAT: boolean;
  45017. CLIPPLANE: boolean;
  45018. CLIPPLANE2: boolean;
  45019. CLIPPLANE3: boolean;
  45020. CLIPPLANE4: boolean;
  45021. POINTSIZE: boolean;
  45022. FOG: boolean;
  45023. LOGARITHMICDEPTH: boolean;
  45024. FORCENORMALFORWARD: boolean;
  45025. SPECULARAA: boolean;
  45026. CLEARCOAT: boolean;
  45027. CLEARCOAT_DEFAULTIOR: boolean;
  45028. CLEARCOAT_TEXTURE: boolean;
  45029. CLEARCOAT_TEXTUREDIRECTUV: number;
  45030. CLEARCOAT_BUMP: boolean;
  45031. CLEARCOAT_BUMPDIRECTUV: number;
  45032. CLEARCOAT_TINT: boolean;
  45033. CLEARCOAT_TINT_TEXTURE: boolean;
  45034. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45035. ANISOTROPIC: boolean;
  45036. ANISOTROPIC_TEXTURE: boolean;
  45037. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45038. BRDF_V_HEIGHT_CORRELATED: boolean;
  45039. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45040. SHEEN: boolean;
  45041. SHEEN_TEXTURE: boolean;
  45042. SHEEN_TEXTUREDIRECTUV: number;
  45043. SHEEN_LINKWITHALBEDO: boolean;
  45044. SUBSURFACE: boolean;
  45045. SS_REFRACTION: boolean;
  45046. SS_TRANSLUCENCY: boolean;
  45047. SS_SCATERRING: boolean;
  45048. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45049. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45050. SS_REFRACTIONMAP_3D: boolean;
  45051. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45052. SS_LODINREFRACTIONALPHA: boolean;
  45053. SS_GAMMAREFRACTION: boolean;
  45054. SS_RGBDREFRACTION: boolean;
  45055. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45056. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45057. UNLIT: boolean;
  45058. DEBUGMODE: number;
  45059. /**
  45060. * Initializes the PBR Material defines.
  45061. */
  45062. constructor();
  45063. /**
  45064. * Resets the PBR Material defines.
  45065. */
  45066. reset(): void;
  45067. }
  45068. /**
  45069. * The Physically based material base class of BJS.
  45070. *
  45071. * This offers the main features of a standard PBR material.
  45072. * For more information, please refer to the documentation :
  45073. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45074. */
  45075. export abstract class PBRBaseMaterial extends PushMaterial {
  45076. /**
  45077. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45078. */
  45079. static readonly PBRMATERIAL_OPAQUE: number;
  45080. /**
  45081. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45082. */
  45083. static readonly PBRMATERIAL_ALPHATEST: number;
  45084. /**
  45085. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45086. */
  45087. static readonly PBRMATERIAL_ALPHABLEND: number;
  45088. /**
  45089. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45090. * They are also discarded below the alpha cutoff threshold to improve performances.
  45091. */
  45092. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45093. /**
  45094. * Defines the default value of how much AO map is occluding the analytical lights
  45095. * (point spot...).
  45096. */
  45097. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45098. /**
  45099. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45100. */
  45101. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45102. /**
  45103. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45104. * to enhance interoperability with other engines.
  45105. */
  45106. static readonly LIGHTFALLOFF_GLTF: number;
  45107. /**
  45108. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45109. * to enhance interoperability with other materials.
  45110. */
  45111. static readonly LIGHTFALLOFF_STANDARD: number;
  45112. /**
  45113. * Intensity of the direct lights e.g. the four lights available in your scene.
  45114. * This impacts both the direct diffuse and specular highlights.
  45115. */
  45116. protected _directIntensity: number;
  45117. /**
  45118. * Intensity of the emissive part of the material.
  45119. * This helps controlling the emissive effect without modifying the emissive color.
  45120. */
  45121. protected _emissiveIntensity: number;
  45122. /**
  45123. * Intensity of the environment e.g. how much the environment will light the object
  45124. * either through harmonics for rough material or through the refelction for shiny ones.
  45125. */
  45126. protected _environmentIntensity: number;
  45127. /**
  45128. * This is a special control allowing the reduction of the specular highlights coming from the
  45129. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45130. */
  45131. protected _specularIntensity: number;
  45132. /**
  45133. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45134. */
  45135. private _lightingInfos;
  45136. /**
  45137. * Debug Control allowing disabling the bump map on this material.
  45138. */
  45139. protected _disableBumpMap: boolean;
  45140. /**
  45141. * AKA Diffuse Texture in standard nomenclature.
  45142. */
  45143. protected _albedoTexture: Nullable<BaseTexture>;
  45144. /**
  45145. * AKA Occlusion Texture in other nomenclature.
  45146. */
  45147. protected _ambientTexture: Nullable<BaseTexture>;
  45148. /**
  45149. * AKA Occlusion Texture Intensity in other nomenclature.
  45150. */
  45151. protected _ambientTextureStrength: number;
  45152. /**
  45153. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45154. * 1 means it completely occludes it
  45155. * 0 mean it has no impact
  45156. */
  45157. protected _ambientTextureImpactOnAnalyticalLights: number;
  45158. /**
  45159. * Stores the alpha values in a texture.
  45160. */
  45161. protected _opacityTexture: Nullable<BaseTexture>;
  45162. /**
  45163. * Stores the reflection values in a texture.
  45164. */
  45165. protected _reflectionTexture: Nullable<BaseTexture>;
  45166. /**
  45167. * Stores the emissive values in a texture.
  45168. */
  45169. protected _emissiveTexture: Nullable<BaseTexture>;
  45170. /**
  45171. * AKA Specular texture in other nomenclature.
  45172. */
  45173. protected _reflectivityTexture: Nullable<BaseTexture>;
  45174. /**
  45175. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45176. */
  45177. protected _metallicTexture: Nullable<BaseTexture>;
  45178. /**
  45179. * Specifies the metallic scalar of the metallic/roughness workflow.
  45180. * Can also be used to scale the metalness values of the metallic texture.
  45181. */
  45182. protected _metallic: Nullable<number>;
  45183. /**
  45184. * Specifies the roughness scalar of the metallic/roughness workflow.
  45185. * Can also be used to scale the roughness values of the metallic texture.
  45186. */
  45187. protected _roughness: Nullable<number>;
  45188. /**
  45189. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45190. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45191. */
  45192. protected _microSurfaceTexture: Nullable<BaseTexture>;
  45193. /**
  45194. * Stores surface normal data used to displace a mesh in a texture.
  45195. */
  45196. protected _bumpTexture: Nullable<BaseTexture>;
  45197. /**
  45198. * Stores the pre-calculated light information of a mesh in a texture.
  45199. */
  45200. protected _lightmapTexture: Nullable<BaseTexture>;
  45201. /**
  45202. * The color of a material in ambient lighting.
  45203. */
  45204. protected _ambientColor: Color3;
  45205. /**
  45206. * AKA Diffuse Color in other nomenclature.
  45207. */
  45208. protected _albedoColor: Color3;
  45209. /**
  45210. * AKA Specular Color in other nomenclature.
  45211. */
  45212. protected _reflectivityColor: Color3;
  45213. /**
  45214. * The color applied when light is reflected from a material.
  45215. */
  45216. protected _reflectionColor: Color3;
  45217. /**
  45218. * The color applied when light is emitted from a material.
  45219. */
  45220. protected _emissiveColor: Color3;
  45221. /**
  45222. * AKA Glossiness in other nomenclature.
  45223. */
  45224. protected _microSurface: number;
  45225. /**
  45226. * Specifies that the material will use the light map as a show map.
  45227. */
  45228. protected _useLightmapAsShadowmap: boolean;
  45229. /**
  45230. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45231. * makes the reflect vector face the model (under horizon).
  45232. */
  45233. protected _useHorizonOcclusion: boolean;
  45234. /**
  45235. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45236. * too much the area relying on ambient texture to define their ambient occlusion.
  45237. */
  45238. protected _useRadianceOcclusion: boolean;
  45239. /**
  45240. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45241. */
  45242. protected _useAlphaFromAlbedoTexture: boolean;
  45243. /**
  45244. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45245. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45246. */
  45247. protected _useSpecularOverAlpha: boolean;
  45248. /**
  45249. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45250. */
  45251. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45252. /**
  45253. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45254. */
  45255. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45256. /**
  45257. * Specifies if the metallic texture contains the roughness information in its green channel.
  45258. */
  45259. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45260. /**
  45261. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45262. */
  45263. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45264. /**
  45265. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45266. */
  45267. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45268. /**
  45269. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45270. */
  45271. protected _useAmbientInGrayScale: boolean;
  45272. /**
  45273. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45274. * The material will try to infer what glossiness each pixel should be.
  45275. */
  45276. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45277. /**
  45278. * Defines the falloff type used in this material.
  45279. * It by default is Physical.
  45280. */
  45281. protected _lightFalloff: number;
  45282. /**
  45283. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45284. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45285. */
  45286. protected _useRadianceOverAlpha: boolean;
  45287. /**
  45288. * Allows using an object space normal map (instead of tangent space).
  45289. */
  45290. protected _useObjectSpaceNormalMap: boolean;
  45291. /**
  45292. * Allows using the bump map in parallax mode.
  45293. */
  45294. protected _useParallax: boolean;
  45295. /**
  45296. * Allows using the bump map in parallax occlusion mode.
  45297. */
  45298. protected _useParallaxOcclusion: boolean;
  45299. /**
  45300. * Controls the scale bias of the parallax mode.
  45301. */
  45302. protected _parallaxScaleBias: number;
  45303. /**
  45304. * If sets to true, disables all the lights affecting the material.
  45305. */
  45306. protected _disableLighting: boolean;
  45307. /**
  45308. * Number of Simultaneous lights allowed on the material.
  45309. */
  45310. protected _maxSimultaneousLights: number;
  45311. /**
  45312. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45313. */
  45314. protected _invertNormalMapX: boolean;
  45315. /**
  45316. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45317. */
  45318. protected _invertNormalMapY: boolean;
  45319. /**
  45320. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45321. */
  45322. protected _twoSidedLighting: boolean;
  45323. /**
  45324. * Defines the alpha limits in alpha test mode.
  45325. */
  45326. protected _alphaCutOff: number;
  45327. /**
  45328. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45329. */
  45330. protected _forceAlphaTest: boolean;
  45331. /**
  45332. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45333. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45334. */
  45335. protected _useAlphaFresnel: boolean;
  45336. /**
  45337. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45338. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45339. */
  45340. protected _useLinearAlphaFresnel: boolean;
  45341. /**
  45342. * The transparency mode of the material.
  45343. */
  45344. protected _transparencyMode: Nullable<number>;
  45345. /**
  45346. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45347. * from cos thetav and roughness:
  45348. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45349. */
  45350. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45351. /**
  45352. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45353. */
  45354. protected _forceIrradianceInFragment: boolean;
  45355. /**
  45356. * Force normal to face away from face.
  45357. */
  45358. protected _forceNormalForward: boolean;
  45359. /**
  45360. * Enables specular anti aliasing in the PBR shader.
  45361. * It will both interacts on the Geometry for analytical and IBL lighting.
  45362. * It also prefilter the roughness map based on the bump values.
  45363. */
  45364. protected _enableSpecularAntiAliasing: boolean;
  45365. /**
  45366. * Default configuration related to image processing available in the PBR Material.
  45367. */
  45368. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45369. /**
  45370. * Keep track of the image processing observer to allow dispose and replace.
  45371. */
  45372. private _imageProcessingObserver;
  45373. /**
  45374. * Attaches a new image processing configuration to the PBR Material.
  45375. * @param configuration
  45376. */
  45377. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45378. /**
  45379. * Stores the available render targets.
  45380. */
  45381. private _renderTargets;
  45382. /**
  45383. * Sets the global ambient color for the material used in lighting calculations.
  45384. */
  45385. private _globalAmbientColor;
  45386. /**
  45387. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45388. */
  45389. private _useLogarithmicDepth;
  45390. /**
  45391. * If set to true, no lighting calculations will be applied.
  45392. */
  45393. private _unlit;
  45394. private _debugMode;
  45395. /**
  45396. * @hidden
  45397. * This is reserved for the inspector.
  45398. * Defines the material debug mode.
  45399. * It helps seeing only some components of the material while troubleshooting.
  45400. */
  45401. debugMode: number;
  45402. /**
  45403. * @hidden
  45404. * This is reserved for the inspector.
  45405. * Specify from where on screen the debug mode should start.
  45406. * The value goes from -1 (full screen) to 1 (not visible)
  45407. * It helps with side by side comparison against the final render
  45408. * This defaults to -1
  45409. */
  45410. private debugLimit;
  45411. /**
  45412. * @hidden
  45413. * This is reserved for the inspector.
  45414. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45415. * You can use the factor to better multiply the final value.
  45416. */
  45417. private debugFactor;
  45418. /**
  45419. * Defines the clear coat layer parameters for the material.
  45420. */
  45421. readonly clearCoat: PBRClearCoatConfiguration;
  45422. /**
  45423. * Defines the anisotropic parameters for the material.
  45424. */
  45425. readonly anisotropy: PBRAnisotropicConfiguration;
  45426. /**
  45427. * Defines the BRDF parameters for the material.
  45428. */
  45429. readonly brdf: PBRBRDFConfiguration;
  45430. /**
  45431. * Defines the Sheen parameters for the material.
  45432. */
  45433. readonly sheen: PBRSheenConfiguration;
  45434. /**
  45435. * Defines the SubSurface parameters for the material.
  45436. */
  45437. readonly subSurface: PBRSubSurfaceConfiguration;
  45438. /**
  45439. * Custom callback helping to override the default shader used in the material.
  45440. */
  45441. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  45442. /**
  45443. * Instantiates a new PBRMaterial instance.
  45444. *
  45445. * @param name The material name
  45446. * @param scene The scene the material will be use in.
  45447. */
  45448. constructor(name: string, scene: Scene);
  45449. /**
  45450. * Gets a boolean indicating that current material needs to register RTT
  45451. */
  45452. readonly hasRenderTargetTextures: boolean;
  45453. /**
  45454. * Gets the name of the material class.
  45455. */
  45456. getClassName(): string;
  45457. /**
  45458. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45459. */
  45460. /**
  45461. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45462. */
  45463. useLogarithmicDepth: boolean;
  45464. /**
  45465. * Gets the current transparency mode.
  45466. */
  45467. /**
  45468. * Sets the transparency mode of the material.
  45469. *
  45470. * | Value | Type | Description |
  45471. * | ----- | ----------------------------------- | ----------- |
  45472. * | 0 | OPAQUE | |
  45473. * | 1 | ALPHATEST | |
  45474. * | 2 | ALPHABLEND | |
  45475. * | 3 | ALPHATESTANDBLEND | |
  45476. *
  45477. */
  45478. transparencyMode: Nullable<number>;
  45479. /**
  45480. * Returns true if alpha blending should be disabled.
  45481. */
  45482. private readonly _disableAlphaBlending;
  45483. /**
  45484. * Specifies whether or not this material should be rendered in alpha blend mode.
  45485. */
  45486. needAlphaBlending(): boolean;
  45487. /**
  45488. * Specifies if the mesh will require alpha blending.
  45489. * @param mesh - BJS mesh.
  45490. */
  45491. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45492. /**
  45493. * Specifies whether or not this material should be rendered in alpha test mode.
  45494. */
  45495. needAlphaTesting(): boolean;
  45496. /**
  45497. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45498. */
  45499. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45500. /**
  45501. * Gets the texture used for the alpha test.
  45502. */
  45503. getAlphaTestTexture(): Nullable<BaseTexture>;
  45504. /**
  45505. * Specifies that the submesh is ready to be used.
  45506. * @param mesh - BJS mesh.
  45507. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45508. * @param useInstances - Specifies that instances should be used.
  45509. * @returns - boolean indicating that the submesh is ready or not.
  45510. */
  45511. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45512. /**
  45513. * Specifies if the material uses metallic roughness workflow.
  45514. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45515. */
  45516. isMetallicWorkflow(): boolean;
  45517. private _prepareEffect;
  45518. private _prepareDefines;
  45519. /**
  45520. * Force shader compilation
  45521. */
  45522. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45523. clipPlane: boolean;
  45524. }>): void;
  45525. /**
  45526. * Initializes the uniform buffer layout for the shader.
  45527. */
  45528. buildUniformLayout(): void;
  45529. /**
  45530. * Unbinds the material from the mesh
  45531. */
  45532. unbind(): void;
  45533. /**
  45534. * Binds the submesh data.
  45535. * @param world - The world matrix.
  45536. * @param mesh - The BJS mesh.
  45537. * @param subMesh - A submesh of the BJS mesh.
  45538. */
  45539. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45540. /**
  45541. * Returns the animatable textures.
  45542. * @returns - Array of animatable textures.
  45543. */
  45544. getAnimatables(): IAnimatable[];
  45545. /**
  45546. * Returns the texture used for reflections.
  45547. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45548. */
  45549. private _getReflectionTexture;
  45550. /**
  45551. * Returns an array of the actively used textures.
  45552. * @returns - Array of BaseTextures
  45553. */
  45554. getActiveTextures(): BaseTexture[];
  45555. /**
  45556. * Checks to see if a texture is used in the material.
  45557. * @param texture - Base texture to use.
  45558. * @returns - Boolean specifying if a texture is used in the material.
  45559. */
  45560. hasTexture(texture: BaseTexture): boolean;
  45561. /**
  45562. * Disposes the resources of the material.
  45563. * @param forceDisposeEffect - Forces the disposal of effects.
  45564. * @param forceDisposeTextures - Forces the disposal of all textures.
  45565. */
  45566. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45567. }
  45568. }
  45569. declare module BABYLON {
  45570. /**
  45571. * The Physically based material of BJS.
  45572. *
  45573. * This offers the main features of a standard PBR material.
  45574. * For more information, please refer to the documentation :
  45575. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45576. */
  45577. export class PBRMaterial extends PBRBaseMaterial {
  45578. /**
  45579. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45580. */
  45581. static readonly PBRMATERIAL_OPAQUE: number;
  45582. /**
  45583. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45584. */
  45585. static readonly PBRMATERIAL_ALPHATEST: number;
  45586. /**
  45587. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45588. */
  45589. static readonly PBRMATERIAL_ALPHABLEND: number;
  45590. /**
  45591. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45592. * They are also discarded below the alpha cutoff threshold to improve performances.
  45593. */
  45594. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45595. /**
  45596. * Defines the default value of how much AO map is occluding the analytical lights
  45597. * (point spot...).
  45598. */
  45599. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45600. /**
  45601. * Intensity of the direct lights e.g. the four lights available in your scene.
  45602. * This impacts both the direct diffuse and specular highlights.
  45603. */
  45604. directIntensity: number;
  45605. /**
  45606. * Intensity of the emissive part of the material.
  45607. * This helps controlling the emissive effect without modifying the emissive color.
  45608. */
  45609. emissiveIntensity: number;
  45610. /**
  45611. * Intensity of the environment e.g. how much the environment will light the object
  45612. * either through harmonics for rough material or through the refelction for shiny ones.
  45613. */
  45614. environmentIntensity: number;
  45615. /**
  45616. * This is a special control allowing the reduction of the specular highlights coming from the
  45617. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45618. */
  45619. specularIntensity: number;
  45620. /**
  45621. * Debug Control allowing disabling the bump map on this material.
  45622. */
  45623. disableBumpMap: boolean;
  45624. /**
  45625. * AKA Diffuse Texture in standard nomenclature.
  45626. */
  45627. albedoTexture: BaseTexture;
  45628. /**
  45629. * AKA Occlusion Texture in other nomenclature.
  45630. */
  45631. ambientTexture: BaseTexture;
  45632. /**
  45633. * AKA Occlusion Texture Intensity in other nomenclature.
  45634. */
  45635. ambientTextureStrength: number;
  45636. /**
  45637. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45638. * 1 means it completely occludes it
  45639. * 0 mean it has no impact
  45640. */
  45641. ambientTextureImpactOnAnalyticalLights: number;
  45642. /**
  45643. * Stores the alpha values in a texture.
  45644. */
  45645. opacityTexture: BaseTexture;
  45646. /**
  45647. * Stores the reflection values in a texture.
  45648. */
  45649. reflectionTexture: Nullable<BaseTexture>;
  45650. /**
  45651. * Stores the emissive values in a texture.
  45652. */
  45653. emissiveTexture: BaseTexture;
  45654. /**
  45655. * AKA Specular texture in other nomenclature.
  45656. */
  45657. reflectivityTexture: BaseTexture;
  45658. /**
  45659. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45660. */
  45661. metallicTexture: BaseTexture;
  45662. /**
  45663. * Specifies the metallic scalar of the metallic/roughness workflow.
  45664. * Can also be used to scale the metalness values of the metallic texture.
  45665. */
  45666. metallic: Nullable<number>;
  45667. /**
  45668. * Specifies the roughness scalar of the metallic/roughness workflow.
  45669. * Can also be used to scale the roughness values of the metallic texture.
  45670. */
  45671. roughness: Nullable<number>;
  45672. /**
  45673. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45674. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45675. */
  45676. microSurfaceTexture: BaseTexture;
  45677. /**
  45678. * Stores surface normal data used to displace a mesh in a texture.
  45679. */
  45680. bumpTexture: BaseTexture;
  45681. /**
  45682. * Stores the pre-calculated light information of a mesh in a texture.
  45683. */
  45684. lightmapTexture: BaseTexture;
  45685. /**
  45686. * Stores the refracted light information in a texture.
  45687. */
  45688. refractionTexture: Nullable<BaseTexture>;
  45689. /**
  45690. * The color of a material in ambient lighting.
  45691. */
  45692. ambientColor: Color3;
  45693. /**
  45694. * AKA Diffuse Color in other nomenclature.
  45695. */
  45696. albedoColor: Color3;
  45697. /**
  45698. * AKA Specular Color in other nomenclature.
  45699. */
  45700. reflectivityColor: Color3;
  45701. /**
  45702. * The color reflected from the material.
  45703. */
  45704. reflectionColor: Color3;
  45705. /**
  45706. * The color emitted from the material.
  45707. */
  45708. emissiveColor: Color3;
  45709. /**
  45710. * AKA Glossiness in other nomenclature.
  45711. */
  45712. microSurface: number;
  45713. /**
  45714. * source material index of refraction (IOR)' / 'destination material IOR.
  45715. */
  45716. indexOfRefraction: number;
  45717. /**
  45718. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45719. */
  45720. invertRefractionY: boolean;
  45721. /**
  45722. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45723. * Materials half opaque for instance using refraction could benefit from this control.
  45724. */
  45725. linkRefractionWithTransparency: boolean;
  45726. /**
  45727. * If true, the light map contains occlusion information instead of lighting info.
  45728. */
  45729. useLightmapAsShadowmap: boolean;
  45730. /**
  45731. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45732. */
  45733. useAlphaFromAlbedoTexture: boolean;
  45734. /**
  45735. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45736. */
  45737. forceAlphaTest: boolean;
  45738. /**
  45739. * Defines the alpha limits in alpha test mode.
  45740. */
  45741. alphaCutOff: number;
  45742. /**
  45743. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45744. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45745. */
  45746. useSpecularOverAlpha: boolean;
  45747. /**
  45748. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45749. */
  45750. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45751. /**
  45752. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45753. */
  45754. useRoughnessFromMetallicTextureAlpha: boolean;
  45755. /**
  45756. * Specifies if the metallic texture contains the roughness information in its green channel.
  45757. */
  45758. useRoughnessFromMetallicTextureGreen: boolean;
  45759. /**
  45760. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45761. */
  45762. useMetallnessFromMetallicTextureBlue: boolean;
  45763. /**
  45764. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45765. */
  45766. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45767. /**
  45768. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45769. */
  45770. useAmbientInGrayScale: boolean;
  45771. /**
  45772. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45773. * The material will try to infer what glossiness each pixel should be.
  45774. */
  45775. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45776. /**
  45777. * BJS is using an harcoded light falloff based on a manually sets up range.
  45778. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45779. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45780. */
  45781. /**
  45782. * BJS is using an harcoded light falloff based on a manually sets up range.
  45783. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45784. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45785. */
  45786. usePhysicalLightFalloff: boolean;
  45787. /**
  45788. * In order to support the falloff compatibility with gltf, a special mode has been added
  45789. * to reproduce the gltf light falloff.
  45790. */
  45791. /**
  45792. * In order to support the falloff compatibility with gltf, a special mode has been added
  45793. * to reproduce the gltf light falloff.
  45794. */
  45795. useGLTFLightFalloff: boolean;
  45796. /**
  45797. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45798. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45799. */
  45800. useRadianceOverAlpha: boolean;
  45801. /**
  45802. * Allows using an object space normal map (instead of tangent space).
  45803. */
  45804. useObjectSpaceNormalMap: boolean;
  45805. /**
  45806. * Allows using the bump map in parallax mode.
  45807. */
  45808. useParallax: boolean;
  45809. /**
  45810. * Allows using the bump map in parallax occlusion mode.
  45811. */
  45812. useParallaxOcclusion: boolean;
  45813. /**
  45814. * Controls the scale bias of the parallax mode.
  45815. */
  45816. parallaxScaleBias: number;
  45817. /**
  45818. * If sets to true, disables all the lights affecting the material.
  45819. */
  45820. disableLighting: boolean;
  45821. /**
  45822. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45823. */
  45824. forceIrradianceInFragment: boolean;
  45825. /**
  45826. * Number of Simultaneous lights allowed on the material.
  45827. */
  45828. maxSimultaneousLights: number;
  45829. /**
  45830. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45831. */
  45832. invertNormalMapX: boolean;
  45833. /**
  45834. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45835. */
  45836. invertNormalMapY: boolean;
  45837. /**
  45838. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45839. */
  45840. twoSidedLighting: boolean;
  45841. /**
  45842. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45843. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45844. */
  45845. useAlphaFresnel: boolean;
  45846. /**
  45847. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45848. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45849. */
  45850. useLinearAlphaFresnel: boolean;
  45851. /**
  45852. * Let user defines the brdf lookup texture used for IBL.
  45853. * A default 8bit version is embedded but you could point at :
  45854. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45855. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45856. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45857. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45858. */
  45859. environmentBRDFTexture: Nullable<BaseTexture>;
  45860. /**
  45861. * Force normal to face away from face.
  45862. */
  45863. forceNormalForward: boolean;
  45864. /**
  45865. * Enables specular anti aliasing in the PBR shader.
  45866. * It will both interacts on the Geometry for analytical and IBL lighting.
  45867. * It also prefilter the roughness map based on the bump values.
  45868. */
  45869. enableSpecularAntiAliasing: boolean;
  45870. /**
  45871. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45872. * makes the reflect vector face the model (under horizon).
  45873. */
  45874. useHorizonOcclusion: boolean;
  45875. /**
  45876. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45877. * too much the area relying on ambient texture to define their ambient occlusion.
  45878. */
  45879. useRadianceOcclusion: boolean;
  45880. /**
  45881. * If set to true, no lighting calculations will be applied.
  45882. */
  45883. unlit: boolean;
  45884. /**
  45885. * Gets the image processing configuration used either in this material.
  45886. */
  45887. /**
  45888. * Sets the Default image processing configuration used either in the this material.
  45889. *
  45890. * If sets to null, the scene one is in use.
  45891. */
  45892. imageProcessingConfiguration: ImageProcessingConfiguration;
  45893. /**
  45894. * Gets wether the color curves effect is enabled.
  45895. */
  45896. /**
  45897. * Sets wether the color curves effect is enabled.
  45898. */
  45899. cameraColorCurvesEnabled: boolean;
  45900. /**
  45901. * Gets wether the color grading effect is enabled.
  45902. */
  45903. /**
  45904. * Gets wether the color grading effect is enabled.
  45905. */
  45906. cameraColorGradingEnabled: boolean;
  45907. /**
  45908. * Gets wether tonemapping is enabled or not.
  45909. */
  45910. /**
  45911. * Sets wether tonemapping is enabled or not
  45912. */
  45913. cameraToneMappingEnabled: boolean;
  45914. /**
  45915. * The camera exposure used on this material.
  45916. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45917. * This corresponds to a photographic exposure.
  45918. */
  45919. /**
  45920. * The camera exposure used on this material.
  45921. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45922. * This corresponds to a photographic exposure.
  45923. */
  45924. cameraExposure: number;
  45925. /**
  45926. * Gets The camera contrast used on this material.
  45927. */
  45928. /**
  45929. * Sets The camera contrast used on this material.
  45930. */
  45931. cameraContrast: number;
  45932. /**
  45933. * Gets the Color Grading 2D Lookup Texture.
  45934. */
  45935. /**
  45936. * Sets the Color Grading 2D Lookup Texture.
  45937. */
  45938. cameraColorGradingTexture: Nullable<BaseTexture>;
  45939. /**
  45940. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45941. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45942. * 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;
  45943. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45944. */
  45945. /**
  45946. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45947. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45948. * 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;
  45949. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45950. */
  45951. cameraColorCurves: Nullable<ColorCurves>;
  45952. /**
  45953. * Instantiates a new PBRMaterial instance.
  45954. *
  45955. * @param name The material name
  45956. * @param scene The scene the material will be use in.
  45957. */
  45958. constructor(name: string, scene: Scene);
  45959. /**
  45960. * Returns the name of this material class.
  45961. */
  45962. getClassName(): string;
  45963. /**
  45964. * Makes a duplicate of the current material.
  45965. * @param name - name to use for the new material.
  45966. */
  45967. clone(name: string): PBRMaterial;
  45968. /**
  45969. * Serializes this PBR Material.
  45970. * @returns - An object with the serialized material.
  45971. */
  45972. serialize(): any;
  45973. /**
  45974. * Parses a PBR Material from a serialized object.
  45975. * @param source - Serialized object.
  45976. * @param scene - BJS scene instance.
  45977. * @param rootUrl - url for the scene object
  45978. * @returns - PBRMaterial
  45979. */
  45980. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45981. }
  45982. }
  45983. declare module BABYLON {
  45984. /**
  45985. * Direct draw surface info
  45986. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45987. */
  45988. export interface DDSInfo {
  45989. /**
  45990. * Width of the texture
  45991. */
  45992. width: number;
  45993. /**
  45994. * Width of the texture
  45995. */
  45996. height: number;
  45997. /**
  45998. * Number of Mipmaps for the texture
  45999. * @see https://en.wikipedia.org/wiki/Mipmap
  46000. */
  46001. mipmapCount: number;
  46002. /**
  46003. * If the textures format is a known fourCC format
  46004. * @see https://www.fourcc.org/
  46005. */
  46006. isFourCC: boolean;
  46007. /**
  46008. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46009. */
  46010. isRGB: boolean;
  46011. /**
  46012. * If the texture is a lumincance format
  46013. */
  46014. isLuminance: boolean;
  46015. /**
  46016. * If this is a cube texture
  46017. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46018. */
  46019. isCube: boolean;
  46020. /**
  46021. * If the texture is a compressed format eg. FOURCC_DXT1
  46022. */
  46023. isCompressed: boolean;
  46024. /**
  46025. * The dxgiFormat of the texture
  46026. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46027. */
  46028. dxgiFormat: number;
  46029. /**
  46030. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46031. */
  46032. textureType: number;
  46033. /**
  46034. * Sphericle polynomial created for the dds texture
  46035. */
  46036. sphericalPolynomial?: SphericalPolynomial;
  46037. }
  46038. /**
  46039. * Class used to provide DDS decompression tools
  46040. */
  46041. export class DDSTools {
  46042. /**
  46043. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46044. */
  46045. static StoreLODInAlphaChannel: boolean;
  46046. /**
  46047. * Gets DDS information from an array buffer
  46048. * @param arrayBuffer defines the array buffer to read data from
  46049. * @returns the DDS information
  46050. */
  46051. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46052. private static _FloatView;
  46053. private static _Int32View;
  46054. private static _ToHalfFloat;
  46055. private static _FromHalfFloat;
  46056. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46057. private static _GetHalfFloatRGBAArrayBuffer;
  46058. private static _GetFloatRGBAArrayBuffer;
  46059. private static _GetFloatAsUIntRGBAArrayBuffer;
  46060. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46061. private static _GetRGBAArrayBuffer;
  46062. private static _ExtractLongWordOrder;
  46063. private static _GetRGBArrayBuffer;
  46064. private static _GetLuminanceArrayBuffer;
  46065. /**
  46066. * Uploads DDS Levels to a Babylon Texture
  46067. * @hidden
  46068. */
  46069. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46070. }
  46071. interface Engine {
  46072. /**
  46073. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46074. * @param rootUrl defines the url where the file to load is located
  46075. * @param scene defines the current scene
  46076. * @param lodScale defines scale to apply to the mip map selection
  46077. * @param lodOffset defines offset to apply to the mip map selection
  46078. * @param onLoad defines an optional callback raised when the texture is loaded
  46079. * @param onError defines an optional callback raised if there is an issue to load the texture
  46080. * @param format defines the format of the data
  46081. * @param forcedExtension defines the extension to use to pick the right loader
  46082. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46083. * @returns the cube texture as an InternalTexture
  46084. */
  46085. 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;
  46086. }
  46087. }
  46088. declare module BABYLON {
  46089. /**
  46090. * Implementation of the DDS Texture Loader.
  46091. * @hidden
  46092. */
  46093. export class _DDSTextureLoader implements IInternalTextureLoader {
  46094. /**
  46095. * Defines wether the loader supports cascade loading the different faces.
  46096. */
  46097. readonly supportCascades: boolean;
  46098. /**
  46099. * This returns if the loader support the current file information.
  46100. * @param extension defines the file extension of the file being loaded
  46101. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46102. * @param fallback defines the fallback internal texture if any
  46103. * @param isBase64 defines whether the texture is encoded as a base64
  46104. * @param isBuffer defines whether the texture data are stored as a buffer
  46105. * @returns true if the loader can load the specified file
  46106. */
  46107. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46108. /**
  46109. * Transform the url before loading if required.
  46110. * @param rootUrl the url of the texture
  46111. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46112. * @returns the transformed texture
  46113. */
  46114. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46115. /**
  46116. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46117. * @param rootUrl the url of the texture
  46118. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46119. * @returns the fallback texture
  46120. */
  46121. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46122. /**
  46123. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46124. * @param data contains the texture data
  46125. * @param texture defines the BabylonJS internal texture
  46126. * @param createPolynomials will be true if polynomials have been requested
  46127. * @param onLoad defines the callback to trigger once the texture is ready
  46128. * @param onError defines the callback to trigger in case of error
  46129. */
  46130. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46131. /**
  46132. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46133. * @param data contains the texture data
  46134. * @param texture defines the BabylonJS internal texture
  46135. * @param callback defines the method to call once ready to upload
  46136. */
  46137. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46138. }
  46139. }
  46140. declare module BABYLON {
  46141. /** @hidden */
  46142. export var rgbdEncodePixelShader: {
  46143. name: string;
  46144. shader: string;
  46145. };
  46146. }
  46147. declare module BABYLON {
  46148. /**
  46149. * Raw texture data and descriptor sufficient for WebGL texture upload
  46150. */
  46151. export interface EnvironmentTextureInfo {
  46152. /**
  46153. * Version of the environment map
  46154. */
  46155. version: number;
  46156. /**
  46157. * Width of image
  46158. */
  46159. width: number;
  46160. /**
  46161. * Irradiance information stored in the file.
  46162. */
  46163. irradiance: any;
  46164. /**
  46165. * Specular information stored in the file.
  46166. */
  46167. specular: any;
  46168. }
  46169. /**
  46170. * Sets of helpers addressing the serialization and deserialization of environment texture
  46171. * stored in a BabylonJS env file.
  46172. * Those files are usually stored as .env files.
  46173. */
  46174. export class EnvironmentTextureTools {
  46175. /**
  46176. * Magic number identifying the env file.
  46177. */
  46178. private static _MagicBytes;
  46179. /**
  46180. * Gets the environment info from an env file.
  46181. * @param data The array buffer containing the .env bytes.
  46182. * @returns the environment file info (the json header) if successfully parsed.
  46183. */
  46184. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46185. /**
  46186. * Creates an environment texture from a loaded cube texture.
  46187. * @param texture defines the cube texture to convert in env file
  46188. * @return a promise containing the environment data if succesfull.
  46189. */
  46190. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46191. /**
  46192. * Creates a JSON representation of the spherical data.
  46193. * @param texture defines the texture containing the polynomials
  46194. * @return the JSON representation of the spherical info
  46195. */
  46196. private static _CreateEnvTextureIrradiance;
  46197. /**
  46198. * Uploads the texture info contained in the env file to the GPU.
  46199. * @param texture defines the internal texture to upload to
  46200. * @param arrayBuffer defines the buffer cotaining the data to load
  46201. * @param info defines the texture info retrieved through the GetEnvInfo method
  46202. * @returns a promise
  46203. */
  46204. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46205. /**
  46206. * Uploads the levels of image data to the GPU.
  46207. * @param texture defines the internal texture to upload to
  46208. * @param imageData defines the array buffer views of image data [mipmap][face]
  46209. * @returns a promise
  46210. */
  46211. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46212. /**
  46213. * Uploads spherical polynomials information to the texture.
  46214. * @param texture defines the texture we are trying to upload the information to
  46215. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46216. */
  46217. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46218. /** @hidden */
  46219. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46220. }
  46221. }
  46222. declare module BABYLON {
  46223. /**
  46224. * Implementation of the ENV Texture Loader.
  46225. * @hidden
  46226. */
  46227. export class _ENVTextureLoader implements IInternalTextureLoader {
  46228. /**
  46229. * Defines wether the loader supports cascade loading the different faces.
  46230. */
  46231. readonly supportCascades: boolean;
  46232. /**
  46233. * This returns if the loader support the current file information.
  46234. * @param extension defines the file extension of the file being loaded
  46235. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46236. * @param fallback defines the fallback internal texture if any
  46237. * @param isBase64 defines whether the texture is encoded as a base64
  46238. * @param isBuffer defines whether the texture data are stored as a buffer
  46239. * @returns true if the loader can load the specified file
  46240. */
  46241. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46242. /**
  46243. * Transform the url before loading if required.
  46244. * @param rootUrl the url of the texture
  46245. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46246. * @returns the transformed texture
  46247. */
  46248. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46249. /**
  46250. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46251. * @param rootUrl the url of the texture
  46252. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46253. * @returns the fallback texture
  46254. */
  46255. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46256. /**
  46257. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46258. * @param data contains the texture data
  46259. * @param texture defines the BabylonJS internal texture
  46260. * @param createPolynomials will be true if polynomials have been requested
  46261. * @param onLoad defines the callback to trigger once the texture is ready
  46262. * @param onError defines the callback to trigger in case of error
  46263. */
  46264. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46265. /**
  46266. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46267. * @param data contains the texture data
  46268. * @param texture defines the BabylonJS internal texture
  46269. * @param callback defines the method to call once ready to upload
  46270. */
  46271. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46272. }
  46273. }
  46274. declare module BABYLON {
  46275. /**
  46276. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46277. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46278. */
  46279. export class KhronosTextureContainer {
  46280. /** contents of the KTX container file */
  46281. arrayBuffer: any;
  46282. private static HEADER_LEN;
  46283. private static COMPRESSED_2D;
  46284. private static COMPRESSED_3D;
  46285. private static TEX_2D;
  46286. private static TEX_3D;
  46287. /**
  46288. * Gets the openGL type
  46289. */
  46290. glType: number;
  46291. /**
  46292. * Gets the openGL type size
  46293. */
  46294. glTypeSize: number;
  46295. /**
  46296. * Gets the openGL format
  46297. */
  46298. glFormat: number;
  46299. /**
  46300. * Gets the openGL internal format
  46301. */
  46302. glInternalFormat: number;
  46303. /**
  46304. * Gets the base internal format
  46305. */
  46306. glBaseInternalFormat: number;
  46307. /**
  46308. * Gets image width in pixel
  46309. */
  46310. pixelWidth: number;
  46311. /**
  46312. * Gets image height in pixel
  46313. */
  46314. pixelHeight: number;
  46315. /**
  46316. * Gets image depth in pixels
  46317. */
  46318. pixelDepth: number;
  46319. /**
  46320. * Gets the number of array elements
  46321. */
  46322. numberOfArrayElements: number;
  46323. /**
  46324. * Gets the number of faces
  46325. */
  46326. numberOfFaces: number;
  46327. /**
  46328. * Gets the number of mipmap levels
  46329. */
  46330. numberOfMipmapLevels: number;
  46331. /**
  46332. * Gets the bytes of key value data
  46333. */
  46334. bytesOfKeyValueData: number;
  46335. /**
  46336. * Gets the load type
  46337. */
  46338. loadType: number;
  46339. /**
  46340. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46341. */
  46342. isInvalid: boolean;
  46343. /**
  46344. * Creates a new KhronosTextureContainer
  46345. * @param arrayBuffer contents of the KTX container file
  46346. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46347. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46348. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46349. */
  46350. constructor(
  46351. /** contents of the KTX container file */
  46352. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46353. /**
  46354. * Uploads KTX content to a Babylon Texture.
  46355. * It is assumed that the texture has already been created & is currently bound
  46356. * @hidden
  46357. */
  46358. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46359. private _upload2DCompressedLevels;
  46360. }
  46361. }
  46362. declare module BABYLON {
  46363. /**
  46364. * Implementation of the KTX Texture Loader.
  46365. * @hidden
  46366. */
  46367. export class _KTXTextureLoader implements IInternalTextureLoader {
  46368. /**
  46369. * Defines wether the loader supports cascade loading the different faces.
  46370. */
  46371. readonly supportCascades: boolean;
  46372. /**
  46373. * This returns if the loader support the current file information.
  46374. * @param extension defines the file extension of the file being loaded
  46375. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46376. * @param fallback defines the fallback internal texture if any
  46377. * @param isBase64 defines whether the texture is encoded as a base64
  46378. * @param isBuffer defines whether the texture data are stored as a buffer
  46379. * @returns true if the loader can load the specified file
  46380. */
  46381. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46382. /**
  46383. * Transform the url before loading if required.
  46384. * @param rootUrl the url of the texture
  46385. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46386. * @returns the transformed texture
  46387. */
  46388. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46389. /**
  46390. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46391. * @param rootUrl the url of the texture
  46392. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46393. * @returns the fallback texture
  46394. */
  46395. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46396. /**
  46397. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46398. * @param data contains the texture data
  46399. * @param texture defines the BabylonJS internal texture
  46400. * @param createPolynomials will be true if polynomials have been requested
  46401. * @param onLoad defines the callback to trigger once the texture is ready
  46402. * @param onError defines the callback to trigger in case of error
  46403. */
  46404. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46405. /**
  46406. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46407. * @param data contains the texture data
  46408. * @param texture defines the BabylonJS internal texture
  46409. * @param callback defines the method to call once ready to upload
  46410. */
  46411. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46412. }
  46413. }
  46414. declare module BABYLON {
  46415. /** @hidden */
  46416. export var _forceSceneHelpersToBundle: boolean;
  46417. interface Scene {
  46418. /**
  46419. * Creates a default light for the scene.
  46420. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46421. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46422. */
  46423. createDefaultLight(replace?: boolean): void;
  46424. /**
  46425. * Creates a default camera for the scene.
  46426. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46427. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46428. * @param replace has default false, when true replaces the active camera in the scene
  46429. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46430. */
  46431. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46432. /**
  46433. * Creates a default camera and a default light.
  46434. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46435. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46436. * @param replace has the default false, when true replaces the active camera/light in the scene
  46437. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46438. */
  46439. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46440. /**
  46441. * Creates a new sky box
  46442. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46443. * @param environmentTexture defines the texture to use as environment texture
  46444. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46445. * @param scale defines the overall scale of the skybox
  46446. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46447. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46448. * @returns a new mesh holding the sky box
  46449. */
  46450. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46451. /**
  46452. * Creates a new environment
  46453. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46454. * @param options defines the options you can use to configure the environment
  46455. * @returns the new EnvironmentHelper
  46456. */
  46457. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46458. /**
  46459. * Creates a new VREXperienceHelper
  46460. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46461. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46462. * @returns a new VREXperienceHelper
  46463. */
  46464. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46465. /**
  46466. * Creates a new XREXperienceHelper
  46467. * @see http://doc.babylonjs.com/how_to/webxr
  46468. * @returns a promise for a new XREXperienceHelper
  46469. */
  46470. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46471. }
  46472. }
  46473. declare module BABYLON {
  46474. /**
  46475. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46476. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46477. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46478. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46479. */
  46480. export class VideoDome extends TransformNode {
  46481. /**
  46482. * Define the video source as a Monoscopic panoramic 360 video.
  46483. */
  46484. static readonly MODE_MONOSCOPIC: number;
  46485. /**
  46486. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46487. */
  46488. static readonly MODE_TOPBOTTOM: number;
  46489. /**
  46490. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46491. */
  46492. static readonly MODE_SIDEBYSIDE: number;
  46493. private _useDirectMapping;
  46494. /**
  46495. * The video texture being displayed on the sphere
  46496. */
  46497. protected _videoTexture: VideoTexture;
  46498. /**
  46499. * Gets the video texture being displayed on the sphere
  46500. */
  46501. readonly videoTexture: VideoTexture;
  46502. /**
  46503. * The skybox material
  46504. */
  46505. protected _material: BackgroundMaterial;
  46506. /**
  46507. * The surface used for the skybox
  46508. */
  46509. protected _mesh: Mesh;
  46510. /**
  46511. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46512. * Also see the options.resolution property.
  46513. */
  46514. fovMultiplier: number;
  46515. private _videoMode;
  46516. /**
  46517. * Gets or set the current video mode for the video. It can be:
  46518. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46519. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46520. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46521. */
  46522. videoMode: number;
  46523. /**
  46524. * Oberserver used in Stereoscopic VR Mode.
  46525. */
  46526. private _onBeforeCameraRenderObserver;
  46527. /**
  46528. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46529. * @param name Element's name, child elements will append suffixes for their own names.
  46530. * @param urlsOrVideo defines the url(s) or the video element to use
  46531. * @param options An object containing optional or exposed sub element properties
  46532. */
  46533. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46534. resolution?: number;
  46535. clickToPlay?: boolean;
  46536. autoPlay?: boolean;
  46537. loop?: boolean;
  46538. size?: number;
  46539. poster?: string;
  46540. faceForward?: boolean;
  46541. useDirectMapping?: boolean;
  46542. }, scene: Scene);
  46543. private _changeVideoMode;
  46544. /**
  46545. * Releases resources associated with this node.
  46546. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46547. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46548. */
  46549. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46550. }
  46551. }
  46552. declare module BABYLON {
  46553. /**
  46554. * This class can be used to get instrumentation data from a Babylon engine
  46555. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46556. */
  46557. export class EngineInstrumentation implements IDisposable {
  46558. /**
  46559. * Define the instrumented engine.
  46560. */
  46561. engine: Engine;
  46562. private _captureGPUFrameTime;
  46563. private _gpuFrameTimeToken;
  46564. private _gpuFrameTime;
  46565. private _captureShaderCompilationTime;
  46566. private _shaderCompilationTime;
  46567. private _onBeginFrameObserver;
  46568. private _onEndFrameObserver;
  46569. private _onBeforeShaderCompilationObserver;
  46570. private _onAfterShaderCompilationObserver;
  46571. /**
  46572. * Gets the perf counter used for GPU frame time
  46573. */
  46574. readonly gpuFrameTimeCounter: PerfCounter;
  46575. /**
  46576. * Gets the GPU frame time capture status
  46577. */
  46578. /**
  46579. * Enable or disable the GPU frame time capture
  46580. */
  46581. captureGPUFrameTime: boolean;
  46582. /**
  46583. * Gets the perf counter used for shader compilation time
  46584. */
  46585. readonly shaderCompilationTimeCounter: PerfCounter;
  46586. /**
  46587. * Gets the shader compilation time capture status
  46588. */
  46589. /**
  46590. * Enable or disable the shader compilation time capture
  46591. */
  46592. captureShaderCompilationTime: boolean;
  46593. /**
  46594. * Instantiates a new engine instrumentation.
  46595. * This class can be used to get instrumentation data from a Babylon engine
  46596. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46597. * @param engine Defines the engine to instrument
  46598. */
  46599. constructor(
  46600. /**
  46601. * Define the instrumented engine.
  46602. */
  46603. engine: Engine);
  46604. /**
  46605. * Dispose and release associated resources.
  46606. */
  46607. dispose(): void;
  46608. }
  46609. }
  46610. declare module BABYLON {
  46611. /**
  46612. * This class can be used to get instrumentation data from a Babylon engine
  46613. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46614. */
  46615. export class SceneInstrumentation implements IDisposable {
  46616. /**
  46617. * Defines the scene to instrument
  46618. */
  46619. scene: Scene;
  46620. private _captureActiveMeshesEvaluationTime;
  46621. private _activeMeshesEvaluationTime;
  46622. private _captureRenderTargetsRenderTime;
  46623. private _renderTargetsRenderTime;
  46624. private _captureFrameTime;
  46625. private _frameTime;
  46626. private _captureRenderTime;
  46627. private _renderTime;
  46628. private _captureInterFrameTime;
  46629. private _interFrameTime;
  46630. private _captureParticlesRenderTime;
  46631. private _particlesRenderTime;
  46632. private _captureSpritesRenderTime;
  46633. private _spritesRenderTime;
  46634. private _capturePhysicsTime;
  46635. private _physicsTime;
  46636. private _captureAnimationsTime;
  46637. private _animationsTime;
  46638. private _captureCameraRenderTime;
  46639. private _cameraRenderTime;
  46640. private _onBeforeActiveMeshesEvaluationObserver;
  46641. private _onAfterActiveMeshesEvaluationObserver;
  46642. private _onBeforeRenderTargetsRenderObserver;
  46643. private _onAfterRenderTargetsRenderObserver;
  46644. private _onAfterRenderObserver;
  46645. private _onBeforeDrawPhaseObserver;
  46646. private _onAfterDrawPhaseObserver;
  46647. private _onBeforeAnimationsObserver;
  46648. private _onBeforeParticlesRenderingObserver;
  46649. private _onAfterParticlesRenderingObserver;
  46650. private _onBeforeSpritesRenderingObserver;
  46651. private _onAfterSpritesRenderingObserver;
  46652. private _onBeforePhysicsObserver;
  46653. private _onAfterPhysicsObserver;
  46654. private _onAfterAnimationsObserver;
  46655. private _onBeforeCameraRenderObserver;
  46656. private _onAfterCameraRenderObserver;
  46657. /**
  46658. * Gets the perf counter used for active meshes evaluation time
  46659. */
  46660. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46661. /**
  46662. * Gets the active meshes evaluation time capture status
  46663. */
  46664. /**
  46665. * Enable or disable the active meshes evaluation time capture
  46666. */
  46667. captureActiveMeshesEvaluationTime: boolean;
  46668. /**
  46669. * Gets the perf counter used for render targets render time
  46670. */
  46671. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46672. /**
  46673. * Gets the render targets render time capture status
  46674. */
  46675. /**
  46676. * Enable or disable the render targets render time capture
  46677. */
  46678. captureRenderTargetsRenderTime: boolean;
  46679. /**
  46680. * Gets the perf counter used for particles render time
  46681. */
  46682. readonly particlesRenderTimeCounter: PerfCounter;
  46683. /**
  46684. * Gets the particles render time capture status
  46685. */
  46686. /**
  46687. * Enable or disable the particles render time capture
  46688. */
  46689. captureParticlesRenderTime: boolean;
  46690. /**
  46691. * Gets the perf counter used for sprites render time
  46692. */
  46693. readonly spritesRenderTimeCounter: PerfCounter;
  46694. /**
  46695. * Gets the sprites render time capture status
  46696. */
  46697. /**
  46698. * Enable or disable the sprites render time capture
  46699. */
  46700. captureSpritesRenderTime: boolean;
  46701. /**
  46702. * Gets the perf counter used for physics time
  46703. */
  46704. readonly physicsTimeCounter: PerfCounter;
  46705. /**
  46706. * Gets the physics time capture status
  46707. */
  46708. /**
  46709. * Enable or disable the physics time capture
  46710. */
  46711. capturePhysicsTime: boolean;
  46712. /**
  46713. * Gets the perf counter used for animations time
  46714. */
  46715. readonly animationsTimeCounter: PerfCounter;
  46716. /**
  46717. * Gets the animations time capture status
  46718. */
  46719. /**
  46720. * Enable or disable the animations time capture
  46721. */
  46722. captureAnimationsTime: boolean;
  46723. /**
  46724. * Gets the perf counter used for frame time capture
  46725. */
  46726. readonly frameTimeCounter: PerfCounter;
  46727. /**
  46728. * Gets the frame time capture status
  46729. */
  46730. /**
  46731. * Enable or disable the frame time capture
  46732. */
  46733. captureFrameTime: boolean;
  46734. /**
  46735. * Gets the perf counter used for inter-frames time capture
  46736. */
  46737. readonly interFrameTimeCounter: PerfCounter;
  46738. /**
  46739. * Gets the inter-frames time capture status
  46740. */
  46741. /**
  46742. * Enable or disable the inter-frames time capture
  46743. */
  46744. captureInterFrameTime: boolean;
  46745. /**
  46746. * Gets the perf counter used for render time capture
  46747. */
  46748. readonly renderTimeCounter: PerfCounter;
  46749. /**
  46750. * Gets the render time capture status
  46751. */
  46752. /**
  46753. * Enable or disable the render time capture
  46754. */
  46755. captureRenderTime: boolean;
  46756. /**
  46757. * Gets the perf counter used for camera render time capture
  46758. */
  46759. readonly cameraRenderTimeCounter: PerfCounter;
  46760. /**
  46761. * Gets the camera render time capture status
  46762. */
  46763. /**
  46764. * Enable or disable the camera render time capture
  46765. */
  46766. captureCameraRenderTime: boolean;
  46767. /**
  46768. * Gets the perf counter used for draw calls
  46769. */
  46770. readonly drawCallsCounter: PerfCounter;
  46771. /**
  46772. * Instantiates a new scene instrumentation.
  46773. * This class can be used to get instrumentation data from a Babylon engine
  46774. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46775. * @param scene Defines the scene to instrument
  46776. */
  46777. constructor(
  46778. /**
  46779. * Defines the scene to instrument
  46780. */
  46781. scene: Scene);
  46782. /**
  46783. * Dispose and release associated resources.
  46784. */
  46785. dispose(): void;
  46786. }
  46787. }
  46788. declare module BABYLON {
  46789. /** @hidden */
  46790. export var glowMapGenerationPixelShader: {
  46791. name: string;
  46792. shader: string;
  46793. };
  46794. }
  46795. declare module BABYLON {
  46796. /** @hidden */
  46797. export var glowMapGenerationVertexShader: {
  46798. name: string;
  46799. shader: string;
  46800. };
  46801. }
  46802. declare module BABYLON {
  46803. /**
  46804. * Effect layer options. This helps customizing the behaviour
  46805. * of the effect layer.
  46806. */
  46807. export interface IEffectLayerOptions {
  46808. /**
  46809. * Multiplication factor apply to the canvas size to compute the render target size
  46810. * used to generated the objects (the smaller the faster).
  46811. */
  46812. mainTextureRatio: number;
  46813. /**
  46814. * Enforces a fixed size texture to ensure effect stability across devices.
  46815. */
  46816. mainTextureFixedSize?: number;
  46817. /**
  46818. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46819. */
  46820. alphaBlendingMode: number;
  46821. /**
  46822. * The camera attached to the layer.
  46823. */
  46824. camera: Nullable<Camera>;
  46825. /**
  46826. * The rendering group to draw the layer in.
  46827. */
  46828. renderingGroupId: number;
  46829. }
  46830. /**
  46831. * The effect layer Helps adding post process effect blended with the main pass.
  46832. *
  46833. * This can be for instance use to generate glow or higlight effects on the scene.
  46834. *
  46835. * The effect layer class can not be used directly and is intented to inherited from to be
  46836. * customized per effects.
  46837. */
  46838. export abstract class EffectLayer {
  46839. private _vertexBuffers;
  46840. private _indexBuffer;
  46841. private _cachedDefines;
  46842. private _effectLayerMapGenerationEffect;
  46843. private _effectLayerOptions;
  46844. private _mergeEffect;
  46845. protected _scene: Scene;
  46846. protected _engine: Engine;
  46847. protected _maxSize: number;
  46848. protected _mainTextureDesiredSize: ISize;
  46849. protected _mainTexture: RenderTargetTexture;
  46850. protected _shouldRender: boolean;
  46851. protected _postProcesses: PostProcess[];
  46852. protected _textures: BaseTexture[];
  46853. protected _emissiveTextureAndColor: {
  46854. texture: Nullable<BaseTexture>;
  46855. color: Color4;
  46856. };
  46857. /**
  46858. * The name of the layer
  46859. */
  46860. name: string;
  46861. /**
  46862. * The clear color of the texture used to generate the glow map.
  46863. */
  46864. neutralColor: Color4;
  46865. /**
  46866. * Specifies wether the highlight layer is enabled or not.
  46867. */
  46868. isEnabled: boolean;
  46869. /**
  46870. * Gets the camera attached to the layer.
  46871. */
  46872. readonly camera: Nullable<Camera>;
  46873. /**
  46874. * Gets the rendering group id the layer should render in.
  46875. */
  46876. readonly renderingGroupId: number;
  46877. /**
  46878. * An event triggered when the effect layer has been disposed.
  46879. */
  46880. onDisposeObservable: Observable<EffectLayer>;
  46881. /**
  46882. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46883. */
  46884. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46885. /**
  46886. * An event triggered when the generated texture is being merged in the scene.
  46887. */
  46888. onBeforeComposeObservable: Observable<EffectLayer>;
  46889. /**
  46890. * An event triggered when the generated texture has been merged in the scene.
  46891. */
  46892. onAfterComposeObservable: Observable<EffectLayer>;
  46893. /**
  46894. * An event triggered when the efffect layer changes its size.
  46895. */
  46896. onSizeChangedObservable: Observable<EffectLayer>;
  46897. /** @hidden */
  46898. static _SceneComponentInitialization: (scene: Scene) => void;
  46899. /**
  46900. * Instantiates a new effect Layer and references it in the scene.
  46901. * @param name The name of the layer
  46902. * @param scene The scene to use the layer in
  46903. */
  46904. constructor(
  46905. /** The Friendly of the effect in the scene */
  46906. name: string, scene: Scene);
  46907. /**
  46908. * Get the effect name of the layer.
  46909. * @return The effect name
  46910. */
  46911. abstract getEffectName(): string;
  46912. /**
  46913. * Checks for the readiness of the element composing the layer.
  46914. * @param subMesh the mesh to check for
  46915. * @param useInstances specify wether or not to use instances to render the mesh
  46916. * @return true if ready otherwise, false
  46917. */
  46918. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46919. /**
  46920. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46921. * @returns true if the effect requires stencil during the main canvas render pass.
  46922. */
  46923. abstract needStencil(): boolean;
  46924. /**
  46925. * Create the merge effect. This is the shader use to blit the information back
  46926. * to the main canvas at the end of the scene rendering.
  46927. * @returns The effect containing the shader used to merge the effect on the main canvas
  46928. */
  46929. protected abstract _createMergeEffect(): Effect;
  46930. /**
  46931. * Creates the render target textures and post processes used in the effect layer.
  46932. */
  46933. protected abstract _createTextureAndPostProcesses(): void;
  46934. /**
  46935. * Implementation specific of rendering the generating effect on the main canvas.
  46936. * @param effect The effect used to render through
  46937. */
  46938. protected abstract _internalRender(effect: Effect): void;
  46939. /**
  46940. * Sets the required values for both the emissive texture and and the main color.
  46941. */
  46942. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46943. /**
  46944. * Free any resources and references associated to a mesh.
  46945. * Internal use
  46946. * @param mesh The mesh to free.
  46947. */
  46948. abstract _disposeMesh(mesh: Mesh): void;
  46949. /**
  46950. * Serializes this layer (Glow or Highlight for example)
  46951. * @returns a serialized layer object
  46952. */
  46953. abstract serialize?(): any;
  46954. /**
  46955. * Initializes the effect layer with the required options.
  46956. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46957. */
  46958. protected _init(options: Partial<IEffectLayerOptions>): void;
  46959. /**
  46960. * Generates the index buffer of the full screen quad blending to the main canvas.
  46961. */
  46962. private _generateIndexBuffer;
  46963. /**
  46964. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46965. */
  46966. private _generateVertexBuffer;
  46967. /**
  46968. * Sets the main texture desired size which is the closest power of two
  46969. * of the engine canvas size.
  46970. */
  46971. private _setMainTextureSize;
  46972. /**
  46973. * Creates the main texture for the effect layer.
  46974. */
  46975. protected _createMainTexture(): void;
  46976. /**
  46977. * Adds specific effects defines.
  46978. * @param defines The defines to add specifics to.
  46979. */
  46980. protected _addCustomEffectDefines(defines: string[]): void;
  46981. /**
  46982. * Checks for the readiness of the element composing the layer.
  46983. * @param subMesh the mesh to check for
  46984. * @param useInstances specify wether or not to use instances to render the mesh
  46985. * @param emissiveTexture the associated emissive texture used to generate the glow
  46986. * @return true if ready otherwise, false
  46987. */
  46988. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46989. /**
  46990. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46991. */
  46992. render(): void;
  46993. /**
  46994. * Determine if a given mesh will be used in the current effect.
  46995. * @param mesh mesh to test
  46996. * @returns true if the mesh will be used
  46997. */
  46998. hasMesh(mesh: AbstractMesh): boolean;
  46999. /**
  47000. * Returns true if the layer contains information to display, otherwise false.
  47001. * @returns true if the glow layer should be rendered
  47002. */
  47003. shouldRender(): boolean;
  47004. /**
  47005. * Returns true if the mesh should render, otherwise false.
  47006. * @param mesh The mesh to render
  47007. * @returns true if it should render otherwise false
  47008. */
  47009. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47010. /**
  47011. * Returns true if the mesh can be rendered, otherwise false.
  47012. * @param mesh The mesh to render
  47013. * @param material The material used on the mesh
  47014. * @returns true if it can be rendered otherwise false
  47015. */
  47016. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47017. /**
  47018. * Returns true if the mesh should render, otherwise false.
  47019. * @param mesh The mesh to render
  47020. * @returns true if it should render otherwise false
  47021. */
  47022. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47023. /**
  47024. * Renders the submesh passed in parameter to the generation map.
  47025. */
  47026. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  47027. /**
  47028. * Rebuild the required buffers.
  47029. * @hidden Internal use only.
  47030. */
  47031. _rebuild(): void;
  47032. /**
  47033. * Dispose only the render target textures and post process.
  47034. */
  47035. private _disposeTextureAndPostProcesses;
  47036. /**
  47037. * Dispose the highlight layer and free resources.
  47038. */
  47039. dispose(): void;
  47040. /**
  47041. * Gets the class name of the effect layer
  47042. * @returns the string with the class name of the effect layer
  47043. */
  47044. getClassName(): string;
  47045. /**
  47046. * Creates an effect layer from parsed effect layer data
  47047. * @param parsedEffectLayer defines effect layer data
  47048. * @param scene defines the current scene
  47049. * @param rootUrl defines the root URL containing the effect layer information
  47050. * @returns a parsed effect Layer
  47051. */
  47052. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47053. }
  47054. }
  47055. declare module BABYLON {
  47056. interface AbstractScene {
  47057. /**
  47058. * The list of effect layers (highlights/glow) added to the scene
  47059. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47060. * @see http://doc.babylonjs.com/how_to/glow_layer
  47061. */
  47062. effectLayers: Array<EffectLayer>;
  47063. /**
  47064. * Removes the given effect layer from this scene.
  47065. * @param toRemove defines the effect layer to remove
  47066. * @returns the index of the removed effect layer
  47067. */
  47068. removeEffectLayer(toRemove: EffectLayer): number;
  47069. /**
  47070. * Adds the given effect layer to this scene
  47071. * @param newEffectLayer defines the effect layer to add
  47072. */
  47073. addEffectLayer(newEffectLayer: EffectLayer): void;
  47074. }
  47075. /**
  47076. * Defines the layer scene component responsible to manage any effect layers
  47077. * in a given scene.
  47078. */
  47079. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47080. /**
  47081. * The component name helpfull to identify the component in the list of scene components.
  47082. */
  47083. readonly name: string;
  47084. /**
  47085. * The scene the component belongs to.
  47086. */
  47087. scene: Scene;
  47088. private _engine;
  47089. private _renderEffects;
  47090. private _needStencil;
  47091. private _previousStencilState;
  47092. /**
  47093. * Creates a new instance of the component for the given scene
  47094. * @param scene Defines the scene to register the component in
  47095. */
  47096. constructor(scene: Scene);
  47097. /**
  47098. * Registers the component in a given scene
  47099. */
  47100. register(): void;
  47101. /**
  47102. * Rebuilds the elements related to this component in case of
  47103. * context lost for instance.
  47104. */
  47105. rebuild(): void;
  47106. /**
  47107. * Serializes the component data to the specified json object
  47108. * @param serializationObject The object to serialize to
  47109. */
  47110. serialize(serializationObject: any): void;
  47111. /**
  47112. * Adds all the element from the container to the scene
  47113. * @param container the container holding the elements
  47114. */
  47115. addFromContainer(container: AbstractScene): void;
  47116. /**
  47117. * Removes all the elements in the container from the scene
  47118. * @param container contains the elements to remove
  47119. * @param dispose if the removed element should be disposed (default: false)
  47120. */
  47121. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47122. /**
  47123. * Disposes the component and the associated ressources.
  47124. */
  47125. dispose(): void;
  47126. private _isReadyForMesh;
  47127. private _renderMainTexture;
  47128. private _setStencil;
  47129. private _setStencilBack;
  47130. private _draw;
  47131. private _drawCamera;
  47132. private _drawRenderingGroup;
  47133. }
  47134. }
  47135. declare module BABYLON {
  47136. /** @hidden */
  47137. export var glowMapMergePixelShader: {
  47138. name: string;
  47139. shader: string;
  47140. };
  47141. }
  47142. declare module BABYLON {
  47143. /** @hidden */
  47144. export var glowMapMergeVertexShader: {
  47145. name: string;
  47146. shader: string;
  47147. };
  47148. }
  47149. declare module BABYLON {
  47150. interface AbstractScene {
  47151. /**
  47152. * Return a the first highlight layer of the scene with a given name.
  47153. * @param name The name of the highlight layer to look for.
  47154. * @return The highlight layer if found otherwise null.
  47155. */
  47156. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47157. }
  47158. /**
  47159. * Glow layer options. This helps customizing the behaviour
  47160. * of the glow layer.
  47161. */
  47162. export interface IGlowLayerOptions {
  47163. /**
  47164. * Multiplication factor apply to the canvas size to compute the render target size
  47165. * used to generated the glowing objects (the smaller the faster).
  47166. */
  47167. mainTextureRatio: number;
  47168. /**
  47169. * Enforces a fixed size texture to ensure resize independant blur.
  47170. */
  47171. mainTextureFixedSize?: number;
  47172. /**
  47173. * How big is the kernel of the blur texture.
  47174. */
  47175. blurKernelSize: number;
  47176. /**
  47177. * The camera attached to the layer.
  47178. */
  47179. camera: Nullable<Camera>;
  47180. /**
  47181. * Enable MSAA by chosing the number of samples.
  47182. */
  47183. mainTextureSamples?: number;
  47184. /**
  47185. * The rendering group to draw the layer in.
  47186. */
  47187. renderingGroupId: number;
  47188. }
  47189. /**
  47190. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47191. *
  47192. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47193. * glowy meshes to your scene.
  47194. *
  47195. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47196. */
  47197. export class GlowLayer extends EffectLayer {
  47198. /**
  47199. * Effect Name of the layer.
  47200. */
  47201. static readonly EffectName: string;
  47202. /**
  47203. * The default blur kernel size used for the glow.
  47204. */
  47205. static DefaultBlurKernelSize: number;
  47206. /**
  47207. * The default texture size ratio used for the glow.
  47208. */
  47209. static DefaultTextureRatio: number;
  47210. /**
  47211. * Sets the kernel size of the blur.
  47212. */
  47213. /**
  47214. * Gets the kernel size of the blur.
  47215. */
  47216. blurKernelSize: number;
  47217. /**
  47218. * Sets the glow intensity.
  47219. */
  47220. /**
  47221. * Gets the glow intensity.
  47222. */
  47223. intensity: number;
  47224. private _options;
  47225. private _intensity;
  47226. private _horizontalBlurPostprocess1;
  47227. private _verticalBlurPostprocess1;
  47228. private _horizontalBlurPostprocess2;
  47229. private _verticalBlurPostprocess2;
  47230. private _blurTexture1;
  47231. private _blurTexture2;
  47232. private _postProcesses1;
  47233. private _postProcesses2;
  47234. private _includedOnlyMeshes;
  47235. private _excludedMeshes;
  47236. /**
  47237. * Callback used to let the user override the color selection on a per mesh basis
  47238. */
  47239. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47240. /**
  47241. * Callback used to let the user override the texture selection on a per mesh basis
  47242. */
  47243. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47244. /**
  47245. * Instantiates a new glow Layer and references it to the scene.
  47246. * @param name The name of the layer
  47247. * @param scene The scene to use the layer in
  47248. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47249. */
  47250. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47251. /**
  47252. * Get the effect name of the layer.
  47253. * @return The effect name
  47254. */
  47255. getEffectName(): string;
  47256. /**
  47257. * Create the merge effect. This is the shader use to blit the information back
  47258. * to the main canvas at the end of the scene rendering.
  47259. */
  47260. protected _createMergeEffect(): Effect;
  47261. /**
  47262. * Creates the render target textures and post processes used in the glow layer.
  47263. */
  47264. protected _createTextureAndPostProcesses(): void;
  47265. /**
  47266. * Checks for the readiness of the element composing the layer.
  47267. * @param subMesh the mesh to check for
  47268. * @param useInstances specify wether or not to use instances to render the mesh
  47269. * @param emissiveTexture the associated emissive texture used to generate the glow
  47270. * @return true if ready otherwise, false
  47271. */
  47272. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47273. /**
  47274. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47275. */
  47276. needStencil(): boolean;
  47277. /**
  47278. * Returns true if the mesh can be rendered, otherwise false.
  47279. * @param mesh The mesh to render
  47280. * @param material The material used on the mesh
  47281. * @returns true if it can be rendered otherwise false
  47282. */
  47283. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47284. /**
  47285. * Implementation specific of rendering the generating effect on the main canvas.
  47286. * @param effect The effect used to render through
  47287. */
  47288. protected _internalRender(effect: Effect): void;
  47289. /**
  47290. * Sets the required values for both the emissive texture and and the main color.
  47291. */
  47292. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47293. /**
  47294. * Returns true if the mesh should render, otherwise false.
  47295. * @param mesh The mesh to render
  47296. * @returns true if it should render otherwise false
  47297. */
  47298. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47299. /**
  47300. * Adds specific effects defines.
  47301. * @param defines The defines to add specifics to.
  47302. */
  47303. protected _addCustomEffectDefines(defines: string[]): void;
  47304. /**
  47305. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47306. * @param mesh The mesh to exclude from the glow layer
  47307. */
  47308. addExcludedMesh(mesh: Mesh): void;
  47309. /**
  47310. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47311. * @param mesh The mesh to remove
  47312. */
  47313. removeExcludedMesh(mesh: Mesh): void;
  47314. /**
  47315. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47316. * @param mesh The mesh to include in the glow layer
  47317. */
  47318. addIncludedOnlyMesh(mesh: Mesh): void;
  47319. /**
  47320. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47321. * @param mesh The mesh to remove
  47322. */
  47323. removeIncludedOnlyMesh(mesh: Mesh): void;
  47324. /**
  47325. * Determine if a given mesh will be used in the glow layer
  47326. * @param mesh The mesh to test
  47327. * @returns true if the mesh will be highlighted by the current glow layer
  47328. */
  47329. hasMesh(mesh: AbstractMesh): boolean;
  47330. /**
  47331. * Free any resources and references associated to a mesh.
  47332. * Internal use
  47333. * @param mesh The mesh to free.
  47334. * @hidden
  47335. */
  47336. _disposeMesh(mesh: Mesh): void;
  47337. /**
  47338. * Gets the class name of the effect layer
  47339. * @returns the string with the class name of the effect layer
  47340. */
  47341. getClassName(): string;
  47342. /**
  47343. * Serializes this glow layer
  47344. * @returns a serialized glow layer object
  47345. */
  47346. serialize(): any;
  47347. /**
  47348. * Creates a Glow Layer from parsed glow layer data
  47349. * @param parsedGlowLayer defines glow layer data
  47350. * @param scene defines the current scene
  47351. * @param rootUrl defines the root URL containing the glow layer information
  47352. * @returns a parsed Glow Layer
  47353. */
  47354. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47355. }
  47356. }
  47357. declare module BABYLON {
  47358. /** @hidden */
  47359. export var glowBlurPostProcessPixelShader: {
  47360. name: string;
  47361. shader: string;
  47362. };
  47363. }
  47364. declare module BABYLON {
  47365. interface AbstractScene {
  47366. /**
  47367. * Return a the first highlight layer of the scene with a given name.
  47368. * @param name The name of the highlight layer to look for.
  47369. * @return The highlight layer if found otherwise null.
  47370. */
  47371. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47372. }
  47373. /**
  47374. * Highlight layer options. This helps customizing the behaviour
  47375. * of the highlight layer.
  47376. */
  47377. export interface IHighlightLayerOptions {
  47378. /**
  47379. * Multiplication factor apply to the canvas size to compute the render target size
  47380. * used to generated the glowing objects (the smaller the faster).
  47381. */
  47382. mainTextureRatio: number;
  47383. /**
  47384. * Enforces a fixed size texture to ensure resize independant blur.
  47385. */
  47386. mainTextureFixedSize?: number;
  47387. /**
  47388. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47389. * of the picture to blur (the smaller the faster).
  47390. */
  47391. blurTextureSizeRatio: number;
  47392. /**
  47393. * How big in texel of the blur texture is the vertical blur.
  47394. */
  47395. blurVerticalSize: number;
  47396. /**
  47397. * How big in texel of the blur texture is the horizontal blur.
  47398. */
  47399. blurHorizontalSize: number;
  47400. /**
  47401. * Alpha blending mode used to apply the blur. Default is combine.
  47402. */
  47403. alphaBlendingMode: number;
  47404. /**
  47405. * The camera attached to the layer.
  47406. */
  47407. camera: Nullable<Camera>;
  47408. /**
  47409. * Should we display highlight as a solid stroke?
  47410. */
  47411. isStroke?: boolean;
  47412. /**
  47413. * The rendering group to draw the layer in.
  47414. */
  47415. renderingGroupId: number;
  47416. }
  47417. /**
  47418. * The highlight layer Helps adding a glow effect around a mesh.
  47419. *
  47420. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47421. * glowy meshes to your scene.
  47422. *
  47423. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47424. */
  47425. export class HighlightLayer extends EffectLayer {
  47426. name: string;
  47427. /**
  47428. * Effect Name of the highlight layer.
  47429. */
  47430. static readonly EffectName: string;
  47431. /**
  47432. * The neutral color used during the preparation of the glow effect.
  47433. * This is black by default as the blend operation is a blend operation.
  47434. */
  47435. static NeutralColor: Color4;
  47436. /**
  47437. * Stencil value used for glowing meshes.
  47438. */
  47439. static GlowingMeshStencilReference: number;
  47440. /**
  47441. * Stencil value used for the other meshes in the scene.
  47442. */
  47443. static NormalMeshStencilReference: number;
  47444. /**
  47445. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47446. */
  47447. innerGlow: boolean;
  47448. /**
  47449. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47450. */
  47451. outerGlow: boolean;
  47452. /**
  47453. * Specifies the horizontal size of the blur.
  47454. */
  47455. /**
  47456. * Gets the horizontal size of the blur.
  47457. */
  47458. blurHorizontalSize: number;
  47459. /**
  47460. * Specifies the vertical size of the blur.
  47461. */
  47462. /**
  47463. * Gets the vertical size of the blur.
  47464. */
  47465. blurVerticalSize: number;
  47466. /**
  47467. * An event triggered when the highlight layer is being blurred.
  47468. */
  47469. onBeforeBlurObservable: Observable<HighlightLayer>;
  47470. /**
  47471. * An event triggered when the highlight layer has been blurred.
  47472. */
  47473. onAfterBlurObservable: Observable<HighlightLayer>;
  47474. private _instanceGlowingMeshStencilReference;
  47475. private _options;
  47476. private _downSamplePostprocess;
  47477. private _horizontalBlurPostprocess;
  47478. private _verticalBlurPostprocess;
  47479. private _blurTexture;
  47480. private _meshes;
  47481. private _excludedMeshes;
  47482. /**
  47483. * Instantiates a new highlight Layer and references it to the scene..
  47484. * @param name The name of the layer
  47485. * @param scene The scene to use the layer in
  47486. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47487. */
  47488. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47489. /**
  47490. * Get the effect name of the layer.
  47491. * @return The effect name
  47492. */
  47493. getEffectName(): string;
  47494. /**
  47495. * Create the merge effect. This is the shader use to blit the information back
  47496. * to the main canvas at the end of the scene rendering.
  47497. */
  47498. protected _createMergeEffect(): Effect;
  47499. /**
  47500. * Creates the render target textures and post processes used in the highlight layer.
  47501. */
  47502. protected _createTextureAndPostProcesses(): void;
  47503. /**
  47504. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47505. */
  47506. needStencil(): boolean;
  47507. /**
  47508. * Checks for the readiness of the element composing the layer.
  47509. * @param subMesh the mesh to check for
  47510. * @param useInstances specify wether or not to use instances to render the mesh
  47511. * @param emissiveTexture the associated emissive texture used to generate the glow
  47512. * @return true if ready otherwise, false
  47513. */
  47514. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47515. /**
  47516. * Implementation specific of rendering the generating effect on the main canvas.
  47517. * @param effect The effect used to render through
  47518. */
  47519. protected _internalRender(effect: Effect): void;
  47520. /**
  47521. * Returns true if the layer contains information to display, otherwise false.
  47522. */
  47523. shouldRender(): boolean;
  47524. /**
  47525. * Returns true if the mesh should render, otherwise false.
  47526. * @param mesh The mesh to render
  47527. * @returns true if it should render otherwise false
  47528. */
  47529. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47530. /**
  47531. * Sets the required values for both the emissive texture and and the main color.
  47532. */
  47533. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47534. /**
  47535. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47536. * @param mesh The mesh to exclude from the highlight layer
  47537. */
  47538. addExcludedMesh(mesh: Mesh): void;
  47539. /**
  47540. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47541. * @param mesh The mesh to highlight
  47542. */
  47543. removeExcludedMesh(mesh: Mesh): void;
  47544. /**
  47545. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47546. * @param mesh mesh to test
  47547. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47548. */
  47549. hasMesh(mesh: AbstractMesh): boolean;
  47550. /**
  47551. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47552. * @param mesh The mesh to highlight
  47553. * @param color The color of the highlight
  47554. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47555. */
  47556. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47557. /**
  47558. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47559. * @param mesh The mesh to highlight
  47560. */
  47561. removeMesh(mesh: Mesh): void;
  47562. /**
  47563. * Force the stencil to the normal expected value for none glowing parts
  47564. */
  47565. private _defaultStencilReference;
  47566. /**
  47567. * Free any resources and references associated to a mesh.
  47568. * Internal use
  47569. * @param mesh The mesh to free.
  47570. * @hidden
  47571. */
  47572. _disposeMesh(mesh: Mesh): void;
  47573. /**
  47574. * Dispose the highlight layer and free resources.
  47575. */
  47576. dispose(): void;
  47577. /**
  47578. * Gets the class name of the effect layer
  47579. * @returns the string with the class name of the effect layer
  47580. */
  47581. getClassName(): string;
  47582. /**
  47583. * Serializes this Highlight layer
  47584. * @returns a serialized Highlight layer object
  47585. */
  47586. serialize(): any;
  47587. /**
  47588. * Creates a Highlight layer from parsed Highlight layer data
  47589. * @param parsedHightlightLayer defines the Highlight layer data
  47590. * @param scene defines the current scene
  47591. * @param rootUrl defines the root URL containing the Highlight layer information
  47592. * @returns a parsed Highlight layer
  47593. */
  47594. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47595. }
  47596. }
  47597. declare module BABYLON {
  47598. /** @hidden */
  47599. export var lensFlarePixelShader: {
  47600. name: string;
  47601. shader: string;
  47602. };
  47603. }
  47604. declare module BABYLON {
  47605. /** @hidden */
  47606. export var lensFlareVertexShader: {
  47607. name: string;
  47608. shader: string;
  47609. };
  47610. }
  47611. declare module BABYLON {
  47612. /**
  47613. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47614. * It is usually composed of several `lensFlare`.
  47615. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47616. */
  47617. export class LensFlareSystem {
  47618. /**
  47619. * Define the name of the lens flare system
  47620. */
  47621. name: string;
  47622. /**
  47623. * List of lens flares used in this system.
  47624. */
  47625. lensFlares: LensFlare[];
  47626. /**
  47627. * Define a limit from the border the lens flare can be visible.
  47628. */
  47629. borderLimit: number;
  47630. /**
  47631. * Define a viewport border we do not want to see the lens flare in.
  47632. */
  47633. viewportBorder: number;
  47634. /**
  47635. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47636. */
  47637. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47638. /**
  47639. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47640. */
  47641. layerMask: number;
  47642. /**
  47643. * Define the id of the lens flare system in the scene.
  47644. * (equal to name by default)
  47645. */
  47646. id: string;
  47647. private _scene;
  47648. private _emitter;
  47649. private _vertexBuffers;
  47650. private _indexBuffer;
  47651. private _effect;
  47652. private _positionX;
  47653. private _positionY;
  47654. private _isEnabled;
  47655. /** @hidden */
  47656. static _SceneComponentInitialization: (scene: Scene) => void;
  47657. /**
  47658. * Instantiates a lens flare system.
  47659. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47660. * It is usually composed of several `lensFlare`.
  47661. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47662. * @param name Define the name of the lens flare system in the scene
  47663. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47664. * @param scene Define the scene the lens flare system belongs to
  47665. */
  47666. constructor(
  47667. /**
  47668. * Define the name of the lens flare system
  47669. */
  47670. name: string, emitter: any, scene: Scene);
  47671. /**
  47672. * Define if the lens flare system is enabled.
  47673. */
  47674. isEnabled: boolean;
  47675. /**
  47676. * Get the scene the effects belongs to.
  47677. * @returns the scene holding the lens flare system
  47678. */
  47679. getScene(): Scene;
  47680. /**
  47681. * Get the emitter of the lens flare system.
  47682. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47683. * @returns the emitter of the lens flare system
  47684. */
  47685. getEmitter(): any;
  47686. /**
  47687. * Set the emitter of the lens flare system.
  47688. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47689. * @param newEmitter Define the new emitter of the system
  47690. */
  47691. setEmitter(newEmitter: any): void;
  47692. /**
  47693. * Get the lens flare system emitter position.
  47694. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47695. * @returns the position
  47696. */
  47697. getEmitterPosition(): Vector3;
  47698. /**
  47699. * @hidden
  47700. */
  47701. computeEffectivePosition(globalViewport: Viewport): boolean;
  47702. /** @hidden */
  47703. _isVisible(): boolean;
  47704. /**
  47705. * @hidden
  47706. */
  47707. render(): boolean;
  47708. /**
  47709. * Dispose and release the lens flare with its associated resources.
  47710. */
  47711. dispose(): void;
  47712. /**
  47713. * Parse a lens flare system from a JSON repressentation
  47714. * @param parsedLensFlareSystem Define the JSON to parse
  47715. * @param scene Define the scene the parsed system should be instantiated in
  47716. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47717. * @returns the parsed system
  47718. */
  47719. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47720. /**
  47721. * Serialize the current Lens Flare System into a JSON representation.
  47722. * @returns the serialized JSON
  47723. */
  47724. serialize(): any;
  47725. }
  47726. }
  47727. declare module BABYLON {
  47728. /**
  47729. * This represents one of the lens effect in a `lensFlareSystem`.
  47730. * It controls one of the indiviual texture used in the effect.
  47731. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47732. */
  47733. export class LensFlare {
  47734. /**
  47735. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47736. */
  47737. size: number;
  47738. /**
  47739. * 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.
  47740. */
  47741. position: number;
  47742. /**
  47743. * Define the lens color.
  47744. */
  47745. color: Color3;
  47746. /**
  47747. * Define the lens texture.
  47748. */
  47749. texture: Nullable<Texture>;
  47750. /**
  47751. * Define the alpha mode to render this particular lens.
  47752. */
  47753. alphaMode: number;
  47754. private _system;
  47755. /**
  47756. * Creates a new Lens Flare.
  47757. * This represents one of the lens effect in a `lensFlareSystem`.
  47758. * It controls one of the indiviual texture used in the effect.
  47759. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47760. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47761. * @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.
  47762. * @param color Define the lens color
  47763. * @param imgUrl Define the lens texture url
  47764. * @param system Define the `lensFlareSystem` this flare is part of
  47765. * @returns The newly created Lens Flare
  47766. */
  47767. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47768. /**
  47769. * Instantiates a new Lens Flare.
  47770. * This represents one of the lens effect in a `lensFlareSystem`.
  47771. * It controls one of the indiviual texture used in the effect.
  47772. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47773. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47774. * @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.
  47775. * @param color Define the lens color
  47776. * @param imgUrl Define the lens texture url
  47777. * @param system Define the `lensFlareSystem` this flare is part of
  47778. */
  47779. constructor(
  47780. /**
  47781. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47782. */
  47783. size: number,
  47784. /**
  47785. * 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.
  47786. */
  47787. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47788. /**
  47789. * Dispose and release the lens flare with its associated resources.
  47790. */
  47791. dispose(): void;
  47792. }
  47793. }
  47794. declare module BABYLON {
  47795. interface AbstractScene {
  47796. /**
  47797. * The list of lens flare system added to the scene
  47798. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47799. */
  47800. lensFlareSystems: Array<LensFlareSystem>;
  47801. /**
  47802. * Removes the given lens flare system from this scene.
  47803. * @param toRemove The lens flare system to remove
  47804. * @returns The index of the removed lens flare system
  47805. */
  47806. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47807. /**
  47808. * Adds the given lens flare system to this scene
  47809. * @param newLensFlareSystem The lens flare system to add
  47810. */
  47811. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47812. /**
  47813. * Gets a lens flare system using its name
  47814. * @param name defines the name to look for
  47815. * @returns the lens flare system or null if not found
  47816. */
  47817. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47818. /**
  47819. * Gets a lens flare system using its id
  47820. * @param id defines the id to look for
  47821. * @returns the lens flare system or null if not found
  47822. */
  47823. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47824. }
  47825. /**
  47826. * Defines the lens flare scene component responsible to manage any lens flares
  47827. * in a given scene.
  47828. */
  47829. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47830. /**
  47831. * The component name helpfull to identify the component in the list of scene components.
  47832. */
  47833. readonly name: string;
  47834. /**
  47835. * The scene the component belongs to.
  47836. */
  47837. scene: Scene;
  47838. /**
  47839. * Creates a new instance of the component for the given scene
  47840. * @param scene Defines the scene to register the component in
  47841. */
  47842. constructor(scene: Scene);
  47843. /**
  47844. * Registers the component in a given scene
  47845. */
  47846. register(): void;
  47847. /**
  47848. * Rebuilds the elements related to this component in case of
  47849. * context lost for instance.
  47850. */
  47851. rebuild(): void;
  47852. /**
  47853. * Adds all the element from the container to the scene
  47854. * @param container the container holding the elements
  47855. */
  47856. addFromContainer(container: AbstractScene): void;
  47857. /**
  47858. * Removes all the elements in the container from the scene
  47859. * @param container contains the elements to remove
  47860. * @param dispose if the removed element should be disposed (default: false)
  47861. */
  47862. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47863. /**
  47864. * Serializes the component data to the specified json object
  47865. * @param serializationObject The object to serialize to
  47866. */
  47867. serialize(serializationObject: any): void;
  47868. /**
  47869. * Disposes the component and the associated ressources.
  47870. */
  47871. dispose(): void;
  47872. private _draw;
  47873. }
  47874. }
  47875. declare module BABYLON {
  47876. /**
  47877. * Defines the shadow generator component responsible to manage any shadow generators
  47878. * in a given scene.
  47879. */
  47880. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47881. /**
  47882. * The component name helpfull to identify the component in the list of scene components.
  47883. */
  47884. readonly name: string;
  47885. /**
  47886. * The scene the component belongs to.
  47887. */
  47888. scene: Scene;
  47889. /**
  47890. * Creates a new instance of the component for the given scene
  47891. * @param scene Defines the scene to register the component in
  47892. */
  47893. constructor(scene: Scene);
  47894. /**
  47895. * Registers the component in a given scene
  47896. */
  47897. register(): void;
  47898. /**
  47899. * Rebuilds the elements related to this component in case of
  47900. * context lost for instance.
  47901. */
  47902. rebuild(): void;
  47903. /**
  47904. * Serializes the component data to the specified json object
  47905. * @param serializationObject The object to serialize to
  47906. */
  47907. serialize(serializationObject: any): void;
  47908. /**
  47909. * Adds all the element from the container to the scene
  47910. * @param container the container holding the elements
  47911. */
  47912. addFromContainer(container: AbstractScene): void;
  47913. /**
  47914. * Removes all the elements in the container from the scene
  47915. * @param container contains the elements to remove
  47916. * @param dispose if the removed element should be disposed (default: false)
  47917. */
  47918. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47919. /**
  47920. * Rebuilds the elements related to this component in case of
  47921. * context lost for instance.
  47922. */
  47923. dispose(): void;
  47924. private _gatherRenderTargets;
  47925. }
  47926. }
  47927. declare module BABYLON {
  47928. /**
  47929. * A point light is a light defined by an unique point in world space.
  47930. * The light is emitted in every direction from this point.
  47931. * A good example of a point light is a standard light bulb.
  47932. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47933. */
  47934. export class PointLight extends ShadowLight {
  47935. private _shadowAngle;
  47936. /**
  47937. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47938. * This specifies what angle the shadow will use to be created.
  47939. *
  47940. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47941. */
  47942. /**
  47943. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47944. * This specifies what angle the shadow will use to be created.
  47945. *
  47946. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47947. */
  47948. shadowAngle: number;
  47949. /**
  47950. * Gets the direction if it has been set.
  47951. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47952. */
  47953. /**
  47954. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47955. */
  47956. direction: Vector3;
  47957. /**
  47958. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47959. * A PointLight emits the light in every direction.
  47960. * It can cast shadows.
  47961. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47962. * ```javascript
  47963. * var pointLight = new PointLight("pl", camera.position, scene);
  47964. * ```
  47965. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47966. * @param name The light friendly name
  47967. * @param position The position of the point light in the scene
  47968. * @param scene The scene the lights belongs to
  47969. */
  47970. constructor(name: string, position: Vector3, scene: Scene);
  47971. /**
  47972. * Returns the string "PointLight"
  47973. * @returns the class name
  47974. */
  47975. getClassName(): string;
  47976. /**
  47977. * Returns the integer 0.
  47978. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47979. */
  47980. getTypeID(): number;
  47981. /**
  47982. * Specifies wether or not the shadowmap should be a cube texture.
  47983. * @returns true if the shadowmap needs to be a cube texture.
  47984. */
  47985. needCube(): boolean;
  47986. /**
  47987. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47988. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47989. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47990. */
  47991. getShadowDirection(faceIndex?: number): Vector3;
  47992. /**
  47993. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47994. * - fov = PI / 2
  47995. * - aspect ratio : 1.0
  47996. * - z-near and far equal to the active camera minZ and maxZ.
  47997. * Returns the PointLight.
  47998. */
  47999. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48000. protected _buildUniformLayout(): void;
  48001. /**
  48002. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48003. * @param effect The effect to update
  48004. * @param lightIndex The index of the light in the effect to update
  48005. * @returns The point light
  48006. */
  48007. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48008. /**
  48009. * Prepares the list of defines specific to the light type.
  48010. * @param defines the list of defines
  48011. * @param lightIndex defines the index of the light for the effect
  48012. */
  48013. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48014. }
  48015. }
  48016. declare module BABYLON {
  48017. /**
  48018. * Header information of HDR texture files.
  48019. */
  48020. export interface HDRInfo {
  48021. /**
  48022. * The height of the texture in pixels.
  48023. */
  48024. height: number;
  48025. /**
  48026. * The width of the texture in pixels.
  48027. */
  48028. width: number;
  48029. /**
  48030. * The index of the beginning of the data in the binary file.
  48031. */
  48032. dataPosition: number;
  48033. }
  48034. /**
  48035. * This groups tools to convert HDR texture to native colors array.
  48036. */
  48037. export class HDRTools {
  48038. private static Ldexp;
  48039. private static Rgbe2float;
  48040. private static readStringLine;
  48041. /**
  48042. * Reads header information from an RGBE texture stored in a native array.
  48043. * More information on this format are available here:
  48044. * https://en.wikipedia.org/wiki/RGBE_image_format
  48045. *
  48046. * @param uint8array The binary file stored in native array.
  48047. * @return The header information.
  48048. */
  48049. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48050. /**
  48051. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48052. * This RGBE texture needs to store the information as a panorama.
  48053. *
  48054. * More information on this format are available here:
  48055. * https://en.wikipedia.org/wiki/RGBE_image_format
  48056. *
  48057. * @param buffer The binary file stored in an array buffer.
  48058. * @param size The expected size of the extracted cubemap.
  48059. * @return The Cube Map information.
  48060. */
  48061. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48062. /**
  48063. * Returns the pixels data extracted from an RGBE texture.
  48064. * This pixels will be stored left to right up to down in the R G B order in one array.
  48065. *
  48066. * More information on this format are available here:
  48067. * https://en.wikipedia.org/wiki/RGBE_image_format
  48068. *
  48069. * @param uint8array The binary file stored in an array buffer.
  48070. * @param hdrInfo The header information of the file.
  48071. * @return The pixels data in RGB right to left up to down order.
  48072. */
  48073. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48074. private static RGBE_ReadPixels_RLE;
  48075. }
  48076. }
  48077. declare module BABYLON {
  48078. /**
  48079. * This represents a texture coming from an HDR input.
  48080. *
  48081. * The only supported format is currently panorama picture stored in RGBE format.
  48082. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48083. */
  48084. export class HDRCubeTexture extends BaseTexture {
  48085. private static _facesMapping;
  48086. private _generateHarmonics;
  48087. private _noMipmap;
  48088. private _textureMatrix;
  48089. private _size;
  48090. private _onLoad;
  48091. private _onError;
  48092. /**
  48093. * The texture URL.
  48094. */
  48095. url: string;
  48096. /**
  48097. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48098. */
  48099. coordinatesMode: number;
  48100. protected _isBlocking: boolean;
  48101. /**
  48102. * Sets wether or not the texture is blocking during loading.
  48103. */
  48104. /**
  48105. * Gets wether or not the texture is blocking during loading.
  48106. */
  48107. isBlocking: boolean;
  48108. protected _rotationY: number;
  48109. /**
  48110. * Sets texture matrix rotation angle around Y axis in radians.
  48111. */
  48112. /**
  48113. * Gets texture matrix rotation angle around Y axis radians.
  48114. */
  48115. rotationY: number;
  48116. /**
  48117. * Gets or sets the center of the bounding box associated with the cube texture
  48118. * It must define where the camera used to render the texture was set
  48119. */
  48120. boundingBoxPosition: Vector3;
  48121. private _boundingBoxSize;
  48122. /**
  48123. * Gets or sets the size of the bounding box associated with the cube texture
  48124. * When defined, the cubemap will switch to local mode
  48125. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48126. * @example https://www.babylonjs-playground.com/#RNASML
  48127. */
  48128. boundingBoxSize: Vector3;
  48129. /**
  48130. * Instantiates an HDRTexture from the following parameters.
  48131. *
  48132. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48133. * @param scene The scene the texture will be used in
  48134. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48135. * @param noMipmap Forces to not generate the mipmap if true
  48136. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48137. * @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)
  48138. * @param reserved Reserved flag for internal use.
  48139. */
  48140. 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>);
  48141. /**
  48142. * Get the current class name of the texture useful for serialization or dynamic coding.
  48143. * @returns "HDRCubeTexture"
  48144. */
  48145. getClassName(): string;
  48146. /**
  48147. * Occurs when the file is raw .hdr file.
  48148. */
  48149. private loadTexture;
  48150. clone(): HDRCubeTexture;
  48151. delayLoad(): void;
  48152. /**
  48153. * Get the texture reflection matrix used to rotate/transform the reflection.
  48154. * @returns the reflection matrix
  48155. */
  48156. getReflectionTextureMatrix(): Matrix;
  48157. /**
  48158. * Set the texture reflection matrix used to rotate/transform the reflection.
  48159. * @param value Define the reflection matrix to set
  48160. */
  48161. setReflectionTextureMatrix(value: Matrix): void;
  48162. /**
  48163. * Parses a JSON representation of an HDR Texture in order to create the texture
  48164. * @param parsedTexture Define the JSON representation
  48165. * @param scene Define the scene the texture should be created in
  48166. * @param rootUrl Define the root url in case we need to load relative dependencies
  48167. * @returns the newly created texture after parsing
  48168. */
  48169. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48170. serialize(): any;
  48171. }
  48172. }
  48173. declare module BABYLON {
  48174. /**
  48175. * Class used to control physics engine
  48176. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48177. */
  48178. export class PhysicsEngine implements IPhysicsEngine {
  48179. private _physicsPlugin;
  48180. /**
  48181. * Global value used to control the smallest number supported by the simulation
  48182. */
  48183. static Epsilon: number;
  48184. private _impostors;
  48185. private _joints;
  48186. /**
  48187. * Gets the gravity vector used by the simulation
  48188. */
  48189. gravity: Vector3;
  48190. /**
  48191. * Factory used to create the default physics plugin.
  48192. * @returns The default physics plugin
  48193. */
  48194. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48195. /**
  48196. * Creates a new Physics Engine
  48197. * @param gravity defines the gravity vector used by the simulation
  48198. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48199. */
  48200. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48201. /**
  48202. * Sets the gravity vector used by the simulation
  48203. * @param gravity defines the gravity vector to use
  48204. */
  48205. setGravity(gravity: Vector3): void;
  48206. /**
  48207. * Set the time step of the physics engine.
  48208. * Default is 1/60.
  48209. * To slow it down, enter 1/600 for example.
  48210. * To speed it up, 1/30
  48211. * @param newTimeStep defines the new timestep to apply to this world.
  48212. */
  48213. setTimeStep(newTimeStep?: number): void;
  48214. /**
  48215. * Get the time step of the physics engine.
  48216. * @returns the current time step
  48217. */
  48218. getTimeStep(): number;
  48219. /**
  48220. * Release all resources
  48221. */
  48222. dispose(): void;
  48223. /**
  48224. * Gets the name of the current physics plugin
  48225. * @returns the name of the plugin
  48226. */
  48227. getPhysicsPluginName(): string;
  48228. /**
  48229. * Adding a new impostor for the impostor tracking.
  48230. * This will be done by the impostor itself.
  48231. * @param impostor the impostor to add
  48232. */
  48233. addImpostor(impostor: PhysicsImpostor): void;
  48234. /**
  48235. * Remove an impostor from the engine.
  48236. * This impostor and its mesh will not longer be updated by the physics engine.
  48237. * @param impostor the impostor to remove
  48238. */
  48239. removeImpostor(impostor: PhysicsImpostor): void;
  48240. /**
  48241. * Add a joint to the physics engine
  48242. * @param mainImpostor defines the main impostor to which the joint is added.
  48243. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48244. * @param joint defines the joint that will connect both impostors.
  48245. */
  48246. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48247. /**
  48248. * Removes a joint from the simulation
  48249. * @param mainImpostor defines the impostor used with the joint
  48250. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48251. * @param joint defines the joint to remove
  48252. */
  48253. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48254. /**
  48255. * Called by the scene. No need to call it.
  48256. * @param delta defines the timespam between frames
  48257. */
  48258. _step(delta: number): void;
  48259. /**
  48260. * Gets the current plugin used to run the simulation
  48261. * @returns current plugin
  48262. */
  48263. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48264. /**
  48265. * Gets the list of physic impostors
  48266. * @returns an array of PhysicsImpostor
  48267. */
  48268. getImpostors(): Array<PhysicsImpostor>;
  48269. /**
  48270. * Gets the impostor for a physics enabled object
  48271. * @param object defines the object impersonated by the impostor
  48272. * @returns the PhysicsImpostor or null if not found
  48273. */
  48274. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48275. /**
  48276. * Gets the impostor for a physics body object
  48277. * @param body defines physics body used by the impostor
  48278. * @returns the PhysicsImpostor or null if not found
  48279. */
  48280. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48281. /**
  48282. * Does a raycast in the physics world
  48283. * @param from when should the ray start?
  48284. * @param to when should the ray end?
  48285. * @returns PhysicsRaycastResult
  48286. */
  48287. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48288. }
  48289. }
  48290. declare module BABYLON {
  48291. /** @hidden */
  48292. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48293. private _useDeltaForWorldStep;
  48294. world: any;
  48295. name: string;
  48296. private _physicsMaterials;
  48297. private _fixedTimeStep;
  48298. private _cannonRaycastResult;
  48299. private _raycastResult;
  48300. private _removeAfterStep;
  48301. BJSCANNON: any;
  48302. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48303. setGravity(gravity: Vector3): void;
  48304. setTimeStep(timeStep: number): void;
  48305. getTimeStep(): number;
  48306. executeStep(delta: number): void;
  48307. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48308. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48309. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48310. private _processChildMeshes;
  48311. removePhysicsBody(impostor: PhysicsImpostor): void;
  48312. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48313. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48314. private _addMaterial;
  48315. private _checkWithEpsilon;
  48316. private _createShape;
  48317. private _createHeightmap;
  48318. private _minus90X;
  48319. private _plus90X;
  48320. private _tmpPosition;
  48321. private _tmpDeltaPosition;
  48322. private _tmpUnityRotation;
  48323. private _updatePhysicsBodyTransformation;
  48324. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48325. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48326. isSupported(): boolean;
  48327. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48328. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48329. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48330. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48331. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48332. getBodyMass(impostor: PhysicsImpostor): number;
  48333. getBodyFriction(impostor: PhysicsImpostor): number;
  48334. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48335. getBodyRestitution(impostor: PhysicsImpostor): number;
  48336. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48337. sleepBody(impostor: PhysicsImpostor): void;
  48338. wakeUpBody(impostor: PhysicsImpostor): void;
  48339. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48340. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48341. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48342. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48343. getRadius(impostor: PhysicsImpostor): number;
  48344. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48345. dispose(): void;
  48346. private _extendNamespace;
  48347. /**
  48348. * Does a raycast in the physics world
  48349. * @param from when should the ray start?
  48350. * @param to when should the ray end?
  48351. * @returns PhysicsRaycastResult
  48352. */
  48353. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48354. }
  48355. }
  48356. declare module BABYLON {
  48357. /** @hidden */
  48358. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48359. world: any;
  48360. name: string;
  48361. BJSOIMO: any;
  48362. private _raycastResult;
  48363. constructor(iterations?: number, oimoInjection?: any);
  48364. setGravity(gravity: Vector3): void;
  48365. setTimeStep(timeStep: number): void;
  48366. getTimeStep(): number;
  48367. private _tmpImpostorsArray;
  48368. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48369. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48370. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48371. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48372. private _tmpPositionVector;
  48373. removePhysicsBody(impostor: PhysicsImpostor): void;
  48374. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48375. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48376. isSupported(): boolean;
  48377. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48378. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48379. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48380. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48381. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48382. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48383. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48384. getBodyMass(impostor: PhysicsImpostor): number;
  48385. getBodyFriction(impostor: PhysicsImpostor): number;
  48386. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48387. getBodyRestitution(impostor: PhysicsImpostor): number;
  48388. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48389. sleepBody(impostor: PhysicsImpostor): void;
  48390. wakeUpBody(impostor: PhysicsImpostor): void;
  48391. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48392. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48393. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48394. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48395. getRadius(impostor: PhysicsImpostor): number;
  48396. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48397. dispose(): void;
  48398. /**
  48399. * Does a raycast in the physics world
  48400. * @param from when should the ray start?
  48401. * @param to when should the ray end?
  48402. * @returns PhysicsRaycastResult
  48403. */
  48404. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48405. }
  48406. }
  48407. declare module BABYLON {
  48408. /**
  48409. * Class containing static functions to help procedurally build meshes
  48410. */
  48411. export class RibbonBuilder {
  48412. /**
  48413. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48414. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48415. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48416. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48417. * * 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
  48418. * * 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
  48419. * * 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
  48420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48421. * * 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
  48422. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48423. * * 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
  48424. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48425. * * 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
  48426. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48428. * @param name defines the name of the mesh
  48429. * @param options defines the options used to create the mesh
  48430. * @param scene defines the hosting scene
  48431. * @returns the ribbon mesh
  48432. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48433. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48434. */
  48435. static CreateRibbon(name: string, options: {
  48436. pathArray: Vector3[][];
  48437. closeArray?: boolean;
  48438. closePath?: boolean;
  48439. offset?: number;
  48440. updatable?: boolean;
  48441. sideOrientation?: number;
  48442. frontUVs?: Vector4;
  48443. backUVs?: Vector4;
  48444. instance?: Mesh;
  48445. invertUV?: boolean;
  48446. uvs?: Vector2[];
  48447. colors?: Color4[];
  48448. }, scene?: Nullable<Scene>): Mesh;
  48449. }
  48450. }
  48451. declare module BABYLON {
  48452. /**
  48453. * Class containing static functions to help procedurally build meshes
  48454. */
  48455. export class ShapeBuilder {
  48456. /**
  48457. * 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.
  48458. * * 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.
  48459. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48460. * * 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.
  48461. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48462. * * 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
  48463. * * 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
  48464. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48465. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48466. * * 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
  48467. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48469. * @param name defines the name of the mesh
  48470. * @param options defines the options used to create the mesh
  48471. * @param scene defines the hosting scene
  48472. * @returns the extruded shape mesh
  48473. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48474. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48475. */
  48476. static ExtrudeShape(name: string, options: {
  48477. shape: Vector3[];
  48478. path: Vector3[];
  48479. scale?: number;
  48480. rotation?: number;
  48481. cap?: number;
  48482. updatable?: boolean;
  48483. sideOrientation?: number;
  48484. frontUVs?: Vector4;
  48485. backUVs?: Vector4;
  48486. instance?: Mesh;
  48487. invertUV?: boolean;
  48488. }, scene?: Nullable<Scene>): Mesh;
  48489. /**
  48490. * Creates an custom extruded shape mesh.
  48491. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  48492. * * 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.
  48493. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48494. * * 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
  48495. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  48496. * * 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
  48497. * * It must returns a float value that will be the scale value applied to the shape on each path point
  48498. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  48499. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  48500. * * 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
  48501. * * 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
  48502. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  48503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48504. * * 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
  48505. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48507. * @param name defines the name of the mesh
  48508. * @param options defines the options used to create the mesh
  48509. * @param scene defines the hosting scene
  48510. * @returns the custom extruded shape mesh
  48511. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  48512. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48513. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48514. */
  48515. static ExtrudeShapeCustom(name: string, options: {
  48516. shape: Vector3[];
  48517. path: Vector3[];
  48518. scaleFunction?: any;
  48519. rotationFunction?: any;
  48520. ribbonCloseArray?: boolean;
  48521. ribbonClosePath?: boolean;
  48522. cap?: number;
  48523. updatable?: boolean;
  48524. sideOrientation?: number;
  48525. frontUVs?: Vector4;
  48526. backUVs?: Vector4;
  48527. instance?: Mesh;
  48528. invertUV?: boolean;
  48529. }, scene?: Nullable<Scene>): Mesh;
  48530. private static _ExtrudeShapeGeneric;
  48531. }
  48532. }
  48533. declare module BABYLON {
  48534. /**
  48535. * AmmoJS Physics plugin
  48536. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48537. * @see https://github.com/kripken/ammo.js/
  48538. */
  48539. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48540. private _useDeltaForWorldStep;
  48541. /**
  48542. * Reference to the Ammo library
  48543. */
  48544. bjsAMMO: any;
  48545. /**
  48546. * Created ammoJS world which physics bodies are added to
  48547. */
  48548. world: any;
  48549. /**
  48550. * Name of the plugin
  48551. */
  48552. name: string;
  48553. private _timeStep;
  48554. private _fixedTimeStep;
  48555. private _maxSteps;
  48556. private _tmpQuaternion;
  48557. private _tmpAmmoTransform;
  48558. private _tmpAmmoQuaternion;
  48559. private _tmpAmmoConcreteContactResultCallback;
  48560. private _collisionConfiguration;
  48561. private _dispatcher;
  48562. private _overlappingPairCache;
  48563. private _solver;
  48564. private _softBodySolver;
  48565. private _tmpAmmoVectorA;
  48566. private _tmpAmmoVectorB;
  48567. private _tmpAmmoVectorC;
  48568. private _tmpAmmoVectorD;
  48569. private _tmpContactCallbackResult;
  48570. private _tmpAmmoVectorRCA;
  48571. private _tmpAmmoVectorRCB;
  48572. private _raycastResult;
  48573. private static readonly DISABLE_COLLISION_FLAG;
  48574. private static readonly KINEMATIC_FLAG;
  48575. private static readonly DISABLE_DEACTIVATION_FLAG;
  48576. /**
  48577. * Initializes the ammoJS plugin
  48578. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48579. * @param ammoInjection can be used to inject your own ammo reference
  48580. */
  48581. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  48582. /**
  48583. * Sets the gravity of the physics world (m/(s^2))
  48584. * @param gravity Gravity to set
  48585. */
  48586. setGravity(gravity: Vector3): void;
  48587. /**
  48588. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48589. * @param timeStep timestep to use in seconds
  48590. */
  48591. setTimeStep(timeStep: number): void;
  48592. /**
  48593. * 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)
  48594. * @param fixedTimeStep fixedTimeStep to use in seconds
  48595. */
  48596. setFixedTimeStep(fixedTimeStep: number): void;
  48597. /**
  48598. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48599. * @param maxSteps the maximum number of steps by the physics engine per frame
  48600. */
  48601. setMaxSteps(maxSteps: number): void;
  48602. /**
  48603. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48604. * @returns the current timestep in seconds
  48605. */
  48606. getTimeStep(): number;
  48607. private _isImpostorInContact;
  48608. private _isImpostorPairInContact;
  48609. private _stepSimulation;
  48610. /**
  48611. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48612. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48613. * After the step the babylon meshes are set to the position of the physics imposters
  48614. * @param delta amount of time to step forward
  48615. * @param impostors array of imposters to update before/after the step
  48616. */
  48617. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48618. /**
  48619. * Update babylon mesh to match physics world object
  48620. * @param impostor imposter to match
  48621. */
  48622. private _afterSoftStep;
  48623. /**
  48624. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48625. * @param impostor imposter to match
  48626. */
  48627. private _ropeStep;
  48628. /**
  48629. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48630. * @param impostor imposter to match
  48631. */
  48632. private _softbodyOrClothStep;
  48633. private _tmpVector;
  48634. private _tmpMatrix;
  48635. /**
  48636. * Applies an impulse on the imposter
  48637. * @param impostor imposter to apply impulse to
  48638. * @param force amount of force to be applied to the imposter
  48639. * @param contactPoint the location to apply the impulse on the imposter
  48640. */
  48641. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48642. /**
  48643. * Applies a force on the imposter
  48644. * @param impostor imposter to apply force
  48645. * @param force amount of force to be applied to the imposter
  48646. * @param contactPoint the location to apply the force on the imposter
  48647. */
  48648. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48649. /**
  48650. * Creates a physics body using the plugin
  48651. * @param impostor the imposter to create the physics body on
  48652. */
  48653. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48654. /**
  48655. * Removes the physics body from the imposter and disposes of the body's memory
  48656. * @param impostor imposter to remove the physics body from
  48657. */
  48658. removePhysicsBody(impostor: PhysicsImpostor): void;
  48659. /**
  48660. * Generates a joint
  48661. * @param impostorJoint the imposter joint to create the joint with
  48662. */
  48663. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48664. /**
  48665. * Removes a joint
  48666. * @param impostorJoint the imposter joint to remove the joint from
  48667. */
  48668. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48669. private _addMeshVerts;
  48670. /**
  48671. * Initialise the soft body vertices to match its object's (mesh) vertices
  48672. * Softbody vertices (nodes) are in world space and to match this
  48673. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  48674. * @param impostor to create the softbody for
  48675. */
  48676. private _softVertexData;
  48677. /**
  48678. * Create an impostor's soft body
  48679. * @param impostor to create the softbody for
  48680. */
  48681. private _createSoftbody;
  48682. /**
  48683. * Create cloth for an impostor
  48684. * @param impostor to create the softbody for
  48685. */
  48686. private _createCloth;
  48687. /**
  48688. * Create rope for an impostor
  48689. * @param impostor to create the softbody for
  48690. */
  48691. private _createRope;
  48692. private _addHullVerts;
  48693. private _createShape;
  48694. /**
  48695. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48696. * @param impostor imposter containing the physics body and babylon object
  48697. */
  48698. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48699. /**
  48700. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48701. * @param impostor imposter containing the physics body and babylon object
  48702. * @param newPosition new position
  48703. * @param newRotation new rotation
  48704. */
  48705. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48706. /**
  48707. * If this plugin is supported
  48708. * @returns true if its supported
  48709. */
  48710. isSupported(): boolean;
  48711. /**
  48712. * Sets the linear velocity of the physics body
  48713. * @param impostor imposter to set the velocity on
  48714. * @param velocity velocity to set
  48715. */
  48716. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48717. /**
  48718. * Sets the angular velocity of the physics body
  48719. * @param impostor imposter to set the velocity on
  48720. * @param velocity velocity to set
  48721. */
  48722. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48723. /**
  48724. * gets the linear velocity
  48725. * @param impostor imposter to get linear velocity from
  48726. * @returns linear velocity
  48727. */
  48728. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48729. /**
  48730. * gets the angular velocity
  48731. * @param impostor imposter to get angular velocity from
  48732. * @returns angular velocity
  48733. */
  48734. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48735. /**
  48736. * Sets the mass of physics body
  48737. * @param impostor imposter to set the mass on
  48738. * @param mass mass to set
  48739. */
  48740. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48741. /**
  48742. * Gets the mass of the physics body
  48743. * @param impostor imposter to get the mass from
  48744. * @returns mass
  48745. */
  48746. getBodyMass(impostor: PhysicsImpostor): number;
  48747. /**
  48748. * Gets friction of the impostor
  48749. * @param impostor impostor to get friction from
  48750. * @returns friction value
  48751. */
  48752. getBodyFriction(impostor: PhysicsImpostor): number;
  48753. /**
  48754. * Sets friction of the impostor
  48755. * @param impostor impostor to set friction on
  48756. * @param friction friction value
  48757. */
  48758. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48759. /**
  48760. * Gets restitution of the impostor
  48761. * @param impostor impostor to get restitution from
  48762. * @returns restitution value
  48763. */
  48764. getBodyRestitution(impostor: PhysicsImpostor): number;
  48765. /**
  48766. * Sets resitution of the impostor
  48767. * @param impostor impostor to set resitution on
  48768. * @param restitution resitution value
  48769. */
  48770. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48771. /**
  48772. * Gets pressure inside the impostor
  48773. * @param impostor impostor to get pressure from
  48774. * @returns pressure value
  48775. */
  48776. getBodyPressure(impostor: PhysicsImpostor): number;
  48777. /**
  48778. * Sets pressure inside a soft body impostor
  48779. * Cloth and rope must remain 0 pressure
  48780. * @param impostor impostor to set pressure on
  48781. * @param pressure pressure value
  48782. */
  48783. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  48784. /**
  48785. * Gets stiffness of the impostor
  48786. * @param impostor impostor to get stiffness from
  48787. * @returns pressure value
  48788. */
  48789. getBodyStiffness(impostor: PhysicsImpostor): number;
  48790. /**
  48791. * Sets stiffness of the impostor
  48792. * @param impostor impostor to set stiffness on
  48793. * @param stiffness stiffness value from 0 to 1
  48794. */
  48795. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  48796. /**
  48797. * Gets velocityIterations of the impostor
  48798. * @param impostor impostor to get velocity iterations from
  48799. * @returns velocityIterations value
  48800. */
  48801. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  48802. /**
  48803. * Sets velocityIterations of the impostor
  48804. * @param impostor impostor to set velocity iterations on
  48805. * @param velocityIterations velocityIterations value
  48806. */
  48807. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  48808. /**
  48809. * Gets positionIterations of the impostor
  48810. * @param impostor impostor to get position iterations from
  48811. * @returns positionIterations value
  48812. */
  48813. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  48814. /**
  48815. * Sets positionIterations of the impostor
  48816. * @param impostor impostor to set position on
  48817. * @param positionIterations positionIterations value
  48818. */
  48819. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  48820. /**
  48821. * Append an anchor to a cloth object
  48822. * @param impostor is the cloth impostor to add anchor to
  48823. * @param otherImpostor is the rigid impostor to anchor to
  48824. * @param width ratio across width from 0 to 1
  48825. * @param height ratio up height from 0 to 1
  48826. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  48827. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48828. */
  48829. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48830. /**
  48831. * Append an hook to a rope object
  48832. * @param impostor is the rope impostor to add hook to
  48833. * @param otherImpostor is the rigid impostor to hook to
  48834. * @param length ratio along the rope from 0 to 1
  48835. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  48836. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48837. */
  48838. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48839. /**
  48840. * Sleeps the physics body and stops it from being active
  48841. * @param impostor impostor to sleep
  48842. */
  48843. sleepBody(impostor: PhysicsImpostor): void;
  48844. /**
  48845. * Activates the physics body
  48846. * @param impostor impostor to activate
  48847. */
  48848. wakeUpBody(impostor: PhysicsImpostor): void;
  48849. /**
  48850. * Updates the distance parameters of the joint
  48851. * @param joint joint to update
  48852. * @param maxDistance maximum distance of the joint
  48853. * @param minDistance minimum distance of the joint
  48854. */
  48855. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48856. /**
  48857. * Sets a motor on the joint
  48858. * @param joint joint to set motor on
  48859. * @param speed speed of the motor
  48860. * @param maxForce maximum force of the motor
  48861. * @param motorIndex index of the motor
  48862. */
  48863. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48864. /**
  48865. * Sets the motors limit
  48866. * @param joint joint to set limit on
  48867. * @param upperLimit upper limit
  48868. * @param lowerLimit lower limit
  48869. */
  48870. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48871. /**
  48872. * Syncs the position and rotation of a mesh with the impostor
  48873. * @param mesh mesh to sync
  48874. * @param impostor impostor to update the mesh with
  48875. */
  48876. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48877. /**
  48878. * Gets the radius of the impostor
  48879. * @param impostor impostor to get radius from
  48880. * @returns the radius
  48881. */
  48882. getRadius(impostor: PhysicsImpostor): number;
  48883. /**
  48884. * Gets the box size of the impostor
  48885. * @param impostor impostor to get box size from
  48886. * @param result the resulting box size
  48887. */
  48888. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48889. /**
  48890. * Disposes of the impostor
  48891. */
  48892. dispose(): void;
  48893. /**
  48894. * Does a raycast in the physics world
  48895. * @param from when should the ray start?
  48896. * @param to when should the ray end?
  48897. * @returns PhysicsRaycastResult
  48898. */
  48899. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48900. }
  48901. }
  48902. declare module BABYLON {
  48903. interface AbstractScene {
  48904. /**
  48905. * The list of reflection probes added to the scene
  48906. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48907. */
  48908. reflectionProbes: Array<ReflectionProbe>;
  48909. /**
  48910. * Removes the given reflection probe from this scene.
  48911. * @param toRemove The reflection probe to remove
  48912. * @returns The index of the removed reflection probe
  48913. */
  48914. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48915. /**
  48916. * Adds the given reflection probe to this scene.
  48917. * @param newReflectionProbe The reflection probe to add
  48918. */
  48919. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48920. }
  48921. /**
  48922. * Class used to generate realtime reflection / refraction cube textures
  48923. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48924. */
  48925. export class ReflectionProbe {
  48926. /** defines the name of the probe */
  48927. name: string;
  48928. private _scene;
  48929. private _renderTargetTexture;
  48930. private _projectionMatrix;
  48931. private _viewMatrix;
  48932. private _target;
  48933. private _add;
  48934. private _attachedMesh;
  48935. private _invertYAxis;
  48936. /** Gets or sets probe position (center of the cube map) */
  48937. position: Vector3;
  48938. /**
  48939. * Creates a new reflection probe
  48940. * @param name defines the name of the probe
  48941. * @param size defines the texture resolution (for each face)
  48942. * @param scene defines the hosting scene
  48943. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48944. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48945. */
  48946. constructor(
  48947. /** defines the name of the probe */
  48948. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48949. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48950. samples: number;
  48951. /** Gets or sets the refresh rate to use (on every frame by default) */
  48952. refreshRate: number;
  48953. /**
  48954. * Gets the hosting scene
  48955. * @returns a Scene
  48956. */
  48957. getScene(): Scene;
  48958. /** Gets the internal CubeTexture used to render to */
  48959. readonly cubeTexture: RenderTargetTexture;
  48960. /** Gets the list of meshes to render */
  48961. readonly renderList: Nullable<AbstractMesh[]>;
  48962. /**
  48963. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48964. * @param mesh defines the mesh to attach to
  48965. */
  48966. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48967. /**
  48968. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48969. * @param renderingGroupId The rendering group id corresponding to its index
  48970. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48971. */
  48972. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48973. /**
  48974. * Clean all associated resources
  48975. */
  48976. dispose(): void;
  48977. /**
  48978. * Converts the reflection probe information to a readable string for debug purpose.
  48979. * @param fullDetails Supports for multiple levels of logging within scene loading
  48980. * @returns the human readable reflection probe info
  48981. */
  48982. toString(fullDetails?: boolean): string;
  48983. /**
  48984. * Get the class name of the relfection probe.
  48985. * @returns "ReflectionProbe"
  48986. */
  48987. getClassName(): string;
  48988. /**
  48989. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48990. * @returns The JSON representation of the texture
  48991. */
  48992. serialize(): any;
  48993. /**
  48994. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48995. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48996. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48997. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48998. * @returns The parsed reflection probe if successful
  48999. */
  49000. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49001. }
  49002. }
  49003. declare module BABYLON {
  49004. /** @hidden */
  49005. export var _BabylonLoaderRegistered: boolean;
  49006. }
  49007. declare module BABYLON {
  49008. /**
  49009. * The Physically based simple base material of BJS.
  49010. *
  49011. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49012. * It is used as the base class for both the specGloss and metalRough conventions.
  49013. */
  49014. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49015. /**
  49016. * Number of Simultaneous lights allowed on the material.
  49017. */
  49018. maxSimultaneousLights: number;
  49019. /**
  49020. * If sets to true, disables all the lights affecting the material.
  49021. */
  49022. disableLighting: boolean;
  49023. /**
  49024. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49025. */
  49026. environmentTexture: BaseTexture;
  49027. /**
  49028. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49029. */
  49030. invertNormalMapX: boolean;
  49031. /**
  49032. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49033. */
  49034. invertNormalMapY: boolean;
  49035. /**
  49036. * Normal map used in the model.
  49037. */
  49038. normalTexture: BaseTexture;
  49039. /**
  49040. * Emissivie color used to self-illuminate the model.
  49041. */
  49042. emissiveColor: Color3;
  49043. /**
  49044. * Emissivie texture used to self-illuminate the model.
  49045. */
  49046. emissiveTexture: BaseTexture;
  49047. /**
  49048. * Occlusion Channel Strenght.
  49049. */
  49050. occlusionStrength: number;
  49051. /**
  49052. * Occlusion Texture of the material (adding extra occlusion effects).
  49053. */
  49054. occlusionTexture: BaseTexture;
  49055. /**
  49056. * Defines the alpha limits in alpha test mode.
  49057. */
  49058. alphaCutOff: number;
  49059. /**
  49060. * Gets the current double sided mode.
  49061. */
  49062. /**
  49063. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49064. */
  49065. doubleSided: boolean;
  49066. /**
  49067. * Stores the pre-calculated light information of a mesh in a texture.
  49068. */
  49069. lightmapTexture: BaseTexture;
  49070. /**
  49071. * If true, the light map contains occlusion information instead of lighting info.
  49072. */
  49073. useLightmapAsShadowmap: boolean;
  49074. /**
  49075. * Instantiates a new PBRMaterial instance.
  49076. *
  49077. * @param name The material name
  49078. * @param scene The scene the material will be use in.
  49079. */
  49080. constructor(name: string, scene: Scene);
  49081. getClassName(): string;
  49082. }
  49083. }
  49084. declare module BABYLON {
  49085. /**
  49086. * The PBR material of BJS following the metal roughness convention.
  49087. *
  49088. * This fits to the PBR convention in the GLTF definition:
  49089. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49090. */
  49091. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49092. /**
  49093. * The base color has two different interpretations depending on the value of metalness.
  49094. * When the material is a metal, the base color is the specific measured reflectance value
  49095. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49096. * of the material.
  49097. */
  49098. baseColor: Color3;
  49099. /**
  49100. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49101. * well as opacity information in the alpha channel.
  49102. */
  49103. baseTexture: BaseTexture;
  49104. /**
  49105. * Specifies the metallic scalar value of the material.
  49106. * Can also be used to scale the metalness values of the metallic texture.
  49107. */
  49108. metallic: number;
  49109. /**
  49110. * Specifies the roughness scalar value of the material.
  49111. * Can also be used to scale the roughness values of the metallic texture.
  49112. */
  49113. roughness: number;
  49114. /**
  49115. * Texture containing both the metallic value in the B channel and the
  49116. * roughness value in the G channel to keep better precision.
  49117. */
  49118. metallicRoughnessTexture: BaseTexture;
  49119. /**
  49120. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49121. *
  49122. * @param name The material name
  49123. * @param scene The scene the material will be use in.
  49124. */
  49125. constructor(name: string, scene: Scene);
  49126. /**
  49127. * Return the currrent class name of the material.
  49128. */
  49129. getClassName(): string;
  49130. /**
  49131. * Makes a duplicate of the current material.
  49132. * @param name - name to use for the new material.
  49133. */
  49134. clone(name: string): PBRMetallicRoughnessMaterial;
  49135. /**
  49136. * Serialize the material to a parsable JSON object.
  49137. */
  49138. serialize(): any;
  49139. /**
  49140. * Parses a JSON object correponding to the serialize function.
  49141. */
  49142. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49143. }
  49144. }
  49145. declare module BABYLON {
  49146. /**
  49147. * The PBR material of BJS following the specular glossiness convention.
  49148. *
  49149. * This fits to the PBR convention in the GLTF definition:
  49150. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49151. */
  49152. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49153. /**
  49154. * Specifies the diffuse color of the material.
  49155. */
  49156. diffuseColor: Color3;
  49157. /**
  49158. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49159. * channel.
  49160. */
  49161. diffuseTexture: BaseTexture;
  49162. /**
  49163. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49164. */
  49165. specularColor: Color3;
  49166. /**
  49167. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49168. */
  49169. glossiness: number;
  49170. /**
  49171. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49172. */
  49173. specularGlossinessTexture: BaseTexture;
  49174. /**
  49175. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49176. *
  49177. * @param name The material name
  49178. * @param scene The scene the material will be use in.
  49179. */
  49180. constructor(name: string, scene: Scene);
  49181. /**
  49182. * Return the currrent class name of the material.
  49183. */
  49184. getClassName(): string;
  49185. /**
  49186. * Makes a duplicate of the current material.
  49187. * @param name - name to use for the new material.
  49188. */
  49189. clone(name: string): PBRSpecularGlossinessMaterial;
  49190. /**
  49191. * Serialize the material to a parsable JSON object.
  49192. */
  49193. serialize(): any;
  49194. /**
  49195. * Parses a JSON object correponding to the serialize function.
  49196. */
  49197. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49198. }
  49199. }
  49200. declare module BABYLON {
  49201. /**
  49202. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49203. * It can help converting any input color in a desired output one. This can then be used to create effects
  49204. * from sepia, black and white to sixties or futuristic rendering...
  49205. *
  49206. * The only supported format is currently 3dl.
  49207. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49208. */
  49209. export class ColorGradingTexture extends BaseTexture {
  49210. /**
  49211. * The current texture matrix. (will always be identity in color grading texture)
  49212. */
  49213. private _textureMatrix;
  49214. /**
  49215. * The texture URL.
  49216. */
  49217. url: string;
  49218. /**
  49219. * Empty line regex stored for GC.
  49220. */
  49221. private static _noneEmptyLineRegex;
  49222. private _engine;
  49223. /**
  49224. * Instantiates a ColorGradingTexture from the following parameters.
  49225. *
  49226. * @param url The location of the color gradind data (currently only supporting 3dl)
  49227. * @param scene The scene the texture will be used in
  49228. */
  49229. constructor(url: string, scene: Scene);
  49230. /**
  49231. * Returns the texture matrix used in most of the material.
  49232. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49233. */
  49234. getTextureMatrix(): Matrix;
  49235. /**
  49236. * Occurs when the file being loaded is a .3dl LUT file.
  49237. */
  49238. private load3dlTexture;
  49239. /**
  49240. * Starts the loading process of the texture.
  49241. */
  49242. private loadTexture;
  49243. /**
  49244. * Clones the color gradind texture.
  49245. */
  49246. clone(): ColorGradingTexture;
  49247. /**
  49248. * Called during delayed load for textures.
  49249. */
  49250. delayLoad(): void;
  49251. /**
  49252. * Parses a color grading texture serialized by Babylon.
  49253. * @param parsedTexture The texture information being parsedTexture
  49254. * @param scene The scene to load the texture in
  49255. * @param rootUrl The root url of the data assets to load
  49256. * @return A color gradind texture
  49257. */
  49258. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49259. /**
  49260. * Serializes the LUT texture to json format.
  49261. */
  49262. serialize(): any;
  49263. }
  49264. }
  49265. declare module BABYLON {
  49266. /**
  49267. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49268. */
  49269. export class EquiRectangularCubeTexture extends BaseTexture {
  49270. /** The six faces of the cube. */
  49271. private static _FacesMapping;
  49272. private _noMipmap;
  49273. private _onLoad;
  49274. private _onError;
  49275. /** The size of the cubemap. */
  49276. private _size;
  49277. /** The buffer of the image. */
  49278. private _buffer;
  49279. /** The width of the input image. */
  49280. private _width;
  49281. /** The height of the input image. */
  49282. private _height;
  49283. /** The URL to the image. */
  49284. url: string;
  49285. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49286. coordinatesMode: number;
  49287. /**
  49288. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49289. * @param url The location of the image
  49290. * @param scene The scene the texture will be used in
  49291. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49292. * @param noMipmap Forces to not generate the mipmap if true
  49293. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49294. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49295. * @param onLoad — defines a callback called when texture is loaded
  49296. * @param onError — defines a callback called if there is an error
  49297. */
  49298. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49299. /**
  49300. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49301. */
  49302. private loadImage;
  49303. /**
  49304. * Convert the image buffer into a cubemap and create a CubeTexture.
  49305. */
  49306. private loadTexture;
  49307. /**
  49308. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49309. * @param buffer The ArrayBuffer that should be converted.
  49310. * @returns The buffer as Float32Array.
  49311. */
  49312. private getFloat32ArrayFromArrayBuffer;
  49313. /**
  49314. * Get the current class name of the texture useful for serialization or dynamic coding.
  49315. * @returns "EquiRectangularCubeTexture"
  49316. */
  49317. getClassName(): string;
  49318. /**
  49319. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49320. * @returns A clone of the current EquiRectangularCubeTexture.
  49321. */
  49322. clone(): EquiRectangularCubeTexture;
  49323. }
  49324. }
  49325. declare module BABYLON {
  49326. /**
  49327. * Based on jsTGALoader - Javascript loader for TGA file
  49328. * By Vincent Thibault
  49329. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49330. */
  49331. export class TGATools {
  49332. private static _TYPE_INDEXED;
  49333. private static _TYPE_RGB;
  49334. private static _TYPE_GREY;
  49335. private static _TYPE_RLE_INDEXED;
  49336. private static _TYPE_RLE_RGB;
  49337. private static _TYPE_RLE_GREY;
  49338. private static _ORIGIN_MASK;
  49339. private static _ORIGIN_SHIFT;
  49340. private static _ORIGIN_BL;
  49341. private static _ORIGIN_BR;
  49342. private static _ORIGIN_UL;
  49343. private static _ORIGIN_UR;
  49344. /**
  49345. * Gets the header of a TGA file
  49346. * @param data defines the TGA data
  49347. * @returns the header
  49348. */
  49349. static GetTGAHeader(data: Uint8Array): any;
  49350. /**
  49351. * Uploads TGA content to a Babylon Texture
  49352. * @hidden
  49353. */
  49354. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49355. /** @hidden */
  49356. 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;
  49357. /** @hidden */
  49358. 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;
  49359. /** @hidden */
  49360. 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;
  49361. /** @hidden */
  49362. 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;
  49363. /** @hidden */
  49364. 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;
  49365. /** @hidden */
  49366. 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;
  49367. }
  49368. }
  49369. declare module BABYLON {
  49370. /**
  49371. * Implementation of the TGA Texture Loader.
  49372. * @hidden
  49373. */
  49374. export class _TGATextureLoader implements IInternalTextureLoader {
  49375. /**
  49376. * Defines wether the loader supports cascade loading the different faces.
  49377. */
  49378. readonly supportCascades: boolean;
  49379. /**
  49380. * This returns if the loader support the current file information.
  49381. * @param extension defines the file extension of the file being loaded
  49382. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49383. * @param fallback defines the fallback internal texture if any
  49384. * @param isBase64 defines whether the texture is encoded as a base64
  49385. * @param isBuffer defines whether the texture data are stored as a buffer
  49386. * @returns true if the loader can load the specified file
  49387. */
  49388. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49389. /**
  49390. * Transform the url before loading if required.
  49391. * @param rootUrl the url of the texture
  49392. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49393. * @returns the transformed texture
  49394. */
  49395. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49396. /**
  49397. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49398. * @param rootUrl the url of the texture
  49399. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49400. * @returns the fallback texture
  49401. */
  49402. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49403. /**
  49404. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49405. * @param data contains the texture data
  49406. * @param texture defines the BabylonJS internal texture
  49407. * @param createPolynomials will be true if polynomials have been requested
  49408. * @param onLoad defines the callback to trigger once the texture is ready
  49409. * @param onError defines the callback to trigger in case of error
  49410. */
  49411. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49412. /**
  49413. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49414. * @param data contains the texture data
  49415. * @param texture defines the BabylonJS internal texture
  49416. * @param callback defines the method to call once ready to upload
  49417. */
  49418. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49419. }
  49420. }
  49421. declare module BABYLON {
  49422. /**
  49423. * 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.
  49424. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49425. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49426. */
  49427. export class CustomProceduralTexture extends ProceduralTexture {
  49428. private _animate;
  49429. private _time;
  49430. private _config;
  49431. private _texturePath;
  49432. /**
  49433. * Instantiates a new Custom Procedural Texture.
  49434. * 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.
  49435. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49436. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49437. * @param name Define the name of the texture
  49438. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49439. * @param size Define the size of the texture to create
  49440. * @param scene Define the scene the texture belongs to
  49441. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49442. * @param generateMipMaps Define if the texture should creates mip maps or not
  49443. */
  49444. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49445. private _loadJson;
  49446. /**
  49447. * Is the texture ready to be used ? (rendered at least once)
  49448. * @returns true if ready, otherwise, false.
  49449. */
  49450. isReady(): boolean;
  49451. /**
  49452. * Render the texture to its associated render target.
  49453. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49454. */
  49455. render(useCameraPostProcess?: boolean): void;
  49456. /**
  49457. * Update the list of dependant textures samplers in the shader.
  49458. */
  49459. updateTextures(): void;
  49460. /**
  49461. * Update the uniform values of the procedural texture in the shader.
  49462. */
  49463. updateShaderUniforms(): void;
  49464. /**
  49465. * Define if the texture animates or not.
  49466. */
  49467. animate: boolean;
  49468. }
  49469. }
  49470. declare module BABYLON {
  49471. /** @hidden */
  49472. export var noisePixelShader: {
  49473. name: string;
  49474. shader: string;
  49475. };
  49476. }
  49477. declare module BABYLON {
  49478. /**
  49479. * Class used to generate noise procedural textures
  49480. */
  49481. export class NoiseProceduralTexture extends ProceduralTexture {
  49482. private _time;
  49483. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49484. brightness: number;
  49485. /** Defines the number of octaves to process */
  49486. octaves: number;
  49487. /** Defines the level of persistence (0.8 by default) */
  49488. persistence: number;
  49489. /** Gets or sets animation speed factor (default is 1) */
  49490. animationSpeedFactor: number;
  49491. /**
  49492. * Creates a new NoiseProceduralTexture
  49493. * @param name defines the name fo the texture
  49494. * @param size defines the size of the texture (default is 256)
  49495. * @param scene defines the hosting scene
  49496. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49497. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49498. */
  49499. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49500. private _updateShaderUniforms;
  49501. protected _getDefines(): string;
  49502. /** Generate the current state of the procedural texture */
  49503. render(useCameraPostProcess?: boolean): void;
  49504. /**
  49505. * Serializes this noise procedural texture
  49506. * @returns a serialized noise procedural texture object
  49507. */
  49508. serialize(): any;
  49509. /**
  49510. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49511. * @param parsedTexture defines parsed texture data
  49512. * @param scene defines the current scene
  49513. * @param rootUrl defines the root URL containing noise procedural texture information
  49514. * @returns a parsed NoiseProceduralTexture
  49515. */
  49516. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49517. }
  49518. }
  49519. declare module BABYLON {
  49520. /**
  49521. * Raw cube texture where the raw buffers are passed in
  49522. */
  49523. export class RawCubeTexture extends CubeTexture {
  49524. /**
  49525. * Creates a cube texture where the raw buffers are passed in.
  49526. * @param scene defines the scene the texture is attached to
  49527. * @param data defines the array of data to use to create each face
  49528. * @param size defines the size of the textures
  49529. * @param format defines the format of the data
  49530. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49531. * @param generateMipMaps defines if the engine should generate the mip levels
  49532. * @param invertY defines if data must be stored with Y axis inverted
  49533. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49534. * @param compression defines the compression used (null by default)
  49535. */
  49536. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49537. /**
  49538. * Updates the raw cube texture.
  49539. * @param data defines the data to store
  49540. * @param format defines the data format
  49541. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49542. * @param invertY defines if data must be stored with Y axis inverted
  49543. * @param compression defines the compression used (null by default)
  49544. * @param level defines which level of the texture to update
  49545. */
  49546. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49547. /**
  49548. * Updates a raw cube texture with RGBD encoded data.
  49549. * @param data defines the array of data [mipmap][face] to use to create each face
  49550. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49551. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49552. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49553. * @returns a promsie that resolves when the operation is complete
  49554. */
  49555. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49556. /**
  49557. * Clones the raw cube texture.
  49558. * @return a new cube texture
  49559. */
  49560. clone(): CubeTexture;
  49561. /** @hidden */
  49562. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49563. }
  49564. }
  49565. declare module BABYLON {
  49566. /**
  49567. * Class used to store 3D textures containing user data
  49568. */
  49569. export class RawTexture3D extends Texture {
  49570. /** Gets or sets the texture format to use */
  49571. format: number;
  49572. private _engine;
  49573. /**
  49574. * Create a new RawTexture3D
  49575. * @param data defines the data of the texture
  49576. * @param width defines the width of the texture
  49577. * @param height defines the height of the texture
  49578. * @param depth defines the depth of the texture
  49579. * @param format defines the texture format to use
  49580. * @param scene defines the hosting scene
  49581. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49582. * @param invertY defines if texture must be stored with Y axis inverted
  49583. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49584. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49585. */
  49586. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49587. /** Gets or sets the texture format to use */
  49588. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49589. /**
  49590. * Update the texture with new data
  49591. * @param data defines the data to store in the texture
  49592. */
  49593. update(data: ArrayBufferView): void;
  49594. }
  49595. }
  49596. declare module BABYLON {
  49597. /**
  49598. * Creates a refraction texture used by refraction channel of the standard material.
  49599. * It is like a mirror but to see through a material.
  49600. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49601. */
  49602. export class RefractionTexture extends RenderTargetTexture {
  49603. /**
  49604. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49605. * 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.
  49606. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49607. */
  49608. refractionPlane: Plane;
  49609. /**
  49610. * Define how deep under the surface we should see.
  49611. */
  49612. depth: number;
  49613. /**
  49614. * Creates a refraction texture used by refraction channel of the standard material.
  49615. * It is like a mirror but to see through a material.
  49616. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49617. * @param name Define the texture name
  49618. * @param size Define the size of the underlying texture
  49619. * @param scene Define the scene the refraction belongs to
  49620. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49621. */
  49622. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49623. /**
  49624. * Clone the refraction texture.
  49625. * @returns the cloned texture
  49626. */
  49627. clone(): RefractionTexture;
  49628. /**
  49629. * Serialize the texture to a JSON representation you could use in Parse later on
  49630. * @returns the serialized JSON representation
  49631. */
  49632. serialize(): any;
  49633. }
  49634. }
  49635. declare module BABYLON {
  49636. /**
  49637. * Defines the options related to the creation of an HtmlElementTexture
  49638. */
  49639. export interface IHtmlElementTextureOptions {
  49640. /**
  49641. * Defines wether mip maps should be created or not.
  49642. */
  49643. generateMipMaps?: boolean;
  49644. /**
  49645. * Defines the sampling mode of the texture.
  49646. */
  49647. samplingMode?: number;
  49648. /**
  49649. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  49650. */
  49651. engine: Nullable<Engine>;
  49652. /**
  49653. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  49654. */
  49655. scene: Nullable<Scene>;
  49656. }
  49657. /**
  49658. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  49659. * To be as efficient as possible depending on your constraints nothing aside the first upload
  49660. * is automatically managed.
  49661. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  49662. * in your application.
  49663. *
  49664. * As the update is not automatic, you need to call them manually.
  49665. */
  49666. export class HtmlElementTexture extends BaseTexture {
  49667. /**
  49668. * The texture URL.
  49669. */
  49670. element: HTMLVideoElement | HTMLCanvasElement;
  49671. private static readonly DefaultOptions;
  49672. private _textureMatrix;
  49673. private _engine;
  49674. private _isVideo;
  49675. private _generateMipMaps;
  49676. private _samplingMode;
  49677. /**
  49678. * Instantiates a HtmlElementTexture from the following parameters.
  49679. *
  49680. * @param name Defines the name of the texture
  49681. * @param element Defines the video or canvas the texture is filled with
  49682. * @param options Defines the other none mandatory texture creation options
  49683. */
  49684. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  49685. private _createInternalTexture;
  49686. /**
  49687. * Returns the texture matrix used in most of the material.
  49688. */
  49689. getTextureMatrix(): Matrix;
  49690. /**
  49691. * Updates the content of the texture.
  49692. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  49693. */
  49694. update(invertY?: Nullable<boolean>): void;
  49695. }
  49696. }
  49697. declare module BABYLON {
  49698. /**
  49699. * Helper class to push actions to a pool of workers.
  49700. */
  49701. export class WorkerPool implements IDisposable {
  49702. private _workerInfos;
  49703. private _pendingActions;
  49704. /**
  49705. * Constructor
  49706. * @param workers Array of workers to use for actions
  49707. */
  49708. constructor(workers: Array<Worker>);
  49709. /**
  49710. * Terminates all workers and clears any pending actions.
  49711. */
  49712. dispose(): void;
  49713. /**
  49714. * Pushes an action to the worker pool. If all the workers are active, the action will be
  49715. * pended until a worker has completed its action.
  49716. * @param action The action to perform. Call onComplete when the action is complete.
  49717. */
  49718. push(action: (worker: Worker, onComplete: () => void) => void): void;
  49719. private _execute;
  49720. }
  49721. }
  49722. declare module BABYLON {
  49723. /**
  49724. * Configuration for Draco compression
  49725. */
  49726. export interface IDracoCompressionConfiguration {
  49727. /**
  49728. * Configuration for the decoder.
  49729. */
  49730. decoder: {
  49731. /**
  49732. * The url to the WebAssembly module.
  49733. */
  49734. wasmUrl?: string;
  49735. /**
  49736. * The url to the WebAssembly binary.
  49737. */
  49738. wasmBinaryUrl?: string;
  49739. /**
  49740. * The url to the fallback JavaScript module.
  49741. */
  49742. fallbackUrl?: string;
  49743. };
  49744. }
  49745. /**
  49746. * Draco compression (https://google.github.io/draco/)
  49747. *
  49748. * This class wraps the Draco module.
  49749. *
  49750. * **Encoder**
  49751. *
  49752. * The encoder is not currently implemented.
  49753. *
  49754. * **Decoder**
  49755. *
  49756. * 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.
  49757. *
  49758. * To update the configuration, use the following code:
  49759. * ```javascript
  49760. * DracoCompression.Configuration = {
  49761. * decoder: {
  49762. * wasmUrl: "<url to the WebAssembly library>",
  49763. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49764. * fallbackUrl: "<url to the fallback JavaScript library>",
  49765. * }
  49766. * };
  49767. * ```
  49768. *
  49769. * 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.
  49770. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49771. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  49772. *
  49773. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  49774. * ```javascript
  49775. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  49776. * ```
  49777. *
  49778. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49779. */
  49780. export class DracoCompression implements IDisposable {
  49781. private _workerPoolPromise?;
  49782. private _decoderModulePromise?;
  49783. /**
  49784. * The configuration. Defaults to the following urls:
  49785. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49786. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49787. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49788. */
  49789. static Configuration: IDracoCompressionConfiguration;
  49790. /**
  49791. * Returns true if the decoder configuration is available.
  49792. */
  49793. static readonly DecoderAvailable: boolean;
  49794. /**
  49795. * Default number of workers to create when creating the draco compression object.
  49796. */
  49797. static DefaultNumWorkers: number;
  49798. private static GetDefaultNumWorkers;
  49799. private static _Default;
  49800. /**
  49801. * Default instance for the draco compression object.
  49802. */
  49803. static readonly Default: DracoCompression;
  49804. /**
  49805. * Constructor
  49806. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  49807. */
  49808. constructor(numWorkers?: number);
  49809. /**
  49810. * Stop all async operations and release resources.
  49811. */
  49812. dispose(): void;
  49813. /**
  49814. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  49815. * @returns a promise that resolves when ready
  49816. */
  49817. whenReadyAsync(): Promise<void>;
  49818. /**
  49819. * Decode Draco compressed mesh data to vertex data.
  49820. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49821. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49822. * @returns A promise that resolves with the decoded vertex data
  49823. */
  49824. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  49825. [kind: string]: number;
  49826. }): Promise<VertexData>;
  49827. }
  49828. }
  49829. declare module BABYLON {
  49830. /**
  49831. * Class for building Constructive Solid Geometry
  49832. */
  49833. export class CSG {
  49834. private polygons;
  49835. /**
  49836. * The world matrix
  49837. */
  49838. matrix: Matrix;
  49839. /**
  49840. * Stores the position
  49841. */
  49842. position: Vector3;
  49843. /**
  49844. * Stores the rotation
  49845. */
  49846. rotation: Vector3;
  49847. /**
  49848. * Stores the rotation quaternion
  49849. */
  49850. rotationQuaternion: Nullable<Quaternion>;
  49851. /**
  49852. * Stores the scaling vector
  49853. */
  49854. scaling: Vector3;
  49855. /**
  49856. * Convert the Mesh to CSG
  49857. * @param mesh The Mesh to convert to CSG
  49858. * @returns A new CSG from the Mesh
  49859. */
  49860. static FromMesh(mesh: Mesh): CSG;
  49861. /**
  49862. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49863. * @param polygons Polygons used to construct a CSG solid
  49864. */
  49865. private static FromPolygons;
  49866. /**
  49867. * Clones, or makes a deep copy, of the CSG
  49868. * @returns A new CSG
  49869. */
  49870. clone(): CSG;
  49871. /**
  49872. * Unions this CSG with another CSG
  49873. * @param csg The CSG to union against this CSG
  49874. * @returns The unioned CSG
  49875. */
  49876. union(csg: CSG): CSG;
  49877. /**
  49878. * Unions this CSG with another CSG in place
  49879. * @param csg The CSG to union against this CSG
  49880. */
  49881. unionInPlace(csg: CSG): void;
  49882. /**
  49883. * Subtracts this CSG with another CSG
  49884. * @param csg The CSG to subtract against this CSG
  49885. * @returns A new CSG
  49886. */
  49887. subtract(csg: CSG): CSG;
  49888. /**
  49889. * Subtracts this CSG with another CSG in place
  49890. * @param csg The CSG to subtact against this CSG
  49891. */
  49892. subtractInPlace(csg: CSG): void;
  49893. /**
  49894. * Intersect this CSG with another CSG
  49895. * @param csg The CSG to intersect against this CSG
  49896. * @returns A new CSG
  49897. */
  49898. intersect(csg: CSG): CSG;
  49899. /**
  49900. * Intersects this CSG with another CSG in place
  49901. * @param csg The CSG to intersect against this CSG
  49902. */
  49903. intersectInPlace(csg: CSG): void;
  49904. /**
  49905. * Return a new CSG solid with solid and empty space switched. This solid is
  49906. * not modified.
  49907. * @returns A new CSG solid with solid and empty space switched
  49908. */
  49909. inverse(): CSG;
  49910. /**
  49911. * Inverses the CSG in place
  49912. */
  49913. inverseInPlace(): void;
  49914. /**
  49915. * This is used to keep meshes transformations so they can be restored
  49916. * when we build back a Babylon Mesh
  49917. * NB : All CSG operations are performed in world coordinates
  49918. * @param csg The CSG to copy the transform attributes from
  49919. * @returns This CSG
  49920. */
  49921. copyTransformAttributes(csg: CSG): CSG;
  49922. /**
  49923. * Build Raw mesh from CSG
  49924. * Coordinates here are in world space
  49925. * @param name The name of the mesh geometry
  49926. * @param scene The Scene
  49927. * @param keepSubMeshes Specifies if the submeshes should be kept
  49928. * @returns A new Mesh
  49929. */
  49930. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49931. /**
  49932. * Build Mesh from CSG taking material and transforms into account
  49933. * @param name The name of the Mesh
  49934. * @param material The material of the Mesh
  49935. * @param scene The Scene
  49936. * @param keepSubMeshes Specifies if submeshes should be kept
  49937. * @returns The new Mesh
  49938. */
  49939. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49940. }
  49941. }
  49942. declare module BABYLON {
  49943. /**
  49944. * Class used to create a trail following a mesh
  49945. */
  49946. export class TrailMesh extends Mesh {
  49947. private _generator;
  49948. private _autoStart;
  49949. private _running;
  49950. private _diameter;
  49951. private _length;
  49952. private _sectionPolygonPointsCount;
  49953. private _sectionVectors;
  49954. private _sectionNormalVectors;
  49955. private _beforeRenderObserver;
  49956. /**
  49957. * @constructor
  49958. * @param name The value used by scene.getMeshByName() to do a lookup.
  49959. * @param generator The mesh to generate a trail.
  49960. * @param scene The scene to add this mesh to.
  49961. * @param diameter Diameter of trailing mesh. Default is 1.
  49962. * @param length Length of trailing mesh. Default is 60.
  49963. * @param autoStart Automatically start trailing mesh. Default true.
  49964. */
  49965. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49966. /**
  49967. * "TrailMesh"
  49968. * @returns "TrailMesh"
  49969. */
  49970. getClassName(): string;
  49971. private _createMesh;
  49972. /**
  49973. * Start trailing mesh.
  49974. */
  49975. start(): void;
  49976. /**
  49977. * Stop trailing mesh.
  49978. */
  49979. stop(): void;
  49980. /**
  49981. * Update trailing mesh geometry.
  49982. */
  49983. update(): void;
  49984. /**
  49985. * Returns a new TrailMesh object.
  49986. * @param name is a string, the name given to the new mesh
  49987. * @param newGenerator use new generator object for cloned trail mesh
  49988. * @returns a new mesh
  49989. */
  49990. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49991. /**
  49992. * Serializes this trail mesh
  49993. * @param serializationObject object to write serialization to
  49994. */
  49995. serialize(serializationObject: any): void;
  49996. /**
  49997. * Parses a serialized trail mesh
  49998. * @param parsedMesh the serialized mesh
  49999. * @param scene the scene to create the trail mesh in
  50000. * @returns the created trail mesh
  50001. */
  50002. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  50003. }
  50004. }
  50005. declare module BABYLON {
  50006. /**
  50007. * Class containing static functions to help procedurally build meshes
  50008. */
  50009. export class TorusKnotBuilder {
  50010. /**
  50011. * Creates a torus knot mesh
  50012. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50013. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50014. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50015. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50016. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50017. * * 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
  50018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50019. * @param name defines the name of the mesh
  50020. * @param options defines the options used to create the mesh
  50021. * @param scene defines the hosting scene
  50022. * @returns the torus knot mesh
  50023. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50024. */
  50025. static CreateTorusKnot(name: string, options: {
  50026. radius?: number;
  50027. tube?: number;
  50028. radialSegments?: number;
  50029. tubularSegments?: number;
  50030. p?: number;
  50031. q?: number;
  50032. updatable?: boolean;
  50033. sideOrientation?: number;
  50034. frontUVs?: Vector4;
  50035. backUVs?: Vector4;
  50036. }, scene: any): Mesh;
  50037. }
  50038. }
  50039. declare module BABYLON {
  50040. /**
  50041. * Polygon
  50042. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  50043. */
  50044. export class Polygon {
  50045. /**
  50046. * Creates a rectangle
  50047. * @param xmin bottom X coord
  50048. * @param ymin bottom Y coord
  50049. * @param xmax top X coord
  50050. * @param ymax top Y coord
  50051. * @returns points that make the resulting rectation
  50052. */
  50053. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  50054. /**
  50055. * Creates a circle
  50056. * @param radius radius of circle
  50057. * @param cx scale in x
  50058. * @param cy scale in y
  50059. * @param numberOfSides number of sides that make up the circle
  50060. * @returns points that make the resulting circle
  50061. */
  50062. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  50063. /**
  50064. * Creates a polygon from input string
  50065. * @param input Input polygon data
  50066. * @returns the parsed points
  50067. */
  50068. static Parse(input: string): Vector2[];
  50069. /**
  50070. * Starts building a polygon from x and y coordinates
  50071. * @param x x coordinate
  50072. * @param y y coordinate
  50073. * @returns the started path2
  50074. */
  50075. static StartingAt(x: number, y: number): Path2;
  50076. }
  50077. /**
  50078. * Builds a polygon
  50079. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  50080. */
  50081. export class PolygonMeshBuilder {
  50082. private _points;
  50083. private _outlinepoints;
  50084. private _holes;
  50085. private _name;
  50086. private _scene;
  50087. private _epoints;
  50088. private _eholes;
  50089. private _addToepoint;
  50090. /**
  50091. * Babylon reference to the earcut plugin.
  50092. */
  50093. bjsEarcut: any;
  50094. /**
  50095. * Creates a PolygonMeshBuilder
  50096. * @param name name of the builder
  50097. * @param contours Path of the polygon
  50098. * @param scene scene to add to when creating the mesh
  50099. * @param earcutInjection can be used to inject your own earcut reference
  50100. */
  50101. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  50102. /**
  50103. * Adds a whole within the polygon
  50104. * @param hole Array of points defining the hole
  50105. * @returns this
  50106. */
  50107. addHole(hole: Vector2[]): PolygonMeshBuilder;
  50108. /**
  50109. * Creates the polygon
  50110. * @param updatable If the mesh should be updatable
  50111. * @param depth The depth of the mesh created
  50112. * @returns the created mesh
  50113. */
  50114. build(updatable?: boolean, depth?: number): Mesh;
  50115. /**
  50116. * Creates the polygon
  50117. * @param depth The depth of the mesh created
  50118. * @returns the created VertexData
  50119. */
  50120. buildVertexData(depth?: number): VertexData;
  50121. /**
  50122. * Adds a side to the polygon
  50123. * @param positions points that make the polygon
  50124. * @param normals normals of the polygon
  50125. * @param uvs uvs of the polygon
  50126. * @param indices indices of the polygon
  50127. * @param bounds bounds of the polygon
  50128. * @param points points of the polygon
  50129. * @param depth depth of the polygon
  50130. * @param flip flip of the polygon
  50131. */
  50132. private addSide;
  50133. }
  50134. }
  50135. declare module BABYLON {
  50136. /**
  50137. * Class containing static functions to help procedurally build meshes
  50138. */
  50139. export class PolygonBuilder {
  50140. /**
  50141. * Creates a polygon mesh
  50142. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50143. * * 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
  50144. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50146. * * 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)
  50147. * * Remember you can only change the shape positions, not their number when updating a polygon
  50148. * @param name defines the name of the mesh
  50149. * @param options defines the options used to create the mesh
  50150. * @param scene defines the hosting scene
  50151. * @param earcutInjection can be used to inject your own earcut reference
  50152. * @returns the polygon mesh
  50153. */
  50154. static CreatePolygon(name: string, options: {
  50155. shape: Vector3[];
  50156. holes?: Vector3[][];
  50157. depth?: number;
  50158. faceUV?: Vector4[];
  50159. faceColors?: Color4[];
  50160. updatable?: boolean;
  50161. sideOrientation?: number;
  50162. frontUVs?: Vector4;
  50163. backUVs?: Vector4;
  50164. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50165. /**
  50166. * Creates an extruded polygon mesh, with depth in the Y direction.
  50167. * * 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)
  50168. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50169. * @param name defines the name of the mesh
  50170. * @param options defines the options used to create the mesh
  50171. * @param scene defines the hosting scene
  50172. * @param earcutInjection can be used to inject your own earcut reference
  50173. * @returns the polygon mesh
  50174. */
  50175. static ExtrudePolygon(name: string, options: {
  50176. shape: Vector3[];
  50177. holes?: Vector3[][];
  50178. depth?: number;
  50179. faceUV?: Vector4[];
  50180. faceColors?: Color4[];
  50181. updatable?: boolean;
  50182. sideOrientation?: number;
  50183. frontUVs?: Vector4;
  50184. backUVs?: Vector4;
  50185. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50186. }
  50187. }
  50188. declare module BABYLON {
  50189. /**
  50190. * Class containing static functions to help procedurally build meshes
  50191. */
  50192. export class LatheBuilder {
  50193. /**
  50194. * Creates lathe mesh.
  50195. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50196. * * 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
  50197. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50198. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50199. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50200. * * 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
  50201. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50202. * * 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
  50203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50204. * * 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
  50205. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50207. * @param name defines the name of the mesh
  50208. * @param options defines the options used to create the mesh
  50209. * @param scene defines the hosting scene
  50210. * @returns the lathe mesh
  50211. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50212. */
  50213. static CreateLathe(name: string, options: {
  50214. shape: Vector3[];
  50215. radius?: number;
  50216. tessellation?: number;
  50217. clip?: number;
  50218. arc?: number;
  50219. closed?: boolean;
  50220. updatable?: boolean;
  50221. sideOrientation?: number;
  50222. frontUVs?: Vector4;
  50223. backUVs?: Vector4;
  50224. cap?: number;
  50225. invertUV?: boolean;
  50226. }, scene?: Nullable<Scene>): Mesh;
  50227. }
  50228. }
  50229. declare module BABYLON {
  50230. /**
  50231. * Class containing static functions to help procedurally build meshes
  50232. */
  50233. export class TubeBuilder {
  50234. /**
  50235. * Creates a tube mesh.
  50236. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50237. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50238. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50239. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50240. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50241. * * 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)
  50242. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50243. * * 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
  50244. * * 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
  50245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50246. * * 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
  50247. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50249. * @param name defines the name of the mesh
  50250. * @param options defines the options used to create the mesh
  50251. * @param scene defines the hosting scene
  50252. * @returns the tube mesh
  50253. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50254. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50255. */
  50256. static CreateTube(name: string, options: {
  50257. path: Vector3[];
  50258. radius?: number;
  50259. tessellation?: number;
  50260. radiusFunction?: {
  50261. (i: number, distance: number): number;
  50262. };
  50263. cap?: number;
  50264. arc?: number;
  50265. updatable?: boolean;
  50266. sideOrientation?: number;
  50267. frontUVs?: Vector4;
  50268. backUVs?: Vector4;
  50269. instance?: Mesh;
  50270. invertUV?: boolean;
  50271. }, scene?: Nullable<Scene>): Mesh;
  50272. }
  50273. }
  50274. declare module BABYLON {
  50275. /**
  50276. * Class containing static functions to help procedurally build meshes
  50277. */
  50278. export class IcoSphereBuilder {
  50279. /**
  50280. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50281. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50282. * * 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`)
  50283. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50284. * * 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
  50285. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50286. * * 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
  50287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50288. * @param name defines the name of the mesh
  50289. * @param options defines the options used to create the mesh
  50290. * @param scene defines the hosting scene
  50291. * @returns the icosahedron mesh
  50292. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50293. */
  50294. static CreateIcoSphere(name: string, options: {
  50295. radius?: number;
  50296. radiusX?: number;
  50297. radiusY?: number;
  50298. radiusZ?: number;
  50299. flat?: boolean;
  50300. subdivisions?: number;
  50301. sideOrientation?: number;
  50302. frontUVs?: Vector4;
  50303. backUVs?: Vector4;
  50304. updatable?: boolean;
  50305. }, scene?: Nullable<Scene>): Mesh;
  50306. }
  50307. }
  50308. declare module BABYLON {
  50309. /**
  50310. * Class containing static functions to help procedurally build meshes
  50311. */
  50312. export class DecalBuilder {
  50313. /**
  50314. * Creates a decal mesh.
  50315. * 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
  50316. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50317. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50318. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50319. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50320. * @param name defines the name of the mesh
  50321. * @param sourceMesh defines the mesh where the decal must be applied
  50322. * @param options defines the options used to create the mesh
  50323. * @param scene defines the hosting scene
  50324. * @returns the decal mesh
  50325. * @see https://doc.babylonjs.com/how_to/decals
  50326. */
  50327. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50328. position?: Vector3;
  50329. normal?: Vector3;
  50330. size?: Vector3;
  50331. angle?: number;
  50332. }): Mesh;
  50333. }
  50334. }
  50335. declare module BABYLON {
  50336. /**
  50337. * Class containing static functions to help procedurally build meshes
  50338. */
  50339. export class MeshBuilder {
  50340. /**
  50341. * Creates a box mesh
  50342. * * The parameter `size` sets the size (float) of each box side (default 1)
  50343. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50344. * * 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)
  50345. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50347. * * 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
  50348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50349. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50350. * @param name defines the name of the mesh
  50351. * @param options defines the options used to create the mesh
  50352. * @param scene defines the hosting scene
  50353. * @returns the box mesh
  50354. */
  50355. static CreateBox(name: string, options: {
  50356. size?: number;
  50357. width?: number;
  50358. height?: number;
  50359. depth?: number;
  50360. faceUV?: Vector4[];
  50361. faceColors?: Color4[];
  50362. sideOrientation?: number;
  50363. frontUVs?: Vector4;
  50364. backUVs?: Vector4;
  50365. updatable?: boolean;
  50366. }, scene?: Nullable<Scene>): Mesh;
  50367. /**
  50368. * Creates a sphere mesh
  50369. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50370. * * 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`)
  50371. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50372. * * 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
  50373. * * 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)
  50374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50375. * * 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
  50376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50377. * @param name defines the name of the mesh
  50378. * @param options defines the options used to create the mesh
  50379. * @param scene defines the hosting scene
  50380. * @returns the sphere mesh
  50381. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50382. */
  50383. static CreateSphere(name: string, options: {
  50384. segments?: number;
  50385. diameter?: number;
  50386. diameterX?: number;
  50387. diameterY?: number;
  50388. diameterZ?: number;
  50389. arc?: number;
  50390. slice?: number;
  50391. sideOrientation?: number;
  50392. frontUVs?: Vector4;
  50393. backUVs?: Vector4;
  50394. updatable?: boolean;
  50395. }, scene?: Nullable<Scene>): Mesh;
  50396. /**
  50397. * Creates a plane polygonal mesh. By default, this is a disc
  50398. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50399. * * 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
  50400. * * 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
  50401. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50402. * * 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
  50403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50404. * @param name defines the name of the mesh
  50405. * @param options defines the options used to create the mesh
  50406. * @param scene defines the hosting scene
  50407. * @returns the plane polygonal mesh
  50408. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50409. */
  50410. static CreateDisc(name: string, options: {
  50411. radius?: number;
  50412. tessellation?: number;
  50413. arc?: number;
  50414. updatable?: boolean;
  50415. sideOrientation?: number;
  50416. frontUVs?: Vector4;
  50417. backUVs?: Vector4;
  50418. }, scene?: Nullable<Scene>): Mesh;
  50419. /**
  50420. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50421. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50422. * * 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`)
  50423. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50424. * * 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
  50425. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50426. * * 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
  50427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50428. * @param name defines the name of the mesh
  50429. * @param options defines the options used to create the mesh
  50430. * @param scene defines the hosting scene
  50431. * @returns the icosahedron mesh
  50432. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50433. */
  50434. static CreateIcoSphere(name: string, options: {
  50435. radius?: number;
  50436. radiusX?: number;
  50437. radiusY?: number;
  50438. radiusZ?: number;
  50439. flat?: boolean;
  50440. subdivisions?: number;
  50441. sideOrientation?: number;
  50442. frontUVs?: Vector4;
  50443. backUVs?: Vector4;
  50444. updatable?: boolean;
  50445. }, scene?: Nullable<Scene>): Mesh;
  50446. /**
  50447. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50448. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50449. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50450. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50451. * * 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
  50452. * * 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
  50453. * * 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
  50454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50455. * * 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
  50456. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50457. * * 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
  50458. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50459. * * 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
  50460. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50462. * @param name defines the name of the mesh
  50463. * @param options defines the options used to create the mesh
  50464. * @param scene defines the hosting scene
  50465. * @returns the ribbon mesh
  50466. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50467. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50468. */
  50469. static CreateRibbon(name: string, options: {
  50470. pathArray: Vector3[][];
  50471. closeArray?: boolean;
  50472. closePath?: boolean;
  50473. offset?: number;
  50474. updatable?: boolean;
  50475. sideOrientation?: number;
  50476. frontUVs?: Vector4;
  50477. backUVs?: Vector4;
  50478. instance?: Mesh;
  50479. invertUV?: boolean;
  50480. uvs?: Vector2[];
  50481. colors?: Color4[];
  50482. }, scene?: Nullable<Scene>): Mesh;
  50483. /**
  50484. * Creates a cylinder or a cone mesh
  50485. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50486. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50487. * * 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.
  50488. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50489. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50490. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50491. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50492. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50493. * * 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).
  50494. * * 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
  50495. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50496. * * 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
  50497. * * 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.
  50498. * * If `enclose` is false, a ring surface is one element.
  50499. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50500. * * 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
  50501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50502. * * 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
  50503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50504. * @param name defines the name of the mesh
  50505. * @param options defines the options used to create the mesh
  50506. * @param scene defines the hosting scene
  50507. * @returns the cylinder mesh
  50508. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50509. */
  50510. static CreateCylinder(name: string, options: {
  50511. height?: number;
  50512. diameterTop?: number;
  50513. diameterBottom?: number;
  50514. diameter?: number;
  50515. tessellation?: number;
  50516. subdivisions?: number;
  50517. arc?: number;
  50518. faceColors?: Color4[];
  50519. faceUV?: Vector4[];
  50520. updatable?: boolean;
  50521. hasRings?: boolean;
  50522. enclose?: boolean;
  50523. sideOrientation?: number;
  50524. frontUVs?: Vector4;
  50525. backUVs?: Vector4;
  50526. }, scene?: Nullable<Scene>): Mesh;
  50527. /**
  50528. * Creates a torus mesh
  50529. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50530. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50531. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50532. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50533. * * 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
  50534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50535. * @param name defines the name of the mesh
  50536. * @param options defines the options used to create the mesh
  50537. * @param scene defines the hosting scene
  50538. * @returns the torus mesh
  50539. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50540. */
  50541. static CreateTorus(name: string, options: {
  50542. diameter?: number;
  50543. thickness?: number;
  50544. tessellation?: number;
  50545. updatable?: boolean;
  50546. sideOrientation?: number;
  50547. frontUVs?: Vector4;
  50548. backUVs?: Vector4;
  50549. }, scene?: Nullable<Scene>): Mesh;
  50550. /**
  50551. * Creates a torus knot mesh
  50552. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50553. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50554. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50555. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50557. * * 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
  50558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50559. * @param name defines the name of the mesh
  50560. * @param options defines the options used to create the mesh
  50561. * @param scene defines the hosting scene
  50562. * @returns the torus knot mesh
  50563. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50564. */
  50565. static CreateTorusKnot(name: string, options: {
  50566. radius?: number;
  50567. tube?: number;
  50568. radialSegments?: number;
  50569. tubularSegments?: number;
  50570. p?: number;
  50571. q?: number;
  50572. updatable?: boolean;
  50573. sideOrientation?: number;
  50574. frontUVs?: Vector4;
  50575. backUVs?: Vector4;
  50576. }, scene?: Nullable<Scene>): Mesh;
  50577. /**
  50578. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50579. * * 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
  50580. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50581. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50582. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50583. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50584. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50585. * * 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
  50586. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50588. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50589. * @param name defines the name of the new line system
  50590. * @param options defines the options used to create the line system
  50591. * @param scene defines the hosting scene
  50592. * @returns a new line system mesh
  50593. */
  50594. static CreateLineSystem(name: string, options: {
  50595. lines: Vector3[][];
  50596. updatable?: boolean;
  50597. instance?: Nullable<LinesMesh>;
  50598. colors?: Nullable<Color4[][]>;
  50599. useVertexAlpha?: boolean;
  50600. }, scene: Nullable<Scene>): LinesMesh;
  50601. /**
  50602. * Creates a line mesh
  50603. * 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
  50604. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50605. * * The parameter `points` is an array successive Vector3
  50606. * * 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
  50607. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50608. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50609. * * When updating an instance, remember that only point positions can change, not the number of points
  50610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50611. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50612. * @param name defines the name of the new line system
  50613. * @param options defines the options used to create the line system
  50614. * @param scene defines the hosting scene
  50615. * @returns a new line mesh
  50616. */
  50617. static CreateLines(name: string, options: {
  50618. points: Vector3[];
  50619. updatable?: boolean;
  50620. instance?: Nullable<LinesMesh>;
  50621. colors?: Color4[];
  50622. useVertexAlpha?: boolean;
  50623. }, scene?: Nullable<Scene>): LinesMesh;
  50624. /**
  50625. * Creates a dashed line mesh
  50626. * * 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
  50627. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50628. * * The parameter `points` is an array successive Vector3
  50629. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50630. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50631. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50632. * * 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
  50633. * * When updating an instance, remember that only point positions can change, not the number of points
  50634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50635. * @param name defines the name of the mesh
  50636. * @param options defines the options used to create the mesh
  50637. * @param scene defines the hosting scene
  50638. * @returns the dashed line mesh
  50639. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50640. */
  50641. static CreateDashedLines(name: string, options: {
  50642. points: Vector3[];
  50643. dashSize?: number;
  50644. gapSize?: number;
  50645. dashNb?: number;
  50646. updatable?: boolean;
  50647. instance?: LinesMesh;
  50648. }, scene?: Nullable<Scene>): LinesMesh;
  50649. /**
  50650. * 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.
  50651. * * 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.
  50652. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50653. * * 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.
  50654. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50655. * * 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
  50656. * * 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
  50657. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50659. * * 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
  50660. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50662. * @param name defines the name of the mesh
  50663. * @param options defines the options used to create the mesh
  50664. * @param scene defines the hosting scene
  50665. * @returns the extruded shape mesh
  50666. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50667. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50668. */
  50669. static ExtrudeShape(name: string, options: {
  50670. shape: Vector3[];
  50671. path: Vector3[];
  50672. scale?: number;
  50673. rotation?: number;
  50674. cap?: number;
  50675. updatable?: boolean;
  50676. sideOrientation?: number;
  50677. frontUVs?: Vector4;
  50678. backUVs?: Vector4;
  50679. instance?: Mesh;
  50680. invertUV?: boolean;
  50681. }, scene?: Nullable<Scene>): Mesh;
  50682. /**
  50683. * Creates an custom extruded shape mesh.
  50684. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50685. * * 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.
  50686. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50687. * * 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
  50688. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50689. * * 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
  50690. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50691. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50692. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50693. * * 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
  50694. * * 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
  50695. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50697. * * 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
  50698. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50700. * @param name defines the name of the mesh
  50701. * @param options defines the options used to create the mesh
  50702. * @param scene defines the hosting scene
  50703. * @returns the custom extruded shape mesh
  50704. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50705. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50706. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50707. */
  50708. static ExtrudeShapeCustom(name: string, options: {
  50709. shape: Vector3[];
  50710. path: Vector3[];
  50711. scaleFunction?: any;
  50712. rotationFunction?: any;
  50713. ribbonCloseArray?: boolean;
  50714. ribbonClosePath?: boolean;
  50715. cap?: number;
  50716. updatable?: boolean;
  50717. sideOrientation?: number;
  50718. frontUVs?: Vector4;
  50719. backUVs?: Vector4;
  50720. instance?: Mesh;
  50721. invertUV?: boolean;
  50722. }, scene?: Nullable<Scene>): Mesh;
  50723. /**
  50724. * Creates lathe mesh.
  50725. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50726. * * 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
  50727. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50728. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50729. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50730. * * 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
  50731. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50732. * * 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
  50733. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50734. * * 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
  50735. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50737. * @param name defines the name of the mesh
  50738. * @param options defines the options used to create the mesh
  50739. * @param scene defines the hosting scene
  50740. * @returns the lathe mesh
  50741. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50742. */
  50743. static CreateLathe(name: string, options: {
  50744. shape: Vector3[];
  50745. radius?: number;
  50746. tessellation?: number;
  50747. clip?: number;
  50748. arc?: number;
  50749. closed?: boolean;
  50750. updatable?: boolean;
  50751. sideOrientation?: number;
  50752. frontUVs?: Vector4;
  50753. backUVs?: Vector4;
  50754. cap?: number;
  50755. invertUV?: boolean;
  50756. }, scene?: Nullable<Scene>): Mesh;
  50757. /**
  50758. * Creates a plane mesh
  50759. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50760. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50761. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50763. * * 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
  50764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50765. * @param name defines the name of the mesh
  50766. * @param options defines the options used to create the mesh
  50767. * @param scene defines the hosting scene
  50768. * @returns the plane mesh
  50769. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50770. */
  50771. static CreatePlane(name: string, options: {
  50772. size?: number;
  50773. width?: number;
  50774. height?: number;
  50775. sideOrientation?: number;
  50776. frontUVs?: Vector4;
  50777. backUVs?: Vector4;
  50778. updatable?: boolean;
  50779. sourcePlane?: Plane;
  50780. }, scene?: Nullable<Scene>): Mesh;
  50781. /**
  50782. * Creates a ground mesh
  50783. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50784. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50786. * @param name defines the name of the mesh
  50787. * @param options defines the options used to create the mesh
  50788. * @param scene defines the hosting scene
  50789. * @returns the ground mesh
  50790. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50791. */
  50792. static CreateGround(name: string, options: {
  50793. width?: number;
  50794. height?: number;
  50795. subdivisions?: number;
  50796. subdivisionsX?: number;
  50797. subdivisionsY?: number;
  50798. updatable?: boolean;
  50799. }, scene?: Nullable<Scene>): Mesh;
  50800. /**
  50801. * Creates a tiled ground mesh
  50802. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50803. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50804. * * 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
  50805. * * 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
  50806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50807. * @param name defines the name of the mesh
  50808. * @param options defines the options used to create the mesh
  50809. * @param scene defines the hosting scene
  50810. * @returns the tiled ground mesh
  50811. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50812. */
  50813. static CreateTiledGround(name: string, options: {
  50814. xmin: number;
  50815. zmin: number;
  50816. xmax: number;
  50817. zmax: number;
  50818. subdivisions?: {
  50819. w: number;
  50820. h: number;
  50821. };
  50822. precision?: {
  50823. w: number;
  50824. h: number;
  50825. };
  50826. updatable?: boolean;
  50827. }, scene?: Nullable<Scene>): Mesh;
  50828. /**
  50829. * Creates a ground mesh from a height map
  50830. * * The parameter `url` sets the URL of the height map image resource.
  50831. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50832. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50833. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50834. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50835. * * 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.
  50836. * * 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).
  50837. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50839. * @param name defines the name of the mesh
  50840. * @param url defines the url to the height map
  50841. * @param options defines the options used to create the mesh
  50842. * @param scene defines the hosting scene
  50843. * @returns the ground mesh
  50844. * @see https://doc.babylonjs.com/babylon101/height_map
  50845. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50846. */
  50847. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50848. width?: number;
  50849. height?: number;
  50850. subdivisions?: number;
  50851. minHeight?: number;
  50852. maxHeight?: number;
  50853. colorFilter?: Color3;
  50854. alphaFilter?: number;
  50855. updatable?: boolean;
  50856. onReady?: (mesh: GroundMesh) => void;
  50857. }, scene?: Nullable<Scene>): GroundMesh;
  50858. /**
  50859. * Creates a polygon mesh
  50860. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50861. * * 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
  50862. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50864. * * 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)
  50865. * * Remember you can only change the shape positions, not their number when updating a polygon
  50866. * @param name defines the name of the mesh
  50867. * @param options defines the options used to create the mesh
  50868. * @param scene defines the hosting scene
  50869. * @param earcutInjection can be used to inject your own earcut reference
  50870. * @returns the polygon mesh
  50871. */
  50872. static CreatePolygon(name: string, options: {
  50873. shape: Vector3[];
  50874. holes?: Vector3[][];
  50875. depth?: number;
  50876. faceUV?: Vector4[];
  50877. faceColors?: Color4[];
  50878. updatable?: boolean;
  50879. sideOrientation?: number;
  50880. frontUVs?: Vector4;
  50881. backUVs?: Vector4;
  50882. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50883. /**
  50884. * Creates an extruded polygon mesh, with depth in the Y direction.
  50885. * * 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)
  50886. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50887. * @param name defines the name of the mesh
  50888. * @param options defines the options used to create the mesh
  50889. * @param scene defines the hosting scene
  50890. * @param earcutInjection can be used to inject your own earcut reference
  50891. * @returns the polygon mesh
  50892. */
  50893. static ExtrudePolygon(name: string, options: {
  50894. shape: Vector3[];
  50895. holes?: Vector3[][];
  50896. depth?: number;
  50897. faceUV?: Vector4[];
  50898. faceColors?: Color4[];
  50899. updatable?: boolean;
  50900. sideOrientation?: number;
  50901. frontUVs?: Vector4;
  50902. backUVs?: Vector4;
  50903. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50904. /**
  50905. * Creates a tube mesh.
  50906. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50907. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50908. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50909. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50910. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50911. * * 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)
  50912. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50913. * * 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
  50914. * * 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
  50915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50916. * * 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
  50917. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50919. * @param name defines the name of the mesh
  50920. * @param options defines the options used to create the mesh
  50921. * @param scene defines the hosting scene
  50922. * @returns the tube mesh
  50923. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50924. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50925. */
  50926. static CreateTube(name: string, options: {
  50927. path: Vector3[];
  50928. radius?: number;
  50929. tessellation?: number;
  50930. radiusFunction?: {
  50931. (i: number, distance: number): number;
  50932. };
  50933. cap?: number;
  50934. arc?: number;
  50935. updatable?: boolean;
  50936. sideOrientation?: number;
  50937. frontUVs?: Vector4;
  50938. backUVs?: Vector4;
  50939. instance?: Mesh;
  50940. invertUV?: boolean;
  50941. }, scene?: Nullable<Scene>): Mesh;
  50942. /**
  50943. * Creates a polyhedron mesh
  50944. * * 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
  50945. * * The parameter `size` (positive float, default 1) sets the polygon size
  50946. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50947. * * 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`
  50948. * * 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
  50949. * * 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)`)
  50950. * * 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
  50951. * * 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
  50952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50953. * * 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
  50954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50955. * @param name defines the name of the mesh
  50956. * @param options defines the options used to create the mesh
  50957. * @param scene defines the hosting scene
  50958. * @returns the polyhedron mesh
  50959. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50960. */
  50961. static CreatePolyhedron(name: string, options: {
  50962. type?: number;
  50963. size?: number;
  50964. sizeX?: number;
  50965. sizeY?: number;
  50966. sizeZ?: number;
  50967. custom?: any;
  50968. faceUV?: Vector4[];
  50969. faceColors?: Color4[];
  50970. flat?: boolean;
  50971. updatable?: boolean;
  50972. sideOrientation?: number;
  50973. frontUVs?: Vector4;
  50974. backUVs?: Vector4;
  50975. }, scene?: Nullable<Scene>): Mesh;
  50976. /**
  50977. * Creates a decal mesh.
  50978. * 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
  50979. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50980. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50981. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50982. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50983. * @param name defines the name of the mesh
  50984. * @param sourceMesh defines the mesh where the decal must be applied
  50985. * @param options defines the options used to create the mesh
  50986. * @param scene defines the hosting scene
  50987. * @returns the decal mesh
  50988. * @see https://doc.babylonjs.com/how_to/decals
  50989. */
  50990. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50991. position?: Vector3;
  50992. normal?: Vector3;
  50993. size?: Vector3;
  50994. angle?: number;
  50995. }): Mesh;
  50996. }
  50997. }
  50998. declare module BABYLON {
  50999. /**
  51000. * A simplifier interface for future simplification implementations
  51001. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51002. */
  51003. export interface ISimplifier {
  51004. /**
  51005. * Simplification of a given mesh according to the given settings.
  51006. * Since this requires computation, it is assumed that the function runs async.
  51007. * @param settings The settings of the simplification, including quality and distance
  51008. * @param successCallback A callback that will be called after the mesh was simplified.
  51009. * @param errorCallback in case of an error, this callback will be called. optional.
  51010. */
  51011. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  51012. }
  51013. /**
  51014. * Expected simplification settings.
  51015. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  51016. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51017. */
  51018. export interface ISimplificationSettings {
  51019. /**
  51020. * Gets or sets the expected quality
  51021. */
  51022. quality: number;
  51023. /**
  51024. * Gets or sets the distance when this optimized version should be used
  51025. */
  51026. distance: number;
  51027. /**
  51028. * Gets an already optimized mesh
  51029. */
  51030. optimizeMesh?: boolean;
  51031. }
  51032. /**
  51033. * Class used to specify simplification options
  51034. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51035. */
  51036. export class SimplificationSettings implements ISimplificationSettings {
  51037. /** expected quality */
  51038. quality: number;
  51039. /** distance when this optimized version should be used */
  51040. distance: number;
  51041. /** already optimized mesh */
  51042. optimizeMesh?: boolean | undefined;
  51043. /**
  51044. * Creates a SimplificationSettings
  51045. * @param quality expected quality
  51046. * @param distance distance when this optimized version should be used
  51047. * @param optimizeMesh already optimized mesh
  51048. */
  51049. constructor(
  51050. /** expected quality */
  51051. quality: number,
  51052. /** distance when this optimized version should be used */
  51053. distance: number,
  51054. /** already optimized mesh */
  51055. optimizeMesh?: boolean | undefined);
  51056. }
  51057. /**
  51058. * Interface used to define a simplification task
  51059. */
  51060. export interface ISimplificationTask {
  51061. /**
  51062. * Array of settings
  51063. */
  51064. settings: Array<ISimplificationSettings>;
  51065. /**
  51066. * Simplification type
  51067. */
  51068. simplificationType: SimplificationType;
  51069. /**
  51070. * Mesh to simplify
  51071. */
  51072. mesh: Mesh;
  51073. /**
  51074. * Callback called on success
  51075. */
  51076. successCallback?: () => void;
  51077. /**
  51078. * Defines if parallel processing can be used
  51079. */
  51080. parallelProcessing: boolean;
  51081. }
  51082. /**
  51083. * Queue used to order the simplification tasks
  51084. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51085. */
  51086. export class SimplificationQueue {
  51087. private _simplificationArray;
  51088. /**
  51089. * Gets a boolean indicating that the process is still running
  51090. */
  51091. running: boolean;
  51092. /**
  51093. * Creates a new queue
  51094. */
  51095. constructor();
  51096. /**
  51097. * Adds a new simplification task
  51098. * @param task defines a task to add
  51099. */
  51100. addTask(task: ISimplificationTask): void;
  51101. /**
  51102. * Execute next task
  51103. */
  51104. executeNext(): void;
  51105. /**
  51106. * Execute a simplification task
  51107. * @param task defines the task to run
  51108. */
  51109. runSimplification(task: ISimplificationTask): void;
  51110. private getSimplifier;
  51111. }
  51112. /**
  51113. * The implemented types of simplification
  51114. * At the moment only Quadratic Error Decimation is implemented
  51115. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51116. */
  51117. export enum SimplificationType {
  51118. /** Quadratic error decimation */
  51119. QUADRATIC = 0
  51120. }
  51121. }
  51122. declare module BABYLON {
  51123. interface Scene {
  51124. /** @hidden (Backing field) */
  51125. _simplificationQueue: SimplificationQueue;
  51126. /**
  51127. * Gets or sets the simplification queue attached to the scene
  51128. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51129. */
  51130. simplificationQueue: SimplificationQueue;
  51131. }
  51132. interface Mesh {
  51133. /**
  51134. * Simplify the mesh according to the given array of settings.
  51135. * Function will return immediately and will simplify async
  51136. * @param settings a collection of simplification settings
  51137. * @param parallelProcessing should all levels calculate parallel or one after the other
  51138. * @param simplificationType the type of simplification to run
  51139. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  51140. * @returns the current mesh
  51141. */
  51142. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  51143. }
  51144. /**
  51145. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  51146. * created in a scene
  51147. */
  51148. export class SimplicationQueueSceneComponent implements ISceneComponent {
  51149. /**
  51150. * The component name helpfull to identify the component in the list of scene components.
  51151. */
  51152. readonly name: string;
  51153. /**
  51154. * The scene the component belongs to.
  51155. */
  51156. scene: Scene;
  51157. /**
  51158. * Creates a new instance of the component for the given scene
  51159. * @param scene Defines the scene to register the component in
  51160. */
  51161. constructor(scene: Scene);
  51162. /**
  51163. * Registers the component in a given scene
  51164. */
  51165. register(): void;
  51166. /**
  51167. * Rebuilds the elements related to this component in case of
  51168. * context lost for instance.
  51169. */
  51170. rebuild(): void;
  51171. /**
  51172. * Disposes the component and the associated ressources
  51173. */
  51174. dispose(): void;
  51175. private _beforeCameraUpdate;
  51176. }
  51177. }
  51178. declare module BABYLON {
  51179. /**
  51180. * Class used to enable access to IndexedDB
  51181. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51182. */
  51183. export class Database implements IOfflineProvider {
  51184. private _callbackManifestChecked;
  51185. private _currentSceneUrl;
  51186. private _db;
  51187. private _enableSceneOffline;
  51188. private _enableTexturesOffline;
  51189. private _manifestVersionFound;
  51190. private _mustUpdateRessources;
  51191. private _hasReachedQuota;
  51192. private _isSupported;
  51193. private _idbFactory;
  51194. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51195. private static IsUASupportingBlobStorage;
  51196. /**
  51197. * Gets a boolean indicating if Database storate is enabled (off by default)
  51198. */
  51199. static IDBStorageEnabled: boolean;
  51200. /**
  51201. * Gets a boolean indicating if scene must be saved in the database
  51202. */
  51203. readonly enableSceneOffline: boolean;
  51204. /**
  51205. * Gets a boolean indicating if textures must be saved in the database
  51206. */
  51207. readonly enableTexturesOffline: boolean;
  51208. /**
  51209. * Creates a new Database
  51210. * @param urlToScene defines the url to load the scene
  51211. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51212. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51213. */
  51214. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51215. private static _ParseURL;
  51216. private static _ReturnFullUrlLocation;
  51217. private _checkManifestFile;
  51218. /**
  51219. * Open the database and make it available
  51220. * @param successCallback defines the callback to call on success
  51221. * @param errorCallback defines the callback to call on error
  51222. */
  51223. open(successCallback: () => void, errorCallback: () => void): void;
  51224. /**
  51225. * Loads an image from the database
  51226. * @param url defines the url to load from
  51227. * @param image defines the target DOM image
  51228. */
  51229. loadImage(url: string, image: HTMLImageElement): void;
  51230. private _loadImageFromDBAsync;
  51231. private _saveImageIntoDBAsync;
  51232. private _checkVersionFromDB;
  51233. private _loadVersionFromDBAsync;
  51234. private _saveVersionIntoDBAsync;
  51235. /**
  51236. * Loads a file from database
  51237. * @param url defines the URL to load from
  51238. * @param sceneLoaded defines a callback to call on success
  51239. * @param progressCallBack defines a callback to call when progress changed
  51240. * @param errorCallback defines a callback to call on error
  51241. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51242. */
  51243. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51244. private _loadFileAsync;
  51245. private _saveFileAsync;
  51246. /**
  51247. * Validates if xhr data is correct
  51248. * @param xhr defines the request to validate
  51249. * @param dataType defines the expected data type
  51250. * @returns true if data is correct
  51251. */
  51252. private static _ValidateXHRData;
  51253. }
  51254. }
  51255. declare module BABYLON {
  51256. /** @hidden */
  51257. export var gpuUpdateParticlesPixelShader: {
  51258. name: string;
  51259. shader: string;
  51260. };
  51261. }
  51262. declare module BABYLON {
  51263. /** @hidden */
  51264. export var gpuUpdateParticlesVertexShader: {
  51265. name: string;
  51266. shader: string;
  51267. };
  51268. }
  51269. declare module BABYLON {
  51270. /** @hidden */
  51271. export var clipPlaneFragmentDeclaration2: {
  51272. name: string;
  51273. shader: string;
  51274. };
  51275. }
  51276. declare module BABYLON {
  51277. /** @hidden */
  51278. export var gpuRenderParticlesPixelShader: {
  51279. name: string;
  51280. shader: string;
  51281. };
  51282. }
  51283. declare module BABYLON {
  51284. /** @hidden */
  51285. export var clipPlaneVertexDeclaration2: {
  51286. name: string;
  51287. shader: string;
  51288. };
  51289. }
  51290. declare module BABYLON {
  51291. /** @hidden */
  51292. export var gpuRenderParticlesVertexShader: {
  51293. name: string;
  51294. shader: string;
  51295. };
  51296. }
  51297. declare module BABYLON {
  51298. /**
  51299. * This represents a GPU particle system in Babylon
  51300. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51301. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51302. */
  51303. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51304. /**
  51305. * The layer mask we are rendering the particles through.
  51306. */
  51307. layerMask: number;
  51308. private _capacity;
  51309. private _activeCount;
  51310. private _currentActiveCount;
  51311. private _accumulatedCount;
  51312. private _renderEffect;
  51313. private _updateEffect;
  51314. private _buffer0;
  51315. private _buffer1;
  51316. private _spriteBuffer;
  51317. private _updateVAO;
  51318. private _renderVAO;
  51319. private _targetIndex;
  51320. private _sourceBuffer;
  51321. private _targetBuffer;
  51322. private _engine;
  51323. private _currentRenderId;
  51324. private _started;
  51325. private _stopped;
  51326. private _timeDelta;
  51327. private _randomTexture;
  51328. private _randomTexture2;
  51329. private _attributesStrideSize;
  51330. private _updateEffectOptions;
  51331. private _randomTextureSize;
  51332. private _actualFrame;
  51333. private readonly _rawTextureWidth;
  51334. /**
  51335. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51336. */
  51337. static readonly IsSupported: boolean;
  51338. /**
  51339. * An event triggered when the system is disposed.
  51340. */
  51341. onDisposeObservable: Observable<GPUParticleSystem>;
  51342. /**
  51343. * Gets the maximum number of particles active at the same time.
  51344. * @returns The max number of active particles.
  51345. */
  51346. getCapacity(): number;
  51347. /**
  51348. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51349. * to override the particles.
  51350. */
  51351. forceDepthWrite: boolean;
  51352. /**
  51353. * Gets or set the number of active particles
  51354. */
  51355. activeParticleCount: number;
  51356. private _preWarmDone;
  51357. /**
  51358. * Is this system ready to be used/rendered
  51359. * @return true if the system is ready
  51360. */
  51361. isReady(): boolean;
  51362. /**
  51363. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51364. * @returns True if it has been started, otherwise false.
  51365. */
  51366. isStarted(): boolean;
  51367. /**
  51368. * Starts the particle system and begins to emit
  51369. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51370. */
  51371. start(delay?: number): void;
  51372. /**
  51373. * Stops the particle system.
  51374. */
  51375. stop(): void;
  51376. /**
  51377. * Remove all active particles
  51378. */
  51379. reset(): void;
  51380. /**
  51381. * Returns the string "GPUParticleSystem"
  51382. * @returns a string containing the class name
  51383. */
  51384. getClassName(): string;
  51385. private _colorGradientsTexture;
  51386. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51387. /**
  51388. * Adds a new color gradient
  51389. * @param gradient defines the gradient to use (between 0 and 1)
  51390. * @param color1 defines the color to affect to the specified gradient
  51391. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51392. * @returns the current particle system
  51393. */
  51394. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51395. /**
  51396. * Remove a specific color gradient
  51397. * @param gradient defines the gradient to remove
  51398. * @returns the current particle system
  51399. */
  51400. removeColorGradient(gradient: number): GPUParticleSystem;
  51401. private _angularSpeedGradientsTexture;
  51402. private _sizeGradientsTexture;
  51403. private _velocityGradientsTexture;
  51404. private _limitVelocityGradientsTexture;
  51405. private _dragGradientsTexture;
  51406. private _addFactorGradient;
  51407. /**
  51408. * Adds a new size gradient
  51409. * @param gradient defines the gradient to use (between 0 and 1)
  51410. * @param factor defines the size factor to affect to the specified gradient
  51411. * @returns the current particle system
  51412. */
  51413. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51414. /**
  51415. * Remove a specific size gradient
  51416. * @param gradient defines the gradient to remove
  51417. * @returns the current particle system
  51418. */
  51419. removeSizeGradient(gradient: number): GPUParticleSystem;
  51420. /**
  51421. * Adds a new angular speed gradient
  51422. * @param gradient defines the gradient to use (between 0 and 1)
  51423. * @param factor defines the angular speed to affect to the specified gradient
  51424. * @returns the current particle system
  51425. */
  51426. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51427. /**
  51428. * Remove a specific angular speed gradient
  51429. * @param gradient defines the gradient to remove
  51430. * @returns the current particle system
  51431. */
  51432. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51433. /**
  51434. * Adds a new velocity gradient
  51435. * @param gradient defines the gradient to use (between 0 and 1)
  51436. * @param factor defines the velocity to affect to the specified gradient
  51437. * @returns the current particle system
  51438. */
  51439. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51440. /**
  51441. * Remove a specific velocity gradient
  51442. * @param gradient defines the gradient to remove
  51443. * @returns the current particle system
  51444. */
  51445. removeVelocityGradient(gradient: number): GPUParticleSystem;
  51446. /**
  51447. * Adds a new limit velocity gradient
  51448. * @param gradient defines the gradient to use (between 0 and 1)
  51449. * @param factor defines the limit velocity value to affect to the specified gradient
  51450. * @returns the current particle system
  51451. */
  51452. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51453. /**
  51454. * Remove a specific limit velocity gradient
  51455. * @param gradient defines the gradient to remove
  51456. * @returns the current particle system
  51457. */
  51458. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  51459. /**
  51460. * Adds a new drag gradient
  51461. * @param gradient defines the gradient to use (between 0 and 1)
  51462. * @param factor defines the drag value to affect to the specified gradient
  51463. * @returns the current particle system
  51464. */
  51465. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  51466. /**
  51467. * Remove a specific drag gradient
  51468. * @param gradient defines the gradient to remove
  51469. * @returns the current particle system
  51470. */
  51471. removeDragGradient(gradient: number): GPUParticleSystem;
  51472. /**
  51473. * Not supported by GPUParticleSystem
  51474. * @param gradient defines the gradient to use (between 0 and 1)
  51475. * @param factor defines the emit rate value to affect to the specified gradient
  51476. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51477. * @returns the current particle system
  51478. */
  51479. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51480. /**
  51481. * Not supported by GPUParticleSystem
  51482. * @param gradient defines the gradient to remove
  51483. * @returns the current particle system
  51484. */
  51485. removeEmitRateGradient(gradient: number): IParticleSystem;
  51486. /**
  51487. * Not supported by GPUParticleSystem
  51488. * @param gradient defines the gradient to use (between 0 and 1)
  51489. * @param factor defines the start size value to affect to the specified gradient
  51490. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51491. * @returns the current particle system
  51492. */
  51493. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51494. /**
  51495. * Not supported by GPUParticleSystem
  51496. * @param gradient defines the gradient to remove
  51497. * @returns the current particle system
  51498. */
  51499. removeStartSizeGradient(gradient: number): IParticleSystem;
  51500. /**
  51501. * Not supported by GPUParticleSystem
  51502. * @param gradient defines the gradient to use (between 0 and 1)
  51503. * @param min defines the color remap minimal range
  51504. * @param max defines the color remap maximal range
  51505. * @returns the current particle system
  51506. */
  51507. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51508. /**
  51509. * Not supported by GPUParticleSystem
  51510. * @param gradient defines the gradient to remove
  51511. * @returns the current particle system
  51512. */
  51513. removeColorRemapGradient(): IParticleSystem;
  51514. /**
  51515. * Not supported by GPUParticleSystem
  51516. * @param gradient defines the gradient to use (between 0 and 1)
  51517. * @param min defines the alpha remap minimal range
  51518. * @param max defines the alpha remap maximal range
  51519. * @returns the current particle system
  51520. */
  51521. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51522. /**
  51523. * Not supported by GPUParticleSystem
  51524. * @param gradient defines the gradient to remove
  51525. * @returns the current particle system
  51526. */
  51527. removeAlphaRemapGradient(): IParticleSystem;
  51528. /**
  51529. * Not supported by GPUParticleSystem
  51530. * @param gradient defines the gradient to use (between 0 and 1)
  51531. * @param color defines the color to affect to the specified gradient
  51532. * @returns the current particle system
  51533. */
  51534. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51535. /**
  51536. * Not supported by GPUParticleSystem
  51537. * @param gradient defines the gradient to remove
  51538. * @returns the current particle system
  51539. */
  51540. removeRampGradient(): IParticleSystem;
  51541. /**
  51542. * Not supported by GPUParticleSystem
  51543. * @returns the list of ramp gradients
  51544. */
  51545. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51546. /**
  51547. * Not supported by GPUParticleSystem
  51548. * Gets or sets a boolean indicating that ramp gradients must be used
  51549. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51550. */
  51551. useRampGradients: boolean;
  51552. /**
  51553. * Not supported by GPUParticleSystem
  51554. * @param gradient defines the gradient to use (between 0 and 1)
  51555. * @param factor defines the life time factor to affect to the specified gradient
  51556. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51557. * @returns the current particle system
  51558. */
  51559. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51560. /**
  51561. * Not supported by GPUParticleSystem
  51562. * @param gradient defines the gradient to remove
  51563. * @returns the current particle system
  51564. */
  51565. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51566. /**
  51567. * Instantiates a GPU particle system.
  51568. * 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.
  51569. * @param name The name of the particle system
  51570. * @param options The options used to create the system
  51571. * @param scene The scene the particle system belongs to
  51572. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51573. */
  51574. constructor(name: string, options: Partial<{
  51575. capacity: number;
  51576. randomTextureSize: number;
  51577. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51578. protected _reset(): void;
  51579. private _createUpdateVAO;
  51580. private _createRenderVAO;
  51581. private _initialize;
  51582. /** @hidden */
  51583. _recreateUpdateEffect(): void;
  51584. /** @hidden */
  51585. _recreateRenderEffect(): void;
  51586. /**
  51587. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51588. * @param preWarm defines if we are in the pre-warmimg phase
  51589. */
  51590. animate(preWarm?: boolean): void;
  51591. private _createFactorGradientTexture;
  51592. private _createSizeGradientTexture;
  51593. private _createAngularSpeedGradientTexture;
  51594. private _createVelocityGradientTexture;
  51595. private _createLimitVelocityGradientTexture;
  51596. private _createDragGradientTexture;
  51597. private _createColorGradientTexture;
  51598. /**
  51599. * Renders the particle system in its current state
  51600. * @param preWarm defines if the system should only update the particles but not render them
  51601. * @returns the current number of particles
  51602. */
  51603. render(preWarm?: boolean): number;
  51604. /**
  51605. * Rebuilds the particle system
  51606. */
  51607. rebuild(): void;
  51608. private _releaseBuffers;
  51609. private _releaseVAOs;
  51610. /**
  51611. * Disposes the particle system and free the associated resources
  51612. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51613. */
  51614. dispose(disposeTexture?: boolean): void;
  51615. /**
  51616. * Clones the particle system.
  51617. * @param name The name of the cloned object
  51618. * @param newEmitter The new emitter to use
  51619. * @returns the cloned particle system
  51620. */
  51621. clone(name: string, newEmitter: any): GPUParticleSystem;
  51622. /**
  51623. * Serializes the particle system to a JSON object.
  51624. * @returns the JSON object
  51625. */
  51626. serialize(): any;
  51627. /**
  51628. * Parses a JSON object to create a GPU particle system.
  51629. * @param parsedParticleSystem The JSON object to parse
  51630. * @param scene The scene to create the particle system in
  51631. * @param rootUrl The root url to use to load external dependencies like texture
  51632. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51633. * @returns the parsed GPU particle system
  51634. */
  51635. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51636. }
  51637. }
  51638. declare module BABYLON {
  51639. /**
  51640. * Represents a set of particle systems working together to create a specific effect
  51641. */
  51642. export class ParticleSystemSet implements IDisposable {
  51643. private _emitterCreationOptions;
  51644. private _emitterNode;
  51645. /**
  51646. * Gets the particle system list
  51647. */
  51648. systems: IParticleSystem[];
  51649. /**
  51650. * Gets the emitter node used with this set
  51651. */
  51652. readonly emitterNode: Nullable<TransformNode>;
  51653. /**
  51654. * Creates a new emitter mesh as a sphere
  51655. * @param options defines the options used to create the sphere
  51656. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51657. * @param scene defines the hosting scene
  51658. */
  51659. setEmitterAsSphere(options: {
  51660. diameter: number;
  51661. segments: number;
  51662. color: Color3;
  51663. }, renderingGroupId: number, scene: Scene): void;
  51664. /**
  51665. * Starts all particle systems of the set
  51666. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51667. */
  51668. start(emitter?: AbstractMesh): void;
  51669. /**
  51670. * Release all associated resources
  51671. */
  51672. dispose(): void;
  51673. /**
  51674. * Serialize the set into a JSON compatible object
  51675. * @returns a JSON compatible representation of the set
  51676. */
  51677. serialize(): any;
  51678. /**
  51679. * Parse a new ParticleSystemSet from a serialized source
  51680. * @param data defines a JSON compatible representation of the set
  51681. * @param scene defines the hosting scene
  51682. * @param gpu defines if we want GPU particles or CPU particles
  51683. * @returns a new ParticleSystemSet
  51684. */
  51685. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51686. }
  51687. }
  51688. declare module BABYLON {
  51689. /**
  51690. * This class is made for on one-liner static method to help creating particle system set.
  51691. */
  51692. export class ParticleHelper {
  51693. /**
  51694. * Gets or sets base Assets URL
  51695. */
  51696. static BaseAssetsUrl: string;
  51697. /**
  51698. * Create a default particle system that you can tweak
  51699. * @param emitter defines the emitter to use
  51700. * @param capacity defines the system capacity (default is 500 particles)
  51701. * @param scene defines the hosting scene
  51702. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51703. * @returns the new Particle system
  51704. */
  51705. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51706. /**
  51707. * This is the main static method (one-liner) of this helper to create different particle systems
  51708. * @param type This string represents the type to the particle system to create
  51709. * @param scene The scene where the particle system should live
  51710. * @param gpu If the system will use gpu
  51711. * @returns the ParticleSystemSet created
  51712. */
  51713. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51714. /**
  51715. * Static function used to export a particle system to a ParticleSystemSet variable.
  51716. * Please note that the emitter shape is not exported
  51717. * @param systems defines the particle systems to export
  51718. * @returns the created particle system set
  51719. */
  51720. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51721. }
  51722. }
  51723. declare module BABYLON {
  51724. interface Engine {
  51725. /**
  51726. * Create an effect to use with particle systems.
  51727. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51728. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51729. * @param uniformsNames defines a list of attribute names
  51730. * @param samplers defines an array of string used to represent textures
  51731. * @param defines defines the string containing the defines to use to compile the shaders
  51732. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51733. * @param onCompiled defines a function to call when the effect creation is successful
  51734. * @param onError defines a function to call when the effect creation has failed
  51735. * @returns the new Effect
  51736. */
  51737. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  51738. }
  51739. interface Mesh {
  51740. /**
  51741. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  51742. * @returns an array of IParticleSystem
  51743. */
  51744. getEmittedParticleSystems(): IParticleSystem[];
  51745. /**
  51746. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51747. * @returns an array of IParticleSystem
  51748. */
  51749. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51750. }
  51751. /**
  51752. * @hidden
  51753. */
  51754. export var _IDoNeedToBeInTheBuild: number;
  51755. }
  51756. declare module BABYLON {
  51757. interface Scene {
  51758. /** @hidden (Backing field) */
  51759. _physicsEngine: Nullable<IPhysicsEngine>;
  51760. /**
  51761. * Gets the current physics engine
  51762. * @returns a IPhysicsEngine or null if none attached
  51763. */
  51764. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51765. /**
  51766. * Enables physics to the current scene
  51767. * @param gravity defines the scene's gravity for the physics engine
  51768. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51769. * @return a boolean indicating if the physics engine was initialized
  51770. */
  51771. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51772. /**
  51773. * Disables and disposes the physics engine associated with the scene
  51774. */
  51775. disablePhysicsEngine(): void;
  51776. /**
  51777. * Gets a boolean indicating if there is an active physics engine
  51778. * @returns a boolean indicating if there is an active physics engine
  51779. */
  51780. isPhysicsEnabled(): boolean;
  51781. /**
  51782. * Deletes a physics compound impostor
  51783. * @param compound defines the compound to delete
  51784. */
  51785. deleteCompoundImpostor(compound: any): void;
  51786. /**
  51787. * An event triggered when physic simulation is about to be run
  51788. */
  51789. onBeforePhysicsObservable: Observable<Scene>;
  51790. /**
  51791. * An event triggered when physic simulation has been done
  51792. */
  51793. onAfterPhysicsObservable: Observable<Scene>;
  51794. }
  51795. interface AbstractMesh {
  51796. /** @hidden */
  51797. _physicsImpostor: Nullable<PhysicsImpostor>;
  51798. /**
  51799. * Gets or sets impostor used for physic simulation
  51800. * @see http://doc.babylonjs.com/features/physics_engine
  51801. */
  51802. physicsImpostor: Nullable<PhysicsImpostor>;
  51803. /**
  51804. * Gets the current physics impostor
  51805. * @see http://doc.babylonjs.com/features/physics_engine
  51806. * @returns a physics impostor or null
  51807. */
  51808. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51809. /** Apply a physic impulse to the mesh
  51810. * @param force defines the force to apply
  51811. * @param contactPoint defines where to apply the force
  51812. * @returns the current mesh
  51813. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51814. */
  51815. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51816. /**
  51817. * Creates a physic joint between two meshes
  51818. * @param otherMesh defines the other mesh to use
  51819. * @param pivot1 defines the pivot to use on this mesh
  51820. * @param pivot2 defines the pivot to use on the other mesh
  51821. * @param options defines additional options (can be plugin dependent)
  51822. * @returns the current mesh
  51823. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51824. */
  51825. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51826. /** @hidden */
  51827. _disposePhysicsObserver: Nullable<Observer<Node>>;
  51828. }
  51829. /**
  51830. * Defines the physics engine scene component responsible to manage a physics engine
  51831. */
  51832. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51833. /**
  51834. * The component name helpful to identify the component in the list of scene components.
  51835. */
  51836. readonly name: string;
  51837. /**
  51838. * The scene the component belongs to.
  51839. */
  51840. scene: Scene;
  51841. /**
  51842. * Creates a new instance of the component for the given scene
  51843. * @param scene Defines the scene to register the component in
  51844. */
  51845. constructor(scene: Scene);
  51846. /**
  51847. * Registers the component in a given scene
  51848. */
  51849. register(): void;
  51850. /**
  51851. * Rebuilds the elements related to this component in case of
  51852. * context lost for instance.
  51853. */
  51854. rebuild(): void;
  51855. /**
  51856. * Disposes the component and the associated ressources
  51857. */
  51858. dispose(): void;
  51859. }
  51860. }
  51861. declare module BABYLON {
  51862. /**
  51863. * A helper for physics simulations
  51864. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51865. */
  51866. export class PhysicsHelper {
  51867. private _scene;
  51868. private _physicsEngine;
  51869. /**
  51870. * Initializes the Physics helper
  51871. * @param scene Babylon.js scene
  51872. */
  51873. constructor(scene: Scene);
  51874. /**
  51875. * Applies a radial explosion impulse
  51876. * @param origin the origin of the explosion
  51877. * @param radiusOrEventOptions the radius or the options of radial explosion
  51878. * @param strength the explosion strength
  51879. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51880. * @returns A physics radial explosion event, or null
  51881. */
  51882. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51883. /**
  51884. * Applies a radial explosion force
  51885. * @param origin the origin of the explosion
  51886. * @param radiusOrEventOptions the radius or the options of radial explosion
  51887. * @param strength the explosion strength
  51888. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51889. * @returns A physics radial explosion event, or null
  51890. */
  51891. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51892. /**
  51893. * Creates a gravitational field
  51894. * @param origin the origin of the explosion
  51895. * @param radiusOrEventOptions the radius or the options of radial explosion
  51896. * @param strength the explosion strength
  51897. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51898. * @returns A physics gravitational field event, or null
  51899. */
  51900. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  51901. /**
  51902. * Creates a physics updraft event
  51903. * @param origin the origin of the updraft
  51904. * @param radiusOrEventOptions the radius or the options of the updraft
  51905. * @param strength the strength of the updraft
  51906. * @param height the height of the updraft
  51907. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  51908. * @returns A physics updraft event, or null
  51909. */
  51910. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  51911. /**
  51912. * Creates a physics vortex event
  51913. * @param origin the of the vortex
  51914. * @param radiusOrEventOptions the radius or the options of the vortex
  51915. * @param strength the strength of the vortex
  51916. * @param height the height of the vortex
  51917. * @returns a Physics vortex event, or null
  51918. * A physics vortex event or null
  51919. */
  51920. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  51921. }
  51922. /**
  51923. * Represents a physics radial explosion event
  51924. */
  51925. class PhysicsRadialExplosionEvent {
  51926. private _scene;
  51927. private _options;
  51928. private _sphere;
  51929. private _dataFetched;
  51930. /**
  51931. * Initializes a radial explosioin event
  51932. * @param _scene BabylonJS scene
  51933. * @param _options The options for the vortex event
  51934. */
  51935. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  51936. /**
  51937. * Returns the data related to the radial explosion event (sphere).
  51938. * @returns The radial explosion event data
  51939. */
  51940. getData(): PhysicsRadialExplosionEventData;
  51941. /**
  51942. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  51943. * @param impostor A physics imposter
  51944. * @param origin the origin of the explosion
  51945. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  51946. */
  51947. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  51948. /**
  51949. * Triggers affecterd impostors callbacks
  51950. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  51951. */
  51952. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  51953. /**
  51954. * Disposes the sphere.
  51955. * @param force Specifies if the sphere should be disposed by force
  51956. */
  51957. dispose(force?: boolean): void;
  51958. /*** Helpers ***/
  51959. private _prepareSphere;
  51960. private _intersectsWithSphere;
  51961. }
  51962. /**
  51963. * Represents a gravitational field event
  51964. */
  51965. class PhysicsGravitationalFieldEvent {
  51966. private _physicsHelper;
  51967. private _scene;
  51968. private _origin;
  51969. private _options;
  51970. private _tickCallback;
  51971. private _sphere;
  51972. private _dataFetched;
  51973. /**
  51974. * Initializes the physics gravitational field event
  51975. * @param _physicsHelper A physics helper
  51976. * @param _scene BabylonJS scene
  51977. * @param _origin The origin position of the gravitational field event
  51978. * @param _options The options for the vortex event
  51979. */
  51980. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  51981. /**
  51982. * Returns the data related to the gravitational field event (sphere).
  51983. * @returns A gravitational field event
  51984. */
  51985. getData(): PhysicsGravitationalFieldEventData;
  51986. /**
  51987. * Enables the gravitational field.
  51988. */
  51989. enable(): void;
  51990. /**
  51991. * Disables the gravitational field.
  51992. */
  51993. disable(): void;
  51994. /**
  51995. * Disposes the sphere.
  51996. * @param force The force to dispose from the gravitational field event
  51997. */
  51998. dispose(force?: boolean): void;
  51999. private _tick;
  52000. }
  52001. /**
  52002. * Represents a physics updraft event
  52003. */
  52004. class PhysicsUpdraftEvent {
  52005. private _scene;
  52006. private _origin;
  52007. private _options;
  52008. private _physicsEngine;
  52009. private _originTop;
  52010. private _originDirection;
  52011. private _tickCallback;
  52012. private _cylinder;
  52013. private _cylinderPosition;
  52014. private _dataFetched;
  52015. /**
  52016. * Initializes the physics updraft event
  52017. * @param _scene BabylonJS scene
  52018. * @param _origin The origin position of the updraft
  52019. * @param _options The options for the updraft event
  52020. */
  52021. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  52022. /**
  52023. * Returns the data related to the updraft event (cylinder).
  52024. * @returns A physics updraft event
  52025. */
  52026. getData(): PhysicsUpdraftEventData;
  52027. /**
  52028. * Enables the updraft.
  52029. */
  52030. enable(): void;
  52031. /**
  52032. * Disables the updraft.
  52033. */
  52034. disable(): void;
  52035. /**
  52036. * Disposes the cylinder.
  52037. * @param force Specifies if the updraft should be disposed by force
  52038. */
  52039. dispose(force?: boolean): void;
  52040. private getImpostorHitData;
  52041. private _tick;
  52042. /*** Helpers ***/
  52043. private _prepareCylinder;
  52044. private _intersectsWithCylinder;
  52045. }
  52046. /**
  52047. * Represents a physics vortex event
  52048. */
  52049. class PhysicsVortexEvent {
  52050. private _scene;
  52051. private _origin;
  52052. private _options;
  52053. private _physicsEngine;
  52054. private _originTop;
  52055. private _tickCallback;
  52056. private _cylinder;
  52057. private _cylinderPosition;
  52058. private _dataFetched;
  52059. /**
  52060. * Initializes the physics vortex event
  52061. * @param _scene The BabylonJS scene
  52062. * @param _origin The origin position of the vortex
  52063. * @param _options The options for the vortex event
  52064. */
  52065. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  52066. /**
  52067. * Returns the data related to the vortex event (cylinder).
  52068. * @returns The physics vortex event data
  52069. */
  52070. getData(): PhysicsVortexEventData;
  52071. /**
  52072. * Enables the vortex.
  52073. */
  52074. enable(): void;
  52075. /**
  52076. * Disables the cortex.
  52077. */
  52078. disable(): void;
  52079. /**
  52080. * Disposes the sphere.
  52081. * @param force
  52082. */
  52083. dispose(force?: boolean): void;
  52084. private getImpostorHitData;
  52085. private _tick;
  52086. /*** Helpers ***/
  52087. private _prepareCylinder;
  52088. private _intersectsWithCylinder;
  52089. }
  52090. /**
  52091. * Options fot the radial explosion event
  52092. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52093. */
  52094. export class PhysicsRadialExplosionEventOptions {
  52095. /**
  52096. * The radius of the sphere for the radial explosion.
  52097. */
  52098. radius: number;
  52099. /**
  52100. * The strenth of the explosion.
  52101. */
  52102. strength: number;
  52103. /**
  52104. * The strenght of the force in correspondence to the distance of the affected object
  52105. */
  52106. falloff: PhysicsRadialImpulseFalloff;
  52107. /**
  52108. * Sphere options for the radial explosion.
  52109. */
  52110. sphere: {
  52111. segments: number;
  52112. diameter: number;
  52113. };
  52114. /**
  52115. * Sphere options for the radial explosion.
  52116. */
  52117. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  52118. }
  52119. /**
  52120. * Options fot the updraft event
  52121. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52122. */
  52123. export class PhysicsUpdraftEventOptions {
  52124. /**
  52125. * The radius of the cylinder for the vortex
  52126. */
  52127. radius: number;
  52128. /**
  52129. * The strenth of the updraft.
  52130. */
  52131. strength: number;
  52132. /**
  52133. * The height of the cylinder for the updraft.
  52134. */
  52135. height: number;
  52136. /**
  52137. * The mode for the the updraft.
  52138. */
  52139. updraftMode: PhysicsUpdraftMode;
  52140. }
  52141. /**
  52142. * Options fot the vortex event
  52143. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52144. */
  52145. export class PhysicsVortexEventOptions {
  52146. /**
  52147. * The radius of the cylinder for the vortex
  52148. */
  52149. radius: number;
  52150. /**
  52151. * The strenth of the vortex.
  52152. */
  52153. strength: number;
  52154. /**
  52155. * The height of the cylinder for the vortex.
  52156. */
  52157. height: number;
  52158. /**
  52159. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  52160. */
  52161. centripetalForceThreshold: number;
  52162. /**
  52163. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  52164. */
  52165. centripetalForceMultiplier: number;
  52166. /**
  52167. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  52168. */
  52169. centrifugalForceMultiplier: number;
  52170. /**
  52171. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  52172. */
  52173. updraftForceMultiplier: number;
  52174. }
  52175. /**
  52176. * The strenght of the force in correspondence to the distance of the affected object
  52177. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52178. */
  52179. export enum PhysicsRadialImpulseFalloff {
  52180. /** Defines that impulse is constant in strength across it's whole radius */
  52181. Constant = 0,
  52182. /** Defines that impulse gets weaker if it's further from the origin */
  52183. Linear = 1
  52184. }
  52185. /**
  52186. * The strength of the force in correspondence to the distance of the affected object
  52187. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52188. */
  52189. export enum PhysicsUpdraftMode {
  52190. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52191. Center = 0,
  52192. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52193. Perpendicular = 1
  52194. }
  52195. /**
  52196. * Interface for a physics hit data
  52197. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52198. */
  52199. export interface PhysicsHitData {
  52200. /**
  52201. * The force applied at the contact point
  52202. */
  52203. force: Vector3;
  52204. /**
  52205. * The contact point
  52206. */
  52207. contactPoint: Vector3;
  52208. /**
  52209. * The distance from the origin to the contact point
  52210. */
  52211. distanceFromOrigin: number;
  52212. }
  52213. /**
  52214. * Interface for radial explosion event data
  52215. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52216. */
  52217. export interface PhysicsRadialExplosionEventData {
  52218. /**
  52219. * A sphere used for the radial explosion event
  52220. */
  52221. sphere: Mesh;
  52222. }
  52223. /**
  52224. * Interface for gravitational field event data
  52225. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52226. */
  52227. export interface PhysicsGravitationalFieldEventData {
  52228. /**
  52229. * A sphere mesh used for the gravitational field event
  52230. */
  52231. sphere: Mesh;
  52232. }
  52233. /**
  52234. * Interface for updraft event data
  52235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52236. */
  52237. export interface PhysicsUpdraftEventData {
  52238. /**
  52239. * A cylinder used for the updraft event
  52240. */
  52241. cylinder: Mesh;
  52242. }
  52243. /**
  52244. * Interface for vortex event data
  52245. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52246. */
  52247. export interface PhysicsVortexEventData {
  52248. /**
  52249. * A cylinder used for the vortex event
  52250. */
  52251. cylinder: Mesh;
  52252. }
  52253. /**
  52254. * Interface for an affected physics impostor
  52255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52256. */
  52257. export interface PhysicsAffectedImpostorWithData {
  52258. /**
  52259. * The impostor affected by the effect
  52260. */
  52261. impostor: PhysicsImpostor;
  52262. /**
  52263. * The data about the hit/horce from the explosion
  52264. */
  52265. hitData: PhysicsHitData;
  52266. }
  52267. }
  52268. declare module BABYLON {
  52269. /** @hidden */
  52270. export var blackAndWhitePixelShader: {
  52271. name: string;
  52272. shader: string;
  52273. };
  52274. }
  52275. declare module BABYLON {
  52276. /**
  52277. * Post process used to render in black and white
  52278. */
  52279. export class BlackAndWhitePostProcess extends PostProcess {
  52280. /**
  52281. * Linear about to convert he result to black and white (default: 1)
  52282. */
  52283. degree: number;
  52284. /**
  52285. * Creates a black and white post process
  52286. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  52287. * @param name The name of the effect.
  52288. * @param options The required width/height ratio to downsize to before computing the render pass.
  52289. * @param camera The camera to apply the render pass to.
  52290. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52291. * @param engine The engine which the post process will be applied. (default: current engine)
  52292. * @param reusable If the post process can be reused on the same frame. (default: false)
  52293. */
  52294. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52295. }
  52296. }
  52297. declare module BABYLON {
  52298. /**
  52299. * This represents a set of one or more post processes in Babylon.
  52300. * A post process can be used to apply a shader to a texture after it is rendered.
  52301. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52302. */
  52303. export class PostProcessRenderEffect {
  52304. private _postProcesses;
  52305. private _getPostProcesses;
  52306. private _singleInstance;
  52307. private _cameras;
  52308. private _indicesForCamera;
  52309. /**
  52310. * Name of the effect
  52311. * @hidden
  52312. */
  52313. _name: string;
  52314. /**
  52315. * Instantiates a post process render effect.
  52316. * A post process can be used to apply a shader to a texture after it is rendered.
  52317. * @param engine The engine the effect is tied to
  52318. * @param name The name of the effect
  52319. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  52320. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  52321. */
  52322. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  52323. /**
  52324. * Checks if all the post processes in the effect are supported.
  52325. */
  52326. readonly isSupported: boolean;
  52327. /**
  52328. * Updates the current state of the effect
  52329. * @hidden
  52330. */
  52331. _update(): void;
  52332. /**
  52333. * Attaches the effect on cameras
  52334. * @param cameras The camera to attach to.
  52335. * @hidden
  52336. */
  52337. _attachCameras(cameras: Camera): void;
  52338. /**
  52339. * Attaches the effect on cameras
  52340. * @param cameras The camera to attach to.
  52341. * @hidden
  52342. */
  52343. _attachCameras(cameras: Camera[]): void;
  52344. /**
  52345. * Detaches the effect on cameras
  52346. * @param cameras The camera to detatch from.
  52347. * @hidden
  52348. */
  52349. _detachCameras(cameras: Camera): void;
  52350. /**
  52351. * Detatches the effect on cameras
  52352. * @param cameras The camera to detatch from.
  52353. * @hidden
  52354. */
  52355. _detachCameras(cameras: Camera[]): void;
  52356. /**
  52357. * Enables the effect on given cameras
  52358. * @param cameras The camera to enable.
  52359. * @hidden
  52360. */
  52361. _enable(cameras: Camera): void;
  52362. /**
  52363. * Enables the effect on given cameras
  52364. * @param cameras The camera to enable.
  52365. * @hidden
  52366. */
  52367. _enable(cameras: Nullable<Camera[]>): void;
  52368. /**
  52369. * Disables the effect on the given cameras
  52370. * @param cameras The camera to disable.
  52371. * @hidden
  52372. */
  52373. _disable(cameras: Camera): void;
  52374. /**
  52375. * Disables the effect on the given cameras
  52376. * @param cameras The camera to disable.
  52377. * @hidden
  52378. */
  52379. _disable(cameras: Nullable<Camera[]>): void;
  52380. /**
  52381. * Gets a list of the post processes contained in the effect.
  52382. * @param camera The camera to get the post processes on.
  52383. * @returns The list of the post processes in the effect.
  52384. */
  52385. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52386. }
  52387. }
  52388. declare module BABYLON {
  52389. /** @hidden */
  52390. export var extractHighlightsPixelShader: {
  52391. name: string;
  52392. shader: string;
  52393. };
  52394. }
  52395. declare module BABYLON {
  52396. /**
  52397. * 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.
  52398. */
  52399. export class ExtractHighlightsPostProcess extends PostProcess {
  52400. /**
  52401. * The luminance threshold, pixels below this value will be set to black.
  52402. */
  52403. threshold: number;
  52404. /** @hidden */
  52405. _exposure: number;
  52406. /**
  52407. * Post process which has the input texture to be used when performing highlight extraction
  52408. * @hidden
  52409. */
  52410. _inputPostProcess: Nullable<PostProcess>;
  52411. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52412. }
  52413. }
  52414. declare module BABYLON {
  52415. /** @hidden */
  52416. export var bloomMergePixelShader: {
  52417. name: string;
  52418. shader: string;
  52419. };
  52420. }
  52421. declare module BABYLON {
  52422. /**
  52423. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52424. */
  52425. export class BloomMergePostProcess extends PostProcess {
  52426. /** Weight of the bloom to be added to the original input. */
  52427. weight: number;
  52428. /**
  52429. * Creates a new instance of @see BloomMergePostProcess
  52430. * @param name The name of the effect.
  52431. * @param originalFromInput Post process which's input will be used for the merge.
  52432. * @param blurred Blurred highlights post process which's output will be used.
  52433. * @param weight Weight of the bloom to be added to the original input.
  52434. * @param options The required width/height ratio to downsize to before computing the render pass.
  52435. * @param camera The camera to apply the render pass to.
  52436. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52437. * @param engine The engine which the post process will be applied. (default: current engine)
  52438. * @param reusable If the post process can be reused on the same frame. (default: false)
  52439. * @param textureType Type of textures used when performing the post process. (default: 0)
  52440. * @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)
  52441. */
  52442. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52443. /** Weight of the bloom to be added to the original input. */
  52444. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52445. }
  52446. }
  52447. declare module BABYLON {
  52448. /**
  52449. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52450. */
  52451. export class BloomEffect extends PostProcessRenderEffect {
  52452. private bloomScale;
  52453. /**
  52454. * @hidden Internal
  52455. */
  52456. _effects: Array<PostProcess>;
  52457. /**
  52458. * @hidden Internal
  52459. */
  52460. _downscale: ExtractHighlightsPostProcess;
  52461. private _blurX;
  52462. private _blurY;
  52463. private _merge;
  52464. /**
  52465. * The luminance threshold to find bright areas of the image to bloom.
  52466. */
  52467. threshold: number;
  52468. /**
  52469. * The strength of the bloom.
  52470. */
  52471. weight: number;
  52472. /**
  52473. * Specifies the size of the bloom blur kernel, relative to the final output size
  52474. */
  52475. kernel: number;
  52476. /**
  52477. * Creates a new instance of @see BloomEffect
  52478. * @param scene The scene the effect belongs to.
  52479. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52480. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52481. * @param bloomWeight The the strength of bloom.
  52482. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52483. * @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)
  52484. */
  52485. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52486. /**
  52487. * Disposes each of the internal effects for a given camera.
  52488. * @param camera The camera to dispose the effect on.
  52489. */
  52490. disposeEffects(camera: Camera): void;
  52491. /**
  52492. * @hidden Internal
  52493. */
  52494. _updateEffects(): void;
  52495. /**
  52496. * Internal
  52497. * @returns if all the contained post processes are ready.
  52498. * @hidden
  52499. */
  52500. _isReady(): boolean;
  52501. }
  52502. }
  52503. declare module BABYLON {
  52504. /** @hidden */
  52505. export var chromaticAberrationPixelShader: {
  52506. name: string;
  52507. shader: string;
  52508. };
  52509. }
  52510. declare module BABYLON {
  52511. /**
  52512. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52513. */
  52514. export class ChromaticAberrationPostProcess extends PostProcess {
  52515. /**
  52516. * The amount of seperation of rgb channels (default: 30)
  52517. */
  52518. aberrationAmount: number;
  52519. /**
  52520. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52521. */
  52522. radialIntensity: number;
  52523. /**
  52524. * 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))
  52525. */
  52526. direction: Vector2;
  52527. /**
  52528. * 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))
  52529. */
  52530. centerPosition: Vector2;
  52531. /**
  52532. * Creates a new instance ChromaticAberrationPostProcess
  52533. * @param name The name of the effect.
  52534. * @param screenWidth The width of the screen to apply the effect on.
  52535. * @param screenHeight The height of the screen to apply the effect on.
  52536. * @param options The required width/height ratio to downsize to before computing the render pass.
  52537. * @param camera The camera to apply the render pass to.
  52538. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52539. * @param engine The engine which the post process will be applied. (default: current engine)
  52540. * @param reusable If the post process can be reused on the same frame. (default: false)
  52541. * @param textureType Type of textures used when performing the post process. (default: 0)
  52542. * @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)
  52543. */
  52544. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52545. }
  52546. }
  52547. declare module BABYLON {
  52548. /** @hidden */
  52549. export var circleOfConfusionPixelShader: {
  52550. name: string;
  52551. shader: string;
  52552. };
  52553. }
  52554. declare module BABYLON {
  52555. /**
  52556. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  52557. */
  52558. export class CircleOfConfusionPostProcess extends PostProcess {
  52559. /**
  52560. * 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.
  52561. */
  52562. lensSize: number;
  52563. /**
  52564. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52565. */
  52566. fStop: number;
  52567. /**
  52568. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52569. */
  52570. focusDistance: number;
  52571. /**
  52572. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  52573. */
  52574. focalLength: number;
  52575. private _depthTexture;
  52576. /**
  52577. * Creates a new instance CircleOfConfusionPostProcess
  52578. * @param name The name of the effect.
  52579. * @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.
  52580. * @param options The required width/height ratio to downsize to before computing the render pass.
  52581. * @param camera The camera to apply the render pass to.
  52582. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52583. * @param engine The engine which the post process will be applied. (default: current engine)
  52584. * @param reusable If the post process can be reused on the same frame. (default: false)
  52585. * @param textureType Type of textures used when performing the post process. (default: 0)
  52586. * @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)
  52587. */
  52588. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52589. /**
  52590. * 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.
  52591. */
  52592. depthTexture: RenderTargetTexture;
  52593. }
  52594. }
  52595. declare module BABYLON {
  52596. /** @hidden */
  52597. export var colorCorrectionPixelShader: {
  52598. name: string;
  52599. shader: string;
  52600. };
  52601. }
  52602. declare module BABYLON {
  52603. /**
  52604. *
  52605. * This post-process allows the modification of rendered colors by using
  52606. * a 'look-up table' (LUT). This effect is also called Color Grading.
  52607. *
  52608. * The object needs to be provided an url to a texture containing the color
  52609. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  52610. * Use an image editing software to tweak the LUT to match your needs.
  52611. *
  52612. * For an example of a color LUT, see here:
  52613. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  52614. * For explanations on color grading, see here:
  52615. * @see http://udn.epicgames.com/Three/ColorGrading.html
  52616. *
  52617. */
  52618. export class ColorCorrectionPostProcess extends PostProcess {
  52619. private _colorTableTexture;
  52620. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52621. }
  52622. }
  52623. declare module BABYLON {
  52624. /** @hidden */
  52625. export var convolutionPixelShader: {
  52626. name: string;
  52627. shader: string;
  52628. };
  52629. }
  52630. declare module BABYLON {
  52631. /**
  52632. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  52633. * input texture to perform effects such as edge detection or sharpening
  52634. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52635. */
  52636. export class ConvolutionPostProcess extends PostProcess {
  52637. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52638. kernel: number[];
  52639. /**
  52640. * Creates a new instance ConvolutionPostProcess
  52641. * @param name The name of the effect.
  52642. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  52643. * @param options The required width/height ratio to downsize to before computing the render pass.
  52644. * @param camera The camera to apply the render pass to.
  52645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52646. * @param engine The engine which the post process will be applied. (default: current engine)
  52647. * @param reusable If the post process can be reused on the same frame. (default: false)
  52648. * @param textureType Type of textures used when performing the post process. (default: 0)
  52649. */
  52650. constructor(name: string,
  52651. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52652. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52653. /**
  52654. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52655. */
  52656. static EdgeDetect0Kernel: number[];
  52657. /**
  52658. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52659. */
  52660. static EdgeDetect1Kernel: number[];
  52661. /**
  52662. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52663. */
  52664. static EdgeDetect2Kernel: number[];
  52665. /**
  52666. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52667. */
  52668. static SharpenKernel: number[];
  52669. /**
  52670. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52671. */
  52672. static EmbossKernel: number[];
  52673. /**
  52674. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52675. */
  52676. static GaussianKernel: number[];
  52677. }
  52678. }
  52679. declare module BABYLON {
  52680. /**
  52681. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  52682. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  52683. * based on samples that have a large difference in distance than the center pixel.
  52684. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  52685. */
  52686. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  52687. direction: Vector2;
  52688. /**
  52689. * Creates a new instance CircleOfConfusionPostProcess
  52690. * @param name The name of the effect.
  52691. * @param scene The scene the effect belongs to.
  52692. * @param direction The direction the blur should be applied.
  52693. * @param kernel The size of the kernel used to blur.
  52694. * @param options The required width/height ratio to downsize to before computing the render pass.
  52695. * @param camera The camera to apply the render pass to.
  52696. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  52697. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  52698. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52699. * @param engine The engine which the post process will be applied. (default: current engine)
  52700. * @param reusable If the post process can be reused on the same frame. (default: false)
  52701. * @param textureType Type of textures used when performing the post process. (default: 0)
  52702. * @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)
  52703. */
  52704. 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);
  52705. }
  52706. }
  52707. declare module BABYLON {
  52708. /** @hidden */
  52709. export var depthOfFieldMergePixelShader: {
  52710. name: string;
  52711. shader: string;
  52712. };
  52713. }
  52714. declare module BABYLON {
  52715. /**
  52716. * Options to be set when merging outputs from the default pipeline.
  52717. */
  52718. export class DepthOfFieldMergePostProcessOptions {
  52719. /**
  52720. * The original image to merge on top of
  52721. */
  52722. originalFromInput: PostProcess;
  52723. /**
  52724. * Parameters to perform the merge of the depth of field effect
  52725. */
  52726. depthOfField?: {
  52727. circleOfConfusion: PostProcess;
  52728. blurSteps: Array<PostProcess>;
  52729. };
  52730. /**
  52731. * Parameters to perform the merge of bloom effect
  52732. */
  52733. bloom?: {
  52734. blurred: PostProcess;
  52735. weight: number;
  52736. };
  52737. }
  52738. /**
  52739. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52740. */
  52741. export class DepthOfFieldMergePostProcess extends PostProcess {
  52742. private blurSteps;
  52743. /**
  52744. * Creates a new instance of DepthOfFieldMergePostProcess
  52745. * @param name The name of the effect.
  52746. * @param originalFromInput Post process which's input will be used for the merge.
  52747. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  52748. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  52749. * @param options The required width/height ratio to downsize to before computing the render pass.
  52750. * @param camera The camera to apply the render pass to.
  52751. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52752. * @param engine The engine which the post process will be applied. (default: current engine)
  52753. * @param reusable If the post process can be reused on the same frame. (default: false)
  52754. * @param textureType Type of textures used when performing the post process. (default: 0)
  52755. * @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)
  52756. */
  52757. 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);
  52758. /**
  52759. * Updates the effect with the current post process compile time values and recompiles the shader.
  52760. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  52761. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  52762. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  52763. * @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
  52764. * @param onCompiled Called when the shader has been compiled.
  52765. * @param onError Called if there is an error when compiling a shader.
  52766. */
  52767. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  52768. }
  52769. }
  52770. declare module BABYLON {
  52771. /**
  52772. * Specifies the level of max blur that should be applied when using the depth of field effect
  52773. */
  52774. export enum DepthOfFieldEffectBlurLevel {
  52775. /**
  52776. * Subtle blur
  52777. */
  52778. Low = 0,
  52779. /**
  52780. * Medium blur
  52781. */
  52782. Medium = 1,
  52783. /**
  52784. * Large blur
  52785. */
  52786. High = 2
  52787. }
  52788. /**
  52789. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52790. */
  52791. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52792. private _circleOfConfusion;
  52793. /**
  52794. * @hidden Internal, blurs from high to low
  52795. */
  52796. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52797. private _depthOfFieldBlurY;
  52798. private _dofMerge;
  52799. /**
  52800. * @hidden Internal post processes in depth of field effect
  52801. */
  52802. _effects: Array<PostProcess>;
  52803. /**
  52804. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52805. */
  52806. focalLength: number;
  52807. /**
  52808. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52809. */
  52810. fStop: number;
  52811. /**
  52812. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52813. */
  52814. focusDistance: number;
  52815. /**
  52816. * 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.
  52817. */
  52818. lensSize: number;
  52819. /**
  52820. * Creates a new instance DepthOfFieldEffect
  52821. * @param scene The scene the effect belongs to.
  52822. * @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.
  52823. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52824. * @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)
  52825. */
  52826. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52827. /**
  52828. * Get the current class name of the current effet
  52829. * @returns "DepthOfFieldEffect"
  52830. */
  52831. getClassName(): string;
  52832. /**
  52833. * 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.
  52834. */
  52835. depthTexture: RenderTargetTexture;
  52836. /**
  52837. * Disposes each of the internal effects for a given camera.
  52838. * @param camera The camera to dispose the effect on.
  52839. */
  52840. disposeEffects(camera: Camera): void;
  52841. /**
  52842. * @hidden Internal
  52843. */
  52844. _updateEffects(): void;
  52845. /**
  52846. * Internal
  52847. * @returns if all the contained post processes are ready.
  52848. * @hidden
  52849. */
  52850. _isReady(): boolean;
  52851. }
  52852. }
  52853. declare module BABYLON {
  52854. /** @hidden */
  52855. export var displayPassPixelShader: {
  52856. name: string;
  52857. shader: string;
  52858. };
  52859. }
  52860. declare module BABYLON {
  52861. /**
  52862. * DisplayPassPostProcess which produces an output the same as it's input
  52863. */
  52864. export class DisplayPassPostProcess extends PostProcess {
  52865. /**
  52866. * Creates the DisplayPassPostProcess
  52867. * @param name The name of the effect.
  52868. * @param options The required width/height ratio to downsize to before computing the render pass.
  52869. * @param camera The camera to apply the render pass to.
  52870. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52871. * @param engine The engine which the post process will be applied. (default: current engine)
  52872. * @param reusable If the post process can be reused on the same frame. (default: false)
  52873. */
  52874. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52875. }
  52876. }
  52877. declare module BABYLON {
  52878. /** @hidden */
  52879. export var filterPixelShader: {
  52880. name: string;
  52881. shader: string;
  52882. };
  52883. }
  52884. declare module BABYLON {
  52885. /**
  52886. * Applies a kernel filter to the image
  52887. */
  52888. export class FilterPostProcess extends PostProcess {
  52889. /** The matrix to be applied to the image */
  52890. kernelMatrix: Matrix;
  52891. /**
  52892. *
  52893. * @param name The name of the effect.
  52894. * @param kernelMatrix The matrix to be applied to the image
  52895. * @param options The required width/height ratio to downsize to before computing the render pass.
  52896. * @param camera The camera to apply the render pass to.
  52897. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52898. * @param engine The engine which the post process will be applied. (default: current engine)
  52899. * @param reusable If the post process can be reused on the same frame. (default: false)
  52900. */
  52901. constructor(name: string,
  52902. /** The matrix to be applied to the image */
  52903. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52904. }
  52905. }
  52906. declare module BABYLON {
  52907. /** @hidden */
  52908. export var fxaaPixelShader: {
  52909. name: string;
  52910. shader: string;
  52911. };
  52912. }
  52913. declare module BABYLON {
  52914. /** @hidden */
  52915. export var fxaaVertexShader: {
  52916. name: string;
  52917. shader: string;
  52918. };
  52919. }
  52920. declare module BABYLON {
  52921. /**
  52922. * Fxaa post process
  52923. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52924. */
  52925. export class FxaaPostProcess extends PostProcess {
  52926. /** @hidden */
  52927. texelWidth: number;
  52928. /** @hidden */
  52929. texelHeight: number;
  52930. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52931. private _getDefines;
  52932. }
  52933. }
  52934. declare module BABYLON {
  52935. /** @hidden */
  52936. export var grainPixelShader: {
  52937. name: string;
  52938. shader: string;
  52939. };
  52940. }
  52941. declare module BABYLON {
  52942. /**
  52943. * The GrainPostProcess adds noise to the image at mid luminance levels
  52944. */
  52945. export class GrainPostProcess extends PostProcess {
  52946. /**
  52947. * The intensity of the grain added (default: 30)
  52948. */
  52949. intensity: number;
  52950. /**
  52951. * If the grain should be randomized on every frame
  52952. */
  52953. animated: boolean;
  52954. /**
  52955. * Creates a new instance of @see GrainPostProcess
  52956. * @param name The name of the effect.
  52957. * @param options The required width/height ratio to downsize to before computing the render pass.
  52958. * @param camera The camera to apply the render pass to.
  52959. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52960. * @param engine The engine which the post process will be applied. (default: current engine)
  52961. * @param reusable If the post process can be reused on the same frame. (default: false)
  52962. * @param textureType Type of textures used when performing the post process. (default: 0)
  52963. * @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)
  52964. */
  52965. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52966. }
  52967. }
  52968. declare module BABYLON {
  52969. /** @hidden */
  52970. export var highlightsPixelShader: {
  52971. name: string;
  52972. shader: string;
  52973. };
  52974. }
  52975. declare module BABYLON {
  52976. /**
  52977. * Extracts highlights from the image
  52978. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52979. */
  52980. export class HighlightsPostProcess extends PostProcess {
  52981. /**
  52982. * Extracts highlights from the image
  52983. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52984. * @param name The name of the effect.
  52985. * @param options The required width/height ratio to downsize to before computing the render pass.
  52986. * @param camera The camera to apply the render pass to.
  52987. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52988. * @param engine The engine which the post process will be applied. (default: current engine)
  52989. * @param reusable If the post process can be reused on the same frame. (default: false)
  52990. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  52991. */
  52992. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52993. }
  52994. }
  52995. declare module BABYLON {
  52996. /** @hidden */
  52997. export var mrtFragmentDeclaration: {
  52998. name: string;
  52999. shader: string;
  53000. };
  53001. }
  53002. declare module BABYLON {
  53003. /** @hidden */
  53004. export var geometryPixelShader: {
  53005. name: string;
  53006. shader: string;
  53007. };
  53008. }
  53009. declare module BABYLON {
  53010. /** @hidden */
  53011. export var geometryVertexShader: {
  53012. name: string;
  53013. shader: string;
  53014. };
  53015. }
  53016. declare module BABYLON {
  53017. /**
  53018. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  53019. */
  53020. export class GeometryBufferRenderer {
  53021. /**
  53022. * Constant used to retrieve the position texture index in the G-Buffer textures array
  53023. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  53024. */
  53025. static readonly POSITION_TEXTURE_TYPE: number;
  53026. /**
  53027. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  53028. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  53029. */
  53030. static readonly VELOCITY_TEXTURE_TYPE: number;
  53031. /**
  53032. * Dictionary used to store the previous transformation matrices of each rendered mesh
  53033. * in order to compute objects velocities when enableVelocity is set to "true"
  53034. * @hidden
  53035. */
  53036. _previousTransformationMatrices: {
  53037. [index: number]: Matrix;
  53038. };
  53039. private _scene;
  53040. private _multiRenderTarget;
  53041. private _ratio;
  53042. private _enablePosition;
  53043. private _enableVelocity;
  53044. private _positionIndex;
  53045. private _velocityIndex;
  53046. protected _effect: Effect;
  53047. protected _cachedDefines: string;
  53048. /**
  53049. * Set the render list (meshes to be rendered) used in the G buffer.
  53050. */
  53051. renderList: Mesh[];
  53052. /**
  53053. * Gets wether or not G buffer are supported by the running hardware.
  53054. * This requires draw buffer supports
  53055. */
  53056. readonly isSupported: boolean;
  53057. /**
  53058. * Returns the index of the given texture type in the G-Buffer textures array
  53059. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  53060. * @returns the index of the given texture type in the G-Buffer textures array
  53061. */
  53062. getTextureIndex(textureType: number): number;
  53063. /**
  53064. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  53065. */
  53066. /**
  53067. * Sets whether or not objects positions are enabled for the G buffer.
  53068. */
  53069. enablePosition: boolean;
  53070. /**
  53071. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  53072. */
  53073. /**
  53074. * Sets wether or not objects velocities are enabled for the G buffer.
  53075. */
  53076. enableVelocity: boolean;
  53077. /**
  53078. * Gets the scene associated with the buffer.
  53079. */
  53080. readonly scene: Scene;
  53081. /**
  53082. * Gets the ratio used by the buffer during its creation.
  53083. * How big is the buffer related to the main canvas.
  53084. */
  53085. readonly ratio: number;
  53086. /** @hidden */
  53087. static _SceneComponentInitialization: (scene: Scene) => void;
  53088. /**
  53089. * Creates a new G Buffer for the scene
  53090. * @param scene The scene the buffer belongs to
  53091. * @param ratio How big is the buffer related to the main canvas.
  53092. */
  53093. constructor(scene: Scene, ratio?: number);
  53094. /**
  53095. * Checks wether everything is ready to render a submesh to the G buffer.
  53096. * @param subMesh the submesh to check readiness for
  53097. * @param useInstances is the mesh drawn using instance or not
  53098. * @returns true if ready otherwise false
  53099. */
  53100. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53101. /**
  53102. * Gets the current underlying G Buffer.
  53103. * @returns the buffer
  53104. */
  53105. getGBuffer(): MultiRenderTarget;
  53106. /**
  53107. * Gets the number of samples used to render the buffer (anti aliasing).
  53108. */
  53109. /**
  53110. * Sets the number of samples used to render the buffer (anti aliasing).
  53111. */
  53112. samples: number;
  53113. /**
  53114. * Disposes the renderer and frees up associated resources.
  53115. */
  53116. dispose(): void;
  53117. protected _createRenderTargets(): void;
  53118. }
  53119. }
  53120. declare module BABYLON {
  53121. interface Scene {
  53122. /** @hidden (Backing field) */
  53123. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53124. /**
  53125. * Gets or Sets the current geometry buffer associated to the scene.
  53126. */
  53127. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53128. /**
  53129. * Enables a GeometryBufferRender and associates it with the scene
  53130. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  53131. * @returns the GeometryBufferRenderer
  53132. */
  53133. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  53134. /**
  53135. * Disables the GeometryBufferRender associated with the scene
  53136. */
  53137. disableGeometryBufferRenderer(): void;
  53138. }
  53139. /**
  53140. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  53141. * in several rendering techniques.
  53142. */
  53143. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  53144. /**
  53145. * The component name helpful to identify the component in the list of scene components.
  53146. */
  53147. readonly name: string;
  53148. /**
  53149. * The scene the component belongs to.
  53150. */
  53151. scene: Scene;
  53152. /**
  53153. * Creates a new instance of the component for the given scene
  53154. * @param scene Defines the scene to register the component in
  53155. */
  53156. constructor(scene: Scene);
  53157. /**
  53158. * Registers the component in a given scene
  53159. */
  53160. register(): void;
  53161. /**
  53162. * Rebuilds the elements related to this component in case of
  53163. * context lost for instance.
  53164. */
  53165. rebuild(): void;
  53166. /**
  53167. * Disposes the component and the associated ressources
  53168. */
  53169. dispose(): void;
  53170. private _gatherRenderTargets;
  53171. }
  53172. }
  53173. declare module BABYLON {
  53174. /** @hidden */
  53175. export var motionBlurPixelShader: {
  53176. name: string;
  53177. shader: string;
  53178. };
  53179. }
  53180. declare module BABYLON {
  53181. /**
  53182. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  53183. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  53184. * As an example, all you have to do is to create the post-process:
  53185. * var mb = new BABYLON.MotionBlurPostProcess(
  53186. * 'mb', // The name of the effect.
  53187. * scene, // The scene containing the objects to blur according to their velocity.
  53188. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  53189. * camera // The camera to apply the render pass to.
  53190. * );
  53191. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  53192. */
  53193. export class MotionBlurPostProcess extends PostProcess {
  53194. /**
  53195. * Defines how much the image is blurred by the movement. Default value is equal to 1
  53196. */
  53197. motionStrength: number;
  53198. /**
  53199. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  53200. */
  53201. /**
  53202. * Sets the number of iterations to be used for motion blur quality
  53203. */
  53204. motionBlurSamples: number;
  53205. private _motionBlurSamples;
  53206. private _geometryBufferRenderer;
  53207. /**
  53208. * Creates a new instance MotionBlurPostProcess
  53209. * @param name The name of the effect.
  53210. * @param scene The scene containing the objects to blur according to their velocity.
  53211. * @param options The required width/height ratio to downsize to before computing the render pass.
  53212. * @param camera The camera to apply the render pass to.
  53213. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53214. * @param engine The engine which the post process will be applied. (default: current engine)
  53215. * @param reusable If the post process can be reused on the same frame. (default: false)
  53216. * @param textureType Type of textures used when performing the post process. (default: 0)
  53217. * @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)
  53218. */
  53219. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53220. /**
  53221. * Disposes the post process.
  53222. * @param camera The camera to dispose the post process on.
  53223. */
  53224. dispose(camera?: Camera): void;
  53225. }
  53226. }
  53227. declare module BABYLON {
  53228. /** @hidden */
  53229. export var refractionPixelShader: {
  53230. name: string;
  53231. shader: string;
  53232. };
  53233. }
  53234. declare module BABYLON {
  53235. /**
  53236. * Post process which applies a refractin texture
  53237. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53238. */
  53239. export class RefractionPostProcess extends PostProcess {
  53240. /** the base color of the refraction (used to taint the rendering) */
  53241. color: Color3;
  53242. /** simulated refraction depth */
  53243. depth: number;
  53244. /** the coefficient of the base color (0 to remove base color tainting) */
  53245. colorLevel: number;
  53246. private _refTexture;
  53247. private _ownRefractionTexture;
  53248. /**
  53249. * Gets or sets the refraction texture
  53250. * Please note that you are responsible for disposing the texture if you set it manually
  53251. */
  53252. refractionTexture: Texture;
  53253. /**
  53254. * Initializes the RefractionPostProcess
  53255. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53256. * @param name The name of the effect.
  53257. * @param refractionTextureUrl Url of the refraction texture to use
  53258. * @param color the base color of the refraction (used to taint the rendering)
  53259. * @param depth simulated refraction depth
  53260. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  53261. * @param camera The camera to apply the render pass to.
  53262. * @param options The required width/height ratio to downsize to before computing the render pass.
  53263. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53264. * @param engine The engine which the post process will be applied. (default: current engine)
  53265. * @param reusable If the post process can be reused on the same frame. (default: false)
  53266. */
  53267. constructor(name: string, refractionTextureUrl: string,
  53268. /** the base color of the refraction (used to taint the rendering) */
  53269. color: Color3,
  53270. /** simulated refraction depth */
  53271. depth: number,
  53272. /** the coefficient of the base color (0 to remove base color tainting) */
  53273. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53274. /**
  53275. * Disposes of the post process
  53276. * @param camera Camera to dispose post process on
  53277. */
  53278. dispose(camera: Camera): void;
  53279. }
  53280. }
  53281. declare module BABYLON {
  53282. /** @hidden */
  53283. export var sharpenPixelShader: {
  53284. name: string;
  53285. shader: string;
  53286. };
  53287. }
  53288. declare module BABYLON {
  53289. /**
  53290. * The SharpenPostProcess applies a sharpen kernel to every pixel
  53291. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53292. */
  53293. export class SharpenPostProcess extends PostProcess {
  53294. /**
  53295. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  53296. */
  53297. colorAmount: number;
  53298. /**
  53299. * How much sharpness should be applied (default: 0.3)
  53300. */
  53301. edgeAmount: number;
  53302. /**
  53303. * Creates a new instance ConvolutionPostProcess
  53304. * @param name The name of the effect.
  53305. * @param options The required width/height ratio to downsize to before computing the render pass.
  53306. * @param camera The camera to apply the render pass to.
  53307. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53308. * @param engine The engine which the post process will be applied. (default: current engine)
  53309. * @param reusable If the post process can be reused on the same frame. (default: false)
  53310. * @param textureType Type of textures used when performing the post process. (default: 0)
  53311. * @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)
  53312. */
  53313. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53314. }
  53315. }
  53316. declare module BABYLON {
  53317. /**
  53318. * PostProcessRenderPipeline
  53319. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53320. */
  53321. export class PostProcessRenderPipeline {
  53322. private engine;
  53323. private _renderEffects;
  53324. private _renderEffectsForIsolatedPass;
  53325. /**
  53326. * List of inspectable custom properties (used by the Inspector)
  53327. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  53328. */
  53329. inspectableCustomProperties: IInspectable[];
  53330. /**
  53331. * @hidden
  53332. */
  53333. protected _cameras: Camera[];
  53334. /** @hidden */
  53335. _name: string;
  53336. /**
  53337. * Gets pipeline name
  53338. */
  53339. readonly name: string;
  53340. /**
  53341. * Initializes a PostProcessRenderPipeline
  53342. * @param engine engine to add the pipeline to
  53343. * @param name name of the pipeline
  53344. */
  53345. constructor(engine: Engine, name: string);
  53346. /**
  53347. * Gets the class name
  53348. * @returns "PostProcessRenderPipeline"
  53349. */
  53350. getClassName(): string;
  53351. /**
  53352. * If all the render effects in the pipeline are supported
  53353. */
  53354. readonly isSupported: boolean;
  53355. /**
  53356. * Adds an effect to the pipeline
  53357. * @param renderEffect the effect to add
  53358. */
  53359. addEffect(renderEffect: PostProcessRenderEffect): void;
  53360. /** @hidden */
  53361. _rebuild(): void;
  53362. /** @hidden */
  53363. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53364. /** @hidden */
  53365. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53366. /** @hidden */
  53367. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53368. /** @hidden */
  53369. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53370. /** @hidden */
  53371. _attachCameras(cameras: Camera, unique: boolean): void;
  53372. /** @hidden */
  53373. _attachCameras(cameras: Camera[], unique: boolean): void;
  53374. /** @hidden */
  53375. _detachCameras(cameras: Camera): void;
  53376. /** @hidden */
  53377. _detachCameras(cameras: Nullable<Camera[]>): void;
  53378. /** @hidden */
  53379. _update(): void;
  53380. /** @hidden */
  53381. _reset(): void;
  53382. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53383. /**
  53384. * Disposes of the pipeline
  53385. */
  53386. dispose(): void;
  53387. }
  53388. }
  53389. declare module BABYLON {
  53390. /**
  53391. * PostProcessRenderPipelineManager class
  53392. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53393. */
  53394. export class PostProcessRenderPipelineManager {
  53395. private _renderPipelines;
  53396. /**
  53397. * Initializes a PostProcessRenderPipelineManager
  53398. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53399. */
  53400. constructor();
  53401. /**
  53402. * Gets the list of supported render pipelines
  53403. */
  53404. readonly supportedPipelines: PostProcessRenderPipeline[];
  53405. /**
  53406. * Adds a pipeline to the manager
  53407. * @param renderPipeline The pipeline to add
  53408. */
  53409. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53410. /**
  53411. * Attaches a camera to the pipeline
  53412. * @param renderPipelineName The name of the pipeline to attach to
  53413. * @param cameras the camera to attach
  53414. * @param unique if the camera can be attached multiple times to the pipeline
  53415. */
  53416. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53417. /**
  53418. * Detaches a camera from the pipeline
  53419. * @param renderPipelineName The name of the pipeline to detach from
  53420. * @param cameras the camera to detach
  53421. */
  53422. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53423. /**
  53424. * Enables an effect by name on a pipeline
  53425. * @param renderPipelineName the name of the pipeline to enable the effect in
  53426. * @param renderEffectName the name of the effect to enable
  53427. * @param cameras the cameras that the effect should be enabled on
  53428. */
  53429. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53430. /**
  53431. * Disables an effect by name on a pipeline
  53432. * @param renderPipelineName the name of the pipeline to disable the effect in
  53433. * @param renderEffectName the name of the effect to disable
  53434. * @param cameras the cameras that the effect should be disabled on
  53435. */
  53436. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53437. /**
  53438. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53439. */
  53440. update(): void;
  53441. /** @hidden */
  53442. _rebuild(): void;
  53443. /**
  53444. * Disposes of the manager and pipelines
  53445. */
  53446. dispose(): void;
  53447. }
  53448. }
  53449. declare module BABYLON {
  53450. interface Scene {
  53451. /** @hidden (Backing field) */
  53452. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53453. /**
  53454. * Gets the postprocess render pipeline manager
  53455. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53456. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53457. */
  53458. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53459. }
  53460. /**
  53461. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53462. */
  53463. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53464. /**
  53465. * The component name helpfull to identify the component in the list of scene components.
  53466. */
  53467. readonly name: string;
  53468. /**
  53469. * The scene the component belongs to.
  53470. */
  53471. scene: Scene;
  53472. /**
  53473. * Creates a new instance of the component for the given scene
  53474. * @param scene Defines the scene to register the component in
  53475. */
  53476. constructor(scene: Scene);
  53477. /**
  53478. * Registers the component in a given scene
  53479. */
  53480. register(): void;
  53481. /**
  53482. * Rebuilds the elements related to this component in case of
  53483. * context lost for instance.
  53484. */
  53485. rebuild(): void;
  53486. /**
  53487. * Disposes the component and the associated ressources
  53488. */
  53489. dispose(): void;
  53490. private _gatherRenderTargets;
  53491. }
  53492. }
  53493. declare module BABYLON {
  53494. /**
  53495. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  53496. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53497. */
  53498. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53499. private _scene;
  53500. private _camerasToBeAttached;
  53501. /**
  53502. * ID of the sharpen post process,
  53503. */
  53504. private readonly SharpenPostProcessId;
  53505. /**
  53506. * @ignore
  53507. * ID of the image processing post process;
  53508. */
  53509. readonly ImageProcessingPostProcessId: string;
  53510. /**
  53511. * @ignore
  53512. * ID of the Fast Approximate Anti-Aliasing post process;
  53513. */
  53514. readonly FxaaPostProcessId: string;
  53515. /**
  53516. * ID of the chromatic aberration post process,
  53517. */
  53518. private readonly ChromaticAberrationPostProcessId;
  53519. /**
  53520. * ID of the grain post process
  53521. */
  53522. private readonly GrainPostProcessId;
  53523. /**
  53524. * Sharpen post process which will apply a sharpen convolution to enhance edges
  53525. */
  53526. sharpen: SharpenPostProcess;
  53527. private _sharpenEffect;
  53528. private bloom;
  53529. /**
  53530. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  53531. */
  53532. depthOfField: DepthOfFieldEffect;
  53533. /**
  53534. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53535. */
  53536. fxaa: FxaaPostProcess;
  53537. /**
  53538. * Image post processing pass used to perform operations such as tone mapping or color grading.
  53539. */
  53540. imageProcessing: ImageProcessingPostProcess;
  53541. /**
  53542. * Chromatic aberration post process which will shift rgb colors in the image
  53543. */
  53544. chromaticAberration: ChromaticAberrationPostProcess;
  53545. private _chromaticAberrationEffect;
  53546. /**
  53547. * Grain post process which add noise to the image
  53548. */
  53549. grain: GrainPostProcess;
  53550. private _grainEffect;
  53551. /**
  53552. * Glow post process which adds a glow to emissive areas of the image
  53553. */
  53554. private _glowLayer;
  53555. /**
  53556. * Animations which can be used to tweak settings over a period of time
  53557. */
  53558. animations: Animation[];
  53559. private _imageProcessingConfigurationObserver;
  53560. private _sharpenEnabled;
  53561. private _bloomEnabled;
  53562. private _depthOfFieldEnabled;
  53563. private _depthOfFieldBlurLevel;
  53564. private _fxaaEnabled;
  53565. private _imageProcessingEnabled;
  53566. private _defaultPipelineTextureType;
  53567. private _bloomScale;
  53568. private _chromaticAberrationEnabled;
  53569. private _grainEnabled;
  53570. private _buildAllowed;
  53571. /**
  53572. * Gets active scene
  53573. */
  53574. readonly scene: Scene;
  53575. /**
  53576. * Enable or disable the sharpen process from the pipeline
  53577. */
  53578. sharpenEnabled: boolean;
  53579. private _resizeObserver;
  53580. private _hardwareScaleLevel;
  53581. private _bloomKernel;
  53582. /**
  53583. * Specifies the size of the bloom blur kernel, relative to the final output size
  53584. */
  53585. bloomKernel: number;
  53586. /**
  53587. * Specifies the weight of the bloom in the final rendering
  53588. */
  53589. private _bloomWeight;
  53590. /**
  53591. * Specifies the luma threshold for the area that will be blurred by the bloom
  53592. */
  53593. private _bloomThreshold;
  53594. private _hdr;
  53595. /**
  53596. * The strength of the bloom.
  53597. */
  53598. bloomWeight: number;
  53599. /**
  53600. * The strength of the bloom.
  53601. */
  53602. bloomThreshold: number;
  53603. /**
  53604. * The scale of the bloom, lower value will provide better performance.
  53605. */
  53606. bloomScale: number;
  53607. /**
  53608. * Enable or disable the bloom from the pipeline
  53609. */
  53610. bloomEnabled: boolean;
  53611. private _rebuildBloom;
  53612. /**
  53613. * If the depth of field is enabled.
  53614. */
  53615. depthOfFieldEnabled: boolean;
  53616. /**
  53617. * Blur level of the depth of field effect. (Higher blur will effect performance)
  53618. */
  53619. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  53620. /**
  53621. * If the anti aliasing is enabled.
  53622. */
  53623. fxaaEnabled: boolean;
  53624. private _samples;
  53625. /**
  53626. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53627. */
  53628. samples: number;
  53629. /**
  53630. * If image processing is enabled.
  53631. */
  53632. imageProcessingEnabled: boolean;
  53633. /**
  53634. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  53635. */
  53636. glowLayerEnabled: boolean;
  53637. /**
  53638. * Gets the glow layer (or null if not defined)
  53639. */
  53640. readonly glowLayer: Nullable<GlowLayer>;
  53641. /**
  53642. * Enable or disable the chromaticAberration process from the pipeline
  53643. */
  53644. chromaticAberrationEnabled: boolean;
  53645. /**
  53646. * Enable or disable the grain process from the pipeline
  53647. */
  53648. grainEnabled: boolean;
  53649. /**
  53650. * @constructor
  53651. * @param name - The rendering pipeline name (default: "")
  53652. * @param hdr - If high dynamic range textures should be used (default: true)
  53653. * @param scene - The scene linked to this pipeline (default: the last created scene)
  53654. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  53655. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  53656. */
  53657. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  53658. /**
  53659. * Get the class name
  53660. * @returns "DefaultRenderingPipeline"
  53661. */
  53662. getClassName(): string;
  53663. /**
  53664. * Force the compilation of the entire pipeline.
  53665. */
  53666. prepare(): void;
  53667. private _hasCleared;
  53668. private _prevPostProcess;
  53669. private _prevPrevPostProcess;
  53670. private _setAutoClearAndTextureSharing;
  53671. private _depthOfFieldSceneObserver;
  53672. private _buildPipeline;
  53673. private _disposePostProcesses;
  53674. /**
  53675. * Adds a camera to the pipeline
  53676. * @param camera the camera to be added
  53677. */
  53678. addCamera(camera: Camera): void;
  53679. /**
  53680. * Removes a camera from the pipeline
  53681. * @param camera the camera to remove
  53682. */
  53683. removeCamera(camera: Camera): void;
  53684. /**
  53685. * Dispose of the pipeline and stop all post processes
  53686. */
  53687. dispose(): void;
  53688. /**
  53689. * Serialize the rendering pipeline (Used when exporting)
  53690. * @returns the serialized object
  53691. */
  53692. serialize(): any;
  53693. /**
  53694. * Parse the serialized pipeline
  53695. * @param source Source pipeline.
  53696. * @param scene The scene to load the pipeline to.
  53697. * @param rootUrl The URL of the serialized pipeline.
  53698. * @returns An instantiated pipeline from the serialized object.
  53699. */
  53700. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  53701. }
  53702. }
  53703. declare module BABYLON {
  53704. /** @hidden */
  53705. export var lensHighlightsPixelShader: {
  53706. name: string;
  53707. shader: string;
  53708. };
  53709. }
  53710. declare module BABYLON {
  53711. /** @hidden */
  53712. export var depthOfFieldPixelShader: {
  53713. name: string;
  53714. shader: string;
  53715. };
  53716. }
  53717. declare module BABYLON {
  53718. /**
  53719. * BABYLON.JS Chromatic Aberration GLSL Shader
  53720. * Author: Olivier Guyot
  53721. * Separates very slightly R, G and B colors on the edges of the screen
  53722. * Inspired by Francois Tarlier & Martins Upitis
  53723. */
  53724. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  53725. /**
  53726. * @ignore
  53727. * The chromatic aberration PostProcess id in the pipeline
  53728. */
  53729. LensChromaticAberrationEffect: string;
  53730. /**
  53731. * @ignore
  53732. * The highlights enhancing PostProcess id in the pipeline
  53733. */
  53734. HighlightsEnhancingEffect: string;
  53735. /**
  53736. * @ignore
  53737. * The depth-of-field PostProcess id in the pipeline
  53738. */
  53739. LensDepthOfFieldEffect: string;
  53740. private _scene;
  53741. private _depthTexture;
  53742. private _grainTexture;
  53743. private _chromaticAberrationPostProcess;
  53744. private _highlightsPostProcess;
  53745. private _depthOfFieldPostProcess;
  53746. private _edgeBlur;
  53747. private _grainAmount;
  53748. private _chromaticAberration;
  53749. private _distortion;
  53750. private _highlightsGain;
  53751. private _highlightsThreshold;
  53752. private _dofDistance;
  53753. private _dofAperture;
  53754. private _dofDarken;
  53755. private _dofPentagon;
  53756. private _blurNoise;
  53757. /**
  53758. * @constructor
  53759. *
  53760. * Effect parameters are as follow:
  53761. * {
  53762. * chromatic_aberration: number; // from 0 to x (1 for realism)
  53763. * edge_blur: number; // from 0 to x (1 for realism)
  53764. * distortion: number; // from 0 to x (1 for realism)
  53765. * grain_amount: number; // from 0 to 1
  53766. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  53767. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  53768. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  53769. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  53770. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  53771. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  53772. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  53773. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  53774. * }
  53775. * Note: if an effect parameter is unset, effect is disabled
  53776. *
  53777. * @param name The rendering pipeline name
  53778. * @param parameters - An object containing all parameters (see above)
  53779. * @param scene The scene linked to this pipeline
  53780. * @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)
  53781. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53782. */
  53783. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  53784. /**
  53785. * Get the class name
  53786. * @returns "LensRenderingPipeline"
  53787. */
  53788. getClassName(): string;
  53789. /**
  53790. * Gets associated scene
  53791. */
  53792. readonly scene: Scene;
  53793. /**
  53794. * Gets or sets the edge blur
  53795. */
  53796. edgeBlur: number;
  53797. /**
  53798. * Gets or sets the grain amount
  53799. */
  53800. grainAmount: number;
  53801. /**
  53802. * Gets or sets the chromatic aberration amount
  53803. */
  53804. chromaticAberration: number;
  53805. /**
  53806. * Gets or sets the depth of field aperture
  53807. */
  53808. dofAperture: number;
  53809. /**
  53810. * Gets or sets the edge distortion
  53811. */
  53812. edgeDistortion: number;
  53813. /**
  53814. * Gets or sets the depth of field distortion
  53815. */
  53816. dofDistortion: number;
  53817. /**
  53818. * Gets or sets the darken out of focus amount
  53819. */
  53820. darkenOutOfFocus: number;
  53821. /**
  53822. * Gets or sets a boolean indicating if blur noise is enabled
  53823. */
  53824. blurNoise: boolean;
  53825. /**
  53826. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  53827. */
  53828. pentagonBokeh: boolean;
  53829. /**
  53830. * Gets or sets the highlight grain amount
  53831. */
  53832. highlightsGain: number;
  53833. /**
  53834. * Gets or sets the highlight threshold
  53835. */
  53836. highlightsThreshold: number;
  53837. /**
  53838. * Sets the amount of blur at the edges
  53839. * @param amount blur amount
  53840. */
  53841. setEdgeBlur(amount: number): void;
  53842. /**
  53843. * Sets edge blur to 0
  53844. */
  53845. disableEdgeBlur(): void;
  53846. /**
  53847. * Sets the amout of grain
  53848. * @param amount Amount of grain
  53849. */
  53850. setGrainAmount(amount: number): void;
  53851. /**
  53852. * Set grain amount to 0
  53853. */
  53854. disableGrain(): void;
  53855. /**
  53856. * Sets the chromatic aberration amount
  53857. * @param amount amount of chromatic aberration
  53858. */
  53859. setChromaticAberration(amount: number): void;
  53860. /**
  53861. * Sets chromatic aberration amount to 0
  53862. */
  53863. disableChromaticAberration(): void;
  53864. /**
  53865. * Sets the EdgeDistortion amount
  53866. * @param amount amount of EdgeDistortion
  53867. */
  53868. setEdgeDistortion(amount: number): void;
  53869. /**
  53870. * Sets edge distortion to 0
  53871. */
  53872. disableEdgeDistortion(): void;
  53873. /**
  53874. * Sets the FocusDistance amount
  53875. * @param amount amount of FocusDistance
  53876. */
  53877. setFocusDistance(amount: number): void;
  53878. /**
  53879. * Disables depth of field
  53880. */
  53881. disableDepthOfField(): void;
  53882. /**
  53883. * Sets the Aperture amount
  53884. * @param amount amount of Aperture
  53885. */
  53886. setAperture(amount: number): void;
  53887. /**
  53888. * Sets the DarkenOutOfFocus amount
  53889. * @param amount amount of DarkenOutOfFocus
  53890. */
  53891. setDarkenOutOfFocus(amount: number): void;
  53892. private _pentagonBokehIsEnabled;
  53893. /**
  53894. * Creates a pentagon bokeh effect
  53895. */
  53896. enablePentagonBokeh(): void;
  53897. /**
  53898. * Disables the pentagon bokeh effect
  53899. */
  53900. disablePentagonBokeh(): void;
  53901. /**
  53902. * Enables noise blur
  53903. */
  53904. enableNoiseBlur(): void;
  53905. /**
  53906. * Disables noise blur
  53907. */
  53908. disableNoiseBlur(): void;
  53909. /**
  53910. * Sets the HighlightsGain amount
  53911. * @param amount amount of HighlightsGain
  53912. */
  53913. setHighlightsGain(amount: number): void;
  53914. /**
  53915. * Sets the HighlightsThreshold amount
  53916. * @param amount amount of HighlightsThreshold
  53917. */
  53918. setHighlightsThreshold(amount: number): void;
  53919. /**
  53920. * Disables highlights
  53921. */
  53922. disableHighlights(): void;
  53923. /**
  53924. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  53925. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  53926. */
  53927. dispose(disableDepthRender?: boolean): void;
  53928. private _createChromaticAberrationPostProcess;
  53929. private _createHighlightsPostProcess;
  53930. private _createDepthOfFieldPostProcess;
  53931. private _createGrainTexture;
  53932. }
  53933. }
  53934. declare module BABYLON {
  53935. /** @hidden */
  53936. export var ssao2PixelShader: {
  53937. name: string;
  53938. shader: string;
  53939. };
  53940. }
  53941. declare module BABYLON {
  53942. /** @hidden */
  53943. export var ssaoCombinePixelShader: {
  53944. name: string;
  53945. shader: string;
  53946. };
  53947. }
  53948. declare module BABYLON {
  53949. /**
  53950. * Render pipeline to produce ssao effect
  53951. */
  53952. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53953. /**
  53954. * @ignore
  53955. * The PassPostProcess id in the pipeline that contains the original scene color
  53956. */
  53957. SSAOOriginalSceneColorEffect: string;
  53958. /**
  53959. * @ignore
  53960. * The SSAO PostProcess id in the pipeline
  53961. */
  53962. SSAORenderEffect: string;
  53963. /**
  53964. * @ignore
  53965. * The horizontal blur PostProcess id in the pipeline
  53966. */
  53967. SSAOBlurHRenderEffect: string;
  53968. /**
  53969. * @ignore
  53970. * The vertical blur PostProcess id in the pipeline
  53971. */
  53972. SSAOBlurVRenderEffect: string;
  53973. /**
  53974. * @ignore
  53975. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53976. */
  53977. SSAOCombineRenderEffect: string;
  53978. /**
  53979. * The output strength of the SSAO post-process. Default value is 1.0.
  53980. */
  53981. totalStrength: number;
  53982. /**
  53983. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53984. */
  53985. maxZ: number;
  53986. /**
  53987. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53988. */
  53989. minZAspect: number;
  53990. private _samples;
  53991. /**
  53992. * Number of samples used for the SSAO calculations. Default value is 8
  53993. */
  53994. samples: number;
  53995. private _textureSamples;
  53996. /**
  53997. * Number of samples to use for antialiasing
  53998. */
  53999. textureSamples: number;
  54000. /**
  54001. * Ratio object used for SSAO ratio and blur ratio
  54002. */
  54003. private _ratio;
  54004. /**
  54005. * Dynamically generated sphere sampler.
  54006. */
  54007. private _sampleSphere;
  54008. /**
  54009. * Blur filter offsets
  54010. */
  54011. private _samplerOffsets;
  54012. private _expensiveBlur;
  54013. /**
  54014. * If bilateral blur should be used
  54015. */
  54016. expensiveBlur: boolean;
  54017. /**
  54018. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  54019. */
  54020. radius: number;
  54021. /**
  54022. * The base color of the SSAO post-process
  54023. * The final result is "base + ssao" between [0, 1]
  54024. */
  54025. base: number;
  54026. /**
  54027. * Support test.
  54028. */
  54029. static readonly IsSupported: boolean;
  54030. private _scene;
  54031. private _depthTexture;
  54032. private _normalTexture;
  54033. private _randomTexture;
  54034. private _originalColorPostProcess;
  54035. private _ssaoPostProcess;
  54036. private _blurHPostProcess;
  54037. private _blurVPostProcess;
  54038. private _ssaoCombinePostProcess;
  54039. private _firstUpdate;
  54040. /**
  54041. * Gets active scene
  54042. */
  54043. readonly scene: Scene;
  54044. /**
  54045. * @constructor
  54046. * @param name The rendering pipeline name
  54047. * @param scene The scene linked to this pipeline
  54048. * @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 }
  54049. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54050. */
  54051. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54052. /**
  54053. * Get the class name
  54054. * @returns "SSAO2RenderingPipeline"
  54055. */
  54056. getClassName(): string;
  54057. /**
  54058. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54059. */
  54060. dispose(disableGeometryBufferRenderer?: boolean): void;
  54061. private _createBlurPostProcess;
  54062. /** @hidden */
  54063. _rebuild(): void;
  54064. private _bits;
  54065. private _radicalInverse_VdC;
  54066. private _hammersley;
  54067. private _hemisphereSample_uniform;
  54068. private _generateHemisphere;
  54069. private _createSSAOPostProcess;
  54070. private _createSSAOCombinePostProcess;
  54071. private _createRandomTexture;
  54072. /**
  54073. * Serialize the rendering pipeline (Used when exporting)
  54074. * @returns the serialized object
  54075. */
  54076. serialize(): any;
  54077. /**
  54078. * Parse the serialized pipeline
  54079. * @param source Source pipeline.
  54080. * @param scene The scene to load the pipeline to.
  54081. * @param rootUrl The URL of the serialized pipeline.
  54082. * @returns An instantiated pipeline from the serialized object.
  54083. */
  54084. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  54085. }
  54086. }
  54087. declare module BABYLON {
  54088. /** @hidden */
  54089. export var ssaoPixelShader: {
  54090. name: string;
  54091. shader: string;
  54092. };
  54093. }
  54094. declare module BABYLON {
  54095. /**
  54096. * Render pipeline to produce ssao effect
  54097. */
  54098. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  54099. /**
  54100. * @ignore
  54101. * The PassPostProcess id in the pipeline that contains the original scene color
  54102. */
  54103. SSAOOriginalSceneColorEffect: string;
  54104. /**
  54105. * @ignore
  54106. * The SSAO PostProcess id in the pipeline
  54107. */
  54108. SSAORenderEffect: string;
  54109. /**
  54110. * @ignore
  54111. * The horizontal blur PostProcess id in the pipeline
  54112. */
  54113. SSAOBlurHRenderEffect: string;
  54114. /**
  54115. * @ignore
  54116. * The vertical blur PostProcess id in the pipeline
  54117. */
  54118. SSAOBlurVRenderEffect: string;
  54119. /**
  54120. * @ignore
  54121. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54122. */
  54123. SSAOCombineRenderEffect: string;
  54124. /**
  54125. * The output strength of the SSAO post-process. Default value is 1.0.
  54126. */
  54127. totalStrength: number;
  54128. /**
  54129. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  54130. */
  54131. radius: number;
  54132. /**
  54133. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  54134. * Must not be equal to fallOff and superior to fallOff.
  54135. * Default value is 0.0075
  54136. */
  54137. area: number;
  54138. /**
  54139. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  54140. * Must not be equal to area and inferior to area.
  54141. * Default value is 0.000001
  54142. */
  54143. fallOff: number;
  54144. /**
  54145. * The base color of the SSAO post-process
  54146. * The final result is "base + ssao" between [0, 1]
  54147. */
  54148. base: number;
  54149. private _scene;
  54150. private _depthTexture;
  54151. private _randomTexture;
  54152. private _originalColorPostProcess;
  54153. private _ssaoPostProcess;
  54154. private _blurHPostProcess;
  54155. private _blurVPostProcess;
  54156. private _ssaoCombinePostProcess;
  54157. private _firstUpdate;
  54158. /**
  54159. * Gets active scene
  54160. */
  54161. readonly scene: Scene;
  54162. /**
  54163. * @constructor
  54164. * @param name - The rendering pipeline name
  54165. * @param scene - The scene linked to this pipeline
  54166. * @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 }
  54167. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  54168. */
  54169. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54170. /**
  54171. * Get the class name
  54172. * @returns "SSAORenderingPipeline"
  54173. */
  54174. getClassName(): string;
  54175. /**
  54176. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54177. */
  54178. dispose(disableDepthRender?: boolean): void;
  54179. private _createBlurPostProcess;
  54180. /** @hidden */
  54181. _rebuild(): void;
  54182. private _createSSAOPostProcess;
  54183. private _createSSAOCombinePostProcess;
  54184. private _createRandomTexture;
  54185. }
  54186. }
  54187. declare module BABYLON {
  54188. /** @hidden */
  54189. export var standardPixelShader: {
  54190. name: string;
  54191. shader: string;
  54192. };
  54193. }
  54194. declare module BABYLON {
  54195. /**
  54196. * Standard rendering pipeline
  54197. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54198. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  54199. */
  54200. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54201. /**
  54202. * Public members
  54203. */
  54204. /**
  54205. * Post-process which contains the original scene color before the pipeline applies all the effects
  54206. */
  54207. originalPostProcess: Nullable<PostProcess>;
  54208. /**
  54209. * Post-process used to down scale an image x4
  54210. */
  54211. downSampleX4PostProcess: Nullable<PostProcess>;
  54212. /**
  54213. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  54214. */
  54215. brightPassPostProcess: Nullable<PostProcess>;
  54216. /**
  54217. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  54218. */
  54219. blurHPostProcesses: PostProcess[];
  54220. /**
  54221. * Post-process array storing all the vertical blur post-processes used by the pipeline
  54222. */
  54223. blurVPostProcesses: PostProcess[];
  54224. /**
  54225. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  54226. */
  54227. textureAdderPostProcess: Nullable<PostProcess>;
  54228. /**
  54229. * Post-process used to create volumetric lighting effect
  54230. */
  54231. volumetricLightPostProcess: Nullable<PostProcess>;
  54232. /**
  54233. * Post-process used to smooth the previous volumetric light post-process on the X axis
  54234. */
  54235. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  54236. /**
  54237. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  54238. */
  54239. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  54240. /**
  54241. * Post-process used to merge the volumetric light effect and the real scene color
  54242. */
  54243. volumetricLightMergePostProces: Nullable<PostProcess>;
  54244. /**
  54245. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  54246. */
  54247. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  54248. /**
  54249. * Base post-process used to calculate the average luminance of the final image for HDR
  54250. */
  54251. luminancePostProcess: Nullable<PostProcess>;
  54252. /**
  54253. * Post-processes used to create down sample post-processes in order to get
  54254. * the average luminance of the final image for HDR
  54255. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  54256. */
  54257. luminanceDownSamplePostProcesses: PostProcess[];
  54258. /**
  54259. * Post-process used to create a HDR effect (light adaptation)
  54260. */
  54261. hdrPostProcess: Nullable<PostProcess>;
  54262. /**
  54263. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  54264. */
  54265. textureAdderFinalPostProcess: Nullable<PostProcess>;
  54266. /**
  54267. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  54268. */
  54269. lensFlareFinalPostProcess: Nullable<PostProcess>;
  54270. /**
  54271. * Post-process used to merge the final HDR post-process and the real scene color
  54272. */
  54273. hdrFinalPostProcess: Nullable<PostProcess>;
  54274. /**
  54275. * Post-process used to create a lens flare effect
  54276. */
  54277. lensFlarePostProcess: Nullable<PostProcess>;
  54278. /**
  54279. * Post-process that merges the result of the lens flare post-process and the real scene color
  54280. */
  54281. lensFlareComposePostProcess: Nullable<PostProcess>;
  54282. /**
  54283. * Post-process used to create a motion blur effect
  54284. */
  54285. motionBlurPostProcess: Nullable<PostProcess>;
  54286. /**
  54287. * Post-process used to create a depth of field effect
  54288. */
  54289. depthOfFieldPostProcess: Nullable<PostProcess>;
  54290. /**
  54291. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54292. */
  54293. fxaaPostProcess: Nullable<FxaaPostProcess>;
  54294. /**
  54295. * Represents the brightness threshold in order to configure the illuminated surfaces
  54296. */
  54297. brightThreshold: number;
  54298. /**
  54299. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  54300. */
  54301. blurWidth: number;
  54302. /**
  54303. * Sets if the blur for highlighted surfaces must be only horizontal
  54304. */
  54305. horizontalBlur: boolean;
  54306. /**
  54307. * Gets the overall exposure used by the pipeline
  54308. */
  54309. /**
  54310. * Sets the overall exposure used by the pipeline
  54311. */
  54312. exposure: number;
  54313. /**
  54314. * Texture used typically to simulate "dirty" on camera lens
  54315. */
  54316. lensTexture: Nullable<Texture>;
  54317. /**
  54318. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  54319. */
  54320. volumetricLightCoefficient: number;
  54321. /**
  54322. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  54323. */
  54324. volumetricLightPower: number;
  54325. /**
  54326. * Used the set the blur intensity to smooth the volumetric lights
  54327. */
  54328. volumetricLightBlurScale: number;
  54329. /**
  54330. * Light (spot or directional) used to generate the volumetric lights rays
  54331. * The source light must have a shadow generate so the pipeline can get its
  54332. * depth map
  54333. */
  54334. sourceLight: Nullable<SpotLight | DirectionalLight>;
  54335. /**
  54336. * For eye adaptation, represents the minimum luminance the eye can see
  54337. */
  54338. hdrMinimumLuminance: number;
  54339. /**
  54340. * For eye adaptation, represents the decrease luminance speed
  54341. */
  54342. hdrDecreaseRate: number;
  54343. /**
  54344. * For eye adaptation, represents the increase luminance speed
  54345. */
  54346. hdrIncreaseRate: number;
  54347. /**
  54348. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  54349. */
  54350. /**
  54351. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  54352. */
  54353. hdrAutoExposure: boolean;
  54354. /**
  54355. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  54356. */
  54357. lensColorTexture: Nullable<Texture>;
  54358. /**
  54359. * The overall strengh for the lens flare effect
  54360. */
  54361. lensFlareStrength: number;
  54362. /**
  54363. * Dispersion coefficient for lens flare ghosts
  54364. */
  54365. lensFlareGhostDispersal: number;
  54366. /**
  54367. * Main lens flare halo width
  54368. */
  54369. lensFlareHaloWidth: number;
  54370. /**
  54371. * Based on the lens distortion effect, defines how much the lens flare result
  54372. * is distorted
  54373. */
  54374. lensFlareDistortionStrength: number;
  54375. /**
  54376. * Lens star texture must be used to simulate rays on the flares and is available
  54377. * in the documentation
  54378. */
  54379. lensStarTexture: Nullable<Texture>;
  54380. /**
  54381. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  54382. * flare effect by taking account of the dirt texture
  54383. */
  54384. lensFlareDirtTexture: Nullable<Texture>;
  54385. /**
  54386. * Represents the focal length for the depth of field effect
  54387. */
  54388. depthOfFieldDistance: number;
  54389. /**
  54390. * Represents the blur intensity for the blurred part of the depth of field effect
  54391. */
  54392. depthOfFieldBlurWidth: number;
  54393. /**
  54394. * For motion blur, defines how much the image is blurred by the movement
  54395. */
  54396. motionStrength: number;
  54397. /**
  54398. * List of animations for the pipeline (IAnimatable implementation)
  54399. */
  54400. animations: Animation[];
  54401. /**
  54402. * Private members
  54403. */
  54404. private _scene;
  54405. private _currentDepthOfFieldSource;
  54406. private _basePostProcess;
  54407. private _fixedExposure;
  54408. private _currentExposure;
  54409. private _hdrAutoExposure;
  54410. private _hdrCurrentLuminance;
  54411. private _floatTextureType;
  54412. private _ratio;
  54413. private _bloomEnabled;
  54414. private _depthOfFieldEnabled;
  54415. private _vlsEnabled;
  54416. private _lensFlareEnabled;
  54417. private _hdrEnabled;
  54418. private _motionBlurEnabled;
  54419. private _fxaaEnabled;
  54420. private _motionBlurSamples;
  54421. private _volumetricLightStepsCount;
  54422. private _samples;
  54423. /**
  54424. * @ignore
  54425. * Specifies if the bloom pipeline is enabled
  54426. */
  54427. BloomEnabled: boolean;
  54428. /**
  54429. * @ignore
  54430. * Specifies if the depth of field pipeline is enabed
  54431. */
  54432. DepthOfFieldEnabled: boolean;
  54433. /**
  54434. * @ignore
  54435. * Specifies if the lens flare pipeline is enabed
  54436. */
  54437. LensFlareEnabled: boolean;
  54438. /**
  54439. * @ignore
  54440. * Specifies if the HDR pipeline is enabled
  54441. */
  54442. HDREnabled: boolean;
  54443. /**
  54444. * @ignore
  54445. * Specifies if the volumetric lights scattering effect is enabled
  54446. */
  54447. VLSEnabled: boolean;
  54448. /**
  54449. * @ignore
  54450. * Specifies if the motion blur effect is enabled
  54451. */
  54452. MotionBlurEnabled: boolean;
  54453. /**
  54454. * Specifies if anti-aliasing is enabled
  54455. */
  54456. fxaaEnabled: boolean;
  54457. /**
  54458. * Specifies the number of steps used to calculate the volumetric lights
  54459. * Typically in interval [50, 200]
  54460. */
  54461. volumetricLightStepsCount: number;
  54462. /**
  54463. * Specifies the number of samples used for the motion blur effect
  54464. * Typically in interval [16, 64]
  54465. */
  54466. motionBlurSamples: number;
  54467. /**
  54468. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54469. */
  54470. samples: number;
  54471. /**
  54472. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54473. * @constructor
  54474. * @param name The rendering pipeline name
  54475. * @param scene The scene linked to this pipeline
  54476. * @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)
  54477. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  54478. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54479. */
  54480. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  54481. private _buildPipeline;
  54482. private _createDownSampleX4PostProcess;
  54483. private _createBrightPassPostProcess;
  54484. private _createBlurPostProcesses;
  54485. private _createTextureAdderPostProcess;
  54486. private _createVolumetricLightPostProcess;
  54487. private _createLuminancePostProcesses;
  54488. private _createHdrPostProcess;
  54489. private _createLensFlarePostProcess;
  54490. private _createDepthOfFieldPostProcess;
  54491. private _createMotionBlurPostProcess;
  54492. private _getDepthTexture;
  54493. private _disposePostProcesses;
  54494. /**
  54495. * Dispose of the pipeline and stop all post processes
  54496. */
  54497. dispose(): void;
  54498. /**
  54499. * Serialize the rendering pipeline (Used when exporting)
  54500. * @returns the serialized object
  54501. */
  54502. serialize(): any;
  54503. /**
  54504. * Parse the serialized pipeline
  54505. * @param source Source pipeline.
  54506. * @param scene The scene to load the pipeline to.
  54507. * @param rootUrl The URL of the serialized pipeline.
  54508. * @returns An instantiated pipeline from the serialized object.
  54509. */
  54510. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  54511. /**
  54512. * Luminance steps
  54513. */
  54514. static LuminanceSteps: number;
  54515. }
  54516. }
  54517. declare module BABYLON {
  54518. /** @hidden */
  54519. export var tonemapPixelShader: {
  54520. name: string;
  54521. shader: string;
  54522. };
  54523. }
  54524. declare module BABYLON {
  54525. /** Defines operator used for tonemapping */
  54526. export enum TonemappingOperator {
  54527. /** Hable */
  54528. Hable = 0,
  54529. /** Reinhard */
  54530. Reinhard = 1,
  54531. /** HejiDawson */
  54532. HejiDawson = 2,
  54533. /** Photographic */
  54534. Photographic = 3
  54535. }
  54536. /**
  54537. * Defines a post process to apply tone mapping
  54538. */
  54539. export class TonemapPostProcess extends PostProcess {
  54540. private _operator;
  54541. /** Defines the required exposure adjustement */
  54542. exposureAdjustment: number;
  54543. /**
  54544. * Creates a new TonemapPostProcess
  54545. * @param name defines the name of the postprocess
  54546. * @param _operator defines the operator to use
  54547. * @param exposureAdjustment defines the required exposure adjustement
  54548. * @param camera defines the camera to use (can be null)
  54549. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  54550. * @param engine defines the hosting engine (can be ignore if camera is set)
  54551. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54552. */
  54553. constructor(name: string, _operator: TonemappingOperator,
  54554. /** Defines the required exposure adjustement */
  54555. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  54556. }
  54557. }
  54558. declare module BABYLON {
  54559. /** @hidden */
  54560. export var depthVertexShader: {
  54561. name: string;
  54562. shader: string;
  54563. };
  54564. }
  54565. declare module BABYLON {
  54566. /** @hidden */
  54567. export var volumetricLightScatteringPixelShader: {
  54568. name: string;
  54569. shader: string;
  54570. };
  54571. }
  54572. declare module BABYLON {
  54573. /** @hidden */
  54574. export var volumetricLightScatteringPassPixelShader: {
  54575. name: string;
  54576. shader: string;
  54577. };
  54578. }
  54579. declare module BABYLON {
  54580. /**
  54581. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  54582. */
  54583. export class VolumetricLightScatteringPostProcess extends PostProcess {
  54584. private _volumetricLightScatteringPass;
  54585. private _volumetricLightScatteringRTT;
  54586. private _viewPort;
  54587. private _screenCoordinates;
  54588. private _cachedDefines;
  54589. /**
  54590. * If not undefined, the mesh position is computed from the attached node position
  54591. */
  54592. attachedNode: {
  54593. position: Vector3;
  54594. };
  54595. /**
  54596. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  54597. */
  54598. customMeshPosition: Vector3;
  54599. /**
  54600. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  54601. */
  54602. useCustomMeshPosition: boolean;
  54603. /**
  54604. * If the post-process should inverse the light scattering direction
  54605. */
  54606. invert: boolean;
  54607. /**
  54608. * The internal mesh used by the post-process
  54609. */
  54610. mesh: Mesh;
  54611. /**
  54612. * @hidden
  54613. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  54614. */
  54615. useDiffuseColor: boolean;
  54616. /**
  54617. * Array containing the excluded meshes not rendered in the internal pass
  54618. */
  54619. excludedMeshes: AbstractMesh[];
  54620. /**
  54621. * Controls the overall intensity of the post-process
  54622. */
  54623. exposure: number;
  54624. /**
  54625. * Dissipates each sample's contribution in range [0, 1]
  54626. */
  54627. decay: number;
  54628. /**
  54629. * Controls the overall intensity of each sample
  54630. */
  54631. weight: number;
  54632. /**
  54633. * Controls the density of each sample
  54634. */
  54635. density: number;
  54636. /**
  54637. * @constructor
  54638. * @param name The post-process name
  54639. * @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)
  54640. * @param camera The camera that the post-process will be attached to
  54641. * @param mesh The mesh used to create the light scattering
  54642. * @param samples The post-process quality, default 100
  54643. * @param samplingModeThe post-process filtering mode
  54644. * @param engine The babylon engine
  54645. * @param reusable If the post-process is reusable
  54646. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  54647. */
  54648. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  54649. /**
  54650. * Returns the string "VolumetricLightScatteringPostProcess"
  54651. * @returns "VolumetricLightScatteringPostProcess"
  54652. */
  54653. getClassName(): string;
  54654. private _isReady;
  54655. /**
  54656. * Sets the new light position for light scattering effect
  54657. * @param position The new custom light position
  54658. */
  54659. setCustomMeshPosition(position: Vector3): void;
  54660. /**
  54661. * Returns the light position for light scattering effect
  54662. * @return Vector3 The custom light position
  54663. */
  54664. getCustomMeshPosition(): Vector3;
  54665. /**
  54666. * Disposes the internal assets and detaches the post-process from the camera
  54667. */
  54668. dispose(camera: Camera): void;
  54669. /**
  54670. * Returns the render target texture used by the post-process
  54671. * @return the render target texture used by the post-process
  54672. */
  54673. getPass(): RenderTargetTexture;
  54674. private _meshExcluded;
  54675. private _createPass;
  54676. private _updateMeshScreenCoordinates;
  54677. /**
  54678. * Creates a default mesh for the Volumeric Light Scattering post-process
  54679. * @param name The mesh name
  54680. * @param scene The scene where to create the mesh
  54681. * @return the default mesh
  54682. */
  54683. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  54684. }
  54685. }
  54686. declare module BABYLON {
  54687. interface Scene {
  54688. /** @hidden (Backing field) */
  54689. _boundingBoxRenderer: BoundingBoxRenderer;
  54690. /** @hidden (Backing field) */
  54691. _forceShowBoundingBoxes: boolean;
  54692. /**
  54693. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  54694. */
  54695. forceShowBoundingBoxes: boolean;
  54696. /**
  54697. * Gets the bounding box renderer associated with the scene
  54698. * @returns a BoundingBoxRenderer
  54699. */
  54700. getBoundingBoxRenderer(): BoundingBoxRenderer;
  54701. }
  54702. interface AbstractMesh {
  54703. /** @hidden (Backing field) */
  54704. _showBoundingBox: boolean;
  54705. /**
  54706. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  54707. */
  54708. showBoundingBox: boolean;
  54709. }
  54710. /**
  54711. * Component responsible of rendering the bounding box of the meshes in a scene.
  54712. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  54713. */
  54714. export class BoundingBoxRenderer implements ISceneComponent {
  54715. /**
  54716. * The component name helpfull to identify the component in the list of scene components.
  54717. */
  54718. readonly name: string;
  54719. /**
  54720. * The scene the component belongs to.
  54721. */
  54722. scene: Scene;
  54723. /**
  54724. * Color of the bounding box lines placed in front of an object
  54725. */
  54726. frontColor: Color3;
  54727. /**
  54728. * Color of the bounding box lines placed behind an object
  54729. */
  54730. backColor: Color3;
  54731. /**
  54732. * Defines if the renderer should show the back lines or not
  54733. */
  54734. showBackLines: boolean;
  54735. /**
  54736. * @hidden
  54737. */
  54738. renderList: SmartArray<BoundingBox>;
  54739. private _colorShader;
  54740. private _vertexBuffers;
  54741. private _indexBuffer;
  54742. /**
  54743. * Instantiates a new bounding box renderer in a scene.
  54744. * @param scene the scene the renderer renders in
  54745. */
  54746. constructor(scene: Scene);
  54747. /**
  54748. * Registers the component in a given scene
  54749. */
  54750. register(): void;
  54751. private _evaluateSubMesh;
  54752. private _activeMesh;
  54753. private _prepareRessources;
  54754. private _createIndexBuffer;
  54755. /**
  54756. * Rebuilds the elements related to this component in case of
  54757. * context lost for instance.
  54758. */
  54759. rebuild(): void;
  54760. /**
  54761. * @hidden
  54762. */
  54763. reset(): void;
  54764. /**
  54765. * Render the bounding boxes of a specific rendering group
  54766. * @param renderingGroupId defines the rendering group to render
  54767. */
  54768. render(renderingGroupId: number): void;
  54769. /**
  54770. * In case of occlusion queries, we can render the occlusion bounding box through this method
  54771. * @param mesh Define the mesh to render the occlusion bounding box for
  54772. */
  54773. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  54774. /**
  54775. * Dispose and release the resources attached to this renderer.
  54776. */
  54777. dispose(): void;
  54778. }
  54779. }
  54780. declare module BABYLON {
  54781. /** @hidden */
  54782. export var depthPixelShader: {
  54783. name: string;
  54784. shader: string;
  54785. };
  54786. }
  54787. declare module BABYLON {
  54788. /**
  54789. * This represents a depth renderer in Babylon.
  54790. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54791. */
  54792. export class DepthRenderer {
  54793. private _scene;
  54794. private _depthMap;
  54795. private _effect;
  54796. private _cachedDefines;
  54797. private _camera;
  54798. /**
  54799. * Specifiess that the depth renderer will only be used within
  54800. * the camera it is created for.
  54801. * This can help forcing its rendering during the camera processing.
  54802. */
  54803. useOnlyInActiveCamera: boolean;
  54804. /** @hidden */
  54805. static _SceneComponentInitialization: (scene: Scene) => void;
  54806. /**
  54807. * Instantiates a depth renderer
  54808. * @param scene The scene the renderer belongs to
  54809. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54810. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54811. */
  54812. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  54813. /**
  54814. * Creates the depth rendering effect and checks if the effect is ready.
  54815. * @param subMesh The submesh to be used to render the depth map of
  54816. * @param useInstances If multiple world instances should be used
  54817. * @returns if the depth renderer is ready to render the depth map
  54818. */
  54819. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54820. /**
  54821. * Gets the texture which the depth map will be written to.
  54822. * @returns The depth map texture
  54823. */
  54824. getDepthMap(): RenderTargetTexture;
  54825. /**
  54826. * Disposes of the depth renderer.
  54827. */
  54828. dispose(): void;
  54829. }
  54830. }
  54831. declare module BABYLON {
  54832. interface Scene {
  54833. /** @hidden (Backing field) */
  54834. _depthRenderer: {
  54835. [id: string]: DepthRenderer;
  54836. };
  54837. /**
  54838. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  54839. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  54840. * @returns the created depth renderer
  54841. */
  54842. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  54843. /**
  54844. * Disables a depth renderer for a given camera
  54845. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  54846. */
  54847. disableDepthRenderer(camera?: Nullable<Camera>): void;
  54848. }
  54849. /**
  54850. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  54851. * in several rendering techniques.
  54852. */
  54853. export class DepthRendererSceneComponent implements ISceneComponent {
  54854. /**
  54855. * The component name helpfull to identify the component in the list of scene components.
  54856. */
  54857. readonly name: string;
  54858. /**
  54859. * The scene the component belongs to.
  54860. */
  54861. scene: Scene;
  54862. /**
  54863. * Creates a new instance of the component for the given scene
  54864. * @param scene Defines the scene to register the component in
  54865. */
  54866. constructor(scene: Scene);
  54867. /**
  54868. * Registers the component in a given scene
  54869. */
  54870. register(): void;
  54871. /**
  54872. * Rebuilds the elements related to this component in case of
  54873. * context lost for instance.
  54874. */
  54875. rebuild(): void;
  54876. /**
  54877. * Disposes the component and the associated ressources
  54878. */
  54879. dispose(): void;
  54880. private _gatherRenderTargets;
  54881. private _gatherActiveCameraRenderTargets;
  54882. }
  54883. }
  54884. declare module BABYLON {
  54885. /** @hidden */
  54886. export var outlinePixelShader: {
  54887. name: string;
  54888. shader: string;
  54889. };
  54890. }
  54891. declare module BABYLON {
  54892. /** @hidden */
  54893. export var outlineVertexShader: {
  54894. name: string;
  54895. shader: string;
  54896. };
  54897. }
  54898. declare module BABYLON {
  54899. interface Scene {
  54900. /** @hidden */
  54901. _outlineRenderer: OutlineRenderer;
  54902. /**
  54903. * Gets the outline renderer associated with the scene
  54904. * @returns a OutlineRenderer
  54905. */
  54906. getOutlineRenderer(): OutlineRenderer;
  54907. }
  54908. interface AbstractMesh {
  54909. /** @hidden (Backing field) */
  54910. _renderOutline: boolean;
  54911. /**
  54912. * Gets or sets a boolean indicating if the outline must be rendered as well
  54913. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  54914. */
  54915. renderOutline: boolean;
  54916. /** @hidden (Backing field) */
  54917. _renderOverlay: boolean;
  54918. /**
  54919. * Gets or sets a boolean indicating if the overlay must be rendered as well
  54920. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  54921. */
  54922. renderOverlay: boolean;
  54923. }
  54924. /**
  54925. * This class is responsible to draw bothe outline/overlay of meshes.
  54926. * It should not be used directly but through the available method on mesh.
  54927. */
  54928. export class OutlineRenderer implements ISceneComponent {
  54929. /**
  54930. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  54931. */
  54932. private static _StencilReference;
  54933. /**
  54934. * The name of the component. Each component must have a unique name.
  54935. */
  54936. name: string;
  54937. /**
  54938. * The scene the component belongs to.
  54939. */
  54940. scene: Scene;
  54941. /**
  54942. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  54943. */
  54944. zOffset: number;
  54945. private _engine;
  54946. private _effect;
  54947. private _cachedDefines;
  54948. private _savedDepthWrite;
  54949. /**
  54950. * Instantiates a new outline renderer. (There could be only one per scene).
  54951. * @param scene Defines the scene it belongs to
  54952. */
  54953. constructor(scene: Scene);
  54954. /**
  54955. * Register the component to one instance of a scene.
  54956. */
  54957. register(): void;
  54958. /**
  54959. * Rebuilds the elements related to this component in case of
  54960. * context lost for instance.
  54961. */
  54962. rebuild(): void;
  54963. /**
  54964. * Disposes the component and the associated ressources.
  54965. */
  54966. dispose(): void;
  54967. /**
  54968. * Renders the outline in the canvas.
  54969. * @param subMesh Defines the sumesh to render
  54970. * @param batch Defines the batch of meshes in case of instances
  54971. * @param useOverlay Defines if the rendering is for the overlay or the outline
  54972. */
  54973. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  54974. /**
  54975. * Returns whether or not the outline renderer is ready for a given submesh.
  54976. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  54977. * @param subMesh Defines the submesh to check readyness for
  54978. * @param useInstances Defines wheter wee are trying to render instances or not
  54979. * @returns true if ready otherwise false
  54980. */
  54981. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54982. private _beforeRenderingMesh;
  54983. private _afterRenderingMesh;
  54984. }
  54985. }
  54986. declare module BABYLON {
  54987. /**
  54988. * Defines the list of states available for a task inside a AssetsManager
  54989. */
  54990. export enum AssetTaskState {
  54991. /**
  54992. * Initialization
  54993. */
  54994. INIT = 0,
  54995. /**
  54996. * Running
  54997. */
  54998. RUNNING = 1,
  54999. /**
  55000. * Done
  55001. */
  55002. DONE = 2,
  55003. /**
  55004. * Error
  55005. */
  55006. ERROR = 3
  55007. }
  55008. /**
  55009. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  55010. */
  55011. export abstract class AbstractAssetTask {
  55012. /**
  55013. * Task name
  55014. */ name: string;
  55015. /**
  55016. * Callback called when the task is successful
  55017. */
  55018. onSuccess: (task: any) => void;
  55019. /**
  55020. * Callback called when the task is not successful
  55021. */
  55022. onError: (task: any, message?: string, exception?: any) => void;
  55023. /**
  55024. * Creates a new AssetsManager
  55025. * @param name defines the name of the task
  55026. */
  55027. constructor(
  55028. /**
  55029. * Task name
  55030. */ name: string);
  55031. private _isCompleted;
  55032. private _taskState;
  55033. private _errorObject;
  55034. /**
  55035. * Get if the task is completed
  55036. */
  55037. readonly isCompleted: boolean;
  55038. /**
  55039. * Gets the current state of the task
  55040. */
  55041. readonly taskState: AssetTaskState;
  55042. /**
  55043. * Gets the current error object (if task is in error)
  55044. */
  55045. readonly errorObject: {
  55046. message?: string;
  55047. exception?: any;
  55048. };
  55049. /**
  55050. * Internal only
  55051. * @hidden
  55052. */
  55053. _setErrorObject(message?: string, exception?: any): void;
  55054. /**
  55055. * Execute the current task
  55056. * @param scene defines the scene where you want your assets to be loaded
  55057. * @param onSuccess is a callback called when the task is successfully executed
  55058. * @param onError is a callback called if an error occurs
  55059. */
  55060. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55061. /**
  55062. * Execute the current task
  55063. * @param scene defines the scene where you want your assets to be loaded
  55064. * @param onSuccess is a callback called when the task is successfully executed
  55065. * @param onError is a callback called if an error occurs
  55066. */
  55067. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55068. /**
  55069. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  55070. * This can be used with failed tasks that have the reason for failure fixed.
  55071. */
  55072. reset(): void;
  55073. private onErrorCallback;
  55074. private onDoneCallback;
  55075. }
  55076. /**
  55077. * Define the interface used by progress events raised during assets loading
  55078. */
  55079. export interface IAssetsProgressEvent {
  55080. /**
  55081. * Defines the number of remaining tasks to process
  55082. */
  55083. remainingCount: number;
  55084. /**
  55085. * Defines the total number of tasks
  55086. */
  55087. totalCount: number;
  55088. /**
  55089. * Defines the task that was just processed
  55090. */
  55091. task: AbstractAssetTask;
  55092. }
  55093. /**
  55094. * Class used to share progress information about assets loading
  55095. */
  55096. export class AssetsProgressEvent implements IAssetsProgressEvent {
  55097. /**
  55098. * Defines the number of remaining tasks to process
  55099. */
  55100. remainingCount: number;
  55101. /**
  55102. * Defines the total number of tasks
  55103. */
  55104. totalCount: number;
  55105. /**
  55106. * Defines the task that was just processed
  55107. */
  55108. task: AbstractAssetTask;
  55109. /**
  55110. * Creates a AssetsProgressEvent
  55111. * @param remainingCount defines the number of remaining tasks to process
  55112. * @param totalCount defines the total number of tasks
  55113. * @param task defines the task that was just processed
  55114. */
  55115. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  55116. }
  55117. /**
  55118. * Define a task used by AssetsManager to load meshes
  55119. */
  55120. export class MeshAssetTask extends AbstractAssetTask {
  55121. /**
  55122. * Defines the name of the task
  55123. */
  55124. name: string;
  55125. /**
  55126. * Defines the list of mesh's names you want to load
  55127. */
  55128. meshesNames: any;
  55129. /**
  55130. * Defines the root url to use as a base to load your meshes and associated resources
  55131. */
  55132. rootUrl: string;
  55133. /**
  55134. * Defines the filename of the scene to load from
  55135. */
  55136. sceneFilename: string;
  55137. /**
  55138. * Gets the list of loaded meshes
  55139. */
  55140. loadedMeshes: Array<AbstractMesh>;
  55141. /**
  55142. * Gets the list of loaded particle systems
  55143. */
  55144. loadedParticleSystems: Array<IParticleSystem>;
  55145. /**
  55146. * Gets the list of loaded skeletons
  55147. */
  55148. loadedSkeletons: Array<Skeleton>;
  55149. /**
  55150. * Gets the list of loaded animation groups
  55151. */
  55152. loadedAnimationGroups: Array<AnimationGroup>;
  55153. /**
  55154. * Callback called when the task is successful
  55155. */
  55156. onSuccess: (task: MeshAssetTask) => void;
  55157. /**
  55158. * Callback called when the task is successful
  55159. */
  55160. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  55161. /**
  55162. * Creates a new MeshAssetTask
  55163. * @param name defines the name of the task
  55164. * @param meshesNames defines the list of mesh's names you want to load
  55165. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  55166. * @param sceneFilename defines the filename of the scene to load from
  55167. */
  55168. constructor(
  55169. /**
  55170. * Defines the name of the task
  55171. */
  55172. name: string,
  55173. /**
  55174. * Defines the list of mesh's names you want to load
  55175. */
  55176. meshesNames: any,
  55177. /**
  55178. * Defines the root url to use as a base to load your meshes and associated resources
  55179. */
  55180. rootUrl: string,
  55181. /**
  55182. * Defines the filename of the scene to load from
  55183. */
  55184. sceneFilename: string);
  55185. /**
  55186. * Execute the current task
  55187. * @param scene defines the scene where you want your assets to be loaded
  55188. * @param onSuccess is a callback called when the task is successfully executed
  55189. * @param onError is a callback called if an error occurs
  55190. */
  55191. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55192. }
  55193. /**
  55194. * Define a task used by AssetsManager to load text content
  55195. */
  55196. export class TextFileAssetTask extends AbstractAssetTask {
  55197. /**
  55198. * Defines the name of the task
  55199. */
  55200. name: string;
  55201. /**
  55202. * Defines the location of the file to load
  55203. */
  55204. url: string;
  55205. /**
  55206. * Gets the loaded text string
  55207. */
  55208. text: string;
  55209. /**
  55210. * Callback called when the task is successful
  55211. */
  55212. onSuccess: (task: TextFileAssetTask) => void;
  55213. /**
  55214. * Callback called when the task is successful
  55215. */
  55216. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  55217. /**
  55218. * Creates a new TextFileAssetTask object
  55219. * @param name defines the name of the task
  55220. * @param url defines the location of the file to load
  55221. */
  55222. constructor(
  55223. /**
  55224. * Defines the name of the task
  55225. */
  55226. name: string,
  55227. /**
  55228. * Defines the location of the file to load
  55229. */
  55230. url: string);
  55231. /**
  55232. * Execute the current task
  55233. * @param scene defines the scene where you want your assets to be loaded
  55234. * @param onSuccess is a callback called when the task is successfully executed
  55235. * @param onError is a callback called if an error occurs
  55236. */
  55237. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55238. }
  55239. /**
  55240. * Define a task used by AssetsManager to load binary data
  55241. */
  55242. export class BinaryFileAssetTask extends AbstractAssetTask {
  55243. /**
  55244. * Defines the name of the task
  55245. */
  55246. name: string;
  55247. /**
  55248. * Defines the location of the file to load
  55249. */
  55250. url: string;
  55251. /**
  55252. * Gets the lodaded data (as an array buffer)
  55253. */
  55254. data: ArrayBuffer;
  55255. /**
  55256. * Callback called when the task is successful
  55257. */
  55258. onSuccess: (task: BinaryFileAssetTask) => void;
  55259. /**
  55260. * Callback called when the task is successful
  55261. */
  55262. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  55263. /**
  55264. * Creates a new BinaryFileAssetTask object
  55265. * @param name defines the name of the new task
  55266. * @param url defines the location of the file to load
  55267. */
  55268. constructor(
  55269. /**
  55270. * Defines the name of the task
  55271. */
  55272. name: string,
  55273. /**
  55274. * Defines the location of the file to load
  55275. */
  55276. url: string);
  55277. /**
  55278. * Execute the current task
  55279. * @param scene defines the scene where you want your assets to be loaded
  55280. * @param onSuccess is a callback called when the task is successfully executed
  55281. * @param onError is a callback called if an error occurs
  55282. */
  55283. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55284. }
  55285. /**
  55286. * Define a task used by AssetsManager to load images
  55287. */
  55288. export class ImageAssetTask extends AbstractAssetTask {
  55289. /**
  55290. * Defines the name of the task
  55291. */
  55292. name: string;
  55293. /**
  55294. * Defines the location of the image to load
  55295. */
  55296. url: string;
  55297. /**
  55298. * Gets the loaded images
  55299. */
  55300. image: HTMLImageElement;
  55301. /**
  55302. * Callback called when the task is successful
  55303. */
  55304. onSuccess: (task: ImageAssetTask) => void;
  55305. /**
  55306. * Callback called when the task is successful
  55307. */
  55308. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  55309. /**
  55310. * Creates a new ImageAssetTask
  55311. * @param name defines the name of the task
  55312. * @param url defines the location of the image to load
  55313. */
  55314. constructor(
  55315. /**
  55316. * Defines the name of the task
  55317. */
  55318. name: string,
  55319. /**
  55320. * Defines the location of the image to load
  55321. */
  55322. url: string);
  55323. /**
  55324. * Execute the current task
  55325. * @param scene defines the scene where you want your assets to be loaded
  55326. * @param onSuccess is a callback called when the task is successfully executed
  55327. * @param onError is a callback called if an error occurs
  55328. */
  55329. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55330. }
  55331. /**
  55332. * Defines the interface used by texture loading tasks
  55333. */
  55334. export interface ITextureAssetTask<TEX extends BaseTexture> {
  55335. /**
  55336. * Gets the loaded texture
  55337. */
  55338. texture: TEX;
  55339. }
  55340. /**
  55341. * Define a task used by AssetsManager to load 2D textures
  55342. */
  55343. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  55344. /**
  55345. * Defines the name of the task
  55346. */
  55347. name: string;
  55348. /**
  55349. * Defines the location of the file to load
  55350. */
  55351. url: string;
  55352. /**
  55353. * Defines if mipmap should not be generated (default is false)
  55354. */
  55355. noMipmap?: boolean | undefined;
  55356. /**
  55357. * Defines if texture must be inverted on Y axis (default is false)
  55358. */
  55359. invertY?: boolean | undefined;
  55360. /**
  55361. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55362. */
  55363. samplingMode: number;
  55364. /**
  55365. * Gets the loaded texture
  55366. */
  55367. texture: Texture;
  55368. /**
  55369. * Callback called when the task is successful
  55370. */
  55371. onSuccess: (task: TextureAssetTask) => void;
  55372. /**
  55373. * Callback called when the task is successful
  55374. */
  55375. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  55376. /**
  55377. * Creates a new TextureAssetTask object
  55378. * @param name defines the name of the task
  55379. * @param url defines the location of the file to load
  55380. * @param noMipmap defines if mipmap should not be generated (default is false)
  55381. * @param invertY defines if texture must be inverted on Y axis (default is false)
  55382. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55383. */
  55384. constructor(
  55385. /**
  55386. * Defines the name of the task
  55387. */
  55388. name: string,
  55389. /**
  55390. * Defines the location of the file to load
  55391. */
  55392. url: string,
  55393. /**
  55394. * Defines if mipmap should not be generated (default is false)
  55395. */
  55396. noMipmap?: boolean | undefined,
  55397. /**
  55398. * Defines if texture must be inverted on Y axis (default is false)
  55399. */
  55400. invertY?: boolean | undefined,
  55401. /**
  55402. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55403. */
  55404. samplingMode?: number);
  55405. /**
  55406. * Execute the current task
  55407. * @param scene defines the scene where you want your assets to be loaded
  55408. * @param onSuccess is a callback called when the task is successfully executed
  55409. * @param onError is a callback called if an error occurs
  55410. */
  55411. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55412. }
  55413. /**
  55414. * Define a task used by AssetsManager to load cube textures
  55415. */
  55416. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  55417. /**
  55418. * Defines the name of the task
  55419. */
  55420. name: string;
  55421. /**
  55422. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55423. */
  55424. url: string;
  55425. /**
  55426. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55427. */
  55428. extensions?: string[] | undefined;
  55429. /**
  55430. * Defines if mipmaps should not be generated (default is false)
  55431. */
  55432. noMipmap?: boolean | undefined;
  55433. /**
  55434. * Defines the explicit list of files (undefined by default)
  55435. */
  55436. files?: string[] | undefined;
  55437. /**
  55438. * Gets the loaded texture
  55439. */
  55440. texture: CubeTexture;
  55441. /**
  55442. * Callback called when the task is successful
  55443. */
  55444. onSuccess: (task: CubeTextureAssetTask) => void;
  55445. /**
  55446. * Callback called when the task is successful
  55447. */
  55448. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  55449. /**
  55450. * Creates a new CubeTextureAssetTask
  55451. * @param name defines the name of the task
  55452. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55453. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55454. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55455. * @param files defines the explicit list of files (undefined by default)
  55456. */
  55457. constructor(
  55458. /**
  55459. * Defines the name of the task
  55460. */
  55461. name: string,
  55462. /**
  55463. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55464. */
  55465. url: string,
  55466. /**
  55467. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55468. */
  55469. extensions?: string[] | undefined,
  55470. /**
  55471. * Defines if mipmaps should not be generated (default is false)
  55472. */
  55473. noMipmap?: boolean | undefined,
  55474. /**
  55475. * Defines the explicit list of files (undefined by default)
  55476. */
  55477. files?: string[] | undefined);
  55478. /**
  55479. * Execute the current task
  55480. * @param scene defines the scene where you want your assets to be loaded
  55481. * @param onSuccess is a callback called when the task is successfully executed
  55482. * @param onError is a callback called if an error occurs
  55483. */
  55484. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55485. }
  55486. /**
  55487. * Define a task used by AssetsManager to load HDR cube textures
  55488. */
  55489. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  55490. /**
  55491. * Defines the name of the task
  55492. */
  55493. name: string;
  55494. /**
  55495. * Defines the location of the file to load
  55496. */
  55497. url: string;
  55498. /**
  55499. * Defines the desired size (the more it increases the longer the generation will be)
  55500. */
  55501. size: number;
  55502. /**
  55503. * Defines if mipmaps should not be generated (default is false)
  55504. */
  55505. noMipmap: boolean;
  55506. /**
  55507. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55508. */
  55509. generateHarmonics: boolean;
  55510. /**
  55511. * 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)
  55512. */
  55513. gammaSpace: boolean;
  55514. /**
  55515. * Internal Use Only
  55516. */
  55517. reserved: boolean;
  55518. /**
  55519. * Gets the loaded texture
  55520. */
  55521. texture: HDRCubeTexture;
  55522. /**
  55523. * Callback called when the task is successful
  55524. */
  55525. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  55526. /**
  55527. * Callback called when the task is successful
  55528. */
  55529. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  55530. /**
  55531. * Creates a new HDRCubeTextureAssetTask object
  55532. * @param name defines the name of the task
  55533. * @param url defines the location of the file to load
  55534. * @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.
  55535. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55536. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55537. * @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)
  55538. * @param reserved Internal use only
  55539. */
  55540. constructor(
  55541. /**
  55542. * Defines the name of the task
  55543. */
  55544. name: string,
  55545. /**
  55546. * Defines the location of the file to load
  55547. */
  55548. url: string,
  55549. /**
  55550. * Defines the desired size (the more it increases the longer the generation will be)
  55551. */
  55552. size: number,
  55553. /**
  55554. * Defines if mipmaps should not be generated (default is false)
  55555. */
  55556. noMipmap?: boolean,
  55557. /**
  55558. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55559. */
  55560. generateHarmonics?: boolean,
  55561. /**
  55562. * 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)
  55563. */
  55564. gammaSpace?: boolean,
  55565. /**
  55566. * Internal Use Only
  55567. */
  55568. reserved?: boolean);
  55569. /**
  55570. * Execute the current task
  55571. * @param scene defines the scene where you want your assets to be loaded
  55572. * @param onSuccess is a callback called when the task is successfully executed
  55573. * @param onError is a callback called if an error occurs
  55574. */
  55575. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55576. }
  55577. /**
  55578. * Define a task used by AssetsManager to load Equirectangular cube textures
  55579. */
  55580. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  55581. /**
  55582. * Defines the name of the task
  55583. */
  55584. name: string;
  55585. /**
  55586. * Defines the location of the file to load
  55587. */
  55588. url: string;
  55589. /**
  55590. * Defines the desired size (the more it increases the longer the generation will be)
  55591. */
  55592. size: number;
  55593. /**
  55594. * Defines if mipmaps should not be generated (default is false)
  55595. */
  55596. noMipmap: boolean;
  55597. /**
  55598. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  55599. * but the standard material would require them in Gamma space) (default is true)
  55600. */
  55601. gammaSpace: boolean;
  55602. /**
  55603. * Gets the loaded texture
  55604. */
  55605. texture: EquiRectangularCubeTexture;
  55606. /**
  55607. * Callback called when the task is successful
  55608. */
  55609. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  55610. /**
  55611. * Callback called when the task is successful
  55612. */
  55613. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  55614. /**
  55615. * Creates a new EquiRectangularCubeTextureAssetTask object
  55616. * @param name defines the name of the task
  55617. * @param url defines the location of the file to load
  55618. * @param size defines the desired size (the more it increases the longer the generation will be)
  55619. * If the size is omitted this implies you are using a preprocessed cubemap.
  55620. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55621. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  55622. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  55623. * (default is true)
  55624. */
  55625. constructor(
  55626. /**
  55627. * Defines the name of the task
  55628. */
  55629. name: string,
  55630. /**
  55631. * Defines the location of the file to load
  55632. */
  55633. url: string,
  55634. /**
  55635. * Defines the desired size (the more it increases the longer the generation will be)
  55636. */
  55637. size: number,
  55638. /**
  55639. * Defines if mipmaps should not be generated (default is false)
  55640. */
  55641. noMipmap?: boolean,
  55642. /**
  55643. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  55644. * but the standard material would require them in Gamma space) (default is true)
  55645. */
  55646. gammaSpace?: boolean);
  55647. /**
  55648. * Execute the current task
  55649. * @param scene defines the scene where you want your assets to be loaded
  55650. * @param onSuccess is a callback called when the task is successfully executed
  55651. * @param onError is a callback called if an error occurs
  55652. */
  55653. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55654. }
  55655. /**
  55656. * This class can be used to easily import assets into a scene
  55657. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  55658. */
  55659. export class AssetsManager {
  55660. private _scene;
  55661. private _isLoading;
  55662. protected _tasks: AbstractAssetTask[];
  55663. protected _waitingTasksCount: number;
  55664. protected _totalTasksCount: number;
  55665. /**
  55666. * Callback called when all tasks are processed
  55667. */
  55668. onFinish: (tasks: AbstractAssetTask[]) => void;
  55669. /**
  55670. * Callback called when a task is successful
  55671. */
  55672. onTaskSuccess: (task: AbstractAssetTask) => void;
  55673. /**
  55674. * Callback called when a task had an error
  55675. */
  55676. onTaskError: (task: AbstractAssetTask) => void;
  55677. /**
  55678. * Callback called when a task is done (whatever the result is)
  55679. */
  55680. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  55681. /**
  55682. * Observable called when all tasks are processed
  55683. */
  55684. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  55685. /**
  55686. * Observable called when a task had an error
  55687. */
  55688. onTaskErrorObservable: Observable<AbstractAssetTask>;
  55689. /**
  55690. * Observable called when all tasks were executed
  55691. */
  55692. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  55693. /**
  55694. * Observable called when a task is done (whatever the result is)
  55695. */
  55696. onProgressObservable: Observable<IAssetsProgressEvent>;
  55697. /**
  55698. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  55699. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  55700. */
  55701. useDefaultLoadingScreen: boolean;
  55702. /**
  55703. * Creates a new AssetsManager
  55704. * @param scene defines the scene to work on
  55705. */
  55706. constructor(scene: Scene);
  55707. /**
  55708. * Add a MeshAssetTask to the list of active tasks
  55709. * @param taskName defines the name of the new task
  55710. * @param meshesNames defines the name of meshes to load
  55711. * @param rootUrl defines the root url to use to locate files
  55712. * @param sceneFilename defines the filename of the scene file
  55713. * @returns a new MeshAssetTask object
  55714. */
  55715. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  55716. /**
  55717. * Add a TextFileAssetTask to the list of active tasks
  55718. * @param taskName defines the name of the new task
  55719. * @param url defines the url of the file to load
  55720. * @returns a new TextFileAssetTask object
  55721. */
  55722. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  55723. /**
  55724. * Add a BinaryFileAssetTask to the list of active tasks
  55725. * @param taskName defines the name of the new task
  55726. * @param url defines the url of the file to load
  55727. * @returns a new BinaryFileAssetTask object
  55728. */
  55729. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  55730. /**
  55731. * Add a ImageAssetTask to the list of active tasks
  55732. * @param taskName defines the name of the new task
  55733. * @param url defines the url of the file to load
  55734. * @returns a new ImageAssetTask object
  55735. */
  55736. addImageTask(taskName: string, url: string): ImageAssetTask;
  55737. /**
  55738. * Add a TextureAssetTask to the list of active tasks
  55739. * @param taskName defines the name of the new task
  55740. * @param url defines the url of the file to load
  55741. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55742. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  55743. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55744. * @returns a new TextureAssetTask object
  55745. */
  55746. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  55747. /**
  55748. * Add a CubeTextureAssetTask to the list of active tasks
  55749. * @param taskName defines the name of the new task
  55750. * @param url defines the url of the file to load
  55751. * @param extensions defines the extension to use to load the cube map (can be null)
  55752. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55753. * @param files defines the list of files to load (can be null)
  55754. * @returns a new CubeTextureAssetTask object
  55755. */
  55756. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  55757. /**
  55758. *
  55759. * Add a HDRCubeTextureAssetTask to the list of active tasks
  55760. * @param taskName defines the name of the new task
  55761. * @param url defines the url of the file to load
  55762. * @param size defines the size you want for the cubemap (can be null)
  55763. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55764. * @param generateHarmonics defines if you want to automatically generate (true by default)
  55765. * @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)
  55766. * @param reserved Internal use only
  55767. * @returns a new HDRCubeTextureAssetTask object
  55768. */
  55769. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  55770. /**
  55771. *
  55772. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  55773. * @param taskName defines the name of the new task
  55774. * @param url defines the url of the file to load
  55775. * @param size defines the size you want for the cubemap (can be null)
  55776. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55777. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55778. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55779. * @returns a new EquiRectangularCubeTextureAssetTask object
  55780. */
  55781. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  55782. /**
  55783. * Remove a task from the assets manager.
  55784. * @param task the task to remove
  55785. */
  55786. removeTask(task: AbstractAssetTask): void;
  55787. private _decreaseWaitingTasksCount;
  55788. private _runTask;
  55789. /**
  55790. * Reset the AssetsManager and remove all tasks
  55791. * @return the current instance of the AssetsManager
  55792. */
  55793. reset(): AssetsManager;
  55794. /**
  55795. * Start the loading process
  55796. * @return the current instance of the AssetsManager
  55797. */
  55798. load(): AssetsManager;
  55799. /**
  55800. * Start the loading process as an async operation
  55801. * @return a promise returning the list of failed tasks
  55802. */
  55803. loadAsync(): Promise<void>;
  55804. }
  55805. }
  55806. declare module BABYLON {
  55807. /**
  55808. * Wrapper class for promise with external resolve and reject.
  55809. */
  55810. export class Deferred<T> {
  55811. /**
  55812. * The promise associated with this deferred object.
  55813. */
  55814. readonly promise: Promise<T>;
  55815. private _resolve;
  55816. private _reject;
  55817. /**
  55818. * The resolve method of the promise associated with this deferred object.
  55819. */
  55820. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  55821. /**
  55822. * The reject method of the promise associated with this deferred object.
  55823. */
  55824. readonly reject: (reason?: any) => void;
  55825. /**
  55826. * Constructor for this deferred object.
  55827. */
  55828. constructor();
  55829. }
  55830. }
  55831. declare module BABYLON {
  55832. /**
  55833. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  55834. */
  55835. export class MeshExploder {
  55836. private _centerMesh;
  55837. private _meshes;
  55838. private _meshesOrigins;
  55839. private _toCenterVectors;
  55840. private _scaledDirection;
  55841. private _newPosition;
  55842. private _centerPosition;
  55843. /**
  55844. * Explodes meshes from a center mesh.
  55845. * @param meshes The meshes to explode.
  55846. * @param centerMesh The mesh to be center of explosion.
  55847. */
  55848. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  55849. private _setCenterMesh;
  55850. /**
  55851. * Get class name
  55852. * @returns "MeshExploder"
  55853. */
  55854. getClassName(): string;
  55855. /**
  55856. * "Exploded meshes"
  55857. * @returns Array of meshes with the centerMesh at index 0.
  55858. */
  55859. getMeshes(): Array<Mesh>;
  55860. /**
  55861. * Explodes meshes giving a specific direction
  55862. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  55863. */
  55864. explode(direction?: number): void;
  55865. }
  55866. }
  55867. declare module BABYLON {
  55868. /**
  55869. * Class used to help managing file picking and drag'n'drop
  55870. */
  55871. export class FilesInput {
  55872. /**
  55873. * List of files ready to be loaded
  55874. */
  55875. static readonly FilesToLoad: {
  55876. [key: string]: File;
  55877. };
  55878. /**
  55879. * Callback called when a file is processed
  55880. */
  55881. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  55882. private _engine;
  55883. private _currentScene;
  55884. private _sceneLoadedCallback;
  55885. private _progressCallback;
  55886. private _additionalRenderLoopLogicCallback;
  55887. private _textureLoadingCallback;
  55888. private _startingProcessingFilesCallback;
  55889. private _onReloadCallback;
  55890. private _errorCallback;
  55891. private _elementToMonitor;
  55892. private _sceneFileToLoad;
  55893. private _filesToLoad;
  55894. /**
  55895. * Creates a new FilesInput
  55896. * @param engine defines the rendering engine
  55897. * @param scene defines the hosting scene
  55898. * @param sceneLoadedCallback callback called when scene is loaded
  55899. * @param progressCallback callback called to track progress
  55900. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  55901. * @param textureLoadingCallback callback called when a texture is loading
  55902. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  55903. * @param onReloadCallback callback called when a reload is requested
  55904. * @param errorCallback callback call if an error occurs
  55905. */
  55906. 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);
  55907. private _dragEnterHandler;
  55908. private _dragOverHandler;
  55909. private _dropHandler;
  55910. /**
  55911. * Calls this function to listen to drag'n'drop events on a specific DOM element
  55912. * @param elementToMonitor defines the DOM element to track
  55913. */
  55914. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  55915. /**
  55916. * Release all associated resources
  55917. */
  55918. dispose(): void;
  55919. private renderFunction;
  55920. private drag;
  55921. private drop;
  55922. private _traverseFolder;
  55923. private _processFiles;
  55924. /**
  55925. * Load files from a drop event
  55926. * @param event defines the drop event to use as source
  55927. */
  55928. loadFiles(event: any): void;
  55929. private _processReload;
  55930. /**
  55931. * Reload the current scene from the loaded files
  55932. */
  55933. reload(): void;
  55934. }
  55935. }
  55936. declare module BABYLON {
  55937. /**
  55938. * Defines the root class used to create scene optimization to use with SceneOptimizer
  55939. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55940. */
  55941. export class SceneOptimization {
  55942. /**
  55943. * Defines the priority of this optimization (0 by default which means first in the list)
  55944. */
  55945. priority: number;
  55946. /**
  55947. * Gets a string describing the action executed by the current optimization
  55948. * @returns description string
  55949. */
  55950. getDescription(): string;
  55951. /**
  55952. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55953. * @param scene defines the current scene where to apply this optimization
  55954. * @param optimizer defines the current optimizer
  55955. * @returns true if everything that can be done was applied
  55956. */
  55957. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55958. /**
  55959. * Creates the SceneOptimization object
  55960. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55961. * @param desc defines the description associated with the optimization
  55962. */
  55963. constructor(
  55964. /**
  55965. * Defines the priority of this optimization (0 by default which means first in the list)
  55966. */
  55967. priority?: number);
  55968. }
  55969. /**
  55970. * Defines an optimization used to reduce the size of render target textures
  55971. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55972. */
  55973. export class TextureOptimization extends SceneOptimization {
  55974. /**
  55975. * Defines the priority of this optimization (0 by default which means first in the list)
  55976. */
  55977. priority: number;
  55978. /**
  55979. * 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
  55980. */
  55981. maximumSize: number;
  55982. /**
  55983. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55984. */
  55985. step: number;
  55986. /**
  55987. * Gets a string describing the action executed by the current optimization
  55988. * @returns description string
  55989. */
  55990. getDescription(): string;
  55991. /**
  55992. * Creates the TextureOptimization object
  55993. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55994. * @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
  55995. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55996. */
  55997. constructor(
  55998. /**
  55999. * Defines the priority of this optimization (0 by default which means first in the list)
  56000. */
  56001. priority?: number,
  56002. /**
  56003. * 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
  56004. */
  56005. maximumSize?: number,
  56006. /**
  56007. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56008. */
  56009. step?: number);
  56010. /**
  56011. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56012. * @param scene defines the current scene where to apply this optimization
  56013. * @param optimizer defines the current optimizer
  56014. * @returns true if everything that can be done was applied
  56015. */
  56016. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56017. }
  56018. /**
  56019. * Defines an optimization used to increase or decrease the rendering resolution
  56020. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56021. */
  56022. export class HardwareScalingOptimization extends SceneOptimization {
  56023. /**
  56024. * Defines the priority of this optimization (0 by default which means first in the list)
  56025. */
  56026. priority: number;
  56027. /**
  56028. * Defines the maximum scale to use (2 by default)
  56029. */
  56030. maximumScale: number;
  56031. /**
  56032. * Defines the step to use between two passes (0.5 by default)
  56033. */
  56034. step: number;
  56035. private _currentScale;
  56036. private _directionOffset;
  56037. /**
  56038. * Gets a string describing the action executed by the current optimization
  56039. * @return description string
  56040. */
  56041. getDescription(): string;
  56042. /**
  56043. * Creates the HardwareScalingOptimization object
  56044. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56045. * @param maximumScale defines the maximum scale to use (2 by default)
  56046. * @param step defines the step to use between two passes (0.5 by default)
  56047. */
  56048. constructor(
  56049. /**
  56050. * Defines the priority of this optimization (0 by default which means first in the list)
  56051. */
  56052. priority?: number,
  56053. /**
  56054. * Defines the maximum scale to use (2 by default)
  56055. */
  56056. maximumScale?: number,
  56057. /**
  56058. * Defines the step to use between two passes (0.5 by default)
  56059. */
  56060. step?: number);
  56061. /**
  56062. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56063. * @param scene defines the current scene where to apply this optimization
  56064. * @param optimizer defines the current optimizer
  56065. * @returns true if everything that can be done was applied
  56066. */
  56067. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56068. }
  56069. /**
  56070. * Defines an optimization used to remove shadows
  56071. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56072. */
  56073. export class ShadowsOptimization extends SceneOptimization {
  56074. /**
  56075. * Gets a string describing the action executed by the current optimization
  56076. * @return description string
  56077. */
  56078. getDescription(): string;
  56079. /**
  56080. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56081. * @param scene defines the current scene where to apply this optimization
  56082. * @param optimizer defines the current optimizer
  56083. * @returns true if everything that can be done was applied
  56084. */
  56085. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56086. }
  56087. /**
  56088. * Defines an optimization used to turn post-processes off
  56089. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56090. */
  56091. export class PostProcessesOptimization extends SceneOptimization {
  56092. /**
  56093. * Gets a string describing the action executed by the current optimization
  56094. * @return description string
  56095. */
  56096. getDescription(): string;
  56097. /**
  56098. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56099. * @param scene defines the current scene where to apply this optimization
  56100. * @param optimizer defines the current optimizer
  56101. * @returns true if everything that can be done was applied
  56102. */
  56103. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56104. }
  56105. /**
  56106. * Defines an optimization used to turn lens flares off
  56107. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56108. */
  56109. export class LensFlaresOptimization extends SceneOptimization {
  56110. /**
  56111. * Gets a string describing the action executed by the current optimization
  56112. * @return description string
  56113. */
  56114. getDescription(): string;
  56115. /**
  56116. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56117. * @param scene defines the current scene where to apply this optimization
  56118. * @param optimizer defines the current optimizer
  56119. * @returns true if everything that can be done was applied
  56120. */
  56121. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56122. }
  56123. /**
  56124. * Defines an optimization based on user defined callback.
  56125. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56126. */
  56127. export class CustomOptimization extends SceneOptimization {
  56128. /**
  56129. * Callback called to apply the custom optimization.
  56130. */
  56131. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  56132. /**
  56133. * Callback called to get custom description
  56134. */
  56135. onGetDescription: () => string;
  56136. /**
  56137. * Gets a string describing the action executed by the current optimization
  56138. * @returns description string
  56139. */
  56140. getDescription(): string;
  56141. /**
  56142. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56143. * @param scene defines the current scene where to apply this optimization
  56144. * @param optimizer defines the current optimizer
  56145. * @returns true if everything that can be done was applied
  56146. */
  56147. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56148. }
  56149. /**
  56150. * Defines an optimization used to turn particles off
  56151. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56152. */
  56153. export class ParticlesOptimization extends SceneOptimization {
  56154. /**
  56155. * Gets a string describing the action executed by the current optimization
  56156. * @return description string
  56157. */
  56158. getDescription(): string;
  56159. /**
  56160. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56161. * @param scene defines the current scene where to apply this optimization
  56162. * @param optimizer defines the current optimizer
  56163. * @returns true if everything that can be done was applied
  56164. */
  56165. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56166. }
  56167. /**
  56168. * Defines an optimization used to turn render targets off
  56169. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56170. */
  56171. export class RenderTargetsOptimization extends SceneOptimization {
  56172. /**
  56173. * Gets a string describing the action executed by the current optimization
  56174. * @return description string
  56175. */
  56176. getDescription(): string;
  56177. /**
  56178. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56179. * @param scene defines the current scene where to apply this optimization
  56180. * @param optimizer defines the current optimizer
  56181. * @returns true if everything that can be done was applied
  56182. */
  56183. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56184. }
  56185. /**
  56186. * Defines an optimization used to merge meshes with compatible materials
  56187. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56188. */
  56189. export class MergeMeshesOptimization extends SceneOptimization {
  56190. private static _UpdateSelectionTree;
  56191. /**
  56192. * Gets or sets a boolean which defines if optimization octree has to be updated
  56193. */
  56194. /**
  56195. * Gets or sets a boolean which defines if optimization octree has to be updated
  56196. */
  56197. static UpdateSelectionTree: boolean;
  56198. /**
  56199. * Gets a string describing the action executed by the current optimization
  56200. * @return description string
  56201. */
  56202. getDescription(): string;
  56203. private _canBeMerged;
  56204. /**
  56205. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56206. * @param scene defines the current scene where to apply this optimization
  56207. * @param optimizer defines the current optimizer
  56208. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  56209. * @returns true if everything that can be done was applied
  56210. */
  56211. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  56212. }
  56213. /**
  56214. * Defines a list of options used by SceneOptimizer
  56215. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56216. */
  56217. export class SceneOptimizerOptions {
  56218. /**
  56219. * Defines the target frame rate to reach (60 by default)
  56220. */
  56221. targetFrameRate: number;
  56222. /**
  56223. * Defines the interval between two checkes (2000ms by default)
  56224. */
  56225. trackerDuration: number;
  56226. /**
  56227. * Gets the list of optimizations to apply
  56228. */
  56229. optimizations: SceneOptimization[];
  56230. /**
  56231. * Creates a new list of options used by SceneOptimizer
  56232. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  56233. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  56234. */
  56235. constructor(
  56236. /**
  56237. * Defines the target frame rate to reach (60 by default)
  56238. */
  56239. targetFrameRate?: number,
  56240. /**
  56241. * Defines the interval between two checkes (2000ms by default)
  56242. */
  56243. trackerDuration?: number);
  56244. /**
  56245. * Add a new optimization
  56246. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  56247. * @returns the current SceneOptimizerOptions
  56248. */
  56249. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  56250. /**
  56251. * Add a new custom optimization
  56252. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  56253. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  56254. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56255. * @returns the current SceneOptimizerOptions
  56256. */
  56257. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  56258. /**
  56259. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  56260. * @param targetFrameRate defines the target frame rate (60 by default)
  56261. * @returns a SceneOptimizerOptions object
  56262. */
  56263. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56264. /**
  56265. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  56266. * @param targetFrameRate defines the target frame rate (60 by default)
  56267. * @returns a SceneOptimizerOptions object
  56268. */
  56269. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56270. /**
  56271. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  56272. * @param targetFrameRate defines the target frame rate (60 by default)
  56273. * @returns a SceneOptimizerOptions object
  56274. */
  56275. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56276. }
  56277. /**
  56278. * Class used to run optimizations in order to reach a target frame rate
  56279. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56280. */
  56281. export class SceneOptimizer implements IDisposable {
  56282. private _isRunning;
  56283. private _options;
  56284. private _scene;
  56285. private _currentPriorityLevel;
  56286. private _targetFrameRate;
  56287. private _trackerDuration;
  56288. private _currentFrameRate;
  56289. private _sceneDisposeObserver;
  56290. private _improvementMode;
  56291. /**
  56292. * Defines an observable called when the optimizer reaches the target frame rate
  56293. */
  56294. onSuccessObservable: Observable<SceneOptimizer>;
  56295. /**
  56296. * Defines an observable called when the optimizer enables an optimization
  56297. */
  56298. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  56299. /**
  56300. * Defines an observable called when the optimizer is not able to reach the target frame rate
  56301. */
  56302. onFailureObservable: Observable<SceneOptimizer>;
  56303. /**
  56304. * Gets a boolean indicating if the optimizer is in improvement mode
  56305. */
  56306. readonly isInImprovementMode: boolean;
  56307. /**
  56308. * Gets the current priority level (0 at start)
  56309. */
  56310. readonly currentPriorityLevel: number;
  56311. /**
  56312. * Gets the current frame rate checked by the SceneOptimizer
  56313. */
  56314. readonly currentFrameRate: number;
  56315. /**
  56316. * Gets or sets the current target frame rate (60 by default)
  56317. */
  56318. /**
  56319. * Gets or sets the current target frame rate (60 by default)
  56320. */
  56321. targetFrameRate: number;
  56322. /**
  56323. * Gets or sets the current interval between two checks (every 2000ms by default)
  56324. */
  56325. /**
  56326. * Gets or sets the current interval between two checks (every 2000ms by default)
  56327. */
  56328. trackerDuration: number;
  56329. /**
  56330. * Gets the list of active optimizations
  56331. */
  56332. readonly optimizations: SceneOptimization[];
  56333. /**
  56334. * Creates a new SceneOptimizer
  56335. * @param scene defines the scene to work on
  56336. * @param options defines the options to use with the SceneOptimizer
  56337. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  56338. * @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)
  56339. */
  56340. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  56341. /**
  56342. * Stops the current optimizer
  56343. */
  56344. stop(): void;
  56345. /**
  56346. * Reset the optimizer to initial step (current priority level = 0)
  56347. */
  56348. reset(): void;
  56349. /**
  56350. * Start the optimizer. By default it will try to reach a specific framerate
  56351. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  56352. */
  56353. start(): void;
  56354. private _checkCurrentState;
  56355. /**
  56356. * Release all resources
  56357. */
  56358. dispose(): void;
  56359. /**
  56360. * Helper function to create a SceneOptimizer with one single line of code
  56361. * @param scene defines the scene to work on
  56362. * @param options defines the options to use with the SceneOptimizer
  56363. * @param onSuccess defines a callback to call on success
  56364. * @param onFailure defines a callback to call on failure
  56365. * @returns the new SceneOptimizer object
  56366. */
  56367. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  56368. }
  56369. }
  56370. declare module BABYLON {
  56371. /**
  56372. * Class used to serialize a scene into a string
  56373. */
  56374. export class SceneSerializer {
  56375. /**
  56376. * Clear cache used by a previous serialization
  56377. */
  56378. static ClearCache(): void;
  56379. /**
  56380. * Serialize a scene into a JSON compatible object
  56381. * @param scene defines the scene to serialize
  56382. * @returns a JSON compatible object
  56383. */
  56384. static Serialize(scene: Scene): any;
  56385. /**
  56386. * Serialize a mesh into a JSON compatible object
  56387. * @param toSerialize defines the mesh to serialize
  56388. * @param withParents defines if parents must be serialized as well
  56389. * @param withChildren defines if children must be serialized as well
  56390. * @returns a JSON compatible object
  56391. */
  56392. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  56393. }
  56394. }
  56395. declare module BABYLON {
  56396. /**
  56397. * Class used to host texture specific utilities
  56398. */
  56399. export class TextureTools {
  56400. /**
  56401. * Uses the GPU to create a copy texture rescaled at a given size
  56402. * @param texture Texture to copy from
  56403. * @param width defines the desired width
  56404. * @param height defines the desired height
  56405. * @param useBilinearMode defines if bilinear mode has to be used
  56406. * @return the generated texture
  56407. */
  56408. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  56409. }
  56410. }
  56411. declare module BABYLON {
  56412. /**
  56413. * This represents the different options avilable for the video capture.
  56414. */
  56415. export interface VideoRecorderOptions {
  56416. /** Defines the mime type of the video */
  56417. mimeType: string;
  56418. /** Defines the video the video should be recorded at */
  56419. fps: number;
  56420. /** Defines the chunk size for the recording data */
  56421. recordChunckSize: number;
  56422. /** The audio tracks to attach to the record */
  56423. audioTracks?: MediaStreamTrack[];
  56424. }
  56425. /**
  56426. * This can helps recording videos from BabylonJS.
  56427. * This is based on the available WebRTC functionalities of the browser.
  56428. *
  56429. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  56430. */
  56431. export class VideoRecorder {
  56432. private static readonly _defaultOptions;
  56433. /**
  56434. * Returns wehther or not the VideoRecorder is available in your browser.
  56435. * @param engine Defines the Babylon Engine to check the support for
  56436. * @returns true if supported otherwise false
  56437. */
  56438. static IsSupported(engine: Engine): boolean;
  56439. private readonly _options;
  56440. private _canvas;
  56441. private _mediaRecorder;
  56442. private _recordedChunks;
  56443. private _fileName;
  56444. private _resolve;
  56445. private _reject;
  56446. /**
  56447. * True wether a recording is already in progress.
  56448. */
  56449. readonly isRecording: boolean;
  56450. /**
  56451. * Create a new VideoCapture object which can help converting what you see in Babylon to
  56452. * a video file.
  56453. * @param engine Defines the BabylonJS Engine you wish to record
  56454. * @param options Defines options that can be used to customized the capture
  56455. */
  56456. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  56457. /**
  56458. * Stops the current recording before the default capture timeout passed in the startRecording
  56459. * functions.
  56460. */
  56461. stopRecording(): void;
  56462. /**
  56463. * Starts recording the canvas for a max duration specified in parameters.
  56464. * @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.
  56465. * @param maxDuration Defines the maximum recording time in seconds.
  56466. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  56467. * @return a promise callback at the end of the recording with the video data in Blob.
  56468. */
  56469. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  56470. /**
  56471. * Releases internal resources used during the recording.
  56472. */
  56473. dispose(): void;
  56474. private _handleDataAvailable;
  56475. private _handleError;
  56476. private _handleStop;
  56477. }
  56478. }
  56479. declare module BABYLON {
  56480. /**
  56481. * Class containing a set of static utilities functions for screenshots
  56482. */
  56483. export class ScreenshotTools {
  56484. /**
  56485. * Captures a screenshot of the current rendering
  56486. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56487. * @param engine defines the rendering engine
  56488. * @param camera defines the source camera
  56489. * @param size This parameter can be set to a single number or to an object with the
  56490. * following (optional) properties: precision, width, height. If a single number is passed,
  56491. * it will be used for both width and height. If an object is passed, the screenshot size
  56492. * will be derived from the parameters. The precision property is a multiplier allowing
  56493. * rendering at a higher or lower resolution
  56494. * @param successCallback defines the callback receives a single parameter which contains the
  56495. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56496. * src parameter of an <img> to display it
  56497. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  56498. * Check your browser for supported MIME types
  56499. */
  56500. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  56501. /**
  56502. * Generates an image screenshot from the specified camera.
  56503. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56504. * @param engine The engine to use for rendering
  56505. * @param camera The camera to use for rendering
  56506. * @param size This parameter can be set to a single number or to an object with the
  56507. * following (optional) properties: precision, width, height. If a single number is passed,
  56508. * it will be used for both width and height. If an object is passed, the screenshot size
  56509. * will be derived from the parameters. The precision property is a multiplier allowing
  56510. * rendering at a higher or lower resolution
  56511. * @param successCallback The callback receives a single parameter which contains the
  56512. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56513. * src parameter of an <img> to display it
  56514. * @param mimeType The MIME type of the screenshot image (default: image/png).
  56515. * Check your browser for supported MIME types
  56516. * @param samples Texture samples (default: 1)
  56517. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  56518. * @param fileName A name for for the downloaded file.
  56519. */
  56520. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  56521. }
  56522. }
  56523. declare module BABYLON {
  56524. /**
  56525. * A cursor which tracks a point on a path
  56526. */
  56527. export class PathCursor {
  56528. private path;
  56529. /**
  56530. * Stores path cursor callbacks for when an onchange event is triggered
  56531. */
  56532. private _onchange;
  56533. /**
  56534. * The value of the path cursor
  56535. */
  56536. value: number;
  56537. /**
  56538. * The animation array of the path cursor
  56539. */
  56540. animations: Animation[];
  56541. /**
  56542. * Initializes the path cursor
  56543. * @param path The path to track
  56544. */
  56545. constructor(path: Path2);
  56546. /**
  56547. * Gets the cursor point on the path
  56548. * @returns A point on the path cursor at the cursor location
  56549. */
  56550. getPoint(): Vector3;
  56551. /**
  56552. * Moves the cursor ahead by the step amount
  56553. * @param step The amount to move the cursor forward
  56554. * @returns This path cursor
  56555. */
  56556. moveAhead(step?: number): PathCursor;
  56557. /**
  56558. * Moves the cursor behind by the step amount
  56559. * @param step The amount to move the cursor back
  56560. * @returns This path cursor
  56561. */
  56562. moveBack(step?: number): PathCursor;
  56563. /**
  56564. * Moves the cursor by the step amount
  56565. * If the step amount is greater than one, an exception is thrown
  56566. * @param step The amount to move the cursor
  56567. * @returns This path cursor
  56568. */
  56569. move(step: number): PathCursor;
  56570. /**
  56571. * Ensures that the value is limited between zero and one
  56572. * @returns This path cursor
  56573. */
  56574. private ensureLimits;
  56575. /**
  56576. * Runs onchange callbacks on change (used by the animation engine)
  56577. * @returns This path cursor
  56578. */
  56579. private raiseOnChange;
  56580. /**
  56581. * Executes a function on change
  56582. * @param f A path cursor onchange callback
  56583. * @returns This path cursor
  56584. */
  56585. onchange(f: (cursor: PathCursor) => void): PathCursor;
  56586. }
  56587. }
  56588. declare module BABYLON {
  56589. /** @hidden */
  56590. export var blurPixelShader: {
  56591. name: string;
  56592. shader: string;
  56593. };
  56594. }
  56595. declare module BABYLON {
  56596. /** @hidden */
  56597. export var bones300Declaration: {
  56598. name: string;
  56599. shader: string;
  56600. };
  56601. }
  56602. declare module BABYLON {
  56603. /** @hidden */
  56604. export var instances300Declaration: {
  56605. name: string;
  56606. shader: string;
  56607. };
  56608. }
  56609. declare module BABYLON {
  56610. /** @hidden */
  56611. export var pointCloudVertexDeclaration: {
  56612. name: string;
  56613. shader: string;
  56614. };
  56615. }
  56616. // Mixins
  56617. interface Window {
  56618. mozIndexedDB: IDBFactory;
  56619. webkitIndexedDB: IDBFactory;
  56620. msIndexedDB: IDBFactory;
  56621. webkitURL: typeof URL;
  56622. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  56623. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  56624. WebGLRenderingContext: WebGLRenderingContext;
  56625. MSGesture: MSGesture;
  56626. CANNON: any;
  56627. AudioContext: AudioContext;
  56628. webkitAudioContext: AudioContext;
  56629. PointerEvent: any;
  56630. Math: Math;
  56631. Uint8Array: Uint8ArrayConstructor;
  56632. Float32Array: Float32ArrayConstructor;
  56633. mozURL: typeof URL;
  56634. msURL: typeof URL;
  56635. VRFrameData: any; // WebVR, from specs 1.1
  56636. DracoDecoderModule: any;
  56637. setImmediate(handler: (...args: any[]) => void): number;
  56638. }
  56639. interface HTMLCanvasElement {
  56640. requestPointerLock(): void;
  56641. msRequestPointerLock?(): void;
  56642. mozRequestPointerLock?(): void;
  56643. webkitRequestPointerLock?(): void;
  56644. /** Track wether a record is in progress */
  56645. isRecording: boolean;
  56646. /** Capture Stream method defined by some browsers */
  56647. captureStream(fps?: number): MediaStream;
  56648. }
  56649. interface CanvasRenderingContext2D {
  56650. msImageSmoothingEnabled: boolean;
  56651. }
  56652. interface MouseEvent {
  56653. mozMovementX: number;
  56654. mozMovementY: number;
  56655. webkitMovementX: number;
  56656. webkitMovementY: number;
  56657. msMovementX: number;
  56658. msMovementY: number;
  56659. }
  56660. interface Navigator {
  56661. mozGetVRDevices: (any: any) => any;
  56662. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56663. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56664. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56665. webkitGetGamepads(): Gamepad[];
  56666. msGetGamepads(): Gamepad[];
  56667. webkitGamepads(): Gamepad[];
  56668. }
  56669. interface HTMLVideoElement {
  56670. mozSrcObject: any;
  56671. }
  56672. interface Math {
  56673. fround(x: number): number;
  56674. imul(a: number, b: number): number;
  56675. }
  56676. interface WebGLRenderingContext {
  56677. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  56678. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  56679. vertexAttribDivisor(index: number, divisor: number): void;
  56680. createVertexArray(): any;
  56681. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  56682. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  56683. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  56684. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  56685. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  56686. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  56687. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  56688. // Queries
  56689. createQuery(): WebGLQuery;
  56690. deleteQuery(query: WebGLQuery): void;
  56691. beginQuery(target: number, query: WebGLQuery): void;
  56692. endQuery(target: number): void;
  56693. getQueryParameter(query: WebGLQuery, pname: number): any;
  56694. getQuery(target: number, pname: number): any;
  56695. MAX_SAMPLES: number;
  56696. RGBA8: number;
  56697. READ_FRAMEBUFFER: number;
  56698. DRAW_FRAMEBUFFER: number;
  56699. UNIFORM_BUFFER: number;
  56700. HALF_FLOAT_OES: number;
  56701. RGBA16F: number;
  56702. RGBA32F: number;
  56703. R32F: number;
  56704. RG32F: number;
  56705. RGB32F: number;
  56706. R16F: number;
  56707. RG16F: number;
  56708. RGB16F: number;
  56709. RED: number;
  56710. RG: number;
  56711. R8: number;
  56712. RG8: number;
  56713. UNSIGNED_INT_24_8: number;
  56714. DEPTH24_STENCIL8: number;
  56715. /* Multiple Render Targets */
  56716. drawBuffers(buffers: number[]): void;
  56717. readBuffer(src: number): void;
  56718. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  56719. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  56720. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  56721. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  56722. // Occlusion Query
  56723. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  56724. ANY_SAMPLES_PASSED: number;
  56725. QUERY_RESULT_AVAILABLE: number;
  56726. QUERY_RESULT: number;
  56727. }
  56728. interface WebGLProgram {
  56729. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  56730. }
  56731. interface EXT_disjoint_timer_query {
  56732. QUERY_COUNTER_BITS_EXT: number;
  56733. TIME_ELAPSED_EXT: number;
  56734. TIMESTAMP_EXT: number;
  56735. GPU_DISJOINT_EXT: number;
  56736. QUERY_RESULT_EXT: number;
  56737. QUERY_RESULT_AVAILABLE_EXT: number;
  56738. queryCounterEXT(query: WebGLQuery, target: number): void;
  56739. createQueryEXT(): WebGLQuery;
  56740. beginQueryEXT(target: number, query: WebGLQuery): void;
  56741. endQueryEXT(target: number): void;
  56742. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  56743. deleteQueryEXT(query: WebGLQuery): void;
  56744. }
  56745. interface WebGLUniformLocation {
  56746. _currentState: any;
  56747. }
  56748. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  56749. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  56750. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  56751. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56752. interface WebGLRenderingContext {
  56753. readonly RASTERIZER_DISCARD: number;
  56754. readonly DEPTH_COMPONENT24: number;
  56755. readonly TEXTURE_3D: number;
  56756. readonly TEXTURE_2D_ARRAY: number;
  56757. readonly TEXTURE_COMPARE_FUNC: number;
  56758. readonly TEXTURE_COMPARE_MODE: number;
  56759. readonly COMPARE_REF_TO_TEXTURE: number;
  56760. readonly TEXTURE_WRAP_R: number;
  56761. readonly HALF_FLOAT: number;
  56762. readonly RGB8: number;
  56763. readonly RED_INTEGER: number;
  56764. readonly RG_INTEGER: number;
  56765. readonly RGB_INTEGER: number;
  56766. readonly RGBA_INTEGER: number;
  56767. readonly R8_SNORM: number;
  56768. readonly RG8_SNORM: number;
  56769. readonly RGB8_SNORM: number;
  56770. readonly RGBA8_SNORM: number;
  56771. readonly R8I: number;
  56772. readonly RG8I: number;
  56773. readonly RGB8I: number;
  56774. readonly RGBA8I: number;
  56775. readonly R8UI: number;
  56776. readonly RG8UI: number;
  56777. readonly RGB8UI: number;
  56778. readonly RGBA8UI: number;
  56779. readonly R16I: number;
  56780. readonly RG16I: number;
  56781. readonly RGB16I: number;
  56782. readonly RGBA16I: number;
  56783. readonly R16UI: number;
  56784. readonly RG16UI: number;
  56785. readonly RGB16UI: number;
  56786. readonly RGBA16UI: number;
  56787. readonly R32I: number;
  56788. readonly RG32I: number;
  56789. readonly RGB32I: number;
  56790. readonly RGBA32I: number;
  56791. readonly R32UI: number;
  56792. readonly RG32UI: number;
  56793. readonly RGB32UI: number;
  56794. readonly RGBA32UI: number;
  56795. readonly RGB10_A2UI: number;
  56796. readonly R11F_G11F_B10F: number;
  56797. readonly RGB9_E5: number;
  56798. readonly RGB10_A2: number;
  56799. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  56800. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  56801. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  56802. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  56803. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  56804. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  56805. 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;
  56806. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  56807. readonly TRANSFORM_FEEDBACK: number;
  56808. readonly INTERLEAVED_ATTRIBS: number;
  56809. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  56810. createTransformFeedback(): WebGLTransformFeedback;
  56811. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  56812. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  56813. beginTransformFeedback(primitiveMode: number): void;
  56814. endTransformFeedback(): void;
  56815. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  56816. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56817. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56818. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56819. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  56820. }
  56821. interface ImageBitmap {
  56822. readonly width: number;
  56823. readonly height: number;
  56824. close(): void;
  56825. }
  56826. interface WebGLQuery extends WebGLObject {
  56827. }
  56828. declare var WebGLQuery: {
  56829. prototype: WebGLQuery;
  56830. new(): WebGLQuery;
  56831. };
  56832. interface WebGLSampler extends WebGLObject {
  56833. }
  56834. declare var WebGLSampler: {
  56835. prototype: WebGLSampler;
  56836. new(): WebGLSampler;
  56837. };
  56838. interface WebGLSync extends WebGLObject {
  56839. }
  56840. declare var WebGLSync: {
  56841. prototype: WebGLSync;
  56842. new(): WebGLSync;
  56843. };
  56844. interface WebGLTransformFeedback extends WebGLObject {
  56845. }
  56846. declare var WebGLTransformFeedback: {
  56847. prototype: WebGLTransformFeedback;
  56848. new(): WebGLTransformFeedback;
  56849. };
  56850. interface WebGLVertexArrayObject extends WebGLObject {
  56851. }
  56852. declare var WebGLVertexArrayObject: {
  56853. prototype: WebGLVertexArrayObject;
  56854. new(): WebGLVertexArrayObject;
  56855. };
  56856. // Type definitions for WebVR API
  56857. // Project: https://w3c.github.io/webvr/
  56858. // Definitions by: six a <https://github.com/lostfictions>
  56859. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56860. interface VRDisplay extends EventTarget {
  56861. /**
  56862. * Dictionary of capabilities describing the VRDisplay.
  56863. */
  56864. readonly capabilities: VRDisplayCapabilities;
  56865. /**
  56866. * z-depth defining the far plane of the eye view frustum
  56867. * enables mapping of values in the render target depth
  56868. * attachment to scene coordinates. Initially set to 10000.0.
  56869. */
  56870. depthFar: number;
  56871. /**
  56872. * z-depth defining the near plane of the eye view frustum
  56873. * enables mapping of values in the render target depth
  56874. * attachment to scene coordinates. Initially set to 0.01.
  56875. */
  56876. depthNear: number;
  56877. /**
  56878. * An identifier for this distinct VRDisplay. Used as an
  56879. * association point in the Gamepad API.
  56880. */
  56881. readonly displayId: number;
  56882. /**
  56883. * A display name, a user-readable name identifying it.
  56884. */
  56885. readonly displayName: string;
  56886. readonly isConnected: boolean;
  56887. readonly isPresenting: boolean;
  56888. /**
  56889. * If this VRDisplay supports room-scale experiences, the optional
  56890. * stage attribute contains details on the room-scale parameters.
  56891. */
  56892. readonly stageParameters: VRStageParameters | null;
  56893. /**
  56894. * Passing the value returned by `requestAnimationFrame` to
  56895. * `cancelAnimationFrame` will unregister the callback.
  56896. * @param handle Define the hanle of the request to cancel
  56897. */
  56898. cancelAnimationFrame(handle: number): void;
  56899. /**
  56900. * Stops presenting to the VRDisplay.
  56901. * @returns a promise to know when it stopped
  56902. */
  56903. exitPresent(): Promise<void>;
  56904. /**
  56905. * Return the current VREyeParameters for the given eye.
  56906. * @param whichEye Define the eye we want the parameter for
  56907. * @returns the eye parameters
  56908. */
  56909. getEyeParameters(whichEye: string): VREyeParameters;
  56910. /**
  56911. * Populates the passed VRFrameData with the information required to render
  56912. * the current frame.
  56913. * @param frameData Define the data structure to populate
  56914. * @returns true if ok otherwise false
  56915. */
  56916. getFrameData(frameData: VRFrameData): boolean;
  56917. /**
  56918. * Get the layers currently being presented.
  56919. * @returns the list of VR layers
  56920. */
  56921. getLayers(): VRLayer[];
  56922. /**
  56923. * Return a VRPose containing the future predicted pose of the VRDisplay
  56924. * when the current frame will be presented. The value returned will not
  56925. * change until JavaScript has returned control to the browser.
  56926. *
  56927. * The VRPose will contain the position, orientation, velocity,
  56928. * and acceleration of each of these properties.
  56929. * @returns the pose object
  56930. */
  56931. getPose(): VRPose;
  56932. /**
  56933. * Return the current instantaneous pose of the VRDisplay, with no
  56934. * prediction applied.
  56935. * @returns the current instantaneous pose
  56936. */
  56937. getImmediatePose(): VRPose;
  56938. /**
  56939. * The callback passed to `requestAnimationFrame` will be called
  56940. * any time a new frame should be rendered. When the VRDisplay is
  56941. * presenting the callback will be called at the native refresh
  56942. * rate of the HMD. When not presenting this function acts
  56943. * identically to how window.requestAnimationFrame acts. Content should
  56944. * make no assumptions of frame rate or vsync behavior as the HMD runs
  56945. * asynchronously from other displays and at differing refresh rates.
  56946. * @param callback Define the eaction to run next frame
  56947. * @returns the request handle it
  56948. */
  56949. requestAnimationFrame(callback: FrameRequestCallback): number;
  56950. /**
  56951. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  56952. * Repeat calls while already presenting will update the VRLayers being displayed.
  56953. * @param layers Define the list of layer to present
  56954. * @returns a promise to know when the request has been fulfilled
  56955. */
  56956. requestPresent(layers: VRLayer[]): Promise<void>;
  56957. /**
  56958. * Reset the pose for this display, treating its current position and
  56959. * orientation as the "origin/zero" values. VRPose.position,
  56960. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  56961. * updated when calling resetPose(). This should be called in only
  56962. * sitting-space experiences.
  56963. */
  56964. resetPose(): void;
  56965. /**
  56966. * The VRLayer provided to the VRDisplay will be captured and presented
  56967. * in the HMD. Calling this function has the same effect on the source
  56968. * canvas as any other operation that uses its source image, and canvases
  56969. * created without preserveDrawingBuffer set to true will be cleared.
  56970. * @param pose Define the pose to submit
  56971. */
  56972. submitFrame(pose?: VRPose): void;
  56973. }
  56974. declare var VRDisplay: {
  56975. prototype: VRDisplay;
  56976. new(): VRDisplay;
  56977. };
  56978. interface VRLayer {
  56979. leftBounds?: number[] | Float32Array | null;
  56980. rightBounds?: number[] | Float32Array | null;
  56981. source?: HTMLCanvasElement | null;
  56982. }
  56983. interface VRDisplayCapabilities {
  56984. readonly canPresent: boolean;
  56985. readonly hasExternalDisplay: boolean;
  56986. readonly hasOrientation: boolean;
  56987. readonly hasPosition: boolean;
  56988. readonly maxLayers: number;
  56989. }
  56990. interface VREyeParameters {
  56991. /** @deprecated */
  56992. readonly fieldOfView: VRFieldOfView;
  56993. readonly offset: Float32Array;
  56994. readonly renderHeight: number;
  56995. readonly renderWidth: number;
  56996. }
  56997. interface VRFieldOfView {
  56998. readonly downDegrees: number;
  56999. readonly leftDegrees: number;
  57000. readonly rightDegrees: number;
  57001. readonly upDegrees: number;
  57002. }
  57003. interface VRFrameData {
  57004. readonly leftProjectionMatrix: Float32Array;
  57005. readonly leftViewMatrix: Float32Array;
  57006. readonly pose: VRPose;
  57007. readonly rightProjectionMatrix: Float32Array;
  57008. readonly rightViewMatrix: Float32Array;
  57009. readonly timestamp: number;
  57010. }
  57011. interface VRPose {
  57012. readonly angularAcceleration: Float32Array | null;
  57013. readonly angularVelocity: Float32Array | null;
  57014. readonly linearAcceleration: Float32Array | null;
  57015. readonly linearVelocity: Float32Array | null;
  57016. readonly orientation: Float32Array | null;
  57017. readonly position: Float32Array | null;
  57018. readonly timestamp: number;
  57019. }
  57020. interface VRStageParameters {
  57021. sittingToStandingTransform?: Float32Array;
  57022. sizeX?: number;
  57023. sizeY?: number;
  57024. }
  57025. interface Navigator {
  57026. getVRDisplays(): Promise<VRDisplay[]>;
  57027. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  57028. }
  57029. interface Window {
  57030. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  57031. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  57032. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  57033. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57034. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57035. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  57036. }
  57037. interface Gamepad {
  57038. readonly displayId: number;
  57039. }
  57040. interface XRDevice {
  57041. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  57042. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  57043. }
  57044. interface XRSession {
  57045. getInputSources(): Array<any>;
  57046. baseLayer: XRWebGLLayer;
  57047. requestFrameOfReference(type: string): Promise<void>;
  57048. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  57049. end(): Promise<void>;
  57050. requestAnimationFrame: Function;
  57051. addEventListener: Function;
  57052. }
  57053. interface XRSessionCreationOptions {
  57054. outputContext?: WebGLRenderingContext | null;
  57055. immersive?: boolean;
  57056. environmentIntegration?: boolean;
  57057. }
  57058. interface XRLayer {
  57059. getViewport: Function;
  57060. framebufferWidth: number;
  57061. framebufferHeight: number;
  57062. }
  57063. interface XRView {
  57064. projectionMatrix: Float32Array;
  57065. }
  57066. interface XRFrame {
  57067. getDevicePose: Function;
  57068. getInputPose: Function;
  57069. views: Array<XRView>;
  57070. baseLayer: XRLayer;
  57071. }
  57072. interface XRFrameOfReference {
  57073. }
  57074. interface XRWebGLLayer extends XRLayer {
  57075. framebuffer: WebGLFramebuffer;
  57076. }
  57077. declare var XRWebGLLayer: {
  57078. prototype: XRWebGLLayer;
  57079. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  57080. };