babylon.d.ts 2.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402
  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. export const Epsilon = 0.001;
  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 Vector3 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. * Inserts the translation vector in the current matrix
  2943. * @param vector3 defines the translation to insert
  2944. * @returns the current updated matrix
  2945. */
  2946. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2947. /**
  2948. * Gets the translation value of the current matrix
  2949. * @returns a new Vector3 as the extracted translation from the matrix
  2950. */
  2951. getTranslation(): Vector3;
  2952. /**
  2953. * Fill a Vector3 with the extracted translation from the matrix
  2954. * @param result defines the Vector3 where to store the translation
  2955. * @returns the current matrix
  2956. */
  2957. getTranslationToRef(result: Vector3): Matrix;
  2958. /**
  2959. * Remove rotation and scaling part from the matrix
  2960. * @returns the updated matrix
  2961. */
  2962. removeRotationAndScaling(): Matrix;
  2963. /**
  2964. * Multiply two matrices
  2965. * @param other defines the second operand
  2966. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2967. */
  2968. multiply(other: DeepImmutable<Matrix>): Matrix;
  2969. /**
  2970. * Copy the current matrix from the given one
  2971. * @param other defines the source matrix
  2972. * @returns the current updated matrix
  2973. */
  2974. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2975. /**
  2976. * Populates the given array from the starting index with the current matrix values
  2977. * @param array defines the target array
  2978. * @param offset defines the offset in the target array where to start storing values
  2979. * @returns the current matrix
  2980. */
  2981. copyToArray(array: Float32Array, offset?: number): Matrix;
  2982. /**
  2983. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2984. * @param other defines the second operand
  2985. * @param result defines the matrix where to store the multiplication
  2986. * @returns the current matrix
  2987. */
  2988. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2989. /**
  2990. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2991. * @param other defines the second operand
  2992. * @param result defines the array where to store the multiplication
  2993. * @param offset defines the offset in the target array where to start storing values
  2994. * @returns the current matrix
  2995. */
  2996. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2997. /**
  2998. * Check equality between this matrix and a second one
  2999. * @param value defines the second matrix to compare
  3000. * @returns true is the current matrix and the given one values are strictly equal
  3001. */
  3002. equals(value: DeepImmutable<Matrix>): boolean;
  3003. /**
  3004. * Clone the current matrix
  3005. * @returns a new matrix from the current matrix
  3006. */
  3007. clone(): Matrix;
  3008. /**
  3009. * Returns the name of the current matrix class
  3010. * @returns the string "Matrix"
  3011. */
  3012. getClassName(): string;
  3013. /**
  3014. * Gets the hash code of the current matrix
  3015. * @returns the hash code
  3016. */
  3017. getHashCode(): number;
  3018. /**
  3019. * Decomposes the current Matrix into a translation, rotation and scaling components
  3020. * @param scale defines the scale vector3 given as a reference to update
  3021. * @param rotation defines the rotation quaternion given as a reference to update
  3022. * @param translation defines the translation vector3 given as a reference to update
  3023. * @returns true if operation was successful
  3024. */
  3025. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3026. /**
  3027. * Gets specific row of the matrix
  3028. * @param index defines the number of the row to get
  3029. * @returns the index-th row of the current matrix as a new Vector4
  3030. */
  3031. getRow(index: number): Nullable<Vector4>;
  3032. /**
  3033. * Sets the index-th row of the current matrix to the vector4 values
  3034. * @param index defines the number of the row to set
  3035. * @param row defines the target vector4
  3036. * @returns the updated current matrix
  3037. */
  3038. setRow(index: number, row: Vector4): Matrix;
  3039. /**
  3040. * Compute the transpose of the matrix
  3041. * @returns the new transposed matrix
  3042. */
  3043. transpose(): Matrix;
  3044. /**
  3045. * Compute the transpose of the matrix and store it in a given matrix
  3046. * @param result defines the target matrix
  3047. * @returns the current matrix
  3048. */
  3049. transposeToRef(result: Matrix): Matrix;
  3050. /**
  3051. * Sets the index-th row of the current matrix with the given 4 x float values
  3052. * @param index defines the row index
  3053. * @param x defines the x component to set
  3054. * @param y defines the y component to set
  3055. * @param z defines the z component to set
  3056. * @param w defines the w component to set
  3057. * @returns the updated current matrix
  3058. */
  3059. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3060. /**
  3061. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3062. * @param scale defines the scale factor
  3063. * @returns a new matrix
  3064. */
  3065. scale(scale: number): Matrix;
  3066. /**
  3067. * Scale the current matrix values by a factor to a given result matrix
  3068. * @param scale defines the scale factor
  3069. * @param result defines the matrix to store the result
  3070. * @returns the current matrix
  3071. */
  3072. scaleToRef(scale: number, result: Matrix): Matrix;
  3073. /**
  3074. * Scale the current matrix values by a factor and add the result to a given matrix
  3075. * @param scale defines the scale factor
  3076. * @param result defines the Matrix to store the result
  3077. * @returns the current matrix
  3078. */
  3079. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3080. /**
  3081. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3082. * @param ref matrix to store the result
  3083. */
  3084. toNormalMatrix(ref: Matrix): void;
  3085. /**
  3086. * Gets only rotation part of the current matrix
  3087. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3088. */
  3089. getRotationMatrix(): Matrix;
  3090. /**
  3091. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3092. * @param result defines the target matrix to store data to
  3093. * @returns the current matrix
  3094. */
  3095. getRotationMatrixToRef(result: Matrix): Matrix;
  3096. /**
  3097. * Toggles model matrix from being right handed to left handed in place and vice versa
  3098. */
  3099. toggleModelMatrixHandInPlace(): void;
  3100. /**
  3101. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3102. */
  3103. toggleProjectionMatrixHandInPlace(): void;
  3104. /**
  3105. * Creates a matrix from an array
  3106. * @param array defines the source array
  3107. * @param offset defines an offset in the source array
  3108. * @returns a new Matrix set from the starting index of the given array
  3109. */
  3110. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3111. /**
  3112. * Copy the content of an array into a given matrix
  3113. * @param array defines the source array
  3114. * @param offset defines an offset in the source array
  3115. * @param result defines the target matrix
  3116. */
  3117. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3118. /**
  3119. * Stores an array into a matrix after having multiplied each component by a given factor
  3120. * @param array defines the source array
  3121. * @param offset defines the offset in the source array
  3122. * @param scale defines the scaling factor
  3123. * @param result defines the target matrix
  3124. */
  3125. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3126. /**
  3127. * Gets an identity matrix that must not be updated
  3128. */
  3129. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3130. /**
  3131. * Stores a list of values (16) inside a given matrix
  3132. * @param initialM11 defines 1st value of 1st row
  3133. * @param initialM12 defines 2nd value of 1st row
  3134. * @param initialM13 defines 3rd value of 1st row
  3135. * @param initialM14 defines 4th value of 1st row
  3136. * @param initialM21 defines 1st value of 2nd row
  3137. * @param initialM22 defines 2nd value of 2nd row
  3138. * @param initialM23 defines 3rd value of 2nd row
  3139. * @param initialM24 defines 4th value of 2nd row
  3140. * @param initialM31 defines 1st value of 3rd row
  3141. * @param initialM32 defines 2nd value of 3rd row
  3142. * @param initialM33 defines 3rd value of 3rd row
  3143. * @param initialM34 defines 4th value of 3rd row
  3144. * @param initialM41 defines 1st value of 4th row
  3145. * @param initialM42 defines 2nd value of 4th row
  3146. * @param initialM43 defines 3rd value of 4th row
  3147. * @param initialM44 defines 4th value of 4th row
  3148. * @param result defines the target matrix
  3149. */
  3150. 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;
  3151. /**
  3152. * Creates new matrix from a list of values (16)
  3153. * @param initialM11 defines 1st value of 1st row
  3154. * @param initialM12 defines 2nd value of 1st row
  3155. * @param initialM13 defines 3rd value of 1st row
  3156. * @param initialM14 defines 4th value of 1st row
  3157. * @param initialM21 defines 1st value of 2nd row
  3158. * @param initialM22 defines 2nd value of 2nd row
  3159. * @param initialM23 defines 3rd value of 2nd row
  3160. * @param initialM24 defines 4th value of 2nd row
  3161. * @param initialM31 defines 1st value of 3rd row
  3162. * @param initialM32 defines 2nd value of 3rd row
  3163. * @param initialM33 defines 3rd value of 3rd row
  3164. * @param initialM34 defines 4th value of 3rd row
  3165. * @param initialM41 defines 1st value of 4th row
  3166. * @param initialM42 defines 2nd value of 4th row
  3167. * @param initialM43 defines 3rd value of 4th row
  3168. * @param initialM44 defines 4th value of 4th row
  3169. * @returns the new matrix
  3170. */
  3171. 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;
  3172. /**
  3173. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3174. * @param scale defines the scale vector3
  3175. * @param rotation defines the rotation quaternion
  3176. * @param translation defines the translation vector3
  3177. * @returns a new matrix
  3178. */
  3179. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3180. /**
  3181. * Sets a matrix to a value 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. * @param result defines the target matrix
  3186. */
  3187. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3188. /**
  3189. * Creates a new identity matrix
  3190. * @returns a new identity matrix
  3191. */
  3192. static Identity(): Matrix;
  3193. /**
  3194. * Creates a new identity matrix and stores the result in a given matrix
  3195. * @param result defines the target matrix
  3196. */
  3197. static IdentityToRef(result: Matrix): void;
  3198. /**
  3199. * Creates a new zero matrix
  3200. * @returns a new zero matrix
  3201. */
  3202. static Zero(): Matrix;
  3203. /**
  3204. * Creates a new rotation matrix for "angle" radians around the X axis
  3205. * @param angle defines the angle (in radians) to use
  3206. * @return the new matrix
  3207. */
  3208. static RotationX(angle: number): Matrix;
  3209. /**
  3210. * Creates a new matrix as the invert of a given matrix
  3211. * @param source defines the source matrix
  3212. * @returns the new matrix
  3213. */
  3214. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3215. /**
  3216. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3217. * @param angle defines the angle (in radians) to use
  3218. * @param result defines the target matrix
  3219. */
  3220. static RotationXToRef(angle: number, result: Matrix): void;
  3221. /**
  3222. * Creates a new rotation matrix for "angle" radians around the Y axis
  3223. * @param angle defines the angle (in radians) to use
  3224. * @return the new matrix
  3225. */
  3226. static RotationY(angle: number): Matrix;
  3227. /**
  3228. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3229. * @param angle defines the angle (in radians) to use
  3230. * @param result defines the target matrix
  3231. */
  3232. static RotationYToRef(angle: number, result: Matrix): void;
  3233. /**
  3234. * Creates a new rotation matrix for "angle" radians around the Z axis
  3235. * @param angle defines the angle (in radians) to use
  3236. * @return the new matrix
  3237. */
  3238. static RotationZ(angle: number): Matrix;
  3239. /**
  3240. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3241. * @param angle defines the angle (in radians) to use
  3242. * @param result defines the target matrix
  3243. */
  3244. static RotationZToRef(angle: number, result: Matrix): void;
  3245. /**
  3246. * Creates a new rotation matrix for "angle" radians around the given axis
  3247. * @param axis defines the axis to use
  3248. * @param angle defines the angle (in radians) to use
  3249. * @return the new matrix
  3250. */
  3251. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3252. /**
  3253. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3254. * @param axis defines the axis to use
  3255. * @param angle defines the angle (in radians) to use
  3256. * @param result defines the target matrix
  3257. */
  3258. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3259. /**
  3260. * Creates a rotation matrix
  3261. * @param yaw defines the yaw angle in radians (Y axis)
  3262. * @param pitch defines the pitch angle in radians (X axis)
  3263. * @param roll defines the roll angle in radians (X axis)
  3264. * @returns the new rotation matrix
  3265. */
  3266. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3267. /**
  3268. * Creates a rotation matrix and stores it in a given matrix
  3269. * @param yaw defines the yaw angle in radians (Y axis)
  3270. * @param pitch defines the pitch angle in radians (X axis)
  3271. * @param roll defines the roll angle in radians (X axis)
  3272. * @param result defines the target matrix
  3273. */
  3274. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3275. /**
  3276. * Creates a scaling matrix
  3277. * @param x defines the scale factor on X axis
  3278. * @param y defines the scale factor on Y axis
  3279. * @param z defines the scale factor on Z axis
  3280. * @returns the new matrix
  3281. */
  3282. static Scaling(x: number, y: number, z: number): Matrix;
  3283. /**
  3284. * Creates a scaling matrix and stores it in a given matrix
  3285. * @param x defines the scale factor on X axis
  3286. * @param y defines the scale factor on Y axis
  3287. * @param z defines the scale factor on Z axis
  3288. * @param result defines the target matrix
  3289. */
  3290. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3291. /**
  3292. * Creates a translation matrix
  3293. * @param x defines the translation on X axis
  3294. * @param y defines the translation on Y axis
  3295. * @param z defines the translationon Z axis
  3296. * @returns the new matrix
  3297. */
  3298. static Translation(x: number, y: number, z: number): Matrix;
  3299. /**
  3300. * Creates a translation matrix and stores it in a given matrix
  3301. * @param x defines the translation on X axis
  3302. * @param y defines the translation on Y axis
  3303. * @param z defines the translationon Z axis
  3304. * @param result defines the target matrix
  3305. */
  3306. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3307. /**
  3308. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3309. * @param startValue defines the start value
  3310. * @param endValue defines the end value
  3311. * @param gradient defines the gradient factor
  3312. * @returns the new matrix
  3313. */
  3314. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3315. /**
  3316. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3317. * @param startValue defines the start value
  3318. * @param endValue defines the end value
  3319. * @param gradient defines the gradient factor
  3320. * @param result defines the Matrix object where to store data
  3321. */
  3322. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3323. /**
  3324. * Builds a new matrix whose values are computed by:
  3325. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3326. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3327. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3328. * @param startValue defines the first matrix
  3329. * @param endValue defines the second matrix
  3330. * @param gradient defines the gradient between the two matrices
  3331. * @returns the new matrix
  3332. */
  3333. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3334. /**
  3335. * Update a matrix to values which are computed by:
  3336. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3337. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3338. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3339. * @param startValue defines the first matrix
  3340. * @param endValue defines the second matrix
  3341. * @param gradient defines the gradient between the two matrices
  3342. * @param result defines the target matrix
  3343. */
  3344. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3345. /**
  3346. * 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"
  3347. * This function works in left handed mode
  3348. * @param eye defines the final position of the entity
  3349. * @param target defines where the entity should look at
  3350. * @param up defines the up vector for the entity
  3351. * @returns the new matrix
  3352. */
  3353. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3354. /**
  3355. * 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".
  3356. * This function works in left handed mode
  3357. * @param eye defines the final position of the entity
  3358. * @param target defines where the entity should look at
  3359. * @param up defines the up vector for the entity
  3360. * @param result defines the target matrix
  3361. */
  3362. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3363. /**
  3364. * 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"
  3365. * This function works in right handed mode
  3366. * @param eye defines the final position of the entity
  3367. * @param target defines where the entity should look at
  3368. * @param up defines the up vector for the entity
  3369. * @returns the new matrix
  3370. */
  3371. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3372. /**
  3373. * 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".
  3374. * This function works in right handed mode
  3375. * @param eye defines the final position of the entity
  3376. * @param target defines where the entity should look at
  3377. * @param up defines the up vector for the entity
  3378. * @param result defines the target matrix
  3379. */
  3380. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3381. /**
  3382. * Create a left-handed orthographic projection matrix
  3383. * @param width defines the viewport width
  3384. * @param height defines the viewport height
  3385. * @param znear defines the near clip plane
  3386. * @param zfar defines the far clip plane
  3387. * @returns a new matrix as a left-handed orthographic projection matrix
  3388. */
  3389. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3390. /**
  3391. * Store a left-handed orthographic projection to a given matrix
  3392. * @param width defines the viewport width
  3393. * @param height defines the viewport height
  3394. * @param znear defines the near clip plane
  3395. * @param zfar defines the far clip plane
  3396. * @param result defines the target matrix
  3397. */
  3398. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3399. /**
  3400. * Create a left-handed orthographic projection matrix
  3401. * @param left defines the viewport left coordinate
  3402. * @param right defines the viewport right coordinate
  3403. * @param bottom defines the viewport bottom coordinate
  3404. * @param top defines the viewport top coordinate
  3405. * @param znear defines the near clip plane
  3406. * @param zfar defines the far clip plane
  3407. * @returns a new matrix as a left-handed orthographic projection matrix
  3408. */
  3409. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3410. /**
  3411. * Stores a left-handed orthographic projection into a given matrix
  3412. * @param left defines the viewport left coordinate
  3413. * @param right defines the viewport right coordinate
  3414. * @param bottom defines the viewport bottom coordinate
  3415. * @param top defines the viewport top coordinate
  3416. * @param znear defines the near clip plane
  3417. * @param zfar defines the far clip plane
  3418. * @param result defines the target matrix
  3419. */
  3420. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3421. /**
  3422. * Creates a right-handed orthographic projection matrix
  3423. * @param left defines the viewport left coordinate
  3424. * @param right defines the viewport right coordinate
  3425. * @param bottom defines the viewport bottom coordinate
  3426. * @param top defines the viewport top coordinate
  3427. * @param znear defines the near clip plane
  3428. * @param zfar defines the far clip plane
  3429. * @returns a new matrix as a right-handed orthographic projection matrix
  3430. */
  3431. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3432. /**
  3433. * Stores a right-handed orthographic projection into a given matrix
  3434. * @param left defines the viewport left coordinate
  3435. * @param right defines the viewport right coordinate
  3436. * @param bottom defines the viewport bottom coordinate
  3437. * @param top defines the viewport top coordinate
  3438. * @param znear defines the near clip plane
  3439. * @param zfar defines the far clip plane
  3440. * @param result defines the target matrix
  3441. */
  3442. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3443. /**
  3444. * Creates a left-handed perspective projection matrix
  3445. * @param width defines the viewport width
  3446. * @param height defines the viewport height
  3447. * @param znear defines the near clip plane
  3448. * @param zfar defines the far clip plane
  3449. * @returns a new matrix as a left-handed perspective projection matrix
  3450. */
  3451. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3452. /**
  3453. * Creates a left-handed perspective projection matrix
  3454. * @param fov defines the horizontal field of view
  3455. * @param aspect defines the aspect ratio
  3456. * @param znear defines the near clip plane
  3457. * @param zfar defines the far clip plane
  3458. * @returns a new matrix as a left-handed perspective projection matrix
  3459. */
  3460. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3461. /**
  3462. * Stores a left-handed perspective projection into a given matrix
  3463. * @param fov defines the horizontal field of view
  3464. * @param aspect defines the aspect ratio
  3465. * @param znear defines the near clip plane
  3466. * @param zfar defines the far clip plane
  3467. * @param result defines the target matrix
  3468. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3469. */
  3470. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3471. /**
  3472. * Creates a right-handed perspective projection matrix
  3473. * @param fov defines the horizontal field of view
  3474. * @param aspect defines the aspect ratio
  3475. * @param znear defines the near clip plane
  3476. * @param zfar defines the far clip plane
  3477. * @returns a new matrix as a right-handed perspective projection matrix
  3478. */
  3479. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3480. /**
  3481. * Stores a right-handed perspective projection into a given matrix
  3482. * @param fov defines the horizontal field of view
  3483. * @param aspect defines the aspect ratio
  3484. * @param znear defines the near clip plane
  3485. * @param zfar defines the far clip plane
  3486. * @param result defines the target matrix
  3487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3488. */
  3489. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3490. /**
  3491. * Stores a perspective projection for WebVR info a given matrix
  3492. * @param fov defines the field of view
  3493. * @param znear defines the near clip plane
  3494. * @param zfar defines the far clip plane
  3495. * @param result defines the target matrix
  3496. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3497. */
  3498. static PerspectiveFovWebVRToRef(fov: {
  3499. upDegrees: number;
  3500. downDegrees: number;
  3501. leftDegrees: number;
  3502. rightDegrees: number;
  3503. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3504. /**
  3505. * Computes a complete transformation matrix
  3506. * @param viewport defines the viewport to use
  3507. * @param world defines the world matrix
  3508. * @param view defines the view matrix
  3509. * @param projection defines the projection matrix
  3510. * @param zmin defines the near clip plane
  3511. * @param zmax defines the far clip plane
  3512. * @returns the transformation matrix
  3513. */
  3514. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3515. /**
  3516. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3517. * @param matrix defines the matrix to use
  3518. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3519. */
  3520. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3521. /**
  3522. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3523. * @param matrix defines the matrix to use
  3524. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3525. */
  3526. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3527. /**
  3528. * Compute the transpose of a given matrix
  3529. * @param matrix defines the matrix to transpose
  3530. * @returns the new matrix
  3531. */
  3532. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3533. /**
  3534. * Compute the transpose of a matrix and store it in a target matrix
  3535. * @param matrix defines the matrix to transpose
  3536. * @param result defines the target matrix
  3537. */
  3538. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3539. /**
  3540. * Computes a reflection matrix from a plane
  3541. * @param plane defines the reflection plane
  3542. * @returns a new matrix
  3543. */
  3544. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3545. /**
  3546. * Computes a reflection matrix from a plane
  3547. * @param plane defines the reflection plane
  3548. * @param result defines the target matrix
  3549. */
  3550. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3551. /**
  3552. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3553. * @param xaxis defines the value of the 1st axis
  3554. * @param yaxis defines the value of the 2nd axis
  3555. * @param zaxis defines the value of the 3rd axis
  3556. * @param result defines the target matrix
  3557. */
  3558. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3559. /**
  3560. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3561. * @param quat defines the quaternion to use
  3562. * @param result defines the target matrix
  3563. */
  3564. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3565. }
  3566. /**
  3567. * Represens a plane by the equation ax + by + cz + d = 0
  3568. */
  3569. export class Plane {
  3570. /**
  3571. * Normal of the plane (a,b,c)
  3572. */
  3573. normal: Vector3;
  3574. /**
  3575. * d component of the plane
  3576. */
  3577. d: number;
  3578. /**
  3579. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3580. * @param a a component of the plane
  3581. * @param b b component of the plane
  3582. * @param c c component of the plane
  3583. * @param d d component of the plane
  3584. */
  3585. constructor(a: number, b: number, c: number, d: number);
  3586. /**
  3587. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3588. */
  3589. asArray(): number[];
  3590. /**
  3591. * @returns a new plane copied from the current Plane.
  3592. */
  3593. clone(): Plane;
  3594. /**
  3595. * @returns the string "Plane".
  3596. */
  3597. getClassName(): string;
  3598. /**
  3599. * @returns the Plane hash code.
  3600. */
  3601. getHashCode(): number;
  3602. /**
  3603. * Normalize the current Plane in place.
  3604. * @returns the updated Plane.
  3605. */
  3606. normalize(): Plane;
  3607. /**
  3608. * Applies a transformation the plane and returns the result
  3609. * @param transformation the transformation matrix to be applied to the plane
  3610. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3611. */
  3612. transform(transformation: DeepImmutable<Matrix>): Plane;
  3613. /**
  3614. * Calcualtte the dot product between the point and the plane normal
  3615. * @param point point to calculate the dot product with
  3616. * @returns the dot product (float) of the point coordinates and the plane normal.
  3617. */
  3618. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3619. /**
  3620. * Updates the current Plane from the plane defined by the three given points.
  3621. * @param point1 one of the points used to contruct the plane
  3622. * @param point2 one of the points used to contruct the plane
  3623. * @param point3 one of the points used to contruct the plane
  3624. * @returns the updated Plane.
  3625. */
  3626. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3627. /**
  3628. * Checks if the plane is facing a given direction
  3629. * @param direction the direction to check if the plane is facing
  3630. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3631. * @returns True is the vector "direction" is the same side than the plane normal.
  3632. */
  3633. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3634. /**
  3635. * Calculates the distance to a point
  3636. * @param point point to calculate distance to
  3637. * @returns the signed distance (float) from the given point to the Plane.
  3638. */
  3639. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3640. /**
  3641. * Creates a plane from an array
  3642. * @param array the array to create a plane from
  3643. * @returns a new Plane from the given array.
  3644. */
  3645. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3646. /**
  3647. * Creates a plane from three points
  3648. * @param point1 point used to create the plane
  3649. * @param point2 point used to create the plane
  3650. * @param point3 point used to create the plane
  3651. * @returns a new Plane defined by the three given points.
  3652. */
  3653. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3654. /**
  3655. * Creates a plane from an origin point and a normal
  3656. * @param origin origin of the plane to be constructed
  3657. * @param normal normal of the plane to be constructed
  3658. * @returns a new Plane the normal vector to this plane at the given origin point.
  3659. * Note : the vector "normal" is updated because normalized.
  3660. */
  3661. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3662. /**
  3663. * Calculates the distance from a plane and a point
  3664. * @param origin origin of the plane to be constructed
  3665. * @param normal normal of the plane to be constructed
  3666. * @param point point to calculate distance to
  3667. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3668. */
  3669. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3670. }
  3671. /**
  3672. * Class used to represent a viewport on screen
  3673. */
  3674. export class Viewport {
  3675. /** viewport left coordinate */
  3676. x: number;
  3677. /** viewport top coordinate */
  3678. y: number;
  3679. /**viewport width */
  3680. width: number;
  3681. /** viewport height */
  3682. height: number;
  3683. /**
  3684. * Creates a Viewport object located at (x, y) and sized (width, height)
  3685. * @param x defines viewport left coordinate
  3686. * @param y defines viewport top coordinate
  3687. * @param width defines the viewport width
  3688. * @param height defines the viewport height
  3689. */
  3690. constructor(
  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 new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3701. * @param renderWidth defines the rendering width
  3702. * @param renderHeight defines the rendering height
  3703. * @returns a new Viewport
  3704. */
  3705. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3706. /**
  3707. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3708. * @param renderWidth defines the rendering width
  3709. * @param renderHeight defines the rendering height
  3710. * @param ref defines the target viewport
  3711. * @returns the current viewport
  3712. */
  3713. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3714. /**
  3715. * Returns a new Viewport copied from the current one
  3716. * @returns a new Viewport
  3717. */
  3718. clone(): Viewport;
  3719. }
  3720. /**
  3721. * Reprasents a camera frustum
  3722. */
  3723. export class Frustum {
  3724. /**
  3725. * Gets the planes representing the frustum
  3726. * @param transform matrix to be applied to the returned planes
  3727. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3728. */
  3729. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3730. /**
  3731. * Gets the near frustum plane transformed by the transform matrix
  3732. * @param transform transformation matrix to be applied to the resulting frustum plane
  3733. * @param frustumPlane the resuling frustum plane
  3734. */
  3735. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3736. /**
  3737. * Gets the far frustum plane transformed by the transform matrix
  3738. * @param transform transformation matrix to be applied to the resulting frustum plane
  3739. * @param frustumPlane the resuling frustum plane
  3740. */
  3741. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3742. /**
  3743. * Gets the left frustum plane transformed by the transform matrix
  3744. * @param transform transformation matrix to be applied to the resulting frustum plane
  3745. * @param frustumPlane the resuling frustum plane
  3746. */
  3747. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3748. /**
  3749. * Gets the right frustum plane transformed by the transform matrix
  3750. * @param transform transformation matrix to be applied to the resulting frustum plane
  3751. * @param frustumPlane the resuling frustum plane
  3752. */
  3753. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3754. /**
  3755. * Gets the top frustum plane transformed by the transform matrix
  3756. * @param transform transformation matrix to be applied to the resulting frustum plane
  3757. * @param frustumPlane the resuling frustum plane
  3758. */
  3759. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3760. /**
  3761. * Gets the bottom frustum plane transformed by the transform matrix
  3762. * @param transform transformation matrix to be applied to the resulting frustum plane
  3763. * @param frustumPlane the resuling frustum plane
  3764. */
  3765. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3766. /**
  3767. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3768. * @param transform transformation matrix to be applied to the resulting frustum planes
  3769. * @param frustumPlanes the resuling frustum planes
  3770. */
  3771. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3772. }
  3773. /** Defines supported spaces */
  3774. export enum Space {
  3775. /** Local (object) space */
  3776. LOCAL = 0,
  3777. /** World space */
  3778. WORLD = 1,
  3779. /** Bone space */
  3780. BONE = 2
  3781. }
  3782. /** Defines the 3 main axes */
  3783. export class Axis {
  3784. /** X axis */
  3785. static X: Vector3;
  3786. /** Y axis */
  3787. static Y: Vector3;
  3788. /** Z axis */
  3789. static Z: Vector3;
  3790. }
  3791. /** Class used to represent a Bezier curve */
  3792. export class BezierCurve {
  3793. /**
  3794. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3795. * @param t defines the time
  3796. * @param x1 defines the left coordinate on X axis
  3797. * @param y1 defines the left coordinate on Y axis
  3798. * @param x2 defines the right coordinate on X axis
  3799. * @param y2 defines the right coordinate on Y axis
  3800. * @returns the interpolated value
  3801. */
  3802. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3803. }
  3804. /**
  3805. * Defines potential orientation for back face culling
  3806. */
  3807. export enum Orientation {
  3808. /**
  3809. * Clockwise
  3810. */
  3811. CW = 0,
  3812. /** Counter clockwise */
  3813. CCW = 1
  3814. }
  3815. /**
  3816. * Defines angle representation
  3817. */
  3818. export class Angle {
  3819. private _radians;
  3820. /**
  3821. * Creates an Angle object of "radians" radians (float).
  3822. */
  3823. constructor(radians: number);
  3824. /**
  3825. * Get value in degrees
  3826. * @returns the Angle value in degrees (float)
  3827. */
  3828. degrees(): number;
  3829. /**
  3830. * Get value in radians
  3831. * @returns the Angle value in radians (float)
  3832. */
  3833. radians(): number;
  3834. /**
  3835. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3836. * @param a defines first vector
  3837. * @param b defines second vector
  3838. * @returns a new Angle
  3839. */
  3840. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3841. /**
  3842. * Gets a new Angle object from the given float in radians
  3843. * @param radians defines the angle value in radians
  3844. * @returns a new Angle
  3845. */
  3846. static FromRadians(radians: number): Angle;
  3847. /**
  3848. * Gets a new Angle object from the given float in degrees
  3849. * @param degrees defines the angle value in degrees
  3850. * @returns a new Angle
  3851. */
  3852. static FromDegrees(degrees: number): Angle;
  3853. }
  3854. /**
  3855. * This represents an arc in a 2d space.
  3856. */
  3857. export class Arc2 {
  3858. /** Defines the start point of the arc */
  3859. startPoint: Vector2;
  3860. /** Defines the mid point of the arc */
  3861. midPoint: Vector2;
  3862. /** Defines the end point of the arc */
  3863. endPoint: Vector2;
  3864. /**
  3865. * Defines the center point of the arc.
  3866. */
  3867. centerPoint: Vector2;
  3868. /**
  3869. * Defines the radius of the arc.
  3870. */
  3871. radius: number;
  3872. /**
  3873. * Defines the angle of the arc (from mid point to end point).
  3874. */
  3875. angle: Angle;
  3876. /**
  3877. * Defines the start angle of the arc (from start point to middle point).
  3878. */
  3879. startAngle: Angle;
  3880. /**
  3881. * Defines the orientation of the arc (clock wise/counter clock wise).
  3882. */
  3883. orientation: Orientation;
  3884. /**
  3885. * Creates an Arc object from the three given points : start, middle and end.
  3886. * @param startPoint Defines the start point of the arc
  3887. * @param midPoint Defines the midlle point of the arc
  3888. * @param endPoint Defines the end point of the arc
  3889. */
  3890. constructor(
  3891. /** Defines the start point of the arc */
  3892. startPoint: Vector2,
  3893. /** Defines the mid point of the arc */
  3894. midPoint: Vector2,
  3895. /** Defines the end point of the arc */
  3896. endPoint: Vector2);
  3897. }
  3898. /**
  3899. * Represents a 2D path made up of multiple 2D points
  3900. */
  3901. export class Path2 {
  3902. private _points;
  3903. private _length;
  3904. /**
  3905. * If the path start and end point are the same
  3906. */
  3907. closed: boolean;
  3908. /**
  3909. * Creates a Path2 object from the starting 2D coordinates x and y.
  3910. * @param x the starting points x value
  3911. * @param y the starting points y value
  3912. */
  3913. constructor(x: number, y: number);
  3914. /**
  3915. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3916. * @param x the added points x value
  3917. * @param y the added points y value
  3918. * @returns the updated Path2.
  3919. */
  3920. addLineTo(x: number, y: number): Path2;
  3921. /**
  3922. * 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.
  3923. * @param midX middle point x value
  3924. * @param midY middle point y value
  3925. * @param endX end point x value
  3926. * @param endY end point y value
  3927. * @param numberOfSegments (default: 36)
  3928. * @returns the updated Path2.
  3929. */
  3930. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3931. /**
  3932. * Closes the Path2.
  3933. * @returns the Path2.
  3934. */
  3935. close(): Path2;
  3936. /**
  3937. * Gets the sum of the distance between each sequential point in the path
  3938. * @returns the Path2 total length (float).
  3939. */
  3940. length(): number;
  3941. /**
  3942. * Gets the points which construct the path
  3943. * @returns the Path2 internal array of points.
  3944. */
  3945. getPoints(): Vector2[];
  3946. /**
  3947. * Retreives the point at the distance aways from the starting point
  3948. * @param normalizedLengthPosition the length along the path to retreive the point from
  3949. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3950. */
  3951. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3952. /**
  3953. * Creates a new path starting from an x and y position
  3954. * @param x starting x value
  3955. * @param y starting y value
  3956. * @returns a new Path2 starting at the coordinates (x, y).
  3957. */
  3958. static StartingAt(x: number, y: number): Path2;
  3959. }
  3960. /**
  3961. * Represents a 3D path made up of multiple 3D points
  3962. */
  3963. export class Path3D {
  3964. /**
  3965. * an array of Vector3, the curve axis of the Path3D
  3966. */
  3967. path: Vector3[];
  3968. private _curve;
  3969. private _distances;
  3970. private _tangents;
  3971. private _normals;
  3972. private _binormals;
  3973. private _raw;
  3974. /**
  3975. * new Path3D(path, normal, raw)
  3976. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3977. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3978. * @param path an array of Vector3, the curve axis of the Path3D
  3979. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3980. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3981. */
  3982. constructor(
  3983. /**
  3984. * an array of Vector3, the curve axis of the Path3D
  3985. */
  3986. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3987. /**
  3988. * Returns the Path3D array of successive Vector3 designing its curve.
  3989. * @returns the Path3D array of successive Vector3 designing its curve.
  3990. */
  3991. getCurve(): Vector3[];
  3992. /**
  3993. * Returns an array populated with tangent vectors on each Path3D curve point.
  3994. * @returns an array populated with tangent vectors on each Path3D curve point.
  3995. */
  3996. getTangents(): Vector3[];
  3997. /**
  3998. * Returns an array populated with normal vectors on each Path3D curve point.
  3999. * @returns an array populated with normal vectors on each Path3D curve point.
  4000. */
  4001. getNormals(): Vector3[];
  4002. /**
  4003. * Returns an array populated with binormal vectors on each Path3D curve point.
  4004. * @returns an array populated with binormal vectors on each Path3D curve point.
  4005. */
  4006. getBinormals(): Vector3[];
  4007. /**
  4008. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4009. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4010. */
  4011. getDistances(): number[];
  4012. /**
  4013. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4014. * @param path path which all values are copied into the curves points
  4015. * @param firstNormal which should be projected onto the curve
  4016. * @returns the same object updated.
  4017. */
  4018. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4019. private _compute;
  4020. private _getFirstNonNullVector;
  4021. private _getLastNonNullVector;
  4022. private _normalVector;
  4023. }
  4024. /**
  4025. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4026. * A Curve3 is designed from a series of successive Vector3.
  4027. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4028. */
  4029. export class Curve3 {
  4030. private _points;
  4031. private _length;
  4032. /**
  4033. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4034. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4035. * @param v1 (Vector3) the control point
  4036. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4037. * @param nbPoints (integer) the wanted number of points in the curve
  4038. * @returns the created Curve3
  4039. */
  4040. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4041. /**
  4042. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4043. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4044. * @param v1 (Vector3) the first control point
  4045. * @param v2 (Vector3) the second control point
  4046. * @param v3 (Vector3) the end point of the Cubic Bezier
  4047. * @param nbPoints (integer) the wanted number of points in the curve
  4048. * @returns the created Curve3
  4049. */
  4050. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4051. /**
  4052. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4053. * @param p1 (Vector3) the origin point of the Hermite Spline
  4054. * @param t1 (Vector3) the tangent vector at the origin point
  4055. * @param p2 (Vector3) the end point of the Hermite Spline
  4056. * @param t2 (Vector3) the tangent vector at the end point
  4057. * @param nbPoints (integer) the wanted number of points in the curve
  4058. * @returns the created Curve3
  4059. */
  4060. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4061. /**
  4062. * Returns a Curve3 object along a CatmullRom Spline curve :
  4063. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4064. * @param nbPoints (integer) the wanted number of points between each curve control points
  4065. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4066. * @returns the created Curve3
  4067. */
  4068. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4069. /**
  4070. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4071. * A Curve3 is designed from a series of successive Vector3.
  4072. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4073. * @param points points which make up the curve
  4074. */
  4075. constructor(points: Vector3[]);
  4076. /**
  4077. * @returns the Curve3 stored array of successive Vector3
  4078. */
  4079. getPoints(): Vector3[];
  4080. /**
  4081. * @returns the computed length (float) of the curve.
  4082. */
  4083. length(): number;
  4084. /**
  4085. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4086. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4087. * curveA and curveB keep unchanged.
  4088. * @param curve the curve to continue from this curve
  4089. * @returns the newly constructed curve
  4090. */
  4091. continue(curve: DeepImmutable<Curve3>): Curve3;
  4092. private _computeLength;
  4093. }
  4094. /**
  4095. * Contains position and normal vectors for a vertex
  4096. */
  4097. export class PositionNormalVertex {
  4098. /** the position of the vertex (defaut: 0,0,0) */
  4099. position: Vector3;
  4100. /** the normal of the vertex (defaut: 0,1,0) */
  4101. normal: Vector3;
  4102. /**
  4103. * Creates a PositionNormalVertex
  4104. * @param position the position of the vertex (defaut: 0,0,0)
  4105. * @param normal the normal of the vertex (defaut: 0,1,0)
  4106. */
  4107. constructor(
  4108. /** the position of the vertex (defaut: 0,0,0) */
  4109. position?: Vector3,
  4110. /** the normal of the vertex (defaut: 0,1,0) */
  4111. normal?: Vector3);
  4112. /**
  4113. * Clones the PositionNormalVertex
  4114. * @returns the cloned PositionNormalVertex
  4115. */
  4116. clone(): PositionNormalVertex;
  4117. }
  4118. /**
  4119. * Contains position, normal and uv vectors for a vertex
  4120. */
  4121. export class PositionNormalTextureVertex {
  4122. /** the position of the vertex (defaut: 0,0,0) */
  4123. position: Vector3;
  4124. /** the normal of the vertex (defaut: 0,1,0) */
  4125. normal: Vector3;
  4126. /** the uv of the vertex (default: 0,0) */
  4127. uv: Vector2;
  4128. /**
  4129. * Creates a PositionNormalTextureVertex
  4130. * @param position the position of the vertex (defaut: 0,0,0)
  4131. * @param normal the normal of the vertex (defaut: 0,1,0)
  4132. * @param uv the uv of the vertex (default: 0,0)
  4133. */
  4134. constructor(
  4135. /** the position of the vertex (defaut: 0,0,0) */
  4136. position?: Vector3,
  4137. /** the normal of the vertex (defaut: 0,1,0) */
  4138. normal?: Vector3,
  4139. /** the uv of the vertex (default: 0,0) */
  4140. uv?: Vector2);
  4141. /**
  4142. * Clones the PositionNormalTextureVertex
  4143. * @returns the cloned PositionNormalTextureVertex
  4144. */
  4145. clone(): PositionNormalTextureVertex;
  4146. }
  4147. /**
  4148. * @hidden
  4149. */
  4150. export class Tmp {
  4151. static Color3: Color3[];
  4152. static Color4: Color4[];
  4153. static Vector2: Vector2[];
  4154. static Vector3: Vector3[];
  4155. static Vector4: Vector4[];
  4156. static Quaternion: Quaternion[];
  4157. static Matrix: Matrix[];
  4158. }
  4159. }
  4160. declare module BABYLON {
  4161. /**
  4162. * Class used to enable access to offline support
  4163. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4164. */
  4165. export interface IOfflineProvider {
  4166. /**
  4167. * Gets a boolean indicating if scene must be saved in the database
  4168. */
  4169. enableSceneOffline: boolean;
  4170. /**
  4171. * Gets a boolean indicating if textures must be saved in the database
  4172. */
  4173. enableTexturesOffline: boolean;
  4174. /**
  4175. * Open the offline support and make it available
  4176. * @param successCallback defines the callback to call on success
  4177. * @param errorCallback defines the callback to call on error
  4178. */
  4179. open(successCallback: () => void, errorCallback: () => void): void;
  4180. /**
  4181. * Loads an image from the offline support
  4182. * @param url defines the url to load from
  4183. * @param image defines the target DOM image
  4184. */
  4185. loadImage(url: string, image: HTMLImageElement): void;
  4186. /**
  4187. * Loads a file from offline support
  4188. * @param url defines the URL to load from
  4189. * @param sceneLoaded defines a callback to call on success
  4190. * @param progressCallBack defines a callback to call when progress changed
  4191. * @param errorCallback defines a callback to call on error
  4192. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4193. */
  4194. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4195. }
  4196. }
  4197. declare module BABYLON {
  4198. /**
  4199. * A class serves as a medium between the observable and its observers
  4200. */
  4201. export class EventState {
  4202. /**
  4203. * Create a new EventState
  4204. * @param mask defines the mask associated with this state
  4205. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4206. * @param target defines the original target of the state
  4207. * @param currentTarget defines the current target of the state
  4208. */
  4209. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4210. /**
  4211. * Initialize the current event state
  4212. * @param mask defines the mask associated with this state
  4213. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4214. * @param target defines the original target of the state
  4215. * @param currentTarget defines the current target of the state
  4216. * @returns the current event state
  4217. */
  4218. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4219. /**
  4220. * An Observer can set this property to true to prevent subsequent observers of being notified
  4221. */
  4222. skipNextObservers: boolean;
  4223. /**
  4224. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4225. */
  4226. mask: number;
  4227. /**
  4228. * The object that originally notified the event
  4229. */
  4230. target?: any;
  4231. /**
  4232. * The current object in the bubbling phase
  4233. */
  4234. currentTarget?: any;
  4235. /**
  4236. * This will be populated with the return value of the last function that was executed.
  4237. * If it is the first function in the callback chain it will be the event data.
  4238. */
  4239. lastReturnValue?: any;
  4240. }
  4241. /**
  4242. * Represent an Observer registered to a given Observable object.
  4243. */
  4244. export class Observer<T> {
  4245. /**
  4246. * Defines the callback to call when the observer is notified
  4247. */
  4248. callback: (eventData: T, eventState: EventState) => void;
  4249. /**
  4250. * Defines the mask of the observer (used to filter notifications)
  4251. */
  4252. mask: number;
  4253. /**
  4254. * Defines the current scope used to restore the JS context
  4255. */
  4256. scope: any;
  4257. /** @hidden */
  4258. _willBeUnregistered: boolean;
  4259. /**
  4260. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4261. */
  4262. unregisterOnNextCall: boolean;
  4263. /**
  4264. * Creates a new observer
  4265. * @param callback defines the callback to call when the observer is notified
  4266. * @param mask defines the mask of the observer (used to filter notifications)
  4267. * @param scope defines the current scope used to restore the JS context
  4268. */
  4269. constructor(
  4270. /**
  4271. * Defines the callback to call when the observer is notified
  4272. */
  4273. callback: (eventData: T, eventState: EventState) => void,
  4274. /**
  4275. * Defines the mask of the observer (used to filter notifications)
  4276. */
  4277. mask: number,
  4278. /**
  4279. * Defines the current scope used to restore the JS context
  4280. */
  4281. scope?: any);
  4282. }
  4283. /**
  4284. * Represent a list of observers registered to multiple Observables object.
  4285. */
  4286. export class MultiObserver<T> {
  4287. private _observers;
  4288. private _observables;
  4289. /**
  4290. * Release associated resources
  4291. */
  4292. dispose(): void;
  4293. /**
  4294. * Raise a callback when one of the observable will notify
  4295. * @param observables defines a list of observables to watch
  4296. * @param callback defines the callback to call on notification
  4297. * @param mask defines the mask used to filter notifications
  4298. * @param scope defines the current scope used to restore the JS context
  4299. * @returns the new MultiObserver
  4300. */
  4301. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4302. }
  4303. /**
  4304. * The Observable class is a simple implementation of the Observable pattern.
  4305. *
  4306. * 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.
  4307. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4308. * 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).
  4309. * 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.
  4310. */
  4311. export class Observable<T> {
  4312. private _observers;
  4313. private _eventState;
  4314. private _onObserverAdded;
  4315. /**
  4316. * Creates a new observable
  4317. * @param onObserverAdded defines a callback to call when a new observer is added
  4318. */
  4319. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4320. /**
  4321. * Create a new Observer with the specified callback
  4322. * @param callback the callback that will be executed for that Observer
  4323. * @param mask the mask used to filter observers
  4324. * @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.
  4325. * @param scope optional scope for the callback to be called from
  4326. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4327. * @returns the new observer created for the callback
  4328. */
  4329. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4330. /**
  4331. * Create a new Observer with the specified callback and unregisters after the next notification
  4332. * @param callback the callback that will be executed for that Observer
  4333. * @returns the new observer created for the callback
  4334. */
  4335. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4336. /**
  4337. * Remove an Observer from the Observable object
  4338. * @param observer the instance of the Observer to remove
  4339. * @returns false if it doesn't belong to this Observable
  4340. */
  4341. remove(observer: Nullable<Observer<T>>): boolean;
  4342. /**
  4343. * Remove a callback from the Observable object
  4344. * @param callback the callback to remove
  4345. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4346. * @returns false if it doesn't belong to this Observable
  4347. */
  4348. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4349. private _deferUnregister;
  4350. private _remove;
  4351. /**
  4352. * Notify all Observers by calling their respective callback with the given data
  4353. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4354. * @param eventData defines the data to send to all observers
  4355. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4356. * @param target defines the original target of the state
  4357. * @param currentTarget defines the current target of the state
  4358. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4359. */
  4360. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4361. /**
  4362. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4363. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4364. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4365. * and it is crucial that all callbacks will be executed.
  4366. * The order of the callbacks is kept, callbacks are not executed parallel.
  4367. *
  4368. * @param eventData The data to be sent to each callback
  4369. * @param mask is used to filter observers defaults to -1
  4370. * @param target defines the callback target (see EventState)
  4371. * @param currentTarget defines he current object in the bubbling phase
  4372. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4373. */
  4374. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4375. /**
  4376. * Notify a specific observer
  4377. * @param observer defines the observer to notify
  4378. * @param eventData defines the data to be sent to each callback
  4379. * @param mask is used to filter observers defaults to -1
  4380. */
  4381. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4382. /**
  4383. * Gets a boolean indicating if the observable has at least one observer
  4384. * @returns true is the Observable has at least one Observer registered
  4385. */
  4386. hasObservers(): boolean;
  4387. /**
  4388. * Clear the list of observers
  4389. */
  4390. clear(): void;
  4391. /**
  4392. * Clone the current observable
  4393. * @returns a new observable
  4394. */
  4395. clone(): Observable<T>;
  4396. /**
  4397. * Does this observable handles observer registered with a given mask
  4398. * @param mask defines the mask to be tested
  4399. * @return whether or not one observer registered with the given mask is handeled
  4400. **/
  4401. hasSpecificMask(mask?: number): boolean;
  4402. }
  4403. }
  4404. declare module BABYLON {
  4405. /**
  4406. * Class used to help managing file picking and drag'n'drop
  4407. * File Storage
  4408. */
  4409. export class FilesInputStore {
  4410. /**
  4411. * List of files ready to be loaded
  4412. */
  4413. static FilesToLoad: {
  4414. [key: string]: File;
  4415. };
  4416. }
  4417. }
  4418. declare module BABYLON {
  4419. /** Defines the cross module used constants to avoid circular dependncies */
  4420. export class Constants {
  4421. /** Defines that alpha blending is disabled */
  4422. static readonly ALPHA_DISABLE: number;
  4423. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4424. static readonly ALPHA_ADD: number;
  4425. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4426. static readonly ALPHA_COMBINE: number;
  4427. /** Defines that alpha blending to DEST - SRC * DEST */
  4428. static readonly ALPHA_SUBTRACT: number;
  4429. /** Defines that alpha blending to SRC * DEST */
  4430. static readonly ALPHA_MULTIPLY: number;
  4431. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4432. static readonly ALPHA_MAXIMIZED: number;
  4433. /** Defines that alpha blending to SRC + DEST */
  4434. static readonly ALPHA_ONEONE: number;
  4435. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4436. static readonly ALPHA_PREMULTIPLIED: number;
  4437. /**
  4438. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4439. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4440. */
  4441. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4442. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4443. static readonly ALPHA_INTERPOLATE: number;
  4444. /**
  4445. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4446. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4447. */
  4448. static readonly ALPHA_SCREENMODE: number;
  4449. /** Defines that the ressource is not delayed*/
  4450. static readonly DELAYLOADSTATE_NONE: number;
  4451. /** Defines that the ressource was successfully delay loaded */
  4452. static readonly DELAYLOADSTATE_LOADED: number;
  4453. /** Defines that the ressource is currently delay loading */
  4454. static readonly DELAYLOADSTATE_LOADING: number;
  4455. /** Defines that the ressource is delayed and has not started loading */
  4456. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4457. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4458. static readonly NEVER: number;
  4459. /** 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 */
  4460. static readonly ALWAYS: number;
  4461. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4462. static readonly LESS: number;
  4463. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4464. static readonly EQUAL: number;
  4465. /** 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 */
  4466. static readonly LEQUAL: number;
  4467. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4468. static readonly GREATER: number;
  4469. /** 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 */
  4470. static readonly GEQUAL: number;
  4471. /** 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 */
  4472. static readonly NOTEQUAL: number;
  4473. /** Passed to stencilOperation to specify that stencil value must be kept */
  4474. static readonly KEEP: number;
  4475. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4476. static readonly REPLACE: number;
  4477. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4478. static readonly INCR: number;
  4479. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4480. static readonly DECR: number;
  4481. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4482. static readonly INVERT: number;
  4483. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4484. static readonly INCR_WRAP: number;
  4485. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4486. static readonly DECR_WRAP: number;
  4487. /** Texture is not repeating outside of 0..1 UVs */
  4488. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4489. /** Texture is repeating outside of 0..1 UVs */
  4490. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4491. /** Texture is repeating and mirrored */
  4492. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4493. /** ALPHA */
  4494. static readonly TEXTUREFORMAT_ALPHA: number;
  4495. /** LUMINANCE */
  4496. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4497. /** LUMINANCE_ALPHA */
  4498. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4499. /** RGB */
  4500. static readonly TEXTUREFORMAT_RGB: number;
  4501. /** RGBA */
  4502. static readonly TEXTUREFORMAT_RGBA: number;
  4503. /** RED */
  4504. static readonly TEXTUREFORMAT_RED: number;
  4505. /** RED (2nd reference) */
  4506. static readonly TEXTUREFORMAT_R: number;
  4507. /** RG */
  4508. static readonly TEXTUREFORMAT_RG: number;
  4509. /** RED_INTEGER */
  4510. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4511. /** RED_INTEGER (2nd reference) */
  4512. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4513. /** RG_INTEGER */
  4514. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4515. /** RGB_INTEGER */
  4516. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4517. /** RGBA_INTEGER */
  4518. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4519. /** UNSIGNED_BYTE */
  4520. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4521. /** UNSIGNED_BYTE (2nd reference) */
  4522. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4523. /** FLOAT */
  4524. static readonly TEXTURETYPE_FLOAT: number;
  4525. /** HALF_FLOAT */
  4526. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4527. /** BYTE */
  4528. static readonly TEXTURETYPE_BYTE: number;
  4529. /** SHORT */
  4530. static readonly TEXTURETYPE_SHORT: number;
  4531. /** UNSIGNED_SHORT */
  4532. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4533. /** INT */
  4534. static readonly TEXTURETYPE_INT: number;
  4535. /** UNSIGNED_INT */
  4536. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4537. /** UNSIGNED_SHORT_4_4_4_4 */
  4538. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4539. /** UNSIGNED_SHORT_5_5_5_1 */
  4540. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4541. /** UNSIGNED_SHORT_5_6_5 */
  4542. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4543. /** UNSIGNED_INT_2_10_10_10_REV */
  4544. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4545. /** UNSIGNED_INT_24_8 */
  4546. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4547. /** UNSIGNED_INT_10F_11F_11F_REV */
  4548. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4549. /** UNSIGNED_INT_5_9_9_9_REV */
  4550. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4551. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4552. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4553. /** nearest is mag = nearest and min = nearest and mip = linear */
  4554. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4555. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4556. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4557. /** Trilinear is mag = linear and min = linear and mip = linear */
  4558. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4559. /** nearest is mag = nearest and min = nearest and mip = linear */
  4560. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4561. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4562. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4563. /** Trilinear is mag = linear and min = linear and mip = linear */
  4564. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4565. /** mag = nearest and min = nearest and mip = nearest */
  4566. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4567. /** mag = nearest and min = linear and mip = nearest */
  4568. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4569. /** mag = nearest and min = linear and mip = linear */
  4570. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4571. /** mag = nearest and min = linear and mip = none */
  4572. static readonly TEXTURE_NEAREST_LINEAR: number;
  4573. /** mag = nearest and min = nearest and mip = none */
  4574. static readonly TEXTURE_NEAREST_NEAREST: number;
  4575. /** mag = linear and min = nearest and mip = nearest */
  4576. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4577. /** mag = linear and min = nearest and mip = linear */
  4578. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4579. /** mag = linear and min = linear and mip = none */
  4580. static readonly TEXTURE_LINEAR_LINEAR: number;
  4581. /** mag = linear and min = nearest and mip = none */
  4582. static readonly TEXTURE_LINEAR_NEAREST: number;
  4583. /** Explicit coordinates mode */
  4584. static readonly TEXTURE_EXPLICIT_MODE: number;
  4585. /** Spherical coordinates mode */
  4586. static readonly TEXTURE_SPHERICAL_MODE: number;
  4587. /** Planar coordinates mode */
  4588. static readonly TEXTURE_PLANAR_MODE: number;
  4589. /** Cubic coordinates mode */
  4590. static readonly TEXTURE_CUBIC_MODE: number;
  4591. /** Projection coordinates mode */
  4592. static readonly TEXTURE_PROJECTION_MODE: number;
  4593. /** Skybox coordinates mode */
  4594. static readonly TEXTURE_SKYBOX_MODE: number;
  4595. /** Inverse Cubic coordinates mode */
  4596. static readonly TEXTURE_INVCUBIC_MODE: number;
  4597. /** Equirectangular coordinates mode */
  4598. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4599. /** Equirectangular Fixed coordinates mode */
  4600. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4601. /** Equirectangular Fixed Mirrored coordinates mode */
  4602. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4603. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4604. static readonly SCALEMODE_FLOOR: number;
  4605. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4606. static readonly SCALEMODE_NEAREST: number;
  4607. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4608. static readonly SCALEMODE_CEILING: number;
  4609. /**
  4610. * The dirty texture flag value
  4611. */
  4612. static readonly MATERIAL_TextureDirtyFlag: number;
  4613. /**
  4614. * The dirty light flag value
  4615. */
  4616. static readonly MATERIAL_LightDirtyFlag: number;
  4617. /**
  4618. * The dirty fresnel flag value
  4619. */
  4620. static readonly MATERIAL_FresnelDirtyFlag: number;
  4621. /**
  4622. * The dirty attribute flag value
  4623. */
  4624. static readonly MATERIAL_AttributesDirtyFlag: number;
  4625. /**
  4626. * The dirty misc flag value
  4627. */
  4628. static readonly MATERIAL_MiscDirtyFlag: number;
  4629. /**
  4630. * The all dirty flag value
  4631. */
  4632. static readonly MATERIAL_AllDirtyFlag: number;
  4633. /**
  4634. * Returns the triangle fill mode
  4635. */
  4636. static readonly MATERIAL_TriangleFillMode: number;
  4637. /**
  4638. * Returns the wireframe mode
  4639. */
  4640. static readonly MATERIAL_WireFrameFillMode: number;
  4641. /**
  4642. * Returns the point fill mode
  4643. */
  4644. static readonly MATERIAL_PointFillMode: number;
  4645. /**
  4646. * Returns the point list draw mode
  4647. */
  4648. static readonly MATERIAL_PointListDrawMode: number;
  4649. /**
  4650. * Returns the line list draw mode
  4651. */
  4652. static readonly MATERIAL_LineListDrawMode: number;
  4653. /**
  4654. * Returns the line loop draw mode
  4655. */
  4656. static readonly MATERIAL_LineLoopDrawMode: number;
  4657. /**
  4658. * Returns the line strip draw mode
  4659. */
  4660. static readonly MATERIAL_LineStripDrawMode: number;
  4661. /**
  4662. * Returns the triangle strip draw mode
  4663. */
  4664. static readonly MATERIAL_TriangleStripDrawMode: number;
  4665. /**
  4666. * Returns the triangle fan draw mode
  4667. */
  4668. static readonly MATERIAL_TriangleFanDrawMode: number;
  4669. /**
  4670. * Stores the clock-wise side orientation
  4671. */
  4672. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4673. /**
  4674. * Stores the counter clock-wise side orientation
  4675. */
  4676. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4677. /**
  4678. * Nothing
  4679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4680. */
  4681. static readonly ACTION_NothingTrigger: number;
  4682. /**
  4683. * On pick
  4684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4685. */
  4686. static readonly ACTION_OnPickTrigger: number;
  4687. /**
  4688. * On left pick
  4689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4690. */
  4691. static readonly ACTION_OnLeftPickTrigger: number;
  4692. /**
  4693. * On right pick
  4694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4695. */
  4696. static readonly ACTION_OnRightPickTrigger: number;
  4697. /**
  4698. * On center pick
  4699. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4700. */
  4701. static readonly ACTION_OnCenterPickTrigger: number;
  4702. /**
  4703. * On pick down
  4704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4705. */
  4706. static readonly ACTION_OnPickDownTrigger: number;
  4707. /**
  4708. * On double pick
  4709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4710. */
  4711. static readonly ACTION_OnDoublePickTrigger: number;
  4712. /**
  4713. * On pick up
  4714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4715. */
  4716. static readonly ACTION_OnPickUpTrigger: number;
  4717. /**
  4718. * On pick out.
  4719. * This trigger will only be raised if you also declared a OnPickDown
  4720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4721. */
  4722. static readonly ACTION_OnPickOutTrigger: number;
  4723. /**
  4724. * On long press
  4725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4726. */
  4727. static readonly ACTION_OnLongPressTrigger: number;
  4728. /**
  4729. * On pointer over
  4730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4731. */
  4732. static readonly ACTION_OnPointerOverTrigger: number;
  4733. /**
  4734. * On pointer out
  4735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4736. */
  4737. static readonly ACTION_OnPointerOutTrigger: number;
  4738. /**
  4739. * On every frame
  4740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4741. */
  4742. static readonly ACTION_OnEveryFrameTrigger: number;
  4743. /**
  4744. * On intersection enter
  4745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4746. */
  4747. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4748. /**
  4749. * On intersection exit
  4750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4751. */
  4752. static readonly ACTION_OnIntersectionExitTrigger: number;
  4753. /**
  4754. * On key down
  4755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4756. */
  4757. static readonly ACTION_OnKeyDownTrigger: number;
  4758. /**
  4759. * On key up
  4760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4761. */
  4762. static readonly ACTION_OnKeyUpTrigger: number;
  4763. /**
  4764. * Billboard mode will only apply to Y axis
  4765. */
  4766. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4767. /**
  4768. * Billboard mode will apply to all axes
  4769. */
  4770. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4771. /**
  4772. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4773. */
  4774. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4775. /**
  4776. * Gets or sets base Assets URL
  4777. */
  4778. static readonly PARTICLES_BaseAssetsUrl: string;
  4779. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4780. * Test order :
  4781. * Is the bounding sphere outside the frustum ?
  4782. * If not, are the bounding box vertices outside the frustum ?
  4783. * It not, then the cullable object is in the frustum.
  4784. */
  4785. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4786. /** Culling strategy : Bounding Sphere Only.
  4787. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4788. * It's also less accurate than the standard because some not visible objects can still be selected.
  4789. * Test : is the bounding sphere outside the frustum ?
  4790. * If not, then the cullable object is in the frustum.
  4791. */
  4792. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4793. /** Culling strategy : Optimistic Inclusion.
  4794. * This in an inclusion test first, then the standard exclusion test.
  4795. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4796. * 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.
  4797. * Anyway, it's as accurate as the standard strategy.
  4798. * Test :
  4799. * Is the cullable object bounding sphere center in the frustum ?
  4800. * If not, apply the default culling strategy.
  4801. */
  4802. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4803. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4804. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4805. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4806. * 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.
  4807. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4808. * Test :
  4809. * Is the cullable object bounding sphere center in the frustum ?
  4810. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4811. */
  4812. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4813. /**
  4814. * No logging while loading
  4815. */
  4816. static readonly SCENELOADER_NO_LOGGING: number;
  4817. /**
  4818. * Minimal logging while loading
  4819. */
  4820. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4821. /**
  4822. * Summary logging while loading
  4823. */
  4824. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4825. /**
  4826. * Detailled logging while loading
  4827. */
  4828. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4829. }
  4830. }
  4831. declare module BABYLON {
  4832. /**
  4833. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4834. * Babylon.js
  4835. */
  4836. export class DomManagement {
  4837. /**
  4838. * Checks if the window object exists
  4839. * @returns true if the window object exists
  4840. */
  4841. static IsWindowObjectExist(): boolean;
  4842. /**
  4843. * Extracts text content from a DOM element hierarchy
  4844. * @param element defines the root element
  4845. * @returns a string
  4846. */
  4847. static GetDOMTextContent(element: HTMLElement): string;
  4848. }
  4849. }
  4850. declare module BABYLON {
  4851. /**
  4852. * Logger used througouht the application to allow configuration of
  4853. * the log level required for the messages.
  4854. */
  4855. export class Logger {
  4856. /**
  4857. * No log
  4858. */
  4859. static readonly NoneLogLevel: number;
  4860. /**
  4861. * Only message logs
  4862. */
  4863. static readonly MessageLogLevel: number;
  4864. /**
  4865. * Only warning logs
  4866. */
  4867. static readonly WarningLogLevel: number;
  4868. /**
  4869. * Only error logs
  4870. */
  4871. static readonly ErrorLogLevel: number;
  4872. /**
  4873. * All logs
  4874. */
  4875. static readonly AllLogLevel: number;
  4876. private static _LogCache;
  4877. /**
  4878. * Gets a value indicating the number of loading errors
  4879. * @ignorenaming
  4880. */
  4881. static errorsCount: number;
  4882. /**
  4883. * Callback called when a new log is added
  4884. */
  4885. static OnNewCacheEntry: (entry: string) => void;
  4886. private static _AddLogEntry;
  4887. private static _FormatMessage;
  4888. private static _LogDisabled;
  4889. private static _LogEnabled;
  4890. private static _WarnDisabled;
  4891. private static _WarnEnabled;
  4892. private static _ErrorDisabled;
  4893. private static _ErrorEnabled;
  4894. /**
  4895. * Log a message to the console
  4896. */
  4897. static Log: (message: string) => void;
  4898. /**
  4899. * Write a warning message to the console
  4900. */
  4901. static Warn: (message: string) => void;
  4902. /**
  4903. * Write an error message to the console
  4904. */
  4905. static Error: (message: string) => void;
  4906. /**
  4907. * Gets current log cache (list of logs)
  4908. */
  4909. static readonly LogCache: string;
  4910. /**
  4911. * Clears the log cache
  4912. */
  4913. static ClearLogCache(): void;
  4914. /**
  4915. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4916. */
  4917. static LogLevels: number;
  4918. }
  4919. }
  4920. declare module BABYLON {
  4921. /** @hidden */
  4922. export class _TypeStore {
  4923. /** @hidden */
  4924. static RegisteredTypes: {
  4925. [key: string]: Object;
  4926. };
  4927. /** @hidden */
  4928. static GetClass(fqdn: string): any;
  4929. }
  4930. }
  4931. declare module BABYLON {
  4932. /**
  4933. * Class containing a set of static utilities functions for deep copy.
  4934. */
  4935. export class DeepCopier {
  4936. /**
  4937. * Tries to copy an object by duplicating every property
  4938. * @param source defines the source object
  4939. * @param destination defines the target object
  4940. * @param doNotCopyList defines a list of properties to avoid
  4941. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4942. */
  4943. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4944. }
  4945. }
  4946. declare module BABYLON {
  4947. /**
  4948. * Class containing a set of static utilities functions for precision date
  4949. */
  4950. export class PrecisionDate {
  4951. /**
  4952. * Gets either window.performance.now() if supported or Date.now() else
  4953. */
  4954. static readonly Now: number;
  4955. }
  4956. }
  4957. declare module BABYLON {
  4958. /**
  4959. * Class used to evalaute queries containing `and` and `or` operators
  4960. */
  4961. export class AndOrNotEvaluator {
  4962. /**
  4963. * Evaluate a query
  4964. * @param query defines the query to evaluate
  4965. * @param evaluateCallback defines the callback used to filter result
  4966. * @returns true if the query matches
  4967. */
  4968. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4969. private static _HandleParenthesisContent;
  4970. private static _SimplifyNegation;
  4971. }
  4972. }
  4973. declare module BABYLON {
  4974. /**
  4975. * Class used to store custom tags
  4976. */
  4977. export class Tags {
  4978. /**
  4979. * Adds support for tags on the given object
  4980. * @param obj defines the object to use
  4981. */
  4982. static EnableFor(obj: any): void;
  4983. /**
  4984. * Removes tags support
  4985. * @param obj defines the object to use
  4986. */
  4987. static DisableFor(obj: any): void;
  4988. /**
  4989. * Gets a boolean indicating if the given object has tags
  4990. * @param obj defines the object to use
  4991. * @returns a boolean
  4992. */
  4993. static HasTags(obj: any): boolean;
  4994. /**
  4995. * Gets the tags available on a given object
  4996. * @param obj defines the object to use
  4997. * @param asString defines if the tags must be returned as a string instead of an array of strings
  4998. * @returns the tags
  4999. */
  5000. static GetTags(obj: any, asString?: boolean): any;
  5001. /**
  5002. * Adds tags to an object
  5003. * @param obj defines the object to use
  5004. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5005. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5006. */
  5007. static AddTagsTo(obj: any, tagsString: string): void;
  5008. /**
  5009. * @hidden
  5010. */
  5011. static _AddTagTo(obj: any, tag: string): void;
  5012. /**
  5013. * Removes specific tags from a specific object
  5014. * @param obj defines the object to use
  5015. * @param tagsString defines the tags to remove
  5016. */
  5017. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5018. /**
  5019. * @hidden
  5020. */
  5021. static _RemoveTagFrom(obj: any, tag: string): void;
  5022. /**
  5023. * Defines if tags hosted on an object match a given query
  5024. * @param obj defines the object to use
  5025. * @param tagsQuery defines the tag query
  5026. * @returns a boolean
  5027. */
  5028. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5029. }
  5030. }
  5031. declare module BABYLON {
  5032. /**
  5033. * Manages the defines for the Material
  5034. */
  5035. export class MaterialDefines {
  5036. private _keys;
  5037. private _isDirty;
  5038. /** @hidden */
  5039. _renderId: number;
  5040. /** @hidden */
  5041. _areLightsDirty: boolean;
  5042. /** @hidden */
  5043. _areAttributesDirty: boolean;
  5044. /** @hidden */
  5045. _areTexturesDirty: boolean;
  5046. /** @hidden */
  5047. _areFresnelDirty: boolean;
  5048. /** @hidden */
  5049. _areMiscDirty: boolean;
  5050. /** @hidden */
  5051. _areImageProcessingDirty: boolean;
  5052. /** @hidden */
  5053. _normals: boolean;
  5054. /** @hidden */
  5055. _uvs: boolean;
  5056. /** @hidden */
  5057. _needNormals: boolean;
  5058. /** @hidden */
  5059. _needUVs: boolean;
  5060. /**
  5061. * Specifies if the material needs to be re-calculated
  5062. */
  5063. readonly isDirty: boolean;
  5064. /**
  5065. * Marks the material to indicate that it has been re-calculated
  5066. */
  5067. markAsProcessed(): void;
  5068. /**
  5069. * Marks the material to indicate that it needs to be re-calculated
  5070. */
  5071. markAsUnprocessed(): void;
  5072. /**
  5073. * Marks the material to indicate all of its defines need to be re-calculated
  5074. */
  5075. markAllAsDirty(): void;
  5076. /**
  5077. * Marks the material to indicate that image processing needs to be re-calculated
  5078. */
  5079. markAsImageProcessingDirty(): void;
  5080. /**
  5081. * Marks the material to indicate the lights need to be re-calculated
  5082. */
  5083. markAsLightDirty(): void;
  5084. /**
  5085. * Marks the attribute state as changed
  5086. */
  5087. markAsAttributesDirty(): void;
  5088. /**
  5089. * Marks the texture state as changed
  5090. */
  5091. markAsTexturesDirty(): void;
  5092. /**
  5093. * Marks the fresnel state as changed
  5094. */
  5095. markAsFresnelDirty(): void;
  5096. /**
  5097. * Marks the misc state as changed
  5098. */
  5099. markAsMiscDirty(): void;
  5100. /**
  5101. * Rebuilds the material defines
  5102. */
  5103. rebuild(): void;
  5104. /**
  5105. * Specifies if two material defines are equal
  5106. * @param other - A material define instance to compare to
  5107. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5108. */
  5109. isEqual(other: MaterialDefines): boolean;
  5110. /**
  5111. * Clones this instance's defines to another instance
  5112. * @param other - material defines to clone values to
  5113. */
  5114. cloneTo(other: MaterialDefines): void;
  5115. /**
  5116. * Resets the material define values
  5117. */
  5118. reset(): void;
  5119. /**
  5120. * Converts the material define values to a string
  5121. * @returns - String of material define information
  5122. */
  5123. toString(): string;
  5124. }
  5125. }
  5126. declare module BABYLON {
  5127. /**
  5128. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5129. */
  5130. export class PerformanceMonitor {
  5131. private _enabled;
  5132. private _rollingFrameTime;
  5133. private _lastFrameTimeMs;
  5134. /**
  5135. * constructor
  5136. * @param frameSampleSize The number of samples required to saturate the sliding window
  5137. */
  5138. constructor(frameSampleSize?: number);
  5139. /**
  5140. * Samples current frame
  5141. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5142. */
  5143. sampleFrame(timeMs?: number): void;
  5144. /**
  5145. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5146. */
  5147. readonly averageFrameTime: number;
  5148. /**
  5149. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5150. */
  5151. readonly averageFrameTimeVariance: number;
  5152. /**
  5153. * Returns the frame time of the most recent frame
  5154. */
  5155. readonly instantaneousFrameTime: number;
  5156. /**
  5157. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5158. */
  5159. readonly averageFPS: number;
  5160. /**
  5161. * Returns the average framerate in frames per second using the most recent frame time
  5162. */
  5163. readonly instantaneousFPS: number;
  5164. /**
  5165. * Returns true if enough samples have been taken to completely fill the sliding window
  5166. */
  5167. readonly isSaturated: boolean;
  5168. /**
  5169. * Enables contributions to the sliding window sample set
  5170. */
  5171. enable(): void;
  5172. /**
  5173. * Disables contributions to the sliding window sample set
  5174. * Samples will not be interpolated over the disabled period
  5175. */
  5176. disable(): void;
  5177. /**
  5178. * Returns true if sampling is enabled
  5179. */
  5180. readonly isEnabled: boolean;
  5181. /**
  5182. * Resets performance monitor
  5183. */
  5184. reset(): void;
  5185. }
  5186. /**
  5187. * RollingAverage
  5188. *
  5189. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5190. */
  5191. export class RollingAverage {
  5192. /**
  5193. * Current average
  5194. */
  5195. average: number;
  5196. /**
  5197. * Current variance
  5198. */
  5199. variance: number;
  5200. protected _samples: Array<number>;
  5201. protected _sampleCount: number;
  5202. protected _pos: number;
  5203. protected _m2: number;
  5204. /**
  5205. * constructor
  5206. * @param length The number of samples required to saturate the sliding window
  5207. */
  5208. constructor(length: number);
  5209. /**
  5210. * Adds a sample to the sample set
  5211. * @param v The sample value
  5212. */
  5213. add(v: number): void;
  5214. /**
  5215. * Returns previously added values or null if outside of history or outside the sliding window domain
  5216. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5217. * @return Value previously recorded with add() or null if outside of range
  5218. */
  5219. history(i: number): number;
  5220. /**
  5221. * Returns true if enough samples have been taken to completely fill the sliding window
  5222. * @return true if sample-set saturated
  5223. */
  5224. isSaturated(): boolean;
  5225. /**
  5226. * Resets the rolling average (equivalent to 0 samples taken so far)
  5227. */
  5228. reset(): void;
  5229. /**
  5230. * Wraps a value around the sample range boundaries
  5231. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5232. * @return Wrapped position in sample range
  5233. */
  5234. protected _wrapPosition(i: number): number;
  5235. }
  5236. }
  5237. declare module BABYLON {
  5238. /**
  5239. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5240. * The underlying implementation relies on an associative array to ensure the best performances.
  5241. * The value can be anything including 'null' but except 'undefined'
  5242. */
  5243. export class StringDictionary<T> {
  5244. /**
  5245. * This will clear this dictionary and copy the content from the 'source' one.
  5246. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5247. * @param source the dictionary to take the content from and copy to this dictionary
  5248. */
  5249. copyFrom(source: StringDictionary<T>): void;
  5250. /**
  5251. * Get a value based from its key
  5252. * @param key the given key to get the matching value from
  5253. * @return the value if found, otherwise undefined is returned
  5254. */
  5255. get(key: string): T | undefined;
  5256. /**
  5257. * Get a value from its key or add it if it doesn't exist.
  5258. * This method will ensure you that a given key/data will be present in the dictionary.
  5259. * @param key the given key to get the matching value from
  5260. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5261. * The factory will only be invoked if there's no data for the given key.
  5262. * @return the value corresponding to the key.
  5263. */
  5264. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5265. /**
  5266. * Get a value from its key if present in the dictionary otherwise add it
  5267. * @param key the key to get the value from
  5268. * @param val if there's no such key/value pair in the dictionary add it with this value
  5269. * @return the value corresponding to the key
  5270. */
  5271. getOrAdd(key: string, val: T): T;
  5272. /**
  5273. * Check if there's a given key in the dictionary
  5274. * @param key the key to check for
  5275. * @return true if the key is present, false otherwise
  5276. */
  5277. contains(key: string): boolean;
  5278. /**
  5279. * Add a new key and its corresponding value
  5280. * @param key the key to add
  5281. * @param value the value corresponding to the key
  5282. * @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
  5283. */
  5284. add(key: string, value: T): boolean;
  5285. /**
  5286. * Update a specific value associated to a key
  5287. * @param key defines the key to use
  5288. * @param value defines the value to store
  5289. * @returns true if the value was updated (or false if the key was not found)
  5290. */
  5291. set(key: string, value: T): boolean;
  5292. /**
  5293. * Get the element of the given key and remove it from the dictionary
  5294. * @param key defines the key to search
  5295. * @returns the value associated with the key or null if not found
  5296. */
  5297. getAndRemove(key: string): Nullable<T>;
  5298. /**
  5299. * Remove a key/value from the dictionary.
  5300. * @param key the key to remove
  5301. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5302. */
  5303. remove(key: string): boolean;
  5304. /**
  5305. * Clear the whole content of the dictionary
  5306. */
  5307. clear(): void;
  5308. /**
  5309. * Gets the current count
  5310. */
  5311. readonly count: number;
  5312. /**
  5313. * Execute a callback on each key/val of the dictionary.
  5314. * Note that you can remove any element in this dictionary in the callback implementation
  5315. * @param callback the callback to execute on a given key/value pair
  5316. */
  5317. forEach(callback: (key: string, val: T) => void): void;
  5318. /**
  5319. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5320. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5321. * Note that you can remove any element in this dictionary in the callback implementation
  5322. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5323. * @returns the first item
  5324. */
  5325. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5326. private _count;
  5327. private _data;
  5328. }
  5329. }
  5330. declare module BABYLON {
  5331. /**
  5332. * Helper class that provides a small promise polyfill
  5333. */
  5334. export class PromisePolyfill {
  5335. /**
  5336. * Static function used to check if the polyfill is required
  5337. * If this is the case then the function will inject the polyfill to window.Promise
  5338. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5339. */
  5340. static Apply(force?: boolean): void;
  5341. }
  5342. }
  5343. declare module BABYLON {
  5344. /**
  5345. * Class used to store data that will be store in GPU memory
  5346. */
  5347. export class Buffer {
  5348. private _engine;
  5349. private _buffer;
  5350. /** @hidden */
  5351. _data: Nullable<DataArray>;
  5352. private _updatable;
  5353. private _instanced;
  5354. /**
  5355. * Gets the byte stride.
  5356. */
  5357. readonly byteStride: number;
  5358. /**
  5359. * Constructor
  5360. * @param engine the engine
  5361. * @param data the data to use for this buffer
  5362. * @param updatable whether the data is updatable
  5363. * @param stride the stride (optional)
  5364. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5365. * @param instanced whether the buffer is instanced (optional)
  5366. * @param useBytes set to true if the stride in in bytes (optional)
  5367. */
  5368. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5369. /**
  5370. * Create a new VertexBuffer based on the current buffer
  5371. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5372. * @param offset defines offset in the buffer (0 by default)
  5373. * @param size defines the size in floats of attributes (position is 3 for instance)
  5374. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5375. * @param instanced defines if the vertex buffer contains indexed data
  5376. * @param useBytes defines if the offset and stride are in bytes
  5377. * @returns the new vertex buffer
  5378. */
  5379. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5380. /**
  5381. * Gets a boolean indicating if the Buffer is updatable?
  5382. * @returns true if the buffer is updatable
  5383. */
  5384. isUpdatable(): boolean;
  5385. /**
  5386. * Gets current buffer's data
  5387. * @returns a DataArray or null
  5388. */
  5389. getData(): Nullable<DataArray>;
  5390. /**
  5391. * Gets underlying native buffer
  5392. * @returns underlying native buffer
  5393. */
  5394. getBuffer(): Nullable<WebGLBuffer>;
  5395. /**
  5396. * Gets the stride in float32 units (i.e. byte stride / 4).
  5397. * May not be an integer if the byte stride is not divisible by 4.
  5398. * DEPRECATED. Use byteStride instead.
  5399. * @returns the stride in float32 units
  5400. */
  5401. getStrideSize(): number;
  5402. /**
  5403. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5404. * @param data defines the data to store
  5405. */
  5406. create(data?: Nullable<DataArray>): void;
  5407. /** @hidden */
  5408. _rebuild(): void;
  5409. /**
  5410. * Update current buffer data
  5411. * @param data defines the data to store
  5412. */
  5413. update(data: DataArray): void;
  5414. /**
  5415. * Updates the data directly.
  5416. * @param data the new data
  5417. * @param offset the new offset
  5418. * @param vertexCount the vertex count (optional)
  5419. * @param useBytes set to true if the offset is in bytes
  5420. */
  5421. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5422. /**
  5423. * Release all resources
  5424. */
  5425. dispose(): void;
  5426. }
  5427. /**
  5428. * Specialized buffer used to store vertex data
  5429. */
  5430. export class VertexBuffer {
  5431. /** @hidden */
  5432. _buffer: Buffer;
  5433. private _kind;
  5434. private _size;
  5435. private _ownsBuffer;
  5436. private _instanced;
  5437. private _instanceDivisor;
  5438. /**
  5439. * The byte type.
  5440. */
  5441. static readonly BYTE: number;
  5442. /**
  5443. * The unsigned byte type.
  5444. */
  5445. static readonly UNSIGNED_BYTE: number;
  5446. /**
  5447. * The short type.
  5448. */
  5449. static readonly SHORT: number;
  5450. /**
  5451. * The unsigned short type.
  5452. */
  5453. static readonly UNSIGNED_SHORT: number;
  5454. /**
  5455. * The integer type.
  5456. */
  5457. static readonly INT: number;
  5458. /**
  5459. * The unsigned integer type.
  5460. */
  5461. static readonly UNSIGNED_INT: number;
  5462. /**
  5463. * The float type.
  5464. */
  5465. static readonly FLOAT: number;
  5466. /**
  5467. * Gets or sets the instance divisor when in instanced mode
  5468. */
  5469. instanceDivisor: number;
  5470. /**
  5471. * Gets the byte stride.
  5472. */
  5473. readonly byteStride: number;
  5474. /**
  5475. * Gets the byte offset.
  5476. */
  5477. readonly byteOffset: number;
  5478. /**
  5479. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5480. */
  5481. readonly normalized: boolean;
  5482. /**
  5483. * Gets the data type of each component in the array.
  5484. */
  5485. readonly type: number;
  5486. /**
  5487. * Constructor
  5488. * @param engine the engine
  5489. * @param data the data to use for this vertex buffer
  5490. * @param kind the vertex buffer kind
  5491. * @param updatable whether the data is updatable
  5492. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5493. * @param stride the stride (optional)
  5494. * @param instanced whether the buffer is instanced (optional)
  5495. * @param offset the offset of the data (optional)
  5496. * @param size the number of components (optional)
  5497. * @param type the type of the component (optional)
  5498. * @param normalized whether the data contains normalized data (optional)
  5499. * @param useBytes set to true if stride and offset are in bytes (optional)
  5500. */
  5501. 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);
  5502. /** @hidden */
  5503. _rebuild(): void;
  5504. /**
  5505. * Returns the kind of the VertexBuffer (string)
  5506. * @returns a string
  5507. */
  5508. getKind(): string;
  5509. /**
  5510. * Gets a boolean indicating if the VertexBuffer is updatable?
  5511. * @returns true if the buffer is updatable
  5512. */
  5513. isUpdatable(): boolean;
  5514. /**
  5515. * Gets current buffer's data
  5516. * @returns a DataArray or null
  5517. */
  5518. getData(): Nullable<DataArray>;
  5519. /**
  5520. * Gets underlying native buffer
  5521. * @returns underlying native buffer
  5522. */
  5523. getBuffer(): Nullable<WebGLBuffer>;
  5524. /**
  5525. * Gets the stride in float32 units (i.e. byte stride / 4).
  5526. * May not be an integer if the byte stride is not divisible by 4.
  5527. * DEPRECATED. Use byteStride instead.
  5528. * @returns the stride in float32 units
  5529. */
  5530. getStrideSize(): number;
  5531. /**
  5532. * Returns the offset as a multiple of the type byte length.
  5533. * DEPRECATED. Use byteOffset instead.
  5534. * @returns the offset in bytes
  5535. */
  5536. getOffset(): number;
  5537. /**
  5538. * Returns the number of components per vertex attribute (integer)
  5539. * @returns the size in float
  5540. */
  5541. getSize(): number;
  5542. /**
  5543. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5544. * @returns true if this buffer is instanced
  5545. */
  5546. getIsInstanced(): boolean;
  5547. /**
  5548. * Returns the instancing divisor, zero for non-instanced (integer).
  5549. * @returns a number
  5550. */
  5551. getInstanceDivisor(): number;
  5552. /**
  5553. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5554. * @param data defines the data to store
  5555. */
  5556. create(data?: DataArray): void;
  5557. /**
  5558. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5559. * This function will create a new buffer if the current one is not updatable
  5560. * @param data defines the data to store
  5561. */
  5562. update(data: DataArray): void;
  5563. /**
  5564. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5565. * Returns the directly updated WebGLBuffer.
  5566. * @param data the new data
  5567. * @param offset the new offset
  5568. * @param useBytes set to true if the offset is in bytes
  5569. */
  5570. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5571. /**
  5572. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5573. */
  5574. dispose(): void;
  5575. /**
  5576. * Enumerates each value of this vertex buffer as numbers.
  5577. * @param count the number of values to enumerate
  5578. * @param callback the callback function called for each value
  5579. */
  5580. forEach(count: number, callback: (value: number, index: number) => void): void;
  5581. /**
  5582. * Positions
  5583. */
  5584. static readonly PositionKind: string;
  5585. /**
  5586. * Normals
  5587. */
  5588. static readonly NormalKind: string;
  5589. /**
  5590. * Tangents
  5591. */
  5592. static readonly TangentKind: string;
  5593. /**
  5594. * Texture coordinates
  5595. */
  5596. static readonly UVKind: string;
  5597. /**
  5598. * Texture coordinates 2
  5599. */
  5600. static readonly UV2Kind: string;
  5601. /**
  5602. * Texture coordinates 3
  5603. */
  5604. static readonly UV3Kind: string;
  5605. /**
  5606. * Texture coordinates 4
  5607. */
  5608. static readonly UV4Kind: string;
  5609. /**
  5610. * Texture coordinates 5
  5611. */
  5612. static readonly UV5Kind: string;
  5613. /**
  5614. * Texture coordinates 6
  5615. */
  5616. static readonly UV6Kind: string;
  5617. /**
  5618. * Colors
  5619. */
  5620. static readonly ColorKind: string;
  5621. /**
  5622. * Matrix indices (for bones)
  5623. */
  5624. static readonly MatricesIndicesKind: string;
  5625. /**
  5626. * Matrix weights (for bones)
  5627. */
  5628. static readonly MatricesWeightsKind: string;
  5629. /**
  5630. * Additional matrix indices (for bones)
  5631. */
  5632. static readonly MatricesIndicesExtraKind: string;
  5633. /**
  5634. * Additional matrix weights (for bones)
  5635. */
  5636. static readonly MatricesWeightsExtraKind: string;
  5637. /**
  5638. * Deduces the stride given a kind.
  5639. * @param kind The kind string to deduce
  5640. * @returns The deduced stride
  5641. */
  5642. static DeduceStride(kind: string): number;
  5643. /**
  5644. * Gets the byte length of the given type.
  5645. * @param type the type
  5646. * @returns the number of bytes
  5647. */
  5648. static GetTypeByteLength(type: number): number;
  5649. /**
  5650. * Enumerates each value of the given parameters as numbers.
  5651. * @param data the data to enumerate
  5652. * @param byteOffset the byte offset of the data
  5653. * @param byteStride the byte stride of the data
  5654. * @param componentCount the number of components per element
  5655. * @param componentType the type of the component
  5656. * @param count the total number of components
  5657. * @param normalized whether the data is normalized
  5658. * @param callback the callback function called for each value
  5659. */
  5660. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5661. private static _GetFloatValue;
  5662. }
  5663. }
  5664. declare module BABYLON {
  5665. /**
  5666. * Class representing spherical polynomial coefficients to the 3rd degree
  5667. */
  5668. export class SphericalPolynomial {
  5669. /**
  5670. * The x coefficients of the spherical polynomial
  5671. */
  5672. x: Vector3;
  5673. /**
  5674. * The y coefficients of the spherical polynomial
  5675. */
  5676. y: Vector3;
  5677. /**
  5678. * The z coefficients of the spherical polynomial
  5679. */
  5680. z: Vector3;
  5681. /**
  5682. * The xx coefficients of the spherical polynomial
  5683. */
  5684. xx: Vector3;
  5685. /**
  5686. * The yy coefficients of the spherical polynomial
  5687. */
  5688. yy: Vector3;
  5689. /**
  5690. * The zz coefficients of the spherical polynomial
  5691. */
  5692. zz: Vector3;
  5693. /**
  5694. * The xy coefficients of the spherical polynomial
  5695. */
  5696. xy: Vector3;
  5697. /**
  5698. * The yz coefficients of the spherical polynomial
  5699. */
  5700. yz: Vector3;
  5701. /**
  5702. * The zx coefficients of the spherical polynomial
  5703. */
  5704. zx: Vector3;
  5705. /**
  5706. * Adds an ambient color to the spherical polynomial
  5707. * @param color the color to add
  5708. */
  5709. addAmbient(color: Color3): void;
  5710. /**
  5711. * Scales the spherical polynomial by the given amount
  5712. * @param scale the amount to scale
  5713. */
  5714. scale(scale: number): void;
  5715. /**
  5716. * Gets the spherical polynomial from harmonics
  5717. * @param harmonics the spherical harmonics
  5718. * @returns the spherical polynomial
  5719. */
  5720. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5721. /**
  5722. * Constructs a spherical polynomial from an array.
  5723. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5724. * @returns the spherical polynomial
  5725. */
  5726. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5727. }
  5728. /**
  5729. * Class representing spherical harmonics coefficients to the 3rd degree
  5730. */
  5731. export class SphericalHarmonics {
  5732. /**
  5733. * The l0,0 coefficients of the spherical harmonics
  5734. */
  5735. l00: Vector3;
  5736. /**
  5737. * The l1,-1 coefficients of the spherical harmonics
  5738. */
  5739. l1_1: Vector3;
  5740. /**
  5741. * The l1,0 coefficients of the spherical harmonics
  5742. */
  5743. l10: Vector3;
  5744. /**
  5745. * The l1,1 coefficients of the spherical harmonics
  5746. */
  5747. l11: Vector3;
  5748. /**
  5749. * The l2,-2 coefficients of the spherical harmonics
  5750. */
  5751. l2_2: Vector3;
  5752. /**
  5753. * The l2,-1 coefficients of the spherical harmonics
  5754. */
  5755. l2_1: Vector3;
  5756. /**
  5757. * The l2,0 coefficients of the spherical harmonics
  5758. */
  5759. l20: Vector3;
  5760. /**
  5761. * The l2,1 coefficients of the spherical harmonics
  5762. */
  5763. l21: Vector3;
  5764. /**
  5765. * The l2,2 coefficients of the spherical harmonics
  5766. */
  5767. lL22: Vector3;
  5768. /**
  5769. * Adds a light to the spherical harmonics
  5770. * @param direction the direction of the light
  5771. * @param color the color of the light
  5772. * @param deltaSolidAngle the delta solid angle of the light
  5773. */
  5774. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5775. /**
  5776. * Scales the spherical harmonics by the given amount
  5777. * @param scale the amount to scale
  5778. */
  5779. scale(scale: number): void;
  5780. /**
  5781. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5782. *
  5783. * ```
  5784. * E_lm = A_l * L_lm
  5785. * ```
  5786. *
  5787. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5788. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5789. * the scaling factors are given in equation 9.
  5790. */
  5791. convertIncidentRadianceToIrradiance(): void;
  5792. /**
  5793. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5794. *
  5795. * ```
  5796. * L = (1/pi) * E * rho
  5797. * ```
  5798. *
  5799. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5800. */
  5801. convertIrradianceToLambertianRadiance(): void;
  5802. /**
  5803. * Gets the spherical harmonics from polynomial
  5804. * @param polynomial the spherical polynomial
  5805. * @returns the spherical harmonics
  5806. */
  5807. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5808. /**
  5809. * Constructs a spherical harmonics from an array.
  5810. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5811. * @returns the spherical harmonics
  5812. */
  5813. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5814. }
  5815. }
  5816. declare module BABYLON {
  5817. /**
  5818. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5819. */
  5820. export interface CubeMapInfo {
  5821. /**
  5822. * The pixel array for the front face.
  5823. * This is stored in format, left to right, up to down format.
  5824. */
  5825. front: Nullable<ArrayBufferView>;
  5826. /**
  5827. * The pixel array for the back face.
  5828. * This is stored in format, left to right, up to down format.
  5829. */
  5830. back: Nullable<ArrayBufferView>;
  5831. /**
  5832. * The pixel array for the left face.
  5833. * This is stored in format, left to right, up to down format.
  5834. */
  5835. left: Nullable<ArrayBufferView>;
  5836. /**
  5837. * The pixel array for the right face.
  5838. * This is stored in format, left to right, up to down format.
  5839. */
  5840. right: Nullable<ArrayBufferView>;
  5841. /**
  5842. * The pixel array for the up face.
  5843. * This is stored in format, left to right, up to down format.
  5844. */
  5845. up: Nullable<ArrayBufferView>;
  5846. /**
  5847. * The pixel array for the down face.
  5848. * This is stored in format, left to right, up to down format.
  5849. */
  5850. down: Nullable<ArrayBufferView>;
  5851. /**
  5852. * The size of the cubemap stored.
  5853. *
  5854. * Each faces will be size * size pixels.
  5855. */
  5856. size: number;
  5857. /**
  5858. * The format of the texture.
  5859. *
  5860. * RGBA, RGB.
  5861. */
  5862. format: number;
  5863. /**
  5864. * The type of the texture data.
  5865. *
  5866. * UNSIGNED_INT, FLOAT.
  5867. */
  5868. type: number;
  5869. /**
  5870. * Specifies whether the texture is in gamma space.
  5871. */
  5872. gammaSpace: boolean;
  5873. }
  5874. /**
  5875. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5876. */
  5877. export class PanoramaToCubeMapTools {
  5878. private static FACE_FRONT;
  5879. private static FACE_BACK;
  5880. private static FACE_RIGHT;
  5881. private static FACE_LEFT;
  5882. private static FACE_DOWN;
  5883. private static FACE_UP;
  5884. /**
  5885. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5886. *
  5887. * @param float32Array The source data.
  5888. * @param inputWidth The width of the input panorama.
  5889. * @param inputHeight The height of the input panorama.
  5890. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5891. * @return The cubemap data
  5892. */
  5893. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5894. private static CreateCubemapTexture;
  5895. private static CalcProjectionSpherical;
  5896. }
  5897. }
  5898. declare module BABYLON {
  5899. /**
  5900. * Helper class dealing with the extraction of spherical polynomial dataArray
  5901. * from a cube map.
  5902. */
  5903. export class CubeMapToSphericalPolynomialTools {
  5904. private static FileFaces;
  5905. /**
  5906. * Converts a texture to the according Spherical Polynomial data.
  5907. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5908. *
  5909. * @param texture The texture to extract the information from.
  5910. * @return The Spherical Polynomial data.
  5911. */
  5912. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5913. /**
  5914. * Converts a cubemap to the according Spherical Polynomial data.
  5915. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5916. *
  5917. * @param cubeInfo The Cube map to extract the information from.
  5918. * @return The Spherical Polynomial data.
  5919. */
  5920. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5921. }
  5922. }
  5923. declare module BABYLON {
  5924. /**
  5925. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5926. * during the life time of the application.
  5927. */
  5928. export class EngineStore {
  5929. /** Gets the list of created engines */
  5930. static Instances: Engine[];
  5931. /**
  5932. * Gets the latest created engine
  5933. */
  5934. static readonly LastCreatedEngine: Nullable<Engine>;
  5935. /**
  5936. * Gets the latest created scene
  5937. */
  5938. static readonly LastCreatedScene: Nullable<Scene>;
  5939. }
  5940. }
  5941. declare module BABYLON {
  5942. /**
  5943. * Define options used to create a render target texture
  5944. */
  5945. export class RenderTargetCreationOptions {
  5946. /**
  5947. * Specifies is mipmaps must be generated
  5948. */
  5949. generateMipMaps?: boolean;
  5950. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5951. generateDepthBuffer?: boolean;
  5952. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5953. generateStencilBuffer?: boolean;
  5954. /** Defines texture type (int by default) */
  5955. type?: number;
  5956. /** Defines sampling mode (trilinear by default) */
  5957. samplingMode?: number;
  5958. /** Defines format (RGBA by default) */
  5959. format?: number;
  5960. }
  5961. }
  5962. declare module BABYLON {
  5963. /**
  5964. * @hidden
  5965. **/
  5966. export class _AlphaState {
  5967. private _isAlphaBlendDirty;
  5968. private _isBlendFunctionParametersDirty;
  5969. private _isBlendEquationParametersDirty;
  5970. private _isBlendConstantsDirty;
  5971. private _alphaBlend;
  5972. private _blendFunctionParameters;
  5973. private _blendEquationParameters;
  5974. private _blendConstants;
  5975. /**
  5976. * Initializes the state.
  5977. */
  5978. constructor();
  5979. readonly isDirty: boolean;
  5980. alphaBlend: boolean;
  5981. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5982. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5983. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5984. reset(): void;
  5985. apply(gl: WebGLRenderingContext): void;
  5986. }
  5987. }
  5988. declare module BABYLON {
  5989. /**
  5990. * @hidden
  5991. **/
  5992. export class _DepthCullingState {
  5993. private _isDepthTestDirty;
  5994. private _isDepthMaskDirty;
  5995. private _isDepthFuncDirty;
  5996. private _isCullFaceDirty;
  5997. private _isCullDirty;
  5998. private _isZOffsetDirty;
  5999. private _isFrontFaceDirty;
  6000. private _depthTest;
  6001. private _depthMask;
  6002. private _depthFunc;
  6003. private _cull;
  6004. private _cullFace;
  6005. private _zOffset;
  6006. private _frontFace;
  6007. /**
  6008. * Initializes the state.
  6009. */
  6010. constructor();
  6011. readonly isDirty: boolean;
  6012. zOffset: number;
  6013. cullFace: Nullable<number>;
  6014. cull: Nullable<boolean>;
  6015. depthFunc: Nullable<number>;
  6016. depthMask: boolean;
  6017. depthTest: boolean;
  6018. frontFace: Nullable<number>;
  6019. reset(): void;
  6020. apply(gl: WebGLRenderingContext): void;
  6021. }
  6022. }
  6023. declare module BABYLON {
  6024. /**
  6025. * @hidden
  6026. **/
  6027. export class _StencilState {
  6028. /** 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 */
  6029. static readonly ALWAYS: number;
  6030. /** Passed to stencilOperation to specify that stencil value must be kept */
  6031. static readonly KEEP: number;
  6032. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6033. static readonly REPLACE: number;
  6034. private _isStencilTestDirty;
  6035. private _isStencilMaskDirty;
  6036. private _isStencilFuncDirty;
  6037. private _isStencilOpDirty;
  6038. private _stencilTest;
  6039. private _stencilMask;
  6040. private _stencilFunc;
  6041. private _stencilFuncRef;
  6042. private _stencilFuncMask;
  6043. private _stencilOpStencilFail;
  6044. private _stencilOpDepthFail;
  6045. private _stencilOpStencilDepthPass;
  6046. readonly isDirty: boolean;
  6047. stencilFunc: number;
  6048. stencilFuncRef: number;
  6049. stencilFuncMask: number;
  6050. stencilOpStencilFail: number;
  6051. stencilOpDepthFail: number;
  6052. stencilOpStencilDepthPass: number;
  6053. stencilMask: number;
  6054. stencilTest: boolean;
  6055. constructor();
  6056. reset(): void;
  6057. apply(gl: WebGLRenderingContext): void;
  6058. }
  6059. }
  6060. declare module BABYLON {
  6061. /**
  6062. * @hidden
  6063. **/
  6064. export class _TimeToken {
  6065. _startTimeQuery: Nullable<WebGLQuery>;
  6066. _endTimeQuery: Nullable<WebGLQuery>;
  6067. _timeElapsedQuery: Nullable<WebGLQuery>;
  6068. _timeElapsedQueryEnded: boolean;
  6069. }
  6070. }
  6071. declare module BABYLON {
  6072. /**
  6073. * Internal interface used to track InternalTexture already bound to the GL context
  6074. */
  6075. export interface IInternalTextureTracker {
  6076. /**
  6077. * Gets or set the previous tracker in the list
  6078. */
  6079. previous: Nullable<IInternalTextureTracker>;
  6080. /**
  6081. * Gets or set the next tracker in the list
  6082. */
  6083. next: Nullable<IInternalTextureTracker>;
  6084. }
  6085. /**
  6086. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6087. */
  6088. export class DummyInternalTextureTracker {
  6089. /**
  6090. * Gets or set the previous tracker in the list
  6091. */
  6092. previous: Nullable<IInternalTextureTracker>;
  6093. /**
  6094. * Gets or set the next tracker in the list
  6095. */
  6096. next: Nullable<IInternalTextureTracker>;
  6097. }
  6098. }
  6099. declare module BABYLON {
  6100. /**
  6101. * Class used to store data associated with WebGL texture data for the engine
  6102. * This class should not be used directly
  6103. */
  6104. export class InternalTexture implements IInternalTextureTracker {
  6105. /** hidden */
  6106. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6107. /**
  6108. * The source of the texture data is unknown
  6109. */
  6110. static DATASOURCE_UNKNOWN: number;
  6111. /**
  6112. * Texture data comes from an URL
  6113. */
  6114. static DATASOURCE_URL: number;
  6115. /**
  6116. * Texture data is only used for temporary storage
  6117. */
  6118. static DATASOURCE_TEMP: number;
  6119. /**
  6120. * Texture data comes from raw data (ArrayBuffer)
  6121. */
  6122. static DATASOURCE_RAW: number;
  6123. /**
  6124. * Texture content is dynamic (video or dynamic texture)
  6125. */
  6126. static DATASOURCE_DYNAMIC: number;
  6127. /**
  6128. * Texture content is generated by rendering to it
  6129. */
  6130. static DATASOURCE_RENDERTARGET: number;
  6131. /**
  6132. * Texture content is part of a multi render target process
  6133. */
  6134. static DATASOURCE_MULTIRENDERTARGET: number;
  6135. /**
  6136. * Texture data comes from a cube data file
  6137. */
  6138. static DATASOURCE_CUBE: number;
  6139. /**
  6140. * Texture data comes from a raw cube data
  6141. */
  6142. static DATASOURCE_CUBERAW: number;
  6143. /**
  6144. * Texture data come from a prefiltered cube data file
  6145. */
  6146. static DATASOURCE_CUBEPREFILTERED: number;
  6147. /**
  6148. * Texture content is raw 3D data
  6149. */
  6150. static DATASOURCE_RAW3D: number;
  6151. /**
  6152. * Texture content is a depth texture
  6153. */
  6154. static DATASOURCE_DEPTHTEXTURE: number;
  6155. /**
  6156. * Texture data comes from a raw cube data encoded with RGBD
  6157. */
  6158. static DATASOURCE_CUBERAW_RGBD: number;
  6159. /**
  6160. * Defines if the texture is ready
  6161. */
  6162. isReady: boolean;
  6163. /**
  6164. * Defines if the texture is a cube texture
  6165. */
  6166. isCube: boolean;
  6167. /**
  6168. * Defines if the texture contains 3D data
  6169. */
  6170. is3D: boolean;
  6171. /**
  6172. * Gets the URL used to load this texture
  6173. */
  6174. url: string;
  6175. /**
  6176. * Gets the sampling mode of the texture
  6177. */
  6178. samplingMode: number;
  6179. /**
  6180. * Gets a boolean indicating if the texture needs mipmaps generation
  6181. */
  6182. generateMipMaps: boolean;
  6183. /**
  6184. * Gets the number of samples used by the texture (WebGL2+ only)
  6185. */
  6186. samples: number;
  6187. /**
  6188. * Gets the type of the texture (int, float...)
  6189. */
  6190. type: number;
  6191. /**
  6192. * Gets the format of the texture (RGB, RGBA...)
  6193. */
  6194. format: number;
  6195. /**
  6196. * Observable called when the texture is loaded
  6197. */
  6198. onLoadedObservable: Observable<InternalTexture>;
  6199. /**
  6200. * Gets the width of the texture
  6201. */
  6202. width: number;
  6203. /**
  6204. * Gets the height of the texture
  6205. */
  6206. height: number;
  6207. /**
  6208. * Gets the depth of the texture
  6209. */
  6210. depth: number;
  6211. /**
  6212. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6213. */
  6214. baseWidth: number;
  6215. /**
  6216. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6217. */
  6218. baseHeight: number;
  6219. /**
  6220. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6221. */
  6222. baseDepth: number;
  6223. /**
  6224. * Gets a boolean indicating if the texture is inverted on Y axis
  6225. */
  6226. invertY: boolean;
  6227. /**
  6228. * Gets or set the previous tracker in the list
  6229. */
  6230. previous: Nullable<IInternalTextureTracker>;
  6231. /**
  6232. * Gets or set the next tracker in the list
  6233. */
  6234. next: Nullable<IInternalTextureTracker>;
  6235. /** @hidden */
  6236. _invertVScale: boolean;
  6237. /** @hidden */
  6238. _initialSlot: number;
  6239. /** @hidden */
  6240. _designatedSlot: number;
  6241. /** @hidden */
  6242. _dataSource: number;
  6243. /** @hidden */
  6244. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6245. /** @hidden */
  6246. _bufferView: Nullable<ArrayBufferView>;
  6247. /** @hidden */
  6248. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6249. /** @hidden */
  6250. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6251. /** @hidden */
  6252. _size: number;
  6253. /** @hidden */
  6254. _extension: string;
  6255. /** @hidden */
  6256. _files: Nullable<string[]>;
  6257. /** @hidden */
  6258. _workingCanvas: HTMLCanvasElement;
  6259. /** @hidden */
  6260. _workingContext: CanvasRenderingContext2D;
  6261. /** @hidden */
  6262. _framebuffer: Nullable<WebGLFramebuffer>;
  6263. /** @hidden */
  6264. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6265. /** @hidden */
  6266. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6267. /** @hidden */
  6268. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6269. /** @hidden */
  6270. _attachments: Nullable<number[]>;
  6271. /** @hidden */
  6272. _cachedCoordinatesMode: Nullable<number>;
  6273. /** @hidden */
  6274. _cachedWrapU: Nullable<number>;
  6275. /** @hidden */
  6276. _cachedWrapV: Nullable<number>;
  6277. /** @hidden */
  6278. _cachedWrapR: Nullable<number>;
  6279. /** @hidden */
  6280. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6281. /** @hidden */
  6282. _isDisabled: boolean;
  6283. /** @hidden */
  6284. _compression: Nullable<string>;
  6285. /** @hidden */
  6286. _generateStencilBuffer: boolean;
  6287. /** @hidden */
  6288. _generateDepthBuffer: boolean;
  6289. /** @hidden */
  6290. _comparisonFunction: number;
  6291. /** @hidden */
  6292. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6293. /** @hidden */
  6294. _lodGenerationScale: number;
  6295. /** @hidden */
  6296. _lodGenerationOffset: number;
  6297. /** @hidden */
  6298. _lodTextureHigh: BaseTexture;
  6299. /** @hidden */
  6300. _lodTextureMid: BaseTexture;
  6301. /** @hidden */
  6302. _lodTextureLow: BaseTexture;
  6303. /** @hidden */
  6304. _isRGBD: boolean;
  6305. /** @hidden */
  6306. _webGLTexture: Nullable<WebGLTexture>;
  6307. /** @hidden */
  6308. _references: number;
  6309. private _engine;
  6310. /**
  6311. * Gets the Engine the texture belongs to.
  6312. * @returns The babylon engine
  6313. */
  6314. getEngine(): Engine;
  6315. /**
  6316. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6317. */
  6318. readonly dataSource: number;
  6319. /**
  6320. * Creates a new InternalTexture
  6321. * @param engine defines the engine to use
  6322. * @param dataSource defines the type of data that will be used
  6323. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6324. */
  6325. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6326. /**
  6327. * Increments the number of references (ie. the number of Texture that point to it)
  6328. */
  6329. incrementReferences(): void;
  6330. /**
  6331. * Change the size of the texture (not the size of the content)
  6332. * @param width defines the new width
  6333. * @param height defines the new height
  6334. * @param depth defines the new depth (1 by default)
  6335. */
  6336. updateSize(width: int, height: int, depth?: int): void;
  6337. /** @hidden */
  6338. _rebuild(): void;
  6339. /** @hidden */
  6340. _swapAndDie(target: InternalTexture): void;
  6341. /**
  6342. * Dispose the current allocated resources
  6343. */
  6344. dispose(): void;
  6345. }
  6346. }
  6347. declare module BABYLON {
  6348. /**
  6349. * This represents the main contract an easing function should follow.
  6350. * Easing functions are used throughout the animation system.
  6351. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6352. */
  6353. export interface IEasingFunction {
  6354. /**
  6355. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6356. * of the easing function.
  6357. * The link below provides some of the most common examples of easing functions.
  6358. * @see https://easings.net/
  6359. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6360. * @returns the corresponding value on the curve defined by the easing function
  6361. */
  6362. ease(gradient: number): number;
  6363. }
  6364. /**
  6365. * Base class used for every default easing function.
  6366. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6367. */
  6368. export class EasingFunction implements IEasingFunction {
  6369. /**
  6370. * Interpolation follows the mathematical formula associated with the easing function.
  6371. */
  6372. static readonly EASINGMODE_EASEIN: number;
  6373. /**
  6374. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6375. */
  6376. static readonly EASINGMODE_EASEOUT: number;
  6377. /**
  6378. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6379. */
  6380. static readonly EASINGMODE_EASEINOUT: number;
  6381. private _easingMode;
  6382. /**
  6383. * Sets the easing mode of the current function.
  6384. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6385. */
  6386. setEasingMode(easingMode: number): void;
  6387. /**
  6388. * Gets the current easing mode.
  6389. * @returns the easing mode
  6390. */
  6391. getEasingMode(): number;
  6392. /**
  6393. * @hidden
  6394. */
  6395. easeInCore(gradient: number): number;
  6396. /**
  6397. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6398. * of the easing function.
  6399. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6400. * @returns the corresponding value on the curve defined by the easing function
  6401. */
  6402. ease(gradient: number): number;
  6403. }
  6404. /**
  6405. * Easing function with a circle shape (see link below).
  6406. * @see https://easings.net/#easeInCirc
  6407. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6408. */
  6409. export class CircleEase extends EasingFunction implements IEasingFunction {
  6410. /** @hidden */
  6411. easeInCore(gradient: number): number;
  6412. }
  6413. /**
  6414. * Easing function with a ease back shape (see link below).
  6415. * @see https://easings.net/#easeInBack
  6416. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6417. */
  6418. export class BackEase extends EasingFunction implements IEasingFunction {
  6419. /** Defines the amplitude of the function */
  6420. amplitude: number;
  6421. /**
  6422. * Instantiates a back ease easing
  6423. * @see https://easings.net/#easeInBack
  6424. * @param amplitude Defines the amplitude of the function
  6425. */
  6426. constructor(
  6427. /** Defines the amplitude of the function */
  6428. amplitude?: number);
  6429. /** @hidden */
  6430. easeInCore(gradient: number): number;
  6431. }
  6432. /**
  6433. * Easing function with a bouncing shape (see link below).
  6434. * @see https://easings.net/#easeInBounce
  6435. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6436. */
  6437. export class BounceEase extends EasingFunction implements IEasingFunction {
  6438. /** Defines the number of bounces */
  6439. bounces: number;
  6440. /** Defines the amplitude of the bounce */
  6441. bounciness: number;
  6442. /**
  6443. * Instantiates a bounce easing
  6444. * @see https://easings.net/#easeInBounce
  6445. * @param bounces Defines the number of bounces
  6446. * @param bounciness Defines the amplitude of the bounce
  6447. */
  6448. constructor(
  6449. /** Defines the number of bounces */
  6450. bounces?: number,
  6451. /** Defines the amplitude of the bounce */
  6452. bounciness?: number);
  6453. /** @hidden */
  6454. easeInCore(gradient: number): number;
  6455. }
  6456. /**
  6457. * Easing function with a power of 3 shape (see link below).
  6458. * @see https://easings.net/#easeInCubic
  6459. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6460. */
  6461. export class CubicEase extends EasingFunction implements IEasingFunction {
  6462. /** @hidden */
  6463. easeInCore(gradient: number): number;
  6464. }
  6465. /**
  6466. * Easing function with an elastic shape (see link below).
  6467. * @see https://easings.net/#easeInElastic
  6468. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6469. */
  6470. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6471. /** Defines the number of oscillations*/
  6472. oscillations: number;
  6473. /** Defines the amplitude of the oscillations*/
  6474. springiness: number;
  6475. /**
  6476. * Instantiates an elastic easing function
  6477. * @see https://easings.net/#easeInElastic
  6478. * @param oscillations Defines the number of oscillations
  6479. * @param springiness Defines the amplitude of the oscillations
  6480. */
  6481. constructor(
  6482. /** Defines the number of oscillations*/
  6483. oscillations?: number,
  6484. /** Defines the amplitude of the oscillations*/
  6485. springiness?: number);
  6486. /** @hidden */
  6487. easeInCore(gradient: number): number;
  6488. }
  6489. /**
  6490. * Easing function with an exponential shape (see link below).
  6491. * @see https://easings.net/#easeInExpo
  6492. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6493. */
  6494. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6495. /** Defines the exponent of the function */
  6496. exponent: number;
  6497. /**
  6498. * Instantiates an exponential easing function
  6499. * @see https://easings.net/#easeInExpo
  6500. * @param exponent Defines the exponent of the function
  6501. */
  6502. constructor(
  6503. /** Defines the exponent of the function */
  6504. exponent?: number);
  6505. /** @hidden */
  6506. easeInCore(gradient: number): number;
  6507. }
  6508. /**
  6509. * Easing function with a power shape (see link below).
  6510. * @see https://easings.net/#easeInQuad
  6511. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6512. */
  6513. export class PowerEase extends EasingFunction implements IEasingFunction {
  6514. /** Defines the power of the function */
  6515. power: number;
  6516. /**
  6517. * Instantiates an power base easing function
  6518. * @see https://easings.net/#easeInQuad
  6519. * @param power Defines the power of the function
  6520. */
  6521. constructor(
  6522. /** Defines the power of the function */
  6523. power?: number);
  6524. /** @hidden */
  6525. easeInCore(gradient: number): number;
  6526. }
  6527. /**
  6528. * Easing function with a power of 2 shape (see link below).
  6529. * @see https://easings.net/#easeInQuad
  6530. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6531. */
  6532. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6533. /** @hidden */
  6534. easeInCore(gradient: number): number;
  6535. }
  6536. /**
  6537. * Easing function with a power of 4 shape (see link below).
  6538. * @see https://easings.net/#easeInQuart
  6539. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6540. */
  6541. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6542. /** @hidden */
  6543. easeInCore(gradient: number): number;
  6544. }
  6545. /**
  6546. * Easing function with a power of 5 shape (see link below).
  6547. * @see https://easings.net/#easeInQuint
  6548. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6549. */
  6550. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6551. /** @hidden */
  6552. easeInCore(gradient: number): number;
  6553. }
  6554. /**
  6555. * Easing function with a sin shape (see link below).
  6556. * @see https://easings.net/#easeInSine
  6557. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6558. */
  6559. export class SineEase extends EasingFunction implements IEasingFunction {
  6560. /** @hidden */
  6561. easeInCore(gradient: number): number;
  6562. }
  6563. /**
  6564. * Easing function with a bezier shape (see link below).
  6565. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6566. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6567. */
  6568. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6569. /** Defines the x component of the start tangent in the bezier curve */
  6570. x1: number;
  6571. /** Defines the y component of the start tangent in the bezier curve */
  6572. y1: number;
  6573. /** Defines the x component of the end tangent in the bezier curve */
  6574. x2: number;
  6575. /** Defines the y component of the end tangent in the bezier curve */
  6576. y2: number;
  6577. /**
  6578. * Instantiates a bezier function
  6579. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6580. * @param x1 Defines the x component of the start tangent in the bezier curve
  6581. * @param y1 Defines the y component of the start tangent in the bezier curve
  6582. * @param x2 Defines the x component of the end tangent in the bezier curve
  6583. * @param y2 Defines the y component of the end tangent in the bezier curve
  6584. */
  6585. constructor(
  6586. /** Defines the x component of the start tangent in the bezier curve */
  6587. x1?: number,
  6588. /** Defines the y component of the start tangent in the bezier curve */
  6589. y1?: number,
  6590. /** Defines the x component of the end tangent in the bezier curve */
  6591. x2?: number,
  6592. /** Defines the y component of the end tangent in the bezier curve */
  6593. y2?: number);
  6594. /** @hidden */
  6595. easeInCore(gradient: number): number;
  6596. }
  6597. }
  6598. declare module BABYLON {
  6599. /**
  6600. * Interface used to define a behavior
  6601. */
  6602. export interface Behavior<T> {
  6603. /** gets or sets behavior's name */
  6604. name: string;
  6605. /**
  6606. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6607. */
  6608. init(): void;
  6609. /**
  6610. * Called when the behavior is attached to a target
  6611. * @param target defines the target where the behavior is attached to
  6612. */
  6613. attach(target: T): void;
  6614. /**
  6615. * Called when the behavior is detached from its target
  6616. */
  6617. detach(): void;
  6618. }
  6619. /**
  6620. * Interface implemented by classes supporting behaviors
  6621. */
  6622. export interface IBehaviorAware<T> {
  6623. /**
  6624. * Attach a behavior
  6625. * @param behavior defines the behavior to attach
  6626. * @returns the current host
  6627. */
  6628. addBehavior(behavior: Behavior<T>): T;
  6629. /**
  6630. * Remove a behavior from the current object
  6631. * @param behavior defines the behavior to detach
  6632. * @returns the current host
  6633. */
  6634. removeBehavior(behavior: Behavior<T>): T;
  6635. /**
  6636. * Gets a behavior using its name to search
  6637. * @param name defines the name to search
  6638. * @returns the behavior or null if not found
  6639. */
  6640. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6641. }
  6642. }
  6643. declare module BABYLON {
  6644. /**
  6645. * Defines a runtime animation
  6646. */
  6647. export class RuntimeAnimation {
  6648. private _events;
  6649. /**
  6650. * The current frame of the runtime animation
  6651. */
  6652. private _currentFrame;
  6653. /**
  6654. * The animation used by the runtime animation
  6655. */
  6656. private _animation;
  6657. /**
  6658. * The target of the runtime animation
  6659. */
  6660. private _target;
  6661. /**
  6662. * The initiating animatable
  6663. */
  6664. private _host;
  6665. /**
  6666. * The original value of the runtime animation
  6667. */
  6668. private _originalValue;
  6669. /**
  6670. * The original blend value of the runtime animation
  6671. */
  6672. private _originalBlendValue;
  6673. /**
  6674. * The offsets cache of the runtime animation
  6675. */
  6676. private _offsetsCache;
  6677. /**
  6678. * The high limits cache of the runtime animation
  6679. */
  6680. private _highLimitsCache;
  6681. /**
  6682. * Specifies if the runtime animation has been stopped
  6683. */
  6684. private _stopped;
  6685. /**
  6686. * The blending factor of the runtime animation
  6687. */
  6688. private _blendingFactor;
  6689. /**
  6690. * The BabylonJS scene
  6691. */
  6692. private _scene;
  6693. /**
  6694. * The current value of the runtime animation
  6695. */
  6696. private _currentValue;
  6697. /** @hidden */
  6698. _workValue: any;
  6699. /**
  6700. * The active target of the runtime animation
  6701. */
  6702. private _activeTarget;
  6703. /**
  6704. * The target path of the runtime animation
  6705. */
  6706. private _targetPath;
  6707. /**
  6708. * The weight of the runtime animation
  6709. */
  6710. private _weight;
  6711. /**
  6712. * The ratio offset of the runtime animation
  6713. */
  6714. private _ratioOffset;
  6715. /**
  6716. * The previous delay of the runtime animation
  6717. */
  6718. private _previousDelay;
  6719. /**
  6720. * The previous ratio of the runtime animation
  6721. */
  6722. private _previousRatio;
  6723. /**
  6724. * Gets the current frame of the runtime animation
  6725. */
  6726. readonly currentFrame: number;
  6727. /**
  6728. * Gets the weight of the runtime animation
  6729. */
  6730. readonly weight: number;
  6731. /**
  6732. * Gets the current value of the runtime animation
  6733. */
  6734. readonly currentValue: any;
  6735. /**
  6736. * Gets the target path of the runtime animation
  6737. */
  6738. readonly targetPath: string;
  6739. /**
  6740. * Gets the actual target of the runtime animation
  6741. */
  6742. readonly target: any;
  6743. /**
  6744. * Create a new RuntimeAnimation object
  6745. * @param target defines the target of the animation
  6746. * @param animation defines the source animation object
  6747. * @param scene defines the hosting scene
  6748. * @param host defines the initiating Animatable
  6749. */
  6750. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  6751. /**
  6752. * Gets the animation from the runtime animation
  6753. */
  6754. readonly animation: Animation;
  6755. /**
  6756. * Resets the runtime animation to the beginning
  6757. * @param restoreOriginal defines whether to restore the target property to the original value
  6758. */
  6759. reset(restoreOriginal?: boolean): void;
  6760. /**
  6761. * Specifies if the runtime animation is stopped
  6762. * @returns Boolean specifying if the runtime animation is stopped
  6763. */
  6764. isStopped(): boolean;
  6765. /**
  6766. * Disposes of the runtime animation
  6767. */
  6768. dispose(): void;
  6769. /**
  6770. * Interpolates the animation from the current frame
  6771. * @param currentFrame The frame to interpolate the animation to
  6772. * @param repeatCount The number of times that the animation should loop
  6773. * @param loopMode The type of looping mode to use
  6774. * @param offsetValue Animation offset value
  6775. * @param highLimitValue The high limit value
  6776. * @returns The interpolated value
  6777. */
  6778. private _interpolate;
  6779. /**
  6780. * Apply the interpolated value to the target
  6781. * @param currentValue defines the value computed by the animation
  6782. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  6783. */
  6784. setValue(currentValue: any, weight?: number): void;
  6785. private _setValue;
  6786. /**
  6787. * Gets the loop pmode of the runtime animation
  6788. * @returns Loop Mode
  6789. */
  6790. private _getCorrectLoopMode;
  6791. /**
  6792. * Move the current animation to a given frame
  6793. * @param frame defines the frame to move to
  6794. */
  6795. goToFrame(frame: number): void;
  6796. /**
  6797. * @hidden Internal use only
  6798. */
  6799. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  6800. /**
  6801. * Execute the current animation
  6802. * @param delay defines the delay to add to the current frame
  6803. * @param from defines the lower bound of the animation range
  6804. * @param to defines the upper bound of the animation range
  6805. * @param loop defines if the current animation must loop
  6806. * @param speedRatio defines the current speed ratio
  6807. * @param weight defines the weight of the animation (default is -1 so no weight)
  6808. * @param onLoop optional callback called when animation loops
  6809. * @returns a boolean indicating if the animation is running
  6810. */
  6811. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  6812. }
  6813. }
  6814. declare module BABYLON {
  6815. /**
  6816. * Class used to store an actual running animation
  6817. */
  6818. export class Animatable {
  6819. /** defines the target object */
  6820. target: any;
  6821. /** defines the starting frame number (default is 0) */
  6822. fromFrame: number;
  6823. /** defines the ending frame number (default is 100) */
  6824. toFrame: number;
  6825. /** defines if the animation must loop (default is false) */
  6826. loopAnimation: boolean;
  6827. /** defines a callback to call when animation ends if it is not looping */
  6828. onAnimationEnd?: (() => void) | null | undefined;
  6829. /** defines a callback to call when animation loops */
  6830. onAnimationLoop?: (() => void) | null | undefined;
  6831. private _localDelayOffset;
  6832. private _pausedDelay;
  6833. private _runtimeAnimations;
  6834. private _paused;
  6835. private _scene;
  6836. private _speedRatio;
  6837. private _weight;
  6838. private _syncRoot;
  6839. /**
  6840. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  6841. * This will only apply for non looping animation (default is true)
  6842. */
  6843. disposeOnEnd: boolean;
  6844. /**
  6845. * Gets a boolean indicating if the animation has started
  6846. */
  6847. animationStarted: boolean;
  6848. /**
  6849. * Observer raised when the animation ends
  6850. */
  6851. onAnimationEndObservable: Observable<Animatable>;
  6852. /**
  6853. * Observer raised when the animation loops
  6854. */
  6855. onAnimationLoopObservable: Observable<Animatable>;
  6856. /**
  6857. * Gets the root Animatable used to synchronize and normalize animations
  6858. */
  6859. readonly syncRoot: Animatable;
  6860. /**
  6861. * Gets the current frame of the first RuntimeAnimation
  6862. * Used to synchronize Animatables
  6863. */
  6864. readonly masterFrame: number;
  6865. /**
  6866. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  6867. */
  6868. weight: number;
  6869. /**
  6870. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  6871. */
  6872. speedRatio: number;
  6873. /**
  6874. * Creates a new Animatable
  6875. * @param scene defines the hosting scene
  6876. * @param target defines the target object
  6877. * @param fromFrame defines the starting frame number (default is 0)
  6878. * @param toFrame defines the ending frame number (default is 100)
  6879. * @param loopAnimation defines if the animation must loop (default is false)
  6880. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  6881. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  6882. * @param animations defines a group of animation to add to the new Animatable
  6883. * @param onAnimationLoop defines a callback to call when animation loops
  6884. */
  6885. constructor(scene: Scene,
  6886. /** defines the target object */
  6887. target: any,
  6888. /** defines the starting frame number (default is 0) */
  6889. fromFrame?: number,
  6890. /** defines the ending frame number (default is 100) */
  6891. toFrame?: number,
  6892. /** defines if the animation must loop (default is false) */
  6893. loopAnimation?: boolean, speedRatio?: number,
  6894. /** defines a callback to call when animation ends if it is not looping */
  6895. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  6896. /** defines a callback to call when animation loops */
  6897. onAnimationLoop?: (() => void) | null | undefined);
  6898. /**
  6899. * Synchronize and normalize current Animatable with a source Animatable
  6900. * This is useful when using animation weights and when animations are not of the same length
  6901. * @param root defines the root Animatable to synchronize with
  6902. * @returns the current Animatable
  6903. */
  6904. syncWith(root: Animatable): Animatable;
  6905. /**
  6906. * Gets the list of runtime animations
  6907. * @returns an array of RuntimeAnimation
  6908. */
  6909. getAnimations(): RuntimeAnimation[];
  6910. /**
  6911. * Adds more animations to the current animatable
  6912. * @param target defines the target of the animations
  6913. * @param animations defines the new animations to add
  6914. */
  6915. appendAnimations(target: any, animations: Animation[]): void;
  6916. /**
  6917. * Gets the source animation for a specific property
  6918. * @param property defines the propertyu to look for
  6919. * @returns null or the source animation for the given property
  6920. */
  6921. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  6922. /**
  6923. * Gets the runtime animation for a specific property
  6924. * @param property defines the propertyu to look for
  6925. * @returns null or the runtime animation for the given property
  6926. */
  6927. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  6928. /**
  6929. * Resets the animatable to its original state
  6930. */
  6931. reset(): void;
  6932. /**
  6933. * Allows the animatable to blend with current running animations
  6934. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6935. * @param blendingSpeed defines the blending speed to use
  6936. */
  6937. enableBlending(blendingSpeed: number): void;
  6938. /**
  6939. * Disable animation blending
  6940. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6941. */
  6942. disableBlending(): void;
  6943. /**
  6944. * Jump directly to a given frame
  6945. * @param frame defines the frame to jump to
  6946. */
  6947. goToFrame(frame: number): void;
  6948. /**
  6949. * Pause the animation
  6950. */
  6951. pause(): void;
  6952. /**
  6953. * Restart the animation
  6954. */
  6955. restart(): void;
  6956. private _raiseOnAnimationEnd;
  6957. /**
  6958. * Stop and delete the current animation
  6959. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  6960. * @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)
  6961. */
  6962. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  6963. /**
  6964. * Wait asynchronously for the animation to end
  6965. * @returns a promise which will be fullfilled when the animation ends
  6966. */
  6967. waitAsync(): Promise<Animatable>;
  6968. /** @hidden */
  6969. _animate(delay: number): boolean;
  6970. }
  6971. }
  6972. declare module BABYLON {
  6973. /**
  6974. * Class used to override all child animations of a given target
  6975. */
  6976. export class AnimationPropertiesOverride {
  6977. /**
  6978. * Gets or sets a value indicating if animation blending must be used
  6979. */
  6980. enableBlending: boolean;
  6981. /**
  6982. * Gets or sets the blending speed to use when enableBlending is true
  6983. */
  6984. blendingSpeed: number;
  6985. /**
  6986. * Gets or sets the default loop mode to use
  6987. */
  6988. loopMode: number;
  6989. }
  6990. }
  6991. declare module BABYLON {
  6992. /** @hidden */
  6993. export class Collider {
  6994. /** Define if a collision was found */
  6995. collisionFound: boolean;
  6996. /**
  6997. * Define last intersection point in local space
  6998. */
  6999. intersectionPoint: Vector3;
  7000. /**
  7001. * Define last collided mesh
  7002. */
  7003. collidedMesh: Nullable<AbstractMesh>;
  7004. private _collisionPoint;
  7005. private _planeIntersectionPoint;
  7006. private _tempVector;
  7007. private _tempVector2;
  7008. private _tempVector3;
  7009. private _tempVector4;
  7010. private _edge;
  7011. private _baseToVertex;
  7012. private _destinationPoint;
  7013. private _slidePlaneNormal;
  7014. private _displacementVector;
  7015. /** @hidden */
  7016. _radius: Vector3;
  7017. /** @hidden */
  7018. _retry: number;
  7019. private _velocity;
  7020. private _basePoint;
  7021. private _epsilon;
  7022. /** @hidden */
  7023. _velocityWorldLength: number;
  7024. /** @hidden */
  7025. _basePointWorld: Vector3;
  7026. private _velocityWorld;
  7027. private _normalizedVelocity;
  7028. /** @hidden */
  7029. _initialVelocity: Vector3;
  7030. /** @hidden */
  7031. _initialPosition: Vector3;
  7032. private _nearestDistance;
  7033. private _collisionMask;
  7034. collisionMask: number;
  7035. /**
  7036. * Gets the plane normal used to compute the sliding response (in local space)
  7037. */
  7038. readonly slidePlaneNormal: Vector3;
  7039. /** @hidden */
  7040. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7041. /** @hidden */
  7042. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7043. /** @hidden */
  7044. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7045. /** @hidden */
  7046. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7047. /** @hidden */
  7048. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7049. /** @hidden */
  7050. _getResponse(pos: Vector3, vel: Vector3): void;
  7051. }
  7052. }
  7053. declare module BABYLON {
  7054. /**
  7055. * @hidden
  7056. */
  7057. export class IntersectionInfo {
  7058. bu: Nullable<number>;
  7059. bv: Nullable<number>;
  7060. distance: number;
  7061. faceId: number;
  7062. subMeshId: number;
  7063. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7064. }
  7065. }
  7066. declare module BABYLON {
  7067. /**
  7068. * ActionEvent is the event being sent when an action is triggered.
  7069. */
  7070. export class ActionEvent {
  7071. /** The mesh or sprite that triggered the action */
  7072. source: any;
  7073. /** The X mouse cursor position at the time of the event */
  7074. pointerX: number;
  7075. /** The Y mouse cursor position at the time of the event */
  7076. pointerY: number;
  7077. /** The mesh that is currently pointed at (can be null) */
  7078. meshUnderPointer: Nullable<AbstractMesh>;
  7079. /** the original (browser) event that triggered the ActionEvent */
  7080. sourceEvent?: any;
  7081. /** additional data for the event */
  7082. additionalData?: any;
  7083. /**
  7084. * Creates a new ActionEvent
  7085. * @param source The mesh or sprite that triggered the action
  7086. * @param pointerX The X mouse cursor position at the time of the event
  7087. * @param pointerY The Y mouse cursor position at the time of the event
  7088. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  7089. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  7090. * @param additionalData additional data for the event
  7091. */
  7092. constructor(
  7093. /** The mesh or sprite that triggered the action */
  7094. source: any,
  7095. /** The X mouse cursor position at the time of the event */
  7096. pointerX: number,
  7097. /** The Y mouse cursor position at the time of the event */
  7098. pointerY: number,
  7099. /** The mesh that is currently pointed at (can be null) */
  7100. meshUnderPointer: Nullable<AbstractMesh>,
  7101. /** the original (browser) event that triggered the ActionEvent */
  7102. sourceEvent?: any,
  7103. /** additional data for the event */
  7104. additionalData?: any);
  7105. /**
  7106. * Helper function to auto-create an ActionEvent from a source mesh.
  7107. * @param source The source mesh that triggered the event
  7108. * @param evt The original (browser) event
  7109. * @param additionalData additional data for the event
  7110. * @returns the new ActionEvent
  7111. */
  7112. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  7113. /**
  7114. * Helper function to auto-create an ActionEvent from a source sprite
  7115. * @param source The source sprite that triggered the event
  7116. * @param scene Scene associated with the sprite
  7117. * @param evt The original (browser) event
  7118. * @param additionalData additional data for the event
  7119. * @returns the new ActionEvent
  7120. */
  7121. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  7122. /**
  7123. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  7124. * @param scene the scene where the event occurred
  7125. * @param evt The original (browser) event
  7126. * @returns the new ActionEvent
  7127. */
  7128. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  7129. /**
  7130. * Helper function to auto-create an ActionEvent from a primitive
  7131. * @param prim defines the target primitive
  7132. * @param pointerPos defines the pointer position
  7133. * @param evt The original (browser) event
  7134. * @param additionalData additional data for the event
  7135. * @returns the new ActionEvent
  7136. */
  7137. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  7138. }
  7139. }
  7140. declare module BABYLON {
  7141. /**
  7142. * Class used to store bounding sphere information
  7143. */
  7144. export class BoundingSphere {
  7145. /**
  7146. * Gets the center of the bounding sphere in local space
  7147. */
  7148. readonly center: Vector3;
  7149. /**
  7150. * Radius of the bounding sphere in local space
  7151. */
  7152. radius: number;
  7153. /**
  7154. * Gets the center of the bounding sphere in world space
  7155. */
  7156. readonly centerWorld: Vector3;
  7157. /**
  7158. * Radius of the bounding sphere in world space
  7159. */
  7160. radiusWorld: number;
  7161. /**
  7162. * Gets the minimum vector in local space
  7163. */
  7164. readonly minimum: Vector3;
  7165. /**
  7166. * Gets the maximum vector in local space
  7167. */
  7168. readonly maximum: Vector3;
  7169. private _worldMatrix;
  7170. private static readonly TmpVector3;
  7171. /**
  7172. * Creates a new bounding sphere
  7173. * @param min defines the minimum vector (in local space)
  7174. * @param max defines the maximum vector (in local space)
  7175. * @param worldMatrix defines the new world matrix
  7176. */
  7177. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7178. /**
  7179. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7180. * @param min defines the new minimum vector (in local space)
  7181. * @param max defines the new maximum vector (in local space)
  7182. * @param worldMatrix defines the new world matrix
  7183. */
  7184. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7185. /**
  7186. * Scale the current bounding sphere by applying a scale factor
  7187. * @param factor defines the scale factor to apply
  7188. * @returns the current bounding box
  7189. */
  7190. scale(factor: number): BoundingSphere;
  7191. /**
  7192. * Gets the world matrix of the bounding box
  7193. * @returns a matrix
  7194. */
  7195. getWorldMatrix(): DeepImmutable<Matrix>;
  7196. /** @hidden */
  7197. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7198. /**
  7199. * Tests if the bounding sphere is intersecting the frustum planes
  7200. * @param frustumPlanes defines the frustum planes to test
  7201. * @returns true if there is an intersection
  7202. */
  7203. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7204. /**
  7205. * Tests if the bounding sphere center is in between the frustum planes.
  7206. * Used for optimistic fast inclusion.
  7207. * @param frustumPlanes defines the frustum planes to test
  7208. * @returns true if the sphere center is in between the frustum planes
  7209. */
  7210. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7211. /**
  7212. * Tests if a point is inside the bounding sphere
  7213. * @param point defines the point to test
  7214. * @returns true if the point is inside the bounding sphere
  7215. */
  7216. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7217. /**
  7218. * Checks if two sphere intersct
  7219. * @param sphere0 sphere 0
  7220. * @param sphere1 sphere 1
  7221. * @returns true if the speres intersect
  7222. */
  7223. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7224. }
  7225. }
  7226. declare module BABYLON {
  7227. /**
  7228. * Class used to store bounding box information
  7229. */
  7230. export class BoundingBox implements ICullable {
  7231. /**
  7232. * Gets the 8 vectors representing the bounding box in local space
  7233. */
  7234. readonly vectors: Vector3[];
  7235. /**
  7236. * Gets the center of the bounding box in local space
  7237. */
  7238. readonly center: Vector3;
  7239. /**
  7240. * Gets the center of the bounding box in world space
  7241. */
  7242. readonly centerWorld: Vector3;
  7243. /**
  7244. * Gets the extend size in local space
  7245. */
  7246. readonly extendSize: Vector3;
  7247. /**
  7248. * Gets the extend size in world space
  7249. */
  7250. readonly extendSizeWorld: Vector3;
  7251. /**
  7252. * Gets the OBB (object bounding box) directions
  7253. */
  7254. readonly directions: Vector3[];
  7255. /**
  7256. * Gets the 8 vectors representing the bounding box in world space
  7257. */
  7258. readonly vectorsWorld: Vector3[];
  7259. /**
  7260. * Gets the minimum vector in world space
  7261. */
  7262. readonly minimumWorld: Vector3;
  7263. /**
  7264. * Gets the maximum vector in world space
  7265. */
  7266. readonly maximumWorld: Vector3;
  7267. /**
  7268. * Gets the minimum vector in local space
  7269. */
  7270. readonly minimum: Vector3;
  7271. /**
  7272. * Gets the maximum vector in local space
  7273. */
  7274. readonly maximum: Vector3;
  7275. private _worldMatrix;
  7276. private static readonly TmpVector3;
  7277. /**
  7278. * @hidden
  7279. */
  7280. _tag: number;
  7281. /**
  7282. * Creates a new bounding box
  7283. * @param min defines the minimum vector (in local space)
  7284. * @param max defines the maximum vector (in local space)
  7285. * @param worldMatrix defines the new world matrix
  7286. */
  7287. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7288. /**
  7289. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7290. * @param min defines the new minimum vector (in local space)
  7291. * @param max defines the new maximum vector (in local space)
  7292. * @param worldMatrix defines the new world matrix
  7293. */
  7294. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7295. /**
  7296. * Scale the current bounding box by applying a scale factor
  7297. * @param factor defines the scale factor to apply
  7298. * @returns the current bounding box
  7299. */
  7300. scale(factor: number): BoundingBox;
  7301. /**
  7302. * Gets the world matrix of the bounding box
  7303. * @returns a matrix
  7304. */
  7305. getWorldMatrix(): DeepImmutable<Matrix>;
  7306. /** @hidden */
  7307. _update(world: DeepImmutable<Matrix>): void;
  7308. /**
  7309. * Tests if the bounding box is intersecting the frustum planes
  7310. * @param frustumPlanes defines the frustum planes to test
  7311. * @returns true if there is an intersection
  7312. */
  7313. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7314. /**
  7315. * Tests if the bounding box is entirely inside the frustum planes
  7316. * @param frustumPlanes defines the frustum planes to test
  7317. * @returns true if there is an inclusion
  7318. */
  7319. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7320. /**
  7321. * Tests if a point is inside the bounding box
  7322. * @param point defines the point to test
  7323. * @returns true if the point is inside the bounding box
  7324. */
  7325. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7326. /**
  7327. * Tests if the bounding box intersects with a bounding sphere
  7328. * @param sphere defines the sphere to test
  7329. * @returns true if there is an intersection
  7330. */
  7331. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7332. /**
  7333. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7334. * @param min defines the min vector to use
  7335. * @param max defines the max vector to use
  7336. * @returns true if there is an intersection
  7337. */
  7338. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7339. /**
  7340. * Tests if two bounding boxes are intersections
  7341. * @param box0 defines the first box to test
  7342. * @param box1 defines the second box to test
  7343. * @returns true if there is an intersection
  7344. */
  7345. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7346. /**
  7347. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7348. * @param minPoint defines the minimum vector of the bounding box
  7349. * @param maxPoint defines the maximum vector of the bounding box
  7350. * @param sphereCenter defines the sphere center
  7351. * @param sphereRadius defines the sphere radius
  7352. * @returns true if there is an intersection
  7353. */
  7354. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7355. /**
  7356. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7357. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7358. * @param frustumPlanes defines the frustum planes to test
  7359. * @return true if there is an inclusion
  7360. */
  7361. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7362. /**
  7363. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7364. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7365. * @param frustumPlanes defines the frustum planes to test
  7366. * @return true if there is an intersection
  7367. */
  7368. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7369. }
  7370. }
  7371. declare module BABYLON {
  7372. /**
  7373. * Interface for cullable objects
  7374. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7375. */
  7376. export interface ICullable {
  7377. /**
  7378. * Checks if the object or part of the object is in the frustum
  7379. * @param frustumPlanes Camera near/planes
  7380. * @returns true if the object is in frustum otherwise false
  7381. */
  7382. isInFrustum(frustumPlanes: Plane[]): boolean;
  7383. /**
  7384. * Checks if a cullable object (mesh...) is in the camera frustum
  7385. * Unlike isInFrustum this cheks the full bounding box
  7386. * @param frustumPlanes Camera near/planes
  7387. * @returns true if the object is in frustum otherwise false
  7388. */
  7389. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7390. }
  7391. /**
  7392. * Info for a bounding data of a mesh
  7393. */
  7394. export class BoundingInfo implements ICullable {
  7395. /**
  7396. * Bounding box for the mesh
  7397. */
  7398. readonly boundingBox: BoundingBox;
  7399. /**
  7400. * Bounding sphere for the mesh
  7401. */
  7402. readonly boundingSphere: BoundingSphere;
  7403. private _isLocked;
  7404. private static readonly TmpVector3;
  7405. /**
  7406. * Constructs bounding info
  7407. * @param minimum min vector of the bounding box/sphere
  7408. * @param maximum max vector of the bounding box/sphere
  7409. * @param worldMatrix defines the new world matrix
  7410. */
  7411. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7412. /**
  7413. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7414. * @param min defines the new minimum vector (in local space)
  7415. * @param max defines the new maximum vector (in local space)
  7416. * @param worldMatrix defines the new world matrix
  7417. */
  7418. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7419. /**
  7420. * min vector of the bounding box/sphere
  7421. */
  7422. readonly minimum: Vector3;
  7423. /**
  7424. * max vector of the bounding box/sphere
  7425. */
  7426. readonly maximum: Vector3;
  7427. /**
  7428. * If the info is locked and won't be updated to avoid perf overhead
  7429. */
  7430. isLocked: boolean;
  7431. /**
  7432. * Updates the bounding sphere and box
  7433. * @param world world matrix to be used to update
  7434. */
  7435. update(world: DeepImmutable<Matrix>): void;
  7436. /**
  7437. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7438. * @param center New center of the bounding info
  7439. * @param extend New extend of the bounding info
  7440. * @returns the current bounding info
  7441. */
  7442. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7443. /**
  7444. * Scale the current bounding info by applying a scale factor
  7445. * @param factor defines the scale factor to apply
  7446. * @returns the current bounding info
  7447. */
  7448. scale(factor: number): BoundingInfo;
  7449. /**
  7450. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7451. * @param frustumPlanes defines the frustum to test
  7452. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7453. * @returns true if the bounding info is in the frustum planes
  7454. */
  7455. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7456. /**
  7457. * Gets the world distance between the min and max points of the bounding box
  7458. */
  7459. readonly diagonalLength: number;
  7460. /**
  7461. * Checks if a cullable object (mesh...) is in the camera frustum
  7462. * Unlike isInFrustum this cheks the full bounding box
  7463. * @param frustumPlanes Camera near/planes
  7464. * @returns true if the object is in frustum otherwise false
  7465. */
  7466. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7467. /** @hidden */
  7468. _checkCollision(collider: Collider): boolean;
  7469. /**
  7470. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7471. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7472. * @param point the point to check intersection with
  7473. * @returns if the point intersects
  7474. */
  7475. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7476. /**
  7477. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7478. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7479. * @param boundingInfo the bounding info to check intersection with
  7480. * @param precise if the intersection should be done using OBB
  7481. * @returns if the bounding info intersects
  7482. */
  7483. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7484. }
  7485. }
  7486. declare module BABYLON {
  7487. /**
  7488. * Defines an array and its length.
  7489. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7490. */
  7491. export interface ISmartArrayLike<T> {
  7492. /**
  7493. * The data of the array.
  7494. */
  7495. data: Array<T>;
  7496. /**
  7497. * The active length of the array.
  7498. */
  7499. length: number;
  7500. }
  7501. /**
  7502. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7503. */
  7504. export class SmartArray<T> implements ISmartArrayLike<T> {
  7505. /**
  7506. * The full set of data from the array.
  7507. */
  7508. data: Array<T>;
  7509. /**
  7510. * The active length of the array.
  7511. */
  7512. length: number;
  7513. protected _id: number;
  7514. /**
  7515. * Instantiates a Smart Array.
  7516. * @param capacity defines the default capacity of the array.
  7517. */
  7518. constructor(capacity: number);
  7519. /**
  7520. * Pushes a value at the end of the active data.
  7521. * @param value defines the object to push in the array.
  7522. */
  7523. push(value: T): void;
  7524. /**
  7525. * Iterates over the active data and apply the lambda to them.
  7526. * @param func defines the action to apply on each value.
  7527. */
  7528. forEach(func: (content: T) => void): void;
  7529. /**
  7530. * Sorts the full sets of data.
  7531. * @param compareFn defines the comparison function to apply.
  7532. */
  7533. sort(compareFn: (a: T, b: T) => number): void;
  7534. /**
  7535. * Resets the active data to an empty array.
  7536. */
  7537. reset(): void;
  7538. /**
  7539. * Releases all the data from the array as well as the array.
  7540. */
  7541. dispose(): void;
  7542. /**
  7543. * Concats the active data with a given array.
  7544. * @param array defines the data to concatenate with.
  7545. */
  7546. concat(array: any): void;
  7547. /**
  7548. * Returns the position of a value in the active data.
  7549. * @param value defines the value to find the index for
  7550. * @returns the index if found in the active data otherwise -1
  7551. */
  7552. indexOf(value: T): number;
  7553. /**
  7554. * Returns whether an element is part of the active data.
  7555. * @param value defines the value to look for
  7556. * @returns true if found in the active data otherwise false
  7557. */
  7558. contains(value: T): boolean;
  7559. private static _GlobalId;
  7560. }
  7561. /**
  7562. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7563. * The data in this array can only be present once
  7564. */
  7565. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7566. private _duplicateId;
  7567. /**
  7568. * Pushes a value at the end of the active data.
  7569. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7570. * @param value defines the object to push in the array.
  7571. */
  7572. push(value: T): void;
  7573. /**
  7574. * Pushes a value at the end of the active data.
  7575. * If the data is already present, it won t be added again
  7576. * @param value defines the object to push in the array.
  7577. * @returns true if added false if it was already present
  7578. */
  7579. pushNoDuplicate(value: T): boolean;
  7580. /**
  7581. * Resets the active data to an empty array.
  7582. */
  7583. reset(): void;
  7584. /**
  7585. * Concats the active data with a given array.
  7586. * This ensures no dupplicate will be present in the result.
  7587. * @param array defines the data to concatenate with.
  7588. */
  7589. concatWithNoDuplicate(array: any): void;
  7590. }
  7591. }
  7592. declare module BABYLON {
  7593. /**
  7594. * Class for creating a cube texture
  7595. */
  7596. export class CubeTexture extends BaseTexture {
  7597. private _delayedOnLoad;
  7598. /**
  7599. * The url of the texture
  7600. */
  7601. url: string;
  7602. /**
  7603. * Gets or sets the center of the bounding box associated with the cube texture.
  7604. * It must define where the camera used to render the texture was set
  7605. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7606. */
  7607. boundingBoxPosition: Vector3;
  7608. private _boundingBoxSize;
  7609. /**
  7610. * Gets or sets the size of the bounding box associated with the cube texture
  7611. * When defined, the cubemap will switch to local mode
  7612. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7613. * @example https://www.babylonjs-playground.com/#RNASML
  7614. */
  7615. /**
  7616. * Returns the bounding box size
  7617. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7618. */
  7619. boundingBoxSize: Vector3;
  7620. protected _rotationY: number;
  7621. /**
  7622. * Sets texture matrix rotation angle around Y axis in radians.
  7623. */
  7624. /**
  7625. * Gets texture matrix rotation angle around Y axis radians.
  7626. */
  7627. rotationY: number;
  7628. /**
  7629. * Are mip maps generated for this texture or not.
  7630. */
  7631. readonly noMipmap: boolean;
  7632. private _noMipmap;
  7633. private _files;
  7634. private _extensions;
  7635. private _textureMatrix;
  7636. private _format;
  7637. private _createPolynomials;
  7638. /** @hidden */
  7639. _prefiltered: boolean;
  7640. /**
  7641. * Creates a cube texture from an array of image urls
  7642. * @param files defines an array of image urls
  7643. * @param scene defines the hosting scene
  7644. * @param noMipmap specifies if mip maps are not used
  7645. * @returns a cube texture
  7646. */
  7647. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7648. /**
  7649. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7650. * @param url defines the url of the prefiltered texture
  7651. * @param scene defines the scene the texture is attached to
  7652. * @param forcedExtension defines the extension of the file if different from the url
  7653. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7654. * @return the prefiltered texture
  7655. */
  7656. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7657. /**
  7658. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7659. * as prefiltered data.
  7660. * @param rootUrl defines the url of the texture or the root name of the six images
  7661. * @param scene defines the scene the texture is attached to
  7662. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7663. * @param noMipmap defines if mipmaps should be created or not
  7664. * @param files defines the six files to load for the different faces
  7665. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7666. * @param onError defines a callback triggered in case of error during load
  7667. * @param format defines the internal format to use for the texture once loaded
  7668. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7669. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7670. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7671. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7672. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7673. * @return the cube texture
  7674. */
  7675. 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);
  7676. /**
  7677. * Get the current class name of the texture useful for serialization or dynamic coding.
  7678. * @returns "CubeTexture"
  7679. */
  7680. getClassName(): string;
  7681. /**
  7682. * Update the url (and optional buffer) of this texture if url was null during construction.
  7683. * @param url the url of the texture
  7684. * @param forcedExtension defines the extension to use
  7685. * @param onLoad callback called when the texture is loaded (defaults to null)
  7686. */
  7687. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7688. /**
  7689. * Delays loading of the cube texture
  7690. * @param forcedExtension defines the extension to use
  7691. */
  7692. delayLoad(forcedExtension?: string): void;
  7693. /**
  7694. * Returns the reflection texture matrix
  7695. * @returns the reflection texture matrix
  7696. */
  7697. getReflectionTextureMatrix(): Matrix;
  7698. /**
  7699. * Sets the reflection texture matrix
  7700. * @param value Reflection texture matrix
  7701. */
  7702. setReflectionTextureMatrix(value: Matrix): void;
  7703. /**
  7704. * Parses text to create a cube texture
  7705. * @param parsedTexture define the serialized text to read from
  7706. * @param scene defines the hosting scene
  7707. * @param rootUrl defines the root url of the cube texture
  7708. * @returns a cube texture
  7709. */
  7710. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7711. /**
  7712. * Makes a clone, or deep copy, of the cube texture
  7713. * @returns a new cube texture
  7714. */
  7715. clone(): CubeTexture;
  7716. }
  7717. }
  7718. declare module BABYLON {
  7719. /** @hidden */
  7720. export var postprocessVertexShader: {
  7721. name: string;
  7722. shader: string;
  7723. };
  7724. }
  7725. declare module BABYLON {
  7726. /**
  7727. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7728. * This is the base of the follow, arc rotate cameras and Free camera
  7729. * @see http://doc.babylonjs.com/features/cameras
  7730. */
  7731. export class TargetCamera extends Camera {
  7732. private static _RigCamTransformMatrix;
  7733. private static _TargetTransformMatrix;
  7734. private static _TargetFocalPoint;
  7735. /**
  7736. * Define the current direction the camera is moving to
  7737. */
  7738. cameraDirection: Vector3;
  7739. /**
  7740. * Define the current rotation the camera is rotating to
  7741. */
  7742. cameraRotation: Vector2;
  7743. /**
  7744. * When set, the up vector of the camera will be updated by the rotation of the camera
  7745. */
  7746. updateUpVectorFromRotation: boolean;
  7747. private _tmpQuaternion;
  7748. /**
  7749. * Define the current rotation of the camera
  7750. */
  7751. rotation: Vector3;
  7752. /**
  7753. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7754. */
  7755. rotationQuaternion: Quaternion;
  7756. /**
  7757. * Define the current speed of the camera
  7758. */
  7759. speed: number;
  7760. /**
  7761. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7762. * around all axis.
  7763. */
  7764. noRotationConstraint: boolean;
  7765. /**
  7766. * Define the current target of the camera as an object or a position.
  7767. */
  7768. lockedTarget: any;
  7769. /** @hidden */
  7770. _currentTarget: Vector3;
  7771. /** @hidden */
  7772. _initialFocalDistance: number;
  7773. /** @hidden */
  7774. _viewMatrix: Matrix;
  7775. /** @hidden */
  7776. _camMatrix: Matrix;
  7777. /** @hidden */
  7778. _cameraTransformMatrix: Matrix;
  7779. /** @hidden */
  7780. _cameraRotationMatrix: Matrix;
  7781. /** @hidden */
  7782. _referencePoint: Vector3;
  7783. /** @hidden */
  7784. _transformedReferencePoint: Vector3;
  7785. protected _globalCurrentTarget: Vector3;
  7786. protected _globalCurrentUpVector: Vector3;
  7787. /** @hidden */
  7788. _reset: () => void;
  7789. private _defaultUp;
  7790. /**
  7791. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  7792. * This is the base of the follow, arc rotate cameras and Free camera
  7793. * @see http://doc.babylonjs.com/features/cameras
  7794. * @param name Defines the name of the camera in the scene
  7795. * @param position Defines the start position of the camera in the scene
  7796. * @param scene Defines the scene the camera belongs to
  7797. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7798. */
  7799. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7800. /**
  7801. * Gets the position in front of the camera at a given distance.
  7802. * @param distance The distance from the camera we want the position to be
  7803. * @returns the position
  7804. */
  7805. getFrontPosition(distance: number): Vector3;
  7806. /** @hidden */
  7807. _getLockedTargetPosition(): Nullable<Vector3>;
  7808. private _storedPosition;
  7809. private _storedRotation;
  7810. private _storedRotationQuaternion;
  7811. /**
  7812. * Store current camera state of the camera (fov, position, rotation, etc..)
  7813. * @returns the camera
  7814. */
  7815. storeState(): Camera;
  7816. /**
  7817. * Restored camera state. You must call storeState() first
  7818. * @returns whether it was successful or not
  7819. * @hidden
  7820. */
  7821. _restoreStateValues(): boolean;
  7822. /** @hidden */
  7823. _initCache(): void;
  7824. /** @hidden */
  7825. _updateCache(ignoreParentClass?: boolean): void;
  7826. /** @hidden */
  7827. _isSynchronizedViewMatrix(): boolean;
  7828. /** @hidden */
  7829. _computeLocalCameraSpeed(): number;
  7830. /** @hidden */
  7831. setTarget(target: Vector3): void;
  7832. /**
  7833. * Return the current target position of the camera. This value is expressed in local space.
  7834. * @returns the target position
  7835. */
  7836. getTarget(): Vector3;
  7837. /** @hidden */
  7838. _decideIfNeedsToMove(): boolean;
  7839. /** @hidden */
  7840. _updatePosition(): void;
  7841. /** @hidden */
  7842. _checkInputs(): void;
  7843. protected _updateCameraRotationMatrix(): void;
  7844. /**
  7845. * 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)
  7846. * @returns the current camera
  7847. */
  7848. private _rotateUpVectorWithCameraRotationMatrix;
  7849. private _cachedRotationZ;
  7850. private _cachedQuaternionRotationZ;
  7851. /** @hidden */
  7852. _getViewMatrix(): Matrix;
  7853. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  7854. /**
  7855. * @hidden
  7856. */
  7857. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7858. /**
  7859. * @hidden
  7860. */
  7861. _updateRigCameras(): void;
  7862. private _getRigCamPositionAndTarget;
  7863. /**
  7864. * Gets the current object class name.
  7865. * @return the class name
  7866. */
  7867. getClassName(): string;
  7868. }
  7869. }
  7870. declare module BABYLON {
  7871. /**
  7872. * @ignore
  7873. * This is a list of all the different input types that are available in the application.
  7874. * Fo instance: ArcRotateCameraGamepadInput...
  7875. */
  7876. export var CameraInputTypes: {};
  7877. /**
  7878. * This is the contract to implement in order to create a new input class.
  7879. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  7880. */
  7881. export interface ICameraInput<TCamera extends Camera> {
  7882. /**
  7883. * Defines the camera the input is attached to.
  7884. */
  7885. camera: Nullable<TCamera>;
  7886. /**
  7887. * Gets the class name of the current intput.
  7888. * @returns the class name
  7889. */
  7890. getClassName(): string;
  7891. /**
  7892. * Get the friendly name associated with the input class.
  7893. * @returns the input friendly name
  7894. */
  7895. getSimpleName(): string;
  7896. /**
  7897. * Attach the input controls to a specific dom element to get the input from.
  7898. * @param element Defines the element the controls should be listened from
  7899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7900. */
  7901. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7902. /**
  7903. * Detach the current controls from the specified dom element.
  7904. * @param element Defines the element to stop listening the inputs from
  7905. */
  7906. detachControl(element: Nullable<HTMLElement>): void;
  7907. /**
  7908. * Update the current camera state depending on the inputs that have been used this frame.
  7909. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7910. */
  7911. checkInputs?: () => void;
  7912. }
  7913. /**
  7914. * Represents a map of input types to input instance or input index to input instance.
  7915. */
  7916. export interface CameraInputsMap<TCamera extends Camera> {
  7917. /**
  7918. * Accessor to the input by input type.
  7919. */
  7920. [name: string]: ICameraInput<TCamera>;
  7921. /**
  7922. * Accessor to the input by input index.
  7923. */
  7924. [idx: number]: ICameraInput<TCamera>;
  7925. }
  7926. /**
  7927. * This represents the input manager used within a camera.
  7928. * It helps dealing with all the different kind of input attached to a camera.
  7929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7930. */
  7931. export class CameraInputsManager<TCamera extends Camera> {
  7932. /**
  7933. * Defines the list of inputs attahed to the camera.
  7934. */
  7935. attached: CameraInputsMap<TCamera>;
  7936. /**
  7937. * Defines the dom element the camera is collecting inputs from.
  7938. * This is null if the controls have not been attached.
  7939. */
  7940. attachedElement: Nullable<HTMLElement>;
  7941. /**
  7942. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7943. */
  7944. noPreventDefault: boolean;
  7945. /**
  7946. * Defined the camera the input manager belongs to.
  7947. */
  7948. camera: TCamera;
  7949. /**
  7950. * Update the current camera state depending on the inputs that have been used this frame.
  7951. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7952. */
  7953. checkInputs: () => void;
  7954. /**
  7955. * Instantiate a new Camera Input Manager.
  7956. * @param camera Defines the camera the input manager blongs to
  7957. */
  7958. constructor(camera: TCamera);
  7959. /**
  7960. * Add an input method to a camera
  7961. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7962. * @param input camera input method
  7963. */
  7964. add(input: ICameraInput<TCamera>): void;
  7965. /**
  7966. * Remove a specific input method from a camera
  7967. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  7968. * @param inputToRemove camera input method
  7969. */
  7970. remove(inputToRemove: ICameraInput<TCamera>): void;
  7971. /**
  7972. * Remove a specific input type from a camera
  7973. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  7974. * @param inputType the type of the input to remove
  7975. */
  7976. removeByType(inputType: string): void;
  7977. private _addCheckInputs;
  7978. /**
  7979. * Attach the input controls to the currently attached dom element to listen the events from.
  7980. * @param input Defines the input to attach
  7981. */
  7982. attachInput(input: ICameraInput<TCamera>): void;
  7983. /**
  7984. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  7985. * @param element Defines the dom element to collect the events from
  7986. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7987. */
  7988. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  7989. /**
  7990. * Detach the current manager inputs controls from a specific dom element.
  7991. * @param element Defines the dom element to collect the events from
  7992. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  7993. */
  7994. detachElement(element: HTMLElement, disconnect?: boolean): void;
  7995. /**
  7996. * Rebuild the dynamic inputCheck function from the current list of
  7997. * defined inputs in the manager.
  7998. */
  7999. rebuildInputCheck(): void;
  8000. /**
  8001. * Remove all attached input methods from a camera
  8002. */
  8003. clear(): void;
  8004. /**
  8005. * Serialize the current input manager attached to a camera.
  8006. * This ensures than once parsed,
  8007. * the input associated to the camera will be identical to the current ones
  8008. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8009. */
  8010. serialize(serializedCamera: any): void;
  8011. /**
  8012. * Parses an input manager serialized JSON to restore the previous list of inputs
  8013. * and states associated to a camera.
  8014. * @param parsedCamera Defines the JSON to parse
  8015. */
  8016. parse(parsedCamera: any): void;
  8017. }
  8018. }
  8019. declare module BABYLON {
  8020. /**
  8021. * Gather the list of keyboard event types as constants.
  8022. */
  8023. export class KeyboardEventTypes {
  8024. /**
  8025. * The keydown event is fired when a key becomes active (pressed).
  8026. */
  8027. static readonly KEYDOWN: number;
  8028. /**
  8029. * The keyup event is fired when a key has been released.
  8030. */
  8031. static readonly KEYUP: number;
  8032. }
  8033. /**
  8034. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8035. */
  8036. export class KeyboardInfo {
  8037. /**
  8038. * Defines the type of event (KeyboardEventTypes)
  8039. */
  8040. type: number;
  8041. /**
  8042. * Defines the related dom event
  8043. */
  8044. event: KeyboardEvent;
  8045. /**
  8046. * Instantiates a new keyboard info.
  8047. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8048. * @param type Defines the type of event (KeyboardEventTypes)
  8049. * @param event Defines the related dom event
  8050. */
  8051. constructor(
  8052. /**
  8053. * Defines the type of event (KeyboardEventTypes)
  8054. */
  8055. type: number,
  8056. /**
  8057. * Defines the related dom event
  8058. */
  8059. event: KeyboardEvent);
  8060. }
  8061. /**
  8062. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8063. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8064. */
  8065. export class KeyboardInfoPre extends KeyboardInfo {
  8066. /**
  8067. * Defines the type of event (KeyboardEventTypes)
  8068. */
  8069. type: number;
  8070. /**
  8071. * Defines the related dom event
  8072. */
  8073. event: KeyboardEvent;
  8074. /**
  8075. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8076. */
  8077. skipOnPointerObservable: boolean;
  8078. /**
  8079. * Instantiates a new keyboard pre info.
  8080. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8081. * @param type Defines the type of event (KeyboardEventTypes)
  8082. * @param event Defines the related dom event
  8083. */
  8084. constructor(
  8085. /**
  8086. * Defines the type of event (KeyboardEventTypes)
  8087. */
  8088. type: number,
  8089. /**
  8090. * Defines the related dom event
  8091. */
  8092. event: KeyboardEvent);
  8093. }
  8094. }
  8095. declare module BABYLON {
  8096. /**
  8097. * Manage the keyboard inputs to control the movement of a free camera.
  8098. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8099. */
  8100. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8101. /**
  8102. * Defines the camera the input is attached to.
  8103. */
  8104. camera: FreeCamera;
  8105. /**
  8106. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8107. */
  8108. keysUp: number[];
  8109. /**
  8110. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8111. */
  8112. keysDown: number[];
  8113. /**
  8114. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8115. */
  8116. keysLeft: number[];
  8117. /**
  8118. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8119. */
  8120. keysRight: number[];
  8121. private _keys;
  8122. private _onCanvasBlurObserver;
  8123. private _onKeyboardObserver;
  8124. private _engine;
  8125. private _scene;
  8126. /**
  8127. * Attach the input controls to a specific dom element to get the input from.
  8128. * @param element Defines the element the controls should be listened from
  8129. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8130. */
  8131. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8132. /**
  8133. * Detach the current controls from the specified dom element.
  8134. * @param element Defines the element to stop listening the inputs from
  8135. */
  8136. detachControl(element: Nullable<HTMLElement>): void;
  8137. /**
  8138. * Update the current camera state depending on the inputs that have been used this frame.
  8139. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8140. */
  8141. checkInputs(): void;
  8142. /**
  8143. * Gets the class name of the current intput.
  8144. * @returns the class name
  8145. */
  8146. getClassName(): string;
  8147. /** @hidden */
  8148. _onLostFocus(): void;
  8149. /**
  8150. * Get the friendly name associated with the input class.
  8151. * @returns the input friendly name
  8152. */
  8153. getSimpleName(): string;
  8154. }
  8155. }
  8156. declare module BABYLON {
  8157. /**
  8158. * Gather the list of pointer event types as constants.
  8159. */
  8160. export class PointerEventTypes {
  8161. /**
  8162. * 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.
  8163. */
  8164. static readonly POINTERDOWN: number;
  8165. /**
  8166. * The pointerup event is fired when a pointer is no longer active.
  8167. */
  8168. static readonly POINTERUP: number;
  8169. /**
  8170. * The pointermove event is fired when a pointer changes coordinates.
  8171. */
  8172. static readonly POINTERMOVE: number;
  8173. /**
  8174. * The pointerwheel event is fired when a mouse wheel has been rotated.
  8175. */
  8176. static readonly POINTERWHEEL: number;
  8177. /**
  8178. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  8179. */
  8180. static readonly POINTERPICK: number;
  8181. /**
  8182. * The pointertap event is fired when a the object has been touched and released without drag.
  8183. */
  8184. static readonly POINTERTAP: number;
  8185. /**
  8186. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  8187. */
  8188. static readonly POINTERDOUBLETAP: number;
  8189. }
  8190. /**
  8191. * Base class of pointer info types.
  8192. */
  8193. export class PointerInfoBase {
  8194. /**
  8195. * Defines the type of event (PointerEventTypes)
  8196. */
  8197. type: number;
  8198. /**
  8199. * Defines the related dom event
  8200. */
  8201. event: PointerEvent | MouseWheelEvent;
  8202. /**
  8203. * Instantiates the base class of pointers info.
  8204. * @param type Defines the type of event (PointerEventTypes)
  8205. * @param event Defines the related dom event
  8206. */
  8207. constructor(
  8208. /**
  8209. * Defines the type of event (PointerEventTypes)
  8210. */
  8211. type: number,
  8212. /**
  8213. * Defines the related dom event
  8214. */
  8215. event: PointerEvent | MouseWheelEvent);
  8216. }
  8217. /**
  8218. * This class is used to store pointer related info for the onPrePointerObservable event.
  8219. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  8220. */
  8221. export class PointerInfoPre extends PointerInfoBase {
  8222. /**
  8223. * Ray from a pointer if availible (eg. 6dof controller)
  8224. */
  8225. ray: Nullable<Ray>;
  8226. /**
  8227. * Defines the local position of the pointer on the canvas.
  8228. */
  8229. localPosition: Vector2;
  8230. /**
  8231. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  8232. */
  8233. skipOnPointerObservable: boolean;
  8234. /**
  8235. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  8236. * @param type Defines the type of event (PointerEventTypes)
  8237. * @param event Defines the related dom event
  8238. * @param localX Defines the local x coordinates of the pointer when the event occured
  8239. * @param localY Defines the local y coordinates of the pointer when the event occured
  8240. */
  8241. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  8242. }
  8243. /**
  8244. * This type contains all the data related to a pointer event in Babylon.js.
  8245. * 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.
  8246. */
  8247. export class PointerInfo extends PointerInfoBase {
  8248. /**
  8249. * Defines the picking info associated to the info (if any)\
  8250. */
  8251. pickInfo: Nullable<PickingInfo>;
  8252. /**
  8253. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  8254. * @param type Defines the type of event (PointerEventTypes)
  8255. * @param event Defines the related dom event
  8256. * @param pickInfo Defines the picking info associated to the info (if any)\
  8257. */
  8258. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  8259. /**
  8260. * Defines the picking info associated to the info (if any)\
  8261. */
  8262. pickInfo: Nullable<PickingInfo>);
  8263. }
  8264. }
  8265. declare module BABYLON {
  8266. /**
  8267. * Manage the mouse inputs to control the movement of a free camera.
  8268. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8269. */
  8270. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  8271. /**
  8272. * Define if touch is enabled in the mouse input
  8273. */
  8274. touchEnabled: boolean;
  8275. /**
  8276. * Defines the camera the input is attached to.
  8277. */
  8278. camera: FreeCamera;
  8279. /**
  8280. * Defines the buttons associated with the input to handle camera move.
  8281. */
  8282. buttons: number[];
  8283. /**
  8284. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  8285. */
  8286. angularSensibility: number;
  8287. private _pointerInput;
  8288. private _onMouseMove;
  8289. private _observer;
  8290. private previousPosition;
  8291. /**
  8292. * Manage the mouse inputs to control the movement of a free camera.
  8293. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8294. * @param touchEnabled Defines if touch is enabled or not
  8295. */
  8296. constructor(
  8297. /**
  8298. * Define if touch is enabled in the mouse input
  8299. */
  8300. touchEnabled?: boolean);
  8301. /**
  8302. * Attach the input controls to a specific dom element to get the input from.
  8303. * @param element Defines the element the controls should be listened from
  8304. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8305. */
  8306. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8307. /**
  8308. * Detach the current controls from the specified dom element.
  8309. * @param element Defines the element to stop listening the inputs from
  8310. */
  8311. detachControl(element: Nullable<HTMLElement>): void;
  8312. /**
  8313. * Gets the class name of the current intput.
  8314. * @returns the class name
  8315. */
  8316. getClassName(): string;
  8317. /**
  8318. * Get the friendly name associated with the input class.
  8319. * @returns the input friendly name
  8320. */
  8321. getSimpleName(): string;
  8322. }
  8323. }
  8324. declare module BABYLON {
  8325. /**
  8326. * Manage the touch inputs to control the movement of a free camera.
  8327. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8328. */
  8329. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  8330. /**
  8331. * Defines the camera the input is attached to.
  8332. */
  8333. camera: FreeCamera;
  8334. /**
  8335. * Defines the touch sensibility for rotation.
  8336. * The higher the faster.
  8337. */
  8338. touchAngularSensibility: number;
  8339. /**
  8340. * Defines the touch sensibility for move.
  8341. * The higher the faster.
  8342. */
  8343. touchMoveSensibility: number;
  8344. private _offsetX;
  8345. private _offsetY;
  8346. private _pointerPressed;
  8347. private _pointerInput;
  8348. private _observer;
  8349. private _onLostFocus;
  8350. /**
  8351. * Attach the input controls to a specific dom element to get the input from.
  8352. * @param element Defines the element the controls should be listened from
  8353. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8354. */
  8355. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8356. /**
  8357. * Detach the current controls from the specified dom element.
  8358. * @param element Defines the element to stop listening the inputs from
  8359. */
  8360. detachControl(element: Nullable<HTMLElement>): void;
  8361. /**
  8362. * Update the current camera state depending on the inputs that have been used this frame.
  8363. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8364. */
  8365. checkInputs(): void;
  8366. /**
  8367. * Gets the class name of the current intput.
  8368. * @returns the class name
  8369. */
  8370. getClassName(): string;
  8371. /**
  8372. * Get the friendly name associated with the input class.
  8373. * @returns the input friendly name
  8374. */
  8375. getSimpleName(): string;
  8376. }
  8377. }
  8378. declare module BABYLON {
  8379. /**
  8380. * Default Inputs manager for the FreeCamera.
  8381. * It groups all the default supported inputs for ease of use.
  8382. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8383. */
  8384. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8385. /**
  8386. * Instantiates a new FreeCameraInputsManager.
  8387. * @param camera Defines the camera the inputs belong to
  8388. */
  8389. constructor(camera: FreeCamera);
  8390. /**
  8391. * Add keyboard input support to the input manager.
  8392. * @returns the current input manager
  8393. */
  8394. addKeyboard(): FreeCameraInputsManager;
  8395. /**
  8396. * Add mouse input support to the input manager.
  8397. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8398. * @returns the current input manager
  8399. */
  8400. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8401. /**
  8402. * Add touch input support to the input manager.
  8403. * @returns the current input manager
  8404. */
  8405. addTouch(): FreeCameraInputsManager;
  8406. }
  8407. }
  8408. declare module BABYLON {
  8409. /**
  8410. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8411. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8412. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8413. */
  8414. export class FreeCamera extends TargetCamera {
  8415. /**
  8416. * Define the collision ellipsoid of the camera.
  8417. * This is helpful to simulate a camera body like the player body around the camera
  8418. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8419. */
  8420. ellipsoid: Vector3;
  8421. /**
  8422. * Define an offset for the position of the ellipsoid around the camera.
  8423. * This can be helpful to determine the center of the body near the gravity center of the body
  8424. * instead of its head.
  8425. */
  8426. ellipsoidOffset: Vector3;
  8427. /**
  8428. * Enable or disable collisions of the camera with the rest of the scene objects.
  8429. */
  8430. checkCollisions: boolean;
  8431. /**
  8432. * Enable or disable gravity on the camera.
  8433. */
  8434. applyGravity: boolean;
  8435. /**
  8436. * Define the input manager associated to the camera.
  8437. */
  8438. inputs: FreeCameraInputsManager;
  8439. /**
  8440. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8441. * Higher values reduce sensitivity.
  8442. */
  8443. /**
  8444. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8445. * Higher values reduce sensitivity.
  8446. */
  8447. angularSensibility: number;
  8448. /**
  8449. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8450. */
  8451. keysUp: number[];
  8452. /**
  8453. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8454. */
  8455. keysDown: number[];
  8456. /**
  8457. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8458. */
  8459. keysLeft: number[];
  8460. /**
  8461. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8462. */
  8463. keysRight: number[];
  8464. /**
  8465. * Event raised when the camera collide with a mesh in the scene.
  8466. */
  8467. onCollide: (collidedMesh: AbstractMesh) => void;
  8468. private _collider;
  8469. private _needMoveForGravity;
  8470. private _oldPosition;
  8471. private _diffPosition;
  8472. private _newPosition;
  8473. /** @hidden */
  8474. _localDirection: Vector3;
  8475. /** @hidden */
  8476. _transformedDirection: Vector3;
  8477. /**
  8478. * Instantiates a Free Camera.
  8479. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8480. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8481. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8482. * @param name Define the name of the camera in the scene
  8483. * @param position Define the start position of the camera in the scene
  8484. * @param scene Define the scene the camera belongs to
  8485. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8486. */
  8487. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8488. /**
  8489. * Attached controls to the current camera.
  8490. * @param element Defines the element the controls should be listened from
  8491. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8492. */
  8493. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8494. /**
  8495. * Detach the current controls from the camera.
  8496. * The camera will stop reacting to inputs.
  8497. * @param element Defines the element to stop listening the inputs from
  8498. */
  8499. detachControl(element: HTMLElement): void;
  8500. private _collisionMask;
  8501. /**
  8502. * Define a collision mask to limit the list of object the camera can collide with
  8503. */
  8504. collisionMask: number;
  8505. /** @hidden */
  8506. _collideWithWorld(displacement: Vector3): void;
  8507. private _onCollisionPositionChange;
  8508. /** @hidden */
  8509. _checkInputs(): void;
  8510. /** @hidden */
  8511. _decideIfNeedsToMove(): boolean;
  8512. /** @hidden */
  8513. _updatePosition(): void;
  8514. /**
  8515. * Destroy the camera and release the current resources hold by it.
  8516. */
  8517. dispose(): void;
  8518. /**
  8519. * Gets the current object class name.
  8520. * @return the class name
  8521. */
  8522. getClassName(): string;
  8523. }
  8524. }
  8525. declare module BABYLON {
  8526. /**
  8527. * Represents a gamepad control stick position
  8528. */
  8529. export class StickValues {
  8530. /**
  8531. * The x component of the control stick
  8532. */
  8533. x: number;
  8534. /**
  8535. * The y component of the control stick
  8536. */
  8537. y: number;
  8538. /**
  8539. * Initializes the gamepad x and y control stick values
  8540. * @param x The x component of the gamepad control stick value
  8541. * @param y The y component of the gamepad control stick value
  8542. */
  8543. constructor(
  8544. /**
  8545. * The x component of the control stick
  8546. */
  8547. x: number,
  8548. /**
  8549. * The y component of the control stick
  8550. */
  8551. y: number);
  8552. }
  8553. /**
  8554. * An interface which manages callbacks for gamepad button changes
  8555. */
  8556. export interface GamepadButtonChanges {
  8557. /**
  8558. * Called when a gamepad has been changed
  8559. */
  8560. changed: boolean;
  8561. /**
  8562. * Called when a gamepad press event has been triggered
  8563. */
  8564. pressChanged: boolean;
  8565. /**
  8566. * Called when a touch event has been triggered
  8567. */
  8568. touchChanged: boolean;
  8569. /**
  8570. * Called when a value has changed
  8571. */
  8572. valueChanged: boolean;
  8573. }
  8574. /**
  8575. * Represents a gamepad
  8576. */
  8577. export class Gamepad {
  8578. /**
  8579. * The id of the gamepad
  8580. */
  8581. id: string;
  8582. /**
  8583. * The index of the gamepad
  8584. */
  8585. index: number;
  8586. /**
  8587. * The browser gamepad
  8588. */
  8589. browserGamepad: any;
  8590. /**
  8591. * Specifies what type of gamepad this represents
  8592. */
  8593. type: number;
  8594. private _leftStick;
  8595. private _rightStick;
  8596. /** @hidden */
  8597. _isConnected: boolean;
  8598. private _leftStickAxisX;
  8599. private _leftStickAxisY;
  8600. private _rightStickAxisX;
  8601. private _rightStickAxisY;
  8602. /**
  8603. * Triggered when the left control stick has been changed
  8604. */
  8605. private _onleftstickchanged;
  8606. /**
  8607. * Triggered when the right control stick has been changed
  8608. */
  8609. private _onrightstickchanged;
  8610. /**
  8611. * Represents a gamepad controller
  8612. */
  8613. static GAMEPAD: number;
  8614. /**
  8615. * Represents a generic controller
  8616. */
  8617. static GENERIC: number;
  8618. /**
  8619. * Represents an XBox controller
  8620. */
  8621. static XBOX: number;
  8622. /**
  8623. * Represents a pose-enabled controller
  8624. */
  8625. static POSE_ENABLED: number;
  8626. /**
  8627. * Specifies whether the left control stick should be Y-inverted
  8628. */
  8629. protected _invertLeftStickY: boolean;
  8630. /**
  8631. * Specifies if the gamepad has been connected
  8632. */
  8633. readonly isConnected: boolean;
  8634. /**
  8635. * Initializes the gamepad
  8636. * @param id The id of the gamepad
  8637. * @param index The index of the gamepad
  8638. * @param browserGamepad The browser gamepad
  8639. * @param leftStickX The x component of the left joystick
  8640. * @param leftStickY The y component of the left joystick
  8641. * @param rightStickX The x component of the right joystick
  8642. * @param rightStickY The y component of the right joystick
  8643. */
  8644. constructor(
  8645. /**
  8646. * The id of the gamepad
  8647. */
  8648. id: string,
  8649. /**
  8650. * The index of the gamepad
  8651. */
  8652. index: number,
  8653. /**
  8654. * The browser gamepad
  8655. */
  8656. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  8657. /**
  8658. * Callback triggered when the left joystick has changed
  8659. * @param callback
  8660. */
  8661. onleftstickchanged(callback: (values: StickValues) => void): void;
  8662. /**
  8663. * Callback triggered when the right joystick has changed
  8664. * @param callback
  8665. */
  8666. onrightstickchanged(callback: (values: StickValues) => void): void;
  8667. /**
  8668. * Gets the left joystick
  8669. */
  8670. /**
  8671. * Sets the left joystick values
  8672. */
  8673. leftStick: StickValues;
  8674. /**
  8675. * Gets the right joystick
  8676. */
  8677. /**
  8678. * Sets the right joystick value
  8679. */
  8680. rightStick: StickValues;
  8681. /**
  8682. * Updates the gamepad joystick positions
  8683. */
  8684. update(): void;
  8685. /**
  8686. * Disposes the gamepad
  8687. */
  8688. dispose(): void;
  8689. }
  8690. /**
  8691. * Represents a generic gamepad
  8692. */
  8693. export class GenericPad extends Gamepad {
  8694. private _buttons;
  8695. private _onbuttondown;
  8696. private _onbuttonup;
  8697. /**
  8698. * Observable triggered when a button has been pressed
  8699. */
  8700. onButtonDownObservable: Observable<number>;
  8701. /**
  8702. * Observable triggered when a button has been released
  8703. */
  8704. onButtonUpObservable: Observable<number>;
  8705. /**
  8706. * Callback triggered when a button has been pressed
  8707. * @param callback Called when a button has been pressed
  8708. */
  8709. onbuttondown(callback: (buttonPressed: number) => void): void;
  8710. /**
  8711. * Callback triggered when a button has been released
  8712. * @param callback Called when a button has been released
  8713. */
  8714. onbuttonup(callback: (buttonReleased: number) => void): void;
  8715. /**
  8716. * Initializes the generic gamepad
  8717. * @param id The id of the generic gamepad
  8718. * @param index The index of the generic gamepad
  8719. * @param browserGamepad The browser gamepad
  8720. */
  8721. constructor(id: string, index: number, browserGamepad: any);
  8722. private _setButtonValue;
  8723. /**
  8724. * Updates the generic gamepad
  8725. */
  8726. update(): void;
  8727. /**
  8728. * Disposes the generic gamepad
  8729. */
  8730. dispose(): void;
  8731. }
  8732. }
  8733. declare module BABYLON {
  8734. /**
  8735. * Raw texture can help creating a texture directly from an array of data.
  8736. * This can be super useful if you either get the data from an uncompressed source or
  8737. * if you wish to create your texture pixel by pixel.
  8738. */
  8739. export class RawTexture extends Texture {
  8740. /**
  8741. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  8742. */
  8743. format: number;
  8744. private _engine;
  8745. /**
  8746. * Instantiates a new RawTexture.
  8747. * Raw texture can help creating a texture directly from an array of data.
  8748. * This can be super useful if you either get the data from an uncompressed source or
  8749. * if you wish to create your texture pixel by pixel.
  8750. * @param data define the array of data to use to create the texture
  8751. * @param width define the width of the texture
  8752. * @param height define the height of the texture
  8753. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  8754. * @param scene define the scene the texture belongs to
  8755. * @param generateMipMaps define whether mip maps should be generated or not
  8756. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8757. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8758. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  8759. */
  8760. constructor(data: ArrayBufferView, width: number, height: number,
  8761. /**
  8762. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  8763. */
  8764. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  8765. /**
  8766. * Updates the texture underlying data.
  8767. * @param data Define the new data of the texture
  8768. */
  8769. update(data: ArrayBufferView): void;
  8770. /**
  8771. * Creates a luminance texture from some data.
  8772. * @param data Define the texture data
  8773. * @param width Define the width of the texture
  8774. * @param height Define the height of the texture
  8775. * @param scene Define the scene the texture belongs to
  8776. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8777. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8778. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8779. * @returns the luminance texture
  8780. */
  8781. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  8782. /**
  8783. * Creates a luminance alpha texture from some data.
  8784. * @param data Define the texture data
  8785. * @param width Define the width of the texture
  8786. * @param height Define the height of the texture
  8787. * @param scene Define the scene the texture belongs to
  8788. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8789. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8790. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8791. * @returns the luminance alpha texture
  8792. */
  8793. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  8794. /**
  8795. * Creates an alpha texture from some data.
  8796. * @param data Define the texture data
  8797. * @param width Define the width of the texture
  8798. * @param height Define the height of the texture
  8799. * @param scene Define the scene the texture belongs to
  8800. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8801. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8802. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8803. * @returns the alpha texture
  8804. */
  8805. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  8806. /**
  8807. * Creates a RGB texture from some data.
  8808. * @param data Define the texture data
  8809. * @param width Define the width of the texture
  8810. * @param height Define the height of the texture
  8811. * @param scene Define the scene the texture belongs to
  8812. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8813. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8814. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8815. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  8816. * @returns the RGB alpha texture
  8817. */
  8818. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  8819. /**
  8820. * Creates a RGBA texture from some data.
  8821. * @param data Define the texture data
  8822. * @param width Define the width of the texture
  8823. * @param height Define the height of the texture
  8824. * @param scene Define the scene the texture belongs to
  8825. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8826. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8827. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8828. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  8829. * @returns the RGBA texture
  8830. */
  8831. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  8832. /**
  8833. * Creates a R texture from some data.
  8834. * @param data Define the texture data
  8835. * @param width Define the width of the texture
  8836. * @param height Define the height of the texture
  8837. * @param scene Define the scene the texture belongs to
  8838. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8839. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8840. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8841. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  8842. * @returns the R texture
  8843. */
  8844. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  8845. }
  8846. }
  8847. declare module BABYLON {
  8848. /**
  8849. * Class used to handle skinning animations
  8850. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8851. */
  8852. export class Skeleton implements IAnimatable {
  8853. /** defines the skeleton name */
  8854. name: string;
  8855. /** defines the skeleton Id */
  8856. id: string;
  8857. /**
  8858. * Defines the list of child bones
  8859. */
  8860. bones: Bone[];
  8861. /**
  8862. * Defines an estimate of the dimension of the skeleton at rest
  8863. */
  8864. dimensionsAtRest: Vector3;
  8865. /**
  8866. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  8867. */
  8868. needInitialSkinMatrix: boolean;
  8869. /**
  8870. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  8871. */
  8872. overrideMesh: Nullable<AbstractMesh>;
  8873. /**
  8874. * Gets the list of animations attached to this skeleton
  8875. */
  8876. animations: Array<Animation>;
  8877. private _scene;
  8878. private _isDirty;
  8879. private _transformMatrices;
  8880. private _transformMatrixTexture;
  8881. private _meshesWithPoseMatrix;
  8882. private _animatables;
  8883. private _identity;
  8884. private _synchronizedWithMesh;
  8885. private _ranges;
  8886. private _lastAbsoluteTransformsUpdateId;
  8887. private _canUseTextureForBones;
  8888. /** @hidden */
  8889. _numBonesWithLinkedTransformNode: number;
  8890. /**
  8891. * Specifies if the skeleton should be serialized
  8892. */
  8893. doNotSerialize: boolean;
  8894. /**
  8895. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  8896. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  8897. */
  8898. useTextureToStoreBoneMatrices: boolean;
  8899. private _animationPropertiesOverride;
  8900. /**
  8901. * Gets or sets the animation properties override
  8902. */
  8903. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8904. /**
  8905. * An observable triggered before computing the skeleton's matrices
  8906. */
  8907. onBeforeComputeObservable: Observable<Skeleton>;
  8908. /**
  8909. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  8910. */
  8911. readonly isUsingTextureForMatrices: boolean;
  8912. /**
  8913. * Creates a new skeleton
  8914. * @param name defines the skeleton name
  8915. * @param id defines the skeleton Id
  8916. * @param scene defines the hosting scene
  8917. */
  8918. constructor(
  8919. /** defines the skeleton name */
  8920. name: string,
  8921. /** defines the skeleton Id */
  8922. id: string, scene: Scene);
  8923. /**
  8924. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  8925. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  8926. * @returns a Float32Array containing matrices data
  8927. */
  8928. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  8929. /**
  8930. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  8931. * @returns a raw texture containing the data
  8932. */
  8933. getTransformMatrixTexture(): Nullable<RawTexture>;
  8934. /**
  8935. * Gets the current hosting scene
  8936. * @returns a scene object
  8937. */
  8938. getScene(): Scene;
  8939. /**
  8940. * Gets a string representing the current skeleton data
  8941. * @param fullDetails defines a boolean indicating if we want a verbose version
  8942. * @returns a string representing the current skeleton data
  8943. */
  8944. toString(fullDetails?: boolean): string;
  8945. /**
  8946. * Get bone's index searching by name
  8947. * @param name defines bone's name to search for
  8948. * @return the indice of the bone. Returns -1 if not found
  8949. */
  8950. getBoneIndexByName(name: string): number;
  8951. /**
  8952. * Creater a new animation range
  8953. * @param name defines the name of the range
  8954. * @param from defines the start key
  8955. * @param to defines the end key
  8956. */
  8957. createAnimationRange(name: string, from: number, to: number): void;
  8958. /**
  8959. * Delete a specific animation range
  8960. * @param name defines the name of the range
  8961. * @param deleteFrames defines if frames must be removed as well
  8962. */
  8963. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  8964. /**
  8965. * Gets a specific animation range
  8966. * @param name defines the name of the range to look for
  8967. * @returns the requested animation range or null if not found
  8968. */
  8969. getAnimationRange(name: string): Nullable<AnimationRange>;
  8970. /**
  8971. * Gets the list of all animation ranges defined on this skeleton
  8972. * @returns an array
  8973. */
  8974. getAnimationRanges(): Nullable<AnimationRange>[];
  8975. /**
  8976. * Copy animation range from a source skeleton.
  8977. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  8978. * @param source defines the source skeleton
  8979. * @param name defines the name of the range to copy
  8980. * @param rescaleAsRequired defines if rescaling must be applied if required
  8981. * @returns true if operation was successful
  8982. */
  8983. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  8984. /**
  8985. * Forces the skeleton to go to rest pose
  8986. */
  8987. returnToRest(): void;
  8988. private _getHighestAnimationFrame;
  8989. /**
  8990. * Begin a specific animation range
  8991. * @param name defines the name of the range to start
  8992. * @param loop defines if looping must be turned on (false by default)
  8993. * @param speedRatio defines the speed ratio to apply (1 by default)
  8994. * @param onAnimationEnd defines a callback which will be called when animation will end
  8995. * @returns a new animatable
  8996. */
  8997. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  8998. /** @hidden */
  8999. _markAsDirty(): void;
  9000. /** @hidden */
  9001. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  9002. /** @hidden */
  9003. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  9004. private _computeTransformMatrices;
  9005. /**
  9006. * Build all resources required to render a skeleton
  9007. */
  9008. prepare(): void;
  9009. /**
  9010. * Gets the list of animatables currently running for this skeleton
  9011. * @returns an array of animatables
  9012. */
  9013. getAnimatables(): IAnimatable[];
  9014. /**
  9015. * Clone the current skeleton
  9016. * @param name defines the name of the new skeleton
  9017. * @param id defines the id of the enw skeleton
  9018. * @returns the new skeleton
  9019. */
  9020. clone(name: string, id: string): Skeleton;
  9021. /**
  9022. * Enable animation blending for this skeleton
  9023. * @param blendingSpeed defines the blending speed to apply
  9024. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9025. */
  9026. enableBlending(blendingSpeed?: number): void;
  9027. /**
  9028. * Releases all resources associated with the current skeleton
  9029. */
  9030. dispose(): void;
  9031. /**
  9032. * Serialize the skeleton in a JSON object
  9033. * @returns a JSON object
  9034. */
  9035. serialize(): any;
  9036. /**
  9037. * Creates a new skeleton from serialized data
  9038. * @param parsedSkeleton defines the serialized data
  9039. * @param scene defines the hosting scene
  9040. * @returns a new skeleton
  9041. */
  9042. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  9043. /**
  9044. * Compute all node absolute transforms
  9045. * @param forceUpdate defines if computation must be done even if cache is up to date
  9046. */
  9047. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  9048. /**
  9049. * Gets the root pose matrix
  9050. * @returns a matrix
  9051. */
  9052. getPoseMatrix(): Nullable<Matrix>;
  9053. /**
  9054. * Sorts bones per internal index
  9055. */
  9056. sortBones(): void;
  9057. private _sortBones;
  9058. }
  9059. }
  9060. declare module BABYLON {
  9061. /**
  9062. * Class used to store bone information
  9063. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9064. */
  9065. export class Bone extends Node {
  9066. /**
  9067. * defines the bone name
  9068. */
  9069. name: string;
  9070. private static _tmpVecs;
  9071. private static _tmpQuat;
  9072. private static _tmpMats;
  9073. /**
  9074. * Gets the list of child bones
  9075. */
  9076. children: Bone[];
  9077. /** Gets the animations associated with this bone */
  9078. animations: Animation[];
  9079. /**
  9080. * Gets or sets bone length
  9081. */
  9082. length: number;
  9083. /**
  9084. * @hidden Internal only
  9085. * Set this value to map this bone to a different index in the transform matrices
  9086. * Set this value to -1 to exclude the bone from the transform matrices
  9087. */
  9088. _index: Nullable<number>;
  9089. private _skeleton;
  9090. private _localMatrix;
  9091. private _restPose;
  9092. private _baseMatrix;
  9093. private _absoluteTransform;
  9094. private _invertedAbsoluteTransform;
  9095. private _parent;
  9096. private _scalingDeterminant;
  9097. private _worldTransform;
  9098. private _localScaling;
  9099. private _localRotation;
  9100. private _localPosition;
  9101. private _needToDecompose;
  9102. private _needToCompose;
  9103. /** @hidden */
  9104. _linkedTransformNode: Nullable<TransformNode>;
  9105. /** @hidden */
  9106. /** @hidden */
  9107. _matrix: Matrix;
  9108. /**
  9109. * Create a new bone
  9110. * @param name defines the bone name
  9111. * @param skeleton defines the parent skeleton
  9112. * @param parentBone defines the parent (can be null if the bone is the root)
  9113. * @param localMatrix defines the local matrix
  9114. * @param restPose defines the rest pose matrix
  9115. * @param baseMatrix defines the base matrix
  9116. * @param index defines index of the bone in the hiearchy
  9117. */
  9118. constructor(
  9119. /**
  9120. * defines the bone name
  9121. */
  9122. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  9123. /**
  9124. * Gets the parent skeleton
  9125. * @returns a skeleton
  9126. */
  9127. getSkeleton(): Skeleton;
  9128. /**
  9129. * Gets parent bone
  9130. * @returns a bone or null if the bone is the root of the bone hierarchy
  9131. */
  9132. getParent(): Nullable<Bone>;
  9133. /**
  9134. * Sets the parent bone
  9135. * @param parent defines the parent (can be null if the bone is the root)
  9136. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9137. */
  9138. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  9139. /**
  9140. * Gets the local matrix
  9141. * @returns a matrix
  9142. */
  9143. getLocalMatrix(): Matrix;
  9144. /**
  9145. * Gets the base matrix (initial matrix which remains unchanged)
  9146. * @returns a matrix
  9147. */
  9148. getBaseMatrix(): Matrix;
  9149. /**
  9150. * Gets the rest pose matrix
  9151. * @returns a matrix
  9152. */
  9153. getRestPose(): Matrix;
  9154. /**
  9155. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9156. */
  9157. getWorldMatrix(): Matrix;
  9158. /**
  9159. * Sets the local matrix to rest pose matrix
  9160. */
  9161. returnToRest(): void;
  9162. /**
  9163. * Gets the inverse of the absolute transform matrix.
  9164. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9165. * @returns a matrix
  9166. */
  9167. getInvertedAbsoluteTransform(): Matrix;
  9168. /**
  9169. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9170. * @returns a matrix
  9171. */
  9172. getAbsoluteTransform(): Matrix;
  9173. /**
  9174. * Links with the given transform node.
  9175. * The local matrix of this bone is copied from the transform node every frame.
  9176. * @param transformNode defines the transform node to link to
  9177. */
  9178. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9179. /** Gets or sets current position (in local space) */
  9180. position: Vector3;
  9181. /** Gets or sets current rotation (in local space) */
  9182. rotation: Vector3;
  9183. /** Gets or sets current rotation quaternion (in local space) */
  9184. rotationQuaternion: Quaternion;
  9185. /** Gets or sets current scaling (in local space) */
  9186. scaling: Vector3;
  9187. /**
  9188. * Gets the animation properties override
  9189. */
  9190. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9191. private _decompose;
  9192. private _compose;
  9193. /**
  9194. * Update the base and local matrices
  9195. * @param matrix defines the new base or local matrix
  9196. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9197. * @param updateLocalMatrix defines if the local matrix should be updated
  9198. */
  9199. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9200. /** @hidden */
  9201. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9202. /**
  9203. * Flag the bone as dirty (Forcing it to update everything)
  9204. */
  9205. markAsDirty(): void;
  9206. private _markAsDirtyAndCompose;
  9207. private _markAsDirtyAndDecompose;
  9208. /**
  9209. * Copy an animation range from another bone
  9210. * @param source defines the source bone
  9211. * @param rangeName defines the range name to copy
  9212. * @param frameOffset defines the frame offset
  9213. * @param rescaleAsRequired defines if rescaling must be applied if required
  9214. * @param skelDimensionsRatio defines the scaling ratio
  9215. * @returns true if operation was successful
  9216. */
  9217. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  9218. /**
  9219. * Translate the bone in local or world space
  9220. * @param vec The amount to translate the bone
  9221. * @param space The space that the translation is in
  9222. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9223. */
  9224. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9225. /**
  9226. * Set the postion of the bone in local or world space
  9227. * @param position The position to set the bone
  9228. * @param space The space that the position is in
  9229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9230. */
  9231. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9232. /**
  9233. * Set the absolute position of the bone (world space)
  9234. * @param position The position to set the bone
  9235. * @param mesh The mesh that this bone is attached to
  9236. */
  9237. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9238. /**
  9239. * Scale the bone on the x, y and z axes (in local space)
  9240. * @param x The amount to scale the bone on the x axis
  9241. * @param y The amount to scale the bone on the y axis
  9242. * @param z The amount to scale the bone on the z axis
  9243. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9244. */
  9245. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9246. /**
  9247. * Set the bone scaling in local space
  9248. * @param scale defines the scaling vector
  9249. */
  9250. setScale(scale: Vector3): void;
  9251. /**
  9252. * Gets the current scaling in local space
  9253. * @returns the current scaling vector
  9254. */
  9255. getScale(): Vector3;
  9256. /**
  9257. * Gets the current scaling in local space and stores it in a target vector
  9258. * @param result defines the target vector
  9259. */
  9260. getScaleToRef(result: Vector3): void;
  9261. /**
  9262. * Set the yaw, pitch, and roll of the bone in local or world space
  9263. * @param yaw The rotation of the bone on the y axis
  9264. * @param pitch The rotation of the bone on the x axis
  9265. * @param roll The rotation of the bone on the z axis
  9266. * @param space The space that the axes of rotation are in
  9267. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9268. */
  9269. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9270. /**
  9271. * Add a rotation to the bone on an axis in local or world space
  9272. * @param axis The axis to rotate the bone on
  9273. * @param amount The amount to rotate the bone
  9274. * @param space The space that the axis is in
  9275. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9276. */
  9277. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9278. /**
  9279. * Set the rotation of the bone to a particular axis angle in local or world space
  9280. * @param axis The axis to rotate the bone on
  9281. * @param angle The angle that the bone should be rotated to
  9282. * @param space The space that the axis is in
  9283. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9284. */
  9285. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9286. /**
  9287. * Set the euler rotation of the bone in local of world space
  9288. * @param rotation The euler rotation that the bone should be set to
  9289. * @param space The space that the rotation is in
  9290. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9291. */
  9292. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9293. /**
  9294. * Set the quaternion rotation of the bone in local of world space
  9295. * @param quat The quaternion rotation that the bone should be set to
  9296. * @param space The space that the rotation is in
  9297. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9298. */
  9299. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9300. /**
  9301. * Set the rotation matrix of the bone in local of world space
  9302. * @param rotMat The rotation matrix that the bone should be set to
  9303. * @param space The space that the rotation is in
  9304. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9305. */
  9306. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9307. private _rotateWithMatrix;
  9308. private _getNegativeRotationToRef;
  9309. /**
  9310. * Get the position of the bone in local or world space
  9311. * @param space The space that the returned position is in
  9312. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9313. * @returns The position of the bone
  9314. */
  9315. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9316. /**
  9317. * Copy the position of the bone to a vector3 in local or world space
  9318. * @param space The space that the returned position is in
  9319. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9320. * @param result The vector3 to copy the position to
  9321. */
  9322. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9323. /**
  9324. * Get the absolute position of the bone (world space)
  9325. * @param mesh The mesh that this bone is attached to
  9326. * @returns The absolute position of the bone
  9327. */
  9328. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9329. /**
  9330. * Copy the absolute position of the bone (world space) to the result param
  9331. * @param mesh The mesh that this bone is attached to
  9332. * @param result The vector3 to copy the absolute position to
  9333. */
  9334. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9335. /**
  9336. * Compute the absolute transforms of this bone and its children
  9337. */
  9338. computeAbsoluteTransforms(): void;
  9339. /**
  9340. * Get the world direction from an axis that is in the local space of the bone
  9341. * @param localAxis The local direction that is used to compute the world direction
  9342. * @param mesh The mesh that this bone is attached to
  9343. * @returns The world direction
  9344. */
  9345. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9346. /**
  9347. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9348. * @param localAxis The local direction that is used to compute the world direction
  9349. * @param mesh The mesh that this bone is attached to
  9350. * @param result The vector3 that the world direction will be copied to
  9351. */
  9352. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9353. /**
  9354. * Get the euler rotation of the bone in local or world space
  9355. * @param space The space that the rotation should be in
  9356. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9357. * @returns The euler rotation
  9358. */
  9359. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9360. /**
  9361. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9362. * @param space The space that the rotation should be in
  9363. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9364. * @param result The vector3 that the rotation should be copied to
  9365. */
  9366. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9367. /**
  9368. * Get the quaternion rotation of the bone in either local or world space
  9369. * @param space The space that the rotation should be in
  9370. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9371. * @returns The quaternion rotation
  9372. */
  9373. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9374. /**
  9375. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9376. * @param space The space that the rotation should be in
  9377. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9378. * @param result The quaternion that the rotation should be copied to
  9379. */
  9380. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9381. /**
  9382. * Get the rotation matrix of the bone in local or world space
  9383. * @param space The space that the rotation should be in
  9384. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9385. * @returns The rotation matrix
  9386. */
  9387. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9388. /**
  9389. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9390. * @param space The space that the rotation should be in
  9391. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9392. * @param result The quaternion that the rotation should be copied to
  9393. */
  9394. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9395. /**
  9396. * Get the world position of a point that is in the local space of the bone
  9397. * @param position The local position
  9398. * @param mesh The mesh that this bone is attached to
  9399. * @returns The world position
  9400. */
  9401. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9402. /**
  9403. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9404. * @param position The local position
  9405. * @param mesh The mesh that this bone is attached to
  9406. * @param result The vector3 that the world position should be copied to
  9407. */
  9408. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9409. /**
  9410. * Get the local position of a point that is in world space
  9411. * @param position The world position
  9412. * @param mesh The mesh that this bone is attached to
  9413. * @returns The local position
  9414. */
  9415. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9416. /**
  9417. * Get the local position of a point that is in world space and copy it to the result param
  9418. * @param position The world position
  9419. * @param mesh The mesh that this bone is attached to
  9420. * @param result The vector3 that the local position should be copied to
  9421. */
  9422. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9423. }
  9424. }
  9425. declare module BABYLON {
  9426. /**
  9427. * 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.
  9428. * @see https://doc.babylonjs.com/how_to/transformnode
  9429. */
  9430. export class TransformNode extends Node {
  9431. /**
  9432. * Object will not rotate to face the camera
  9433. */
  9434. static BILLBOARDMODE_NONE: number;
  9435. /**
  9436. * Object will rotate to face the camera but only on the x axis
  9437. */
  9438. static BILLBOARDMODE_X: number;
  9439. /**
  9440. * Object will rotate to face the camera but only on the y axis
  9441. */
  9442. static BILLBOARDMODE_Y: number;
  9443. /**
  9444. * Object will rotate to face the camera but only on the z axis
  9445. */
  9446. static BILLBOARDMODE_Z: number;
  9447. /**
  9448. * Object will rotate to face the camera
  9449. */
  9450. static BILLBOARDMODE_ALL: number;
  9451. private _forward;
  9452. private _forwardInverted;
  9453. private _up;
  9454. private _right;
  9455. private _rightInverted;
  9456. private _position;
  9457. private _rotation;
  9458. private _rotationQuaternion;
  9459. protected _scaling: Vector3;
  9460. protected _isDirty: boolean;
  9461. private _transformToBoneReferal;
  9462. /**
  9463. * Set the billboard mode. Default is 0.
  9464. *
  9465. * | Value | Type | Description |
  9466. * | --- | --- | --- |
  9467. * | 0 | BILLBOARDMODE_NONE | |
  9468. * | 1 | BILLBOARDMODE_X | |
  9469. * | 2 | BILLBOARDMODE_Y | |
  9470. * | 4 | BILLBOARDMODE_Z | |
  9471. * | 7 | BILLBOARDMODE_ALL | |
  9472. *
  9473. */
  9474. billboardMode: number;
  9475. /**
  9476. * 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
  9477. */
  9478. scalingDeterminant: number;
  9479. /**
  9480. * Sets the distance of the object to max, often used by skybox
  9481. */
  9482. infiniteDistance: boolean;
  9483. /**
  9484. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  9485. * By default the system will update normals to compensate
  9486. */
  9487. ignoreNonUniformScaling: boolean;
  9488. /** @hidden */
  9489. _poseMatrix: Matrix;
  9490. /** @hidden */
  9491. _localMatrix: Matrix;
  9492. private _absolutePosition;
  9493. private _pivotMatrix;
  9494. private _pivotMatrixInverse;
  9495. protected _postMultiplyPivotMatrix: boolean;
  9496. protected _isWorldMatrixFrozen: boolean;
  9497. /** @hidden */
  9498. _indexInSceneTransformNodesArray: number;
  9499. /**
  9500. * An event triggered after the world matrix is updated
  9501. */
  9502. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  9503. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  9504. /**
  9505. * Gets a string identifying the name of the class
  9506. * @returns "TransformNode" string
  9507. */
  9508. getClassName(): string;
  9509. /**
  9510. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  9511. */
  9512. position: Vector3;
  9513. /**
  9514. * 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)).
  9515. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  9516. */
  9517. rotation: Vector3;
  9518. /**
  9519. * 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)).
  9520. */
  9521. scaling: Vector3;
  9522. /**
  9523. * 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).
  9524. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  9525. */
  9526. rotationQuaternion: Nullable<Quaternion>;
  9527. /**
  9528. * The forward direction of that transform in world space.
  9529. */
  9530. readonly forward: Vector3;
  9531. /**
  9532. * The up direction of that transform in world space.
  9533. */
  9534. readonly up: Vector3;
  9535. /**
  9536. * The right direction of that transform in world space.
  9537. */
  9538. readonly right: Vector3;
  9539. /**
  9540. * Copies the parameter passed Matrix into the mesh Pose matrix.
  9541. * @param matrix the matrix to copy the pose from
  9542. * @returns this TransformNode.
  9543. */
  9544. updatePoseMatrix(matrix: Matrix): TransformNode;
  9545. /**
  9546. * Returns the mesh Pose matrix.
  9547. * @returns the pose matrix
  9548. */
  9549. getPoseMatrix(): Matrix;
  9550. /** @hidden */
  9551. _isSynchronized(): boolean;
  9552. /** @hidden */
  9553. _initCache(): void;
  9554. /**
  9555. * Flag the transform node as dirty (Forcing it to update everything)
  9556. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  9557. * @returns this transform node
  9558. */
  9559. markAsDirty(property: string): TransformNode;
  9560. /**
  9561. * Returns the current mesh absolute position.
  9562. * Returns a Vector3.
  9563. */
  9564. readonly absolutePosition: Vector3;
  9565. /**
  9566. * Sets a new matrix to apply before all other transformation
  9567. * @param matrix defines the transform matrix
  9568. * @returns the current TransformNode
  9569. */
  9570. setPreTransformMatrix(matrix: Matrix): TransformNode;
  9571. /**
  9572. * Sets a new pivot matrix to the current node
  9573. * @param matrix defines the new pivot matrix to use
  9574. * @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
  9575. * @returns the current TransformNode
  9576. */
  9577. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  9578. /**
  9579. * Returns the mesh pivot matrix.
  9580. * Default : Identity.
  9581. * @returns the matrix
  9582. */
  9583. getPivotMatrix(): Matrix;
  9584. /**
  9585. * Prevents the World matrix to be computed any longer.
  9586. * @returns the TransformNode.
  9587. */
  9588. freezeWorldMatrix(): TransformNode;
  9589. /**
  9590. * Allows back the World matrix computation.
  9591. * @returns the TransformNode.
  9592. */
  9593. unfreezeWorldMatrix(): this;
  9594. /**
  9595. * True if the World matrix has been frozen.
  9596. */
  9597. readonly isWorldMatrixFrozen: boolean;
  9598. /**
  9599. * Retuns the mesh absolute position in the World.
  9600. * @returns a Vector3.
  9601. */
  9602. getAbsolutePosition(): Vector3;
  9603. /**
  9604. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  9605. * @param absolutePosition the absolute position to set
  9606. * @returns the TransformNode.
  9607. */
  9608. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  9609. /**
  9610. * Sets the mesh position in its local space.
  9611. * @param vector3 the position to set in localspace
  9612. * @returns the TransformNode.
  9613. */
  9614. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  9615. /**
  9616. * Returns the mesh position in the local space from the current World matrix values.
  9617. * @returns a new Vector3.
  9618. */
  9619. getPositionExpressedInLocalSpace(): Vector3;
  9620. /**
  9621. * Translates the mesh along the passed Vector3 in its local space.
  9622. * @param vector3 the distance to translate in localspace
  9623. * @returns the TransformNode.
  9624. */
  9625. locallyTranslate(vector3: Vector3): TransformNode;
  9626. private static _lookAtVectorCache;
  9627. /**
  9628. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  9629. * @param targetPoint the position (must be in same space as current mesh) to look at
  9630. * @param yawCor optional yaw (y-axis) correction in radians
  9631. * @param pitchCor optional pitch (x-axis) correction in radians
  9632. * @param rollCor optional roll (z-axis) correction in radians
  9633. * @param space the choosen space of the target
  9634. * @returns the TransformNode.
  9635. */
  9636. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  9637. /**
  9638. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  9639. * This Vector3 is expressed in the World space.
  9640. * @param localAxis axis to rotate
  9641. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  9642. */
  9643. getDirection(localAxis: Vector3): Vector3;
  9644. /**
  9645. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  9646. * localAxis is expressed in the mesh local space.
  9647. * result is computed in the Wordl space from the mesh World matrix.
  9648. * @param localAxis axis to rotate
  9649. * @param result the resulting transformnode
  9650. * @returns this TransformNode.
  9651. */
  9652. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  9653. /**
  9654. * Sets this transform node rotation to the given local axis.
  9655. * @param localAxis the axis in local space
  9656. * @param yawCor optional yaw (y-axis) correction in radians
  9657. * @param pitchCor optional pitch (x-axis) correction in radians
  9658. * @param rollCor optional roll (z-axis) correction in radians
  9659. * @returns this TransformNode
  9660. */
  9661. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  9662. /**
  9663. * Sets a new pivot point to the current node
  9664. * @param point defines the new pivot point to use
  9665. * @param space defines if the point is in world or local space (local by default)
  9666. * @returns the current TransformNode
  9667. */
  9668. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  9669. /**
  9670. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  9671. * @returns the pivot point
  9672. */
  9673. getPivotPoint(): Vector3;
  9674. /**
  9675. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  9676. * @param result the vector3 to store the result
  9677. * @returns this TransformNode.
  9678. */
  9679. getPivotPointToRef(result: Vector3): TransformNode;
  9680. /**
  9681. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  9682. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  9683. */
  9684. getAbsolutePivotPoint(): Vector3;
  9685. /**
  9686. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  9687. * @param result vector3 to store the result
  9688. * @returns this TransformNode.
  9689. */
  9690. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  9691. /**
  9692. * Defines the passed node as the parent of the current node.
  9693. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  9694. * @param node the node ot set as the parent
  9695. * @returns this TransformNode.
  9696. */
  9697. setParent(node: Nullable<Node>): TransformNode;
  9698. private _nonUniformScaling;
  9699. /**
  9700. * True if the scaling property of this object is non uniform eg. (1,2,1)
  9701. */
  9702. readonly nonUniformScaling: boolean;
  9703. /** @hidden */
  9704. _updateNonUniformScalingState(value: boolean): boolean;
  9705. /**
  9706. * Attach the current TransformNode to another TransformNode associated with a bone
  9707. * @param bone Bone affecting the TransformNode
  9708. * @param affectedTransformNode TransformNode associated with the bone
  9709. * @returns this object
  9710. */
  9711. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  9712. /**
  9713. * Detach the transform node if its associated with a bone
  9714. * @returns this object
  9715. */
  9716. detachFromBone(): TransformNode;
  9717. private static _rotationAxisCache;
  9718. /**
  9719. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  9720. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  9721. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  9722. * The passed axis is also normalized.
  9723. * @param axis the axis to rotate around
  9724. * @param amount the amount to rotate in radians
  9725. * @param space Space to rotate in (Default: local)
  9726. * @returns the TransformNode.
  9727. */
  9728. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  9729. /**
  9730. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  9731. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  9732. * The passed axis is also normalized. .
  9733. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  9734. * @param point the point to rotate around
  9735. * @param axis the axis to rotate around
  9736. * @param amount the amount to rotate in radians
  9737. * @returns the TransformNode
  9738. */
  9739. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  9740. /**
  9741. * Translates the mesh along the axis vector for the passed distance in the given space.
  9742. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  9743. * @param axis the axis to translate in
  9744. * @param distance the distance to translate
  9745. * @param space Space to rotate in (Default: local)
  9746. * @returns the TransformNode.
  9747. */
  9748. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  9749. /**
  9750. * Adds a rotation step to the mesh current rotation.
  9751. * x, y, z are Euler angles expressed in radians.
  9752. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  9753. * This means this rotation is made in the mesh local space only.
  9754. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  9755. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  9756. * ```javascript
  9757. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  9758. * ```
  9759. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  9760. * 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.
  9761. * @param x Rotation to add
  9762. * @param y Rotation to add
  9763. * @param z Rotation to add
  9764. * @returns the TransformNode.
  9765. */
  9766. addRotation(x: number, y: number, z: number): TransformNode;
  9767. /**
  9768. * Computes the world matrix of the node
  9769. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9770. * @returns the world matrix
  9771. */
  9772. computeWorldMatrix(force?: boolean): Matrix;
  9773. protected _afterComputeWorldMatrix(): void;
  9774. /**
  9775. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  9776. * @param func callback function to add
  9777. *
  9778. * @returns the TransformNode.
  9779. */
  9780. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  9781. /**
  9782. * Removes a registered callback function.
  9783. * @param func callback function to remove
  9784. * @returns the TransformNode.
  9785. */
  9786. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  9787. /**
  9788. * Gets the position of the current mesh in camera space
  9789. * @param camera defines the camera to use
  9790. * @returns a position
  9791. */
  9792. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  9793. /**
  9794. * Returns the distance from the mesh to the active camera
  9795. * @param camera defines the camera to use
  9796. * @returns the distance
  9797. */
  9798. getDistanceToCamera(camera?: Nullable<Camera>): number;
  9799. /**
  9800. * Clone the current transform node
  9801. * @param name Name of the new clone
  9802. * @param newParent New parent for the clone
  9803. * @param doNotCloneChildren Do not clone children hierarchy
  9804. * @returns the new transform node
  9805. */
  9806. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  9807. /**
  9808. * Serializes the objects information.
  9809. * @param currentSerializationObject defines the object to serialize in
  9810. * @returns the serialized object
  9811. */
  9812. serialize(currentSerializationObject?: any): any;
  9813. /**
  9814. * Returns a new TransformNode object parsed from the source provided.
  9815. * @param parsedTransformNode is the source.
  9816. * @param scene the scne the object belongs to
  9817. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  9818. * @returns a new TransformNode object parsed from the source provided.
  9819. */
  9820. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  9821. /**
  9822. * Get all child-transformNodes of this node
  9823. * @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
  9824. * @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
  9825. * @returns an array of TransformNode
  9826. */
  9827. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  9828. /**
  9829. * Releases resources associated with this transform node.
  9830. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9831. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9832. */
  9833. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9834. }
  9835. }
  9836. declare module BABYLON {
  9837. /**
  9838. * Defines the types of pose enabled controllers that are supported
  9839. */
  9840. export enum PoseEnabledControllerType {
  9841. /**
  9842. * HTC Vive
  9843. */
  9844. VIVE = 0,
  9845. /**
  9846. * Oculus Rift
  9847. */
  9848. OCULUS = 1,
  9849. /**
  9850. * Windows mixed reality
  9851. */
  9852. WINDOWS = 2,
  9853. /**
  9854. * Samsung gear VR
  9855. */
  9856. GEAR_VR = 3,
  9857. /**
  9858. * Google Daydream
  9859. */
  9860. DAYDREAM = 4,
  9861. /**
  9862. * Generic
  9863. */
  9864. GENERIC = 5
  9865. }
  9866. /**
  9867. * Defines the MutableGamepadButton interface for the state of a gamepad button
  9868. */
  9869. export interface MutableGamepadButton {
  9870. /**
  9871. * Value of the button/trigger
  9872. */
  9873. value: number;
  9874. /**
  9875. * If the button/trigger is currently touched
  9876. */
  9877. touched: boolean;
  9878. /**
  9879. * If the button/trigger is currently pressed
  9880. */
  9881. pressed: boolean;
  9882. }
  9883. /**
  9884. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  9885. * @hidden
  9886. */
  9887. export interface ExtendedGamepadButton extends GamepadButton {
  9888. /**
  9889. * If the button/trigger is currently pressed
  9890. */
  9891. readonly pressed: boolean;
  9892. /**
  9893. * If the button/trigger is currently touched
  9894. */
  9895. readonly touched: boolean;
  9896. /**
  9897. * Value of the button/trigger
  9898. */
  9899. readonly value: number;
  9900. }
  9901. /** @hidden */
  9902. export interface _GamePadFactory {
  9903. /**
  9904. * Returns wether or not the current gamepad can be created for this type of controller.
  9905. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  9906. * @returns true if it can be created, otherwise false
  9907. */
  9908. canCreate(gamepadInfo: any): boolean;
  9909. /**
  9910. * Creates a new instance of the Gamepad.
  9911. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  9912. * @returns the new gamepad instance
  9913. */
  9914. create(gamepadInfo: any): Gamepad;
  9915. }
  9916. /**
  9917. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  9918. */
  9919. export class PoseEnabledControllerHelper {
  9920. /** @hidden */
  9921. static _ControllerFactories: _GamePadFactory[];
  9922. /** @hidden */
  9923. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  9924. /**
  9925. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  9926. * @param vrGamepad the gamepad to initialized
  9927. * @returns a vr controller of the type the gamepad identified as
  9928. */
  9929. static InitiateController(vrGamepad: any): Gamepad;
  9930. }
  9931. /**
  9932. * Defines the PoseEnabledController object that contains state of a vr capable controller
  9933. */
  9934. export class PoseEnabledController extends Gamepad implements PoseControlled {
  9935. private _deviceRoomPosition;
  9936. private _deviceRoomRotationQuaternion;
  9937. /**
  9938. * The device position in babylon space
  9939. */
  9940. devicePosition: Vector3;
  9941. /**
  9942. * The device rotation in babylon space
  9943. */
  9944. deviceRotationQuaternion: Quaternion;
  9945. /**
  9946. * The scale factor of the device in babylon space
  9947. */
  9948. deviceScaleFactor: number;
  9949. /**
  9950. * (Likely devicePosition should be used instead) The device position in its room space
  9951. */
  9952. position: Vector3;
  9953. /**
  9954. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  9955. */
  9956. rotationQuaternion: Quaternion;
  9957. /**
  9958. * The type of controller (Eg. Windows mixed reality)
  9959. */
  9960. controllerType: PoseEnabledControllerType;
  9961. protected _calculatedPosition: Vector3;
  9962. private _calculatedRotation;
  9963. /**
  9964. * The raw pose from the device
  9965. */
  9966. rawPose: DevicePose;
  9967. private _trackPosition;
  9968. private _maxRotationDistFromHeadset;
  9969. private _draggedRoomRotation;
  9970. /**
  9971. * @hidden
  9972. */
  9973. _disableTrackPosition(fixedPosition: Vector3): void;
  9974. /**
  9975. * Internal, the mesh attached to the controller
  9976. * @hidden
  9977. */
  9978. _mesh: Nullable<AbstractMesh>;
  9979. private _poseControlledCamera;
  9980. private _leftHandSystemQuaternion;
  9981. /**
  9982. * Internal, matrix used to convert room space to babylon space
  9983. * @hidden
  9984. */
  9985. _deviceToWorld: Matrix;
  9986. /**
  9987. * Node to be used when casting a ray from the controller
  9988. * @hidden
  9989. */
  9990. _pointingPoseNode: Nullable<TransformNode>;
  9991. /**
  9992. * Name of the child mesh that can be used to cast a ray from the controller
  9993. */
  9994. static readonly POINTING_POSE: string;
  9995. /**
  9996. * Creates a new PoseEnabledController from a gamepad
  9997. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  9998. */
  9999. constructor(browserGamepad: any);
  10000. private _workingMatrix;
  10001. /**
  10002. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  10003. */
  10004. update(): void;
  10005. /**
  10006. * Updates only the pose device and mesh without doing any button event checking
  10007. */
  10008. protected _updatePoseAndMesh(): void;
  10009. /**
  10010. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  10011. * @param poseData raw pose fromthe device
  10012. */
  10013. updateFromDevice(poseData: DevicePose): void;
  10014. /**
  10015. * @hidden
  10016. */
  10017. _meshAttachedObservable: Observable<AbstractMesh>;
  10018. /**
  10019. * Attaches a mesh to the controller
  10020. * @param mesh the mesh to be attached
  10021. */
  10022. attachToMesh(mesh: AbstractMesh): void;
  10023. /**
  10024. * Attaches the controllers mesh to a camera
  10025. * @param camera the camera the mesh should be attached to
  10026. */
  10027. attachToPoseControlledCamera(camera: TargetCamera): void;
  10028. /**
  10029. * Disposes of the controller
  10030. */
  10031. dispose(): void;
  10032. /**
  10033. * The mesh that is attached to the controller
  10034. */
  10035. readonly mesh: Nullable<AbstractMesh>;
  10036. /**
  10037. * Gets the ray of the controller in the direction the controller is pointing
  10038. * @param length the length the resulting ray should be
  10039. * @returns a ray in the direction the controller is pointing
  10040. */
  10041. getForwardRay(length?: number): Ray;
  10042. }
  10043. }
  10044. declare module BABYLON {
  10045. /**
  10046. * Defines the WebVRController object that represents controllers tracked in 3D space
  10047. */
  10048. export abstract class WebVRController extends PoseEnabledController {
  10049. /**
  10050. * Internal, the default controller model for the controller
  10051. */
  10052. protected _defaultModel: AbstractMesh;
  10053. /**
  10054. * Fired when the trigger state has changed
  10055. */
  10056. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  10057. /**
  10058. * Fired when the main button state has changed
  10059. */
  10060. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  10061. /**
  10062. * Fired when the secondary button state has changed
  10063. */
  10064. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  10065. /**
  10066. * Fired when the pad state has changed
  10067. */
  10068. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  10069. /**
  10070. * Fired when controllers stick values have changed
  10071. */
  10072. onPadValuesChangedObservable: Observable<StickValues>;
  10073. /**
  10074. * Array of button availible on the controller
  10075. */
  10076. protected _buttons: Array<MutableGamepadButton>;
  10077. private _onButtonStateChange;
  10078. /**
  10079. * Fired when a controller button's state has changed
  10080. * @param callback the callback containing the button that was modified
  10081. */
  10082. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  10083. /**
  10084. * X and Y axis corrisponding to the controllers joystick
  10085. */
  10086. pad: StickValues;
  10087. /**
  10088. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  10089. */
  10090. hand: string;
  10091. /**
  10092. * The default controller model for the controller
  10093. */
  10094. readonly defaultModel: AbstractMesh;
  10095. /**
  10096. * Creates a new WebVRController from a gamepad
  10097. * @param vrGamepad the gamepad that the WebVRController should be created from
  10098. */
  10099. constructor(vrGamepad: any);
  10100. /**
  10101. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  10102. */
  10103. update(): void;
  10104. /**
  10105. * Function to be called when a button is modified
  10106. */
  10107. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  10108. /**
  10109. * Loads a mesh and attaches it to the controller
  10110. * @param scene the scene the mesh should be added to
  10111. * @param meshLoaded callback for when the mesh has been loaded
  10112. */
  10113. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  10114. private _setButtonValue;
  10115. private _changes;
  10116. private _checkChanges;
  10117. /**
  10118. * Disposes of th webVRCOntroller
  10119. */
  10120. dispose(): void;
  10121. }
  10122. }
  10123. declare module BABYLON {
  10124. /**
  10125. * Interface describing all the common properties and methods a shadow light needs to implement.
  10126. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10127. * as well as binding the different shadow properties to the effects.
  10128. */
  10129. export interface IShadowLight extends Light {
  10130. /**
  10131. * The light id in the scene (used in scene.findLighById for instance)
  10132. */
  10133. id: string;
  10134. /**
  10135. * The position the shdow will be casted from.
  10136. */
  10137. position: Vector3;
  10138. /**
  10139. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10140. */
  10141. direction: Vector3;
  10142. /**
  10143. * The transformed position. Position of the light in world space taking parenting in account.
  10144. */
  10145. transformedPosition: Vector3;
  10146. /**
  10147. * The transformed direction. Direction of the light in world space taking parenting in account.
  10148. */
  10149. transformedDirection: Vector3;
  10150. /**
  10151. * The friendly name of the light in the scene.
  10152. */
  10153. name: string;
  10154. /**
  10155. * Defines the shadow projection clipping minimum z value.
  10156. */
  10157. shadowMinZ: number;
  10158. /**
  10159. * Defines the shadow projection clipping maximum z value.
  10160. */
  10161. shadowMaxZ: number;
  10162. /**
  10163. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10164. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10165. */
  10166. computeTransformedInformation(): boolean;
  10167. /**
  10168. * Gets the scene the light belongs to.
  10169. * @returns The scene
  10170. */
  10171. getScene(): Scene;
  10172. /**
  10173. * Callback defining a custom Projection Matrix Builder.
  10174. * This can be used to override the default projection matrix computation.
  10175. */
  10176. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10177. /**
  10178. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10179. * @param matrix The materix to updated with the projection information
  10180. * @param viewMatrix The transform matrix of the light
  10181. * @param renderList The list of mesh to render in the map
  10182. * @returns The current light
  10183. */
  10184. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10185. /**
  10186. * Gets the current depth scale used in ESM.
  10187. * @returns The scale
  10188. */
  10189. getDepthScale(): number;
  10190. /**
  10191. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10192. * @returns true if a cube texture needs to be use
  10193. */
  10194. needCube(): boolean;
  10195. /**
  10196. * Detects if the projection matrix requires to be recomputed this frame.
  10197. * @returns true if it requires to be recomputed otherwise, false.
  10198. */
  10199. needProjectionMatrixCompute(): boolean;
  10200. /**
  10201. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10202. */
  10203. forceProjectionMatrixCompute(): void;
  10204. /**
  10205. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10206. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10207. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10208. */
  10209. getShadowDirection(faceIndex?: number): Vector3;
  10210. /**
  10211. * Gets the minZ used for shadow according to both the scene and the light.
  10212. * @param activeCamera The camera we are returning the min for
  10213. * @returns the depth min z
  10214. */
  10215. getDepthMinZ(activeCamera: Camera): number;
  10216. /**
  10217. * Gets the maxZ used for shadow according to both the scene and the light.
  10218. * @param activeCamera The camera we are returning the max for
  10219. * @returns the depth max z
  10220. */
  10221. getDepthMaxZ(activeCamera: Camera): number;
  10222. }
  10223. /**
  10224. * Base implementation IShadowLight
  10225. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10226. */
  10227. export abstract class ShadowLight extends Light implements IShadowLight {
  10228. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10229. protected _position: Vector3;
  10230. protected _setPosition(value: Vector3): void;
  10231. /**
  10232. * Sets the position the shadow will be casted from. Also use as the light position for both
  10233. * point and spot lights.
  10234. */
  10235. /**
  10236. * Sets the position the shadow will be casted from. Also use as the light position for both
  10237. * point and spot lights.
  10238. */
  10239. position: Vector3;
  10240. protected _direction: Vector3;
  10241. protected _setDirection(value: Vector3): void;
  10242. /**
  10243. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10244. * Also use as the light direction on spot and directional lights.
  10245. */
  10246. /**
  10247. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10248. * Also use as the light direction on spot and directional lights.
  10249. */
  10250. direction: Vector3;
  10251. private _shadowMinZ;
  10252. /**
  10253. * Gets the shadow projection clipping minimum z value.
  10254. */
  10255. /**
  10256. * Sets the shadow projection clipping minimum z value.
  10257. */
  10258. shadowMinZ: number;
  10259. private _shadowMaxZ;
  10260. /**
  10261. * Sets the shadow projection clipping maximum z value.
  10262. */
  10263. /**
  10264. * Gets the shadow projection clipping maximum z value.
  10265. */
  10266. shadowMaxZ: number;
  10267. /**
  10268. * Callback defining a custom Projection Matrix Builder.
  10269. * This can be used to override the default projection matrix computation.
  10270. */
  10271. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10272. /**
  10273. * The transformed position. Position of the light in world space taking parenting in account.
  10274. */
  10275. transformedPosition: Vector3;
  10276. /**
  10277. * The transformed direction. Direction of the light in world space taking parenting in account.
  10278. */
  10279. transformedDirection: Vector3;
  10280. private _needProjectionMatrixCompute;
  10281. /**
  10282. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10283. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10284. */
  10285. computeTransformedInformation(): boolean;
  10286. /**
  10287. * Return the depth scale used for the shadow map.
  10288. * @returns the depth scale.
  10289. */
  10290. getDepthScale(): number;
  10291. /**
  10292. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10293. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10294. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10295. */
  10296. getShadowDirection(faceIndex?: number): Vector3;
  10297. /**
  10298. * Returns the ShadowLight absolute position in the World.
  10299. * @returns the position vector in world space
  10300. */
  10301. getAbsolutePosition(): Vector3;
  10302. /**
  10303. * Sets the ShadowLight direction toward the passed target.
  10304. * @param target The point tot target in local space
  10305. * @returns the updated ShadowLight direction
  10306. */
  10307. setDirectionToTarget(target: Vector3): Vector3;
  10308. /**
  10309. * Returns the light rotation in euler definition.
  10310. * @returns the x y z rotation in local space.
  10311. */
  10312. getRotation(): Vector3;
  10313. /**
  10314. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10315. * @returns true if a cube texture needs to be use
  10316. */
  10317. needCube(): boolean;
  10318. /**
  10319. * Detects if the projection matrix requires to be recomputed this frame.
  10320. * @returns true if it requires to be recomputed otherwise, false.
  10321. */
  10322. needProjectionMatrixCompute(): boolean;
  10323. /**
  10324. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10325. */
  10326. forceProjectionMatrixCompute(): void;
  10327. /** @hidden */
  10328. _initCache(): void;
  10329. /** @hidden */
  10330. _isSynchronized(): boolean;
  10331. /**
  10332. * Computes the world matrix of the node
  10333. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10334. * @returns the world matrix
  10335. */
  10336. computeWorldMatrix(force?: boolean): Matrix;
  10337. /**
  10338. * Gets the minZ used for shadow according to both the scene and the light.
  10339. * @param activeCamera The camera we are returning the min for
  10340. * @returns the depth min z
  10341. */
  10342. getDepthMinZ(activeCamera: Camera): number;
  10343. /**
  10344. * Gets the maxZ used for shadow according to both the scene and the light.
  10345. * @param activeCamera The camera we are returning the max for
  10346. * @returns the depth max z
  10347. */
  10348. getDepthMaxZ(activeCamera: Camera): number;
  10349. /**
  10350. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10351. * @param matrix The materix to updated with the projection information
  10352. * @param viewMatrix The transform matrix of the light
  10353. * @param renderList The list of mesh to render in the map
  10354. * @returns The current light
  10355. */
  10356. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10357. }
  10358. }
  10359. declare module BABYLON {
  10360. /**
  10361. * "Static Class" containing the most commonly used helper while dealing with material for
  10362. * rendering purpose.
  10363. *
  10364. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  10365. *
  10366. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  10367. */
  10368. export class MaterialHelper {
  10369. /**
  10370. * Bind the current view position to an effect.
  10371. * @param effect The effect to be bound
  10372. * @param scene The scene the eyes position is used from
  10373. */
  10374. static BindEyePosition(effect: Effect, scene: Scene): void;
  10375. /**
  10376. * Helps preparing the defines values about the UVs in used in the effect.
  10377. * UVs are shared as much as we can accross channels in the shaders.
  10378. * @param texture The texture we are preparing the UVs for
  10379. * @param defines The defines to update
  10380. * @param key The channel key "diffuse", "specular"... used in the shader
  10381. */
  10382. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  10383. /**
  10384. * Binds a texture matrix value to its corrsponding uniform
  10385. * @param texture The texture to bind the matrix for
  10386. * @param uniformBuffer The uniform buffer receivin the data
  10387. * @param key The channel key "diffuse", "specular"... used in the shader
  10388. */
  10389. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  10390. /**
  10391. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  10392. * @param mesh defines the current mesh
  10393. * @param scene defines the current scene
  10394. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  10395. * @param pointsCloud defines if point cloud rendering has to be turned on
  10396. * @param fogEnabled defines if fog has to be turned on
  10397. * @param alphaTest defines if alpha testing has to be turned on
  10398. * @param defines defines the current list of defines
  10399. */
  10400. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  10401. /**
  10402. * Helper used to prepare the list of defines associated with frame values for shader compilation
  10403. * @param scene defines the current scene
  10404. * @param engine defines the current engine
  10405. * @param defines specifies the list of active defines
  10406. * @param useInstances defines if instances have to be turned on
  10407. * @param useClipPlane defines if clip plane have to be turned on
  10408. */
  10409. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  10410. /**
  10411. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  10412. * @param mesh The mesh containing the geometry data we will draw
  10413. * @param defines The defines to update
  10414. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  10415. * @param useBones Precise whether bones should be used or not (override mesh info)
  10416. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  10417. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  10418. * @returns false if defines are considered not dirty and have not been checked
  10419. */
  10420. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  10421. /**
  10422. * Prepares the defines related to the light information passed in parameter
  10423. * @param scene The scene we are intending to draw
  10424. * @param mesh The mesh the effect is compiling for
  10425. * @param defines The defines to update
  10426. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10427. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  10428. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  10429. * @returns true if normals will be required for the rest of the effect
  10430. */
  10431. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  10432. /**
  10433. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  10434. * that won t be acctive due to defines being turned off.
  10435. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  10436. * @param samplersList The samplers list
  10437. * @param defines The defines helping in the list generation
  10438. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  10439. */
  10440. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  10441. /**
  10442. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  10443. * @param defines The defines to update while falling back
  10444. * @param fallbacks The authorized effect fallbacks
  10445. * @param maxSimultaneousLights The maximum number of lights allowed
  10446. * @param rank the current rank of the Effect
  10447. * @returns The newly affected rank
  10448. */
  10449. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  10450. /**
  10451. * Prepares the list of attributes required for morph targets according to the effect defines.
  10452. * @param attribs The current list of supported attribs
  10453. * @param mesh The mesh to prepare the morph targets attributes for
  10454. * @param defines The current Defines of the effect
  10455. */
  10456. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  10457. /**
  10458. * Prepares the list of attributes required for bones according to the effect defines.
  10459. * @param attribs The current list of supported attribs
  10460. * @param mesh The mesh to prepare the bones attributes for
  10461. * @param defines The current Defines of the effect
  10462. * @param fallbacks The current efffect fallback strategy
  10463. */
  10464. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  10465. /**
  10466. * Prepares the list of attributes required for instances according to the effect defines.
  10467. * @param attribs The current list of supported attribs
  10468. * @param defines The current Defines of the effect
  10469. */
  10470. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  10471. /**
  10472. * Binds the light shadow information to the effect for the given mesh.
  10473. * @param light The light containing the generator
  10474. * @param scene The scene the lights belongs to
  10475. * @param mesh The mesh we are binding the information to render
  10476. * @param lightIndex The light index in the effect used to render the mesh
  10477. * @param effect The effect we are binding the data to
  10478. */
  10479. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  10480. /**
  10481. * Binds the light information to the effect.
  10482. * @param light The light containing the generator
  10483. * @param effect The effect we are binding the data to
  10484. * @param lightIndex The light index in the effect used to render
  10485. */
  10486. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  10487. /**
  10488. * Binds the lights information from the scene to the effect for the given mesh.
  10489. * @param scene The scene the lights belongs to
  10490. * @param mesh The mesh we are binding the information to render
  10491. * @param effect The effect we are binding the data to
  10492. * @param defines The generated defines for the effect
  10493. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  10494. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10495. */
  10496. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  10497. private static _tempFogColor;
  10498. /**
  10499. * Binds the fog information from the scene to the effect for the given mesh.
  10500. * @param scene The scene the lights belongs to
  10501. * @param mesh The mesh we are binding the information to render
  10502. * @param effect The effect we are binding the data to
  10503. * @param linearSpace Defines if the fog effect is applied in linear space
  10504. */
  10505. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  10506. /**
  10507. * Binds the bones information from the mesh to the effect.
  10508. * @param mesh The mesh we are binding the information to render
  10509. * @param effect The effect we are binding the data to
  10510. */
  10511. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  10512. /**
  10513. * Binds the morph targets information from the mesh to the effect.
  10514. * @param abstractMesh The mesh we are binding the information to render
  10515. * @param effect The effect we are binding the data to
  10516. */
  10517. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  10518. /**
  10519. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  10520. * @param defines The generated defines used in the effect
  10521. * @param effect The effect we are binding the data to
  10522. * @param scene The scene we are willing to render with logarithmic scale for
  10523. */
  10524. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  10525. /**
  10526. * Binds the clip plane information from the scene to the effect.
  10527. * @param scene The scene the clip plane information are extracted from
  10528. * @param effect The effect we are binding the data to
  10529. */
  10530. static BindClipPlane(effect: Effect, scene: Scene): void;
  10531. }
  10532. }
  10533. declare module BABYLON {
  10534. /** @hidden */
  10535. export var shadowMapPixelShader: {
  10536. name: string;
  10537. shader: string;
  10538. };
  10539. }
  10540. declare module BABYLON {
  10541. /** @hidden */
  10542. export var bonesDeclaration: {
  10543. name: string;
  10544. shader: string;
  10545. };
  10546. }
  10547. declare module BABYLON {
  10548. /** @hidden */
  10549. export var morphTargetsVertexGlobalDeclaration: {
  10550. name: string;
  10551. shader: string;
  10552. };
  10553. }
  10554. declare module BABYLON {
  10555. /** @hidden */
  10556. export var morphTargetsVertexDeclaration: {
  10557. name: string;
  10558. shader: string;
  10559. };
  10560. }
  10561. declare module BABYLON {
  10562. /** @hidden */
  10563. export var instancesDeclaration: {
  10564. name: string;
  10565. shader: string;
  10566. };
  10567. }
  10568. declare module BABYLON {
  10569. /** @hidden */
  10570. export var helperFunctions: {
  10571. name: string;
  10572. shader: string;
  10573. };
  10574. }
  10575. declare module BABYLON {
  10576. /** @hidden */
  10577. export var morphTargetsVertex: {
  10578. name: string;
  10579. shader: string;
  10580. };
  10581. }
  10582. declare module BABYLON {
  10583. /** @hidden */
  10584. export var instancesVertex: {
  10585. name: string;
  10586. shader: string;
  10587. };
  10588. }
  10589. declare module BABYLON {
  10590. /** @hidden */
  10591. export var bonesVertex: {
  10592. name: string;
  10593. shader: string;
  10594. };
  10595. }
  10596. declare module BABYLON {
  10597. /** @hidden */
  10598. export var shadowMapVertexShader: {
  10599. name: string;
  10600. shader: string;
  10601. };
  10602. }
  10603. declare module BABYLON {
  10604. /** @hidden */
  10605. export var depthBoxBlurPixelShader: {
  10606. name: string;
  10607. shader: string;
  10608. };
  10609. }
  10610. declare module BABYLON {
  10611. /**
  10612. * Defines the options associated with the creation of a custom shader for a shadow generator.
  10613. */
  10614. export interface ICustomShaderOptions {
  10615. /**
  10616. * Gets or sets the custom shader name to use
  10617. */
  10618. shaderName: string;
  10619. /**
  10620. * The list of attribute names used in the shader
  10621. */
  10622. attributes?: string[];
  10623. /**
  10624. * The list of unifrom names used in the shader
  10625. */
  10626. uniforms?: string[];
  10627. /**
  10628. * The list of sampler names used in the shader
  10629. */
  10630. samplers?: string[];
  10631. /**
  10632. * The list of defines used in the shader
  10633. */
  10634. defines?: string[];
  10635. }
  10636. /**
  10637. * Interface to implement to create a shadow generator compatible with BJS.
  10638. */
  10639. export interface IShadowGenerator {
  10640. /**
  10641. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10642. * @returns The render target texture if present otherwise, null
  10643. */
  10644. getShadowMap(): Nullable<RenderTargetTexture>;
  10645. /**
  10646. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10647. * @returns The render target texture if the shadow map is present otherwise, null
  10648. */
  10649. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10650. /**
  10651. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10652. * @param subMesh The submesh we want to render in the shadow map
  10653. * @param useInstances Defines wether will draw in the map using instances
  10654. * @returns true if ready otherwise, false
  10655. */
  10656. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10657. /**
  10658. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10659. * @param defines Defines of the material we want to update
  10660. * @param lightIndex Index of the light in the enabled light list of the material
  10661. */
  10662. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  10663. /**
  10664. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10665. * defined in the generator but impacting the effect).
  10666. * It implies the unifroms available on the materials are the standard BJS ones.
  10667. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10668. * @param effect The effect we are binfing the information for
  10669. */
  10670. bindShadowLight(lightIndex: string, effect: Effect): void;
  10671. /**
  10672. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10673. * (eq to shadow prjection matrix * light transform matrix)
  10674. * @returns The transform matrix used to create the shadow map
  10675. */
  10676. getTransformMatrix(): Matrix;
  10677. /**
  10678. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10679. * Cube and 2D textures for instance.
  10680. */
  10681. recreateShadowMap(): void;
  10682. /**
  10683. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10684. * @param onCompiled Callback triggered at the and of the effects compilation
  10685. * @param options Sets of optional options forcing the compilation with different modes
  10686. */
  10687. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10688. useInstances: boolean;
  10689. }>): void;
  10690. /**
  10691. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10692. * @param options Sets of optional options forcing the compilation with different modes
  10693. * @returns A promise that resolves when the compilation completes
  10694. */
  10695. forceCompilationAsync(options?: Partial<{
  10696. useInstances: boolean;
  10697. }>): Promise<void>;
  10698. /**
  10699. * Serializes the shadow generator setup to a json object.
  10700. * @returns The serialized JSON object
  10701. */
  10702. serialize(): any;
  10703. /**
  10704. * Disposes the Shadow map and related Textures and effects.
  10705. */
  10706. dispose(): void;
  10707. }
  10708. /**
  10709. * Default implementation IShadowGenerator.
  10710. * This is the main object responsible of generating shadows in the framework.
  10711. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  10712. */
  10713. export class ShadowGenerator implements IShadowGenerator {
  10714. /**
  10715. * Shadow generator mode None: no filtering applied.
  10716. */
  10717. static readonly FILTER_NONE: number;
  10718. /**
  10719. * Shadow generator mode ESM: Exponential Shadow Mapping.
  10720. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10721. */
  10722. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  10723. /**
  10724. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  10725. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  10726. */
  10727. static readonly FILTER_POISSONSAMPLING: number;
  10728. /**
  10729. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  10730. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10731. */
  10732. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  10733. /**
  10734. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  10735. * edge artifacts on steep falloff.
  10736. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10737. */
  10738. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  10739. /**
  10740. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  10741. * edge artifacts on steep falloff.
  10742. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10743. */
  10744. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  10745. /**
  10746. * Shadow generator mode PCF: Percentage Closer Filtering
  10747. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10748. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  10749. */
  10750. static readonly FILTER_PCF: number;
  10751. /**
  10752. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  10753. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10754. * Contact Hardening
  10755. */
  10756. static readonly FILTER_PCSS: number;
  10757. /**
  10758. * Reserved for PCF and PCSS
  10759. * Highest Quality.
  10760. *
  10761. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  10762. *
  10763. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  10764. */
  10765. static readonly QUALITY_HIGH: number;
  10766. /**
  10767. * Reserved for PCF and PCSS
  10768. * Good tradeoff for quality/perf cross devices
  10769. *
  10770. * Execute PCF on a 3*3 kernel.
  10771. *
  10772. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  10773. */
  10774. static readonly QUALITY_MEDIUM: number;
  10775. /**
  10776. * Reserved for PCF and PCSS
  10777. * The lowest quality but the fastest.
  10778. *
  10779. * Execute PCF on a 1*1 kernel.
  10780. *
  10781. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  10782. */
  10783. static readonly QUALITY_LOW: number;
  10784. /** Gets or sets the custom shader name to use */
  10785. customShaderOptions: ICustomShaderOptions;
  10786. /**
  10787. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  10788. */
  10789. onBeforeShadowMapRenderObservable: Observable<Effect>;
  10790. private _bias;
  10791. /**
  10792. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  10793. */
  10794. /**
  10795. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  10796. */
  10797. bias: number;
  10798. private _normalBias;
  10799. /**
  10800. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10801. */
  10802. /**
  10803. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10804. */
  10805. normalBias: number;
  10806. private _blurBoxOffset;
  10807. /**
  10808. * Gets the blur box offset: offset applied during the blur pass.
  10809. * Only useful if useKernelBlur = false
  10810. */
  10811. /**
  10812. * Sets the blur box offset: offset applied during the blur pass.
  10813. * Only useful if useKernelBlur = false
  10814. */
  10815. blurBoxOffset: number;
  10816. private _blurScale;
  10817. /**
  10818. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10819. * 2 means half of the size.
  10820. */
  10821. /**
  10822. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10823. * 2 means half of the size.
  10824. */
  10825. blurScale: number;
  10826. private _blurKernel;
  10827. /**
  10828. * Gets the blur kernel: kernel size of the blur pass.
  10829. * Only useful if useKernelBlur = true
  10830. */
  10831. /**
  10832. * Sets the blur kernel: kernel size of the blur pass.
  10833. * Only useful if useKernelBlur = true
  10834. */
  10835. blurKernel: number;
  10836. private _useKernelBlur;
  10837. /**
  10838. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  10839. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10840. */
  10841. /**
  10842. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  10843. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10844. */
  10845. useKernelBlur: boolean;
  10846. private _depthScale;
  10847. /**
  10848. * Gets the depth scale used in ESM mode.
  10849. */
  10850. /**
  10851. * Sets the depth scale used in ESM mode.
  10852. * This can override the scale stored on the light.
  10853. */
  10854. depthScale: number;
  10855. private _filter;
  10856. /**
  10857. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  10858. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10859. */
  10860. /**
  10861. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10862. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10863. */
  10864. filter: number;
  10865. /**
  10866. * Gets if the current filter is set to Poisson Sampling.
  10867. */
  10868. /**
  10869. * Sets the current filter to Poisson Sampling.
  10870. */
  10871. usePoissonSampling: boolean;
  10872. /**
  10873. * Gets if the current filter is set to ESM.
  10874. */
  10875. /**
  10876. * Sets the current filter is to ESM.
  10877. */
  10878. useExponentialShadowMap: boolean;
  10879. /**
  10880. * Gets if the current filter is set to filtered ESM.
  10881. */
  10882. /**
  10883. * Gets if the current filter is set to filtered ESM.
  10884. */
  10885. useBlurExponentialShadowMap: boolean;
  10886. /**
  10887. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10888. * exponential to prevent steep falloff artifacts).
  10889. */
  10890. /**
  10891. * Sets the current filter to "close ESM" (using the inverse of the
  10892. * exponential to prevent steep falloff artifacts).
  10893. */
  10894. useCloseExponentialShadowMap: boolean;
  10895. /**
  10896. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10897. * exponential to prevent steep falloff artifacts).
  10898. */
  10899. /**
  10900. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10901. * exponential to prevent steep falloff artifacts).
  10902. */
  10903. useBlurCloseExponentialShadowMap: boolean;
  10904. /**
  10905. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10906. */
  10907. /**
  10908. * Sets the current filter to "PCF" (percentage closer filtering).
  10909. */
  10910. usePercentageCloserFiltering: boolean;
  10911. private _filteringQuality;
  10912. /**
  10913. * Gets the PCF or PCSS Quality.
  10914. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10915. */
  10916. /**
  10917. * Sets the PCF or PCSS Quality.
  10918. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10919. */
  10920. filteringQuality: number;
  10921. /**
  10922. * Gets if the current filter is set to "PCSS" (contact hardening).
  10923. */
  10924. /**
  10925. * Sets the current filter to "PCSS" (contact hardening).
  10926. */
  10927. useContactHardeningShadow: boolean;
  10928. private _contactHardeningLightSizeUVRatio;
  10929. /**
  10930. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10931. * Using a ratio helps keeping shape stability independently of the map size.
  10932. *
  10933. * It does not account for the light projection as it was having too much
  10934. * instability during the light setup or during light position changes.
  10935. *
  10936. * Only valid if useContactHardeningShadow is true.
  10937. */
  10938. /**
  10939. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10940. * Using a ratio helps keeping shape stability independently of the map size.
  10941. *
  10942. * It does not account for the light projection as it was having too much
  10943. * instability during the light setup or during light position changes.
  10944. *
  10945. * Only valid if useContactHardeningShadow is true.
  10946. */
  10947. contactHardeningLightSizeUVRatio: number;
  10948. private _darkness;
  10949. /**
  10950. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10951. * 0 means strongest and 1 would means no shadow.
  10952. * @returns the darkness.
  10953. */
  10954. getDarkness(): number;
  10955. /**
  10956. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10957. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10958. * @returns the shadow generator allowing fluent coding.
  10959. */
  10960. setDarkness(darkness: number): ShadowGenerator;
  10961. private _transparencyShadow;
  10962. /**
  10963. * Sets the ability to have transparent shadow (boolean).
  10964. * @param transparent True if transparent else False
  10965. * @returns the shadow generator allowing fluent coding
  10966. */
  10967. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10968. private _shadowMap;
  10969. private _shadowMap2;
  10970. /**
  10971. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10972. * @returns The render target texture if present otherwise, null
  10973. */
  10974. getShadowMap(): Nullable<RenderTargetTexture>;
  10975. /**
  10976. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10977. * @returns The render target texture if the shadow map is present otherwise, null
  10978. */
  10979. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10980. /**
  10981. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10982. * @param mesh Mesh to add
  10983. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10984. * @returns the Shadow Generator itself
  10985. */
  10986. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10987. /**
  10988. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10989. * @param mesh Mesh to remove
  10990. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10991. * @returns the Shadow Generator itself
  10992. */
  10993. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10994. /**
  10995. * Controls the extent to which the shadows fade out at the edge of the frustum
  10996. * Used only by directionals and spots
  10997. */
  10998. frustumEdgeFalloff: number;
  10999. private _light;
  11000. /**
  11001. * Returns the associated light object.
  11002. * @returns the light generating the shadow
  11003. */
  11004. getLight(): IShadowLight;
  11005. /**
  11006. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11007. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11008. * It might on the other hand introduce peter panning.
  11009. */
  11010. forceBackFacesOnly: boolean;
  11011. private _scene;
  11012. private _lightDirection;
  11013. private _effect;
  11014. private _viewMatrix;
  11015. private _projectionMatrix;
  11016. private _transformMatrix;
  11017. private _cachedPosition;
  11018. private _cachedDirection;
  11019. private _cachedDefines;
  11020. private _currentRenderID;
  11021. private _boxBlurPostprocess;
  11022. private _kernelBlurXPostprocess;
  11023. private _kernelBlurYPostprocess;
  11024. private _blurPostProcesses;
  11025. private _mapSize;
  11026. private _currentFaceIndex;
  11027. private _currentFaceIndexCache;
  11028. private _textureType;
  11029. private _defaultTextureMatrix;
  11030. /** @hidden */
  11031. static _SceneComponentInitialization: (scene: Scene) => void;
  11032. /**
  11033. * Creates a ShadowGenerator object.
  11034. * A ShadowGenerator is the required tool to use the shadows.
  11035. * Each light casting shadows needs to use its own ShadowGenerator.
  11036. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11037. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11038. * @param light The light object generating the shadows.
  11039. * @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.
  11040. */
  11041. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11042. private _initializeGenerator;
  11043. private _initializeShadowMap;
  11044. private _initializeBlurRTTAndPostProcesses;
  11045. private _renderForShadowMap;
  11046. private _renderSubMeshForShadowMap;
  11047. private _applyFilterValues;
  11048. /**
  11049. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11050. * @param onCompiled Callback triggered at the and of the effects compilation
  11051. * @param options Sets of optional options forcing the compilation with different modes
  11052. */
  11053. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11054. useInstances: boolean;
  11055. }>): void;
  11056. /**
  11057. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11058. * @param options Sets of optional options forcing the compilation with different modes
  11059. * @returns A promise that resolves when the compilation completes
  11060. */
  11061. forceCompilationAsync(options?: Partial<{
  11062. useInstances: boolean;
  11063. }>): Promise<void>;
  11064. /**
  11065. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11066. * @param subMesh The submesh we want to render in the shadow map
  11067. * @param useInstances Defines wether will draw in the map using instances
  11068. * @returns true if ready otherwise, false
  11069. */
  11070. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11071. /**
  11072. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11073. * @param defines Defines of the material we want to update
  11074. * @param lightIndex Index of the light in the enabled light list of the material
  11075. */
  11076. prepareDefines(defines: any, lightIndex: number): void;
  11077. /**
  11078. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11079. * defined in the generator but impacting the effect).
  11080. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11081. * @param effect The effect we are binfing the information for
  11082. */
  11083. bindShadowLight(lightIndex: string, effect: Effect): void;
  11084. /**
  11085. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11086. * (eq to shadow prjection matrix * light transform matrix)
  11087. * @returns The transform matrix used to create the shadow map
  11088. */
  11089. getTransformMatrix(): Matrix;
  11090. /**
  11091. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11092. * Cube and 2D textures for instance.
  11093. */
  11094. recreateShadowMap(): void;
  11095. private _disposeBlurPostProcesses;
  11096. private _disposeRTTandPostProcesses;
  11097. /**
  11098. * Disposes the ShadowGenerator.
  11099. * Returns nothing.
  11100. */
  11101. dispose(): void;
  11102. /**
  11103. * Serializes the shadow generator setup to a json object.
  11104. * @returns The serialized JSON object
  11105. */
  11106. serialize(): any;
  11107. /**
  11108. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11109. * @param parsedShadowGenerator The JSON object to parse
  11110. * @param scene The scene to create the shadow map for
  11111. * @returns The parsed shadow generator
  11112. */
  11113. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11114. }
  11115. }
  11116. declare module BABYLON {
  11117. /**
  11118. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11119. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11120. * 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.
  11121. */
  11122. export abstract class Light extends Node {
  11123. /**
  11124. * Falloff Default: light is falling off following the material specification:
  11125. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11126. */
  11127. static readonly FALLOFF_DEFAULT: number;
  11128. /**
  11129. * Falloff Physical: light is falling off following the inverse squared distance law.
  11130. */
  11131. static readonly FALLOFF_PHYSICAL: number;
  11132. /**
  11133. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11134. * to enhance interoperability with other engines.
  11135. */
  11136. static readonly FALLOFF_GLTF: number;
  11137. /**
  11138. * Falloff Standard: light is falling off like in the standard material
  11139. * to enhance interoperability with other materials.
  11140. */
  11141. static readonly FALLOFF_STANDARD: number;
  11142. /**
  11143. * If every light affecting the material is in this lightmapMode,
  11144. * material.lightmapTexture adds or multiplies
  11145. * (depends on material.useLightmapAsShadowmap)
  11146. * after every other light calculations.
  11147. */
  11148. static readonly LIGHTMAP_DEFAULT: number;
  11149. /**
  11150. * material.lightmapTexture as only diffuse lighting from this light
  11151. * adds only specular lighting from this light
  11152. * adds dynamic shadows
  11153. */
  11154. static readonly LIGHTMAP_SPECULAR: number;
  11155. /**
  11156. * material.lightmapTexture as only lighting
  11157. * no light calculation from this light
  11158. * only adds dynamic shadows from this light
  11159. */
  11160. static readonly LIGHTMAP_SHADOWSONLY: number;
  11161. /**
  11162. * Each light type uses the default quantity according to its type:
  11163. * point/spot lights use luminous intensity
  11164. * directional lights use illuminance
  11165. */
  11166. static readonly INTENSITYMODE_AUTOMATIC: number;
  11167. /**
  11168. * lumen (lm)
  11169. */
  11170. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11171. /**
  11172. * candela (lm/sr)
  11173. */
  11174. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11175. /**
  11176. * lux (lm/m^2)
  11177. */
  11178. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11179. /**
  11180. * nit (cd/m^2)
  11181. */
  11182. static readonly INTENSITYMODE_LUMINANCE: number;
  11183. /**
  11184. * Light type const id of the point light.
  11185. */
  11186. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11187. /**
  11188. * Light type const id of the directional light.
  11189. */
  11190. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11191. /**
  11192. * Light type const id of the spot light.
  11193. */
  11194. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11195. /**
  11196. * Light type const id of the hemispheric light.
  11197. */
  11198. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11199. /**
  11200. * Diffuse gives the basic color to an object.
  11201. */
  11202. diffuse: Color3;
  11203. /**
  11204. * Specular produces a highlight color on an object.
  11205. * Note: This is note affecting PBR materials.
  11206. */
  11207. specular: Color3;
  11208. /**
  11209. * Defines the falloff type for this light. This lets overrriding how punctual light are
  11210. * falling off base on range or angle.
  11211. * This can be set to any values in Light.FALLOFF_x.
  11212. *
  11213. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  11214. * other types of materials.
  11215. */
  11216. falloffType: number;
  11217. /**
  11218. * Strength of the light.
  11219. * Note: By default it is define in the framework own unit.
  11220. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11221. */
  11222. intensity: number;
  11223. private _range;
  11224. protected _inverseSquaredRange: number;
  11225. /**
  11226. * Defines how far from the source the light is impacting in scene units.
  11227. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11228. */
  11229. /**
  11230. * Defines how far from the source the light is impacting in scene units.
  11231. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11232. */
  11233. range: number;
  11234. /**
  11235. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11236. * of light.
  11237. */
  11238. private _photometricScale;
  11239. private _intensityMode;
  11240. /**
  11241. * Gets the photometric scale used to interpret the intensity.
  11242. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11243. */
  11244. /**
  11245. * Sets the photometric scale used to interpret the intensity.
  11246. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11247. */
  11248. intensityMode: number;
  11249. private _radius;
  11250. /**
  11251. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11252. */
  11253. /**
  11254. * sets the light radius used by PBR Materials to simulate soft area lights.
  11255. */
  11256. radius: number;
  11257. private _renderPriority;
  11258. /**
  11259. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11260. * exceeding the number allowed of the materials.
  11261. */
  11262. renderPriority: number;
  11263. private _shadowEnabled;
  11264. /**
  11265. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11266. * the current shadow generator.
  11267. */
  11268. /**
  11269. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11270. * the current shadow generator.
  11271. */
  11272. shadowEnabled: boolean;
  11273. private _includedOnlyMeshes;
  11274. /**
  11275. * Gets the only meshes impacted by this light.
  11276. */
  11277. /**
  11278. * Sets the only meshes impacted by this light.
  11279. */
  11280. includedOnlyMeshes: AbstractMesh[];
  11281. private _excludedMeshes;
  11282. /**
  11283. * Gets the meshes not impacted by this light.
  11284. */
  11285. /**
  11286. * Sets the meshes not impacted by this light.
  11287. */
  11288. excludedMeshes: AbstractMesh[];
  11289. private _excludeWithLayerMask;
  11290. /**
  11291. * Gets the layer id use to find what meshes are not impacted by the light.
  11292. * Inactive if 0
  11293. */
  11294. /**
  11295. * Sets the layer id use to find what meshes are not impacted by the light.
  11296. * Inactive if 0
  11297. */
  11298. excludeWithLayerMask: number;
  11299. private _includeOnlyWithLayerMask;
  11300. /**
  11301. * Gets the layer id use to find what meshes are impacted by the light.
  11302. * Inactive if 0
  11303. */
  11304. /**
  11305. * Sets the layer id use to find what meshes are impacted by the light.
  11306. * Inactive if 0
  11307. */
  11308. includeOnlyWithLayerMask: number;
  11309. private _lightmapMode;
  11310. /**
  11311. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11312. */
  11313. /**
  11314. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11315. */
  11316. lightmapMode: number;
  11317. /**
  11318. * Shadow generator associted to the light.
  11319. * @hidden Internal use only.
  11320. */
  11321. _shadowGenerator: Nullable<IShadowGenerator>;
  11322. /**
  11323. * @hidden Internal use only.
  11324. */
  11325. _excludedMeshesIds: string[];
  11326. /**
  11327. * @hidden Internal use only.
  11328. */
  11329. _includedOnlyMeshesIds: string[];
  11330. /**
  11331. * The current light unifom buffer.
  11332. * @hidden Internal use only.
  11333. */
  11334. _uniformBuffer: UniformBuffer;
  11335. /**
  11336. * Creates a Light object in the scene.
  11337. * Documentation : https://doc.babylonjs.com/babylon101/lights
  11338. * @param name The firendly name of the light
  11339. * @param scene The scene the light belongs too
  11340. */
  11341. constructor(name: string, scene: Scene);
  11342. protected abstract _buildUniformLayout(): void;
  11343. /**
  11344. * Sets the passed Effect "effect" with the Light information.
  11345. * @param effect The effect to update
  11346. * @param lightIndex The index of the light in the effect to update
  11347. * @returns The light
  11348. */
  11349. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11350. /**
  11351. * Returns the string "Light".
  11352. * @returns the class name
  11353. */
  11354. getClassName(): string;
  11355. /** @hidden */
  11356. readonly _isLight: boolean;
  11357. /**
  11358. * Converts the light information to a readable string for debug purpose.
  11359. * @param fullDetails Supports for multiple levels of logging within scene loading
  11360. * @returns the human readable light info
  11361. */
  11362. toString(fullDetails?: boolean): string;
  11363. /** @hidden */
  11364. protected _syncParentEnabledState(): void;
  11365. /**
  11366. * Set the enabled state of this node.
  11367. * @param value - the new enabled state
  11368. */
  11369. setEnabled(value: boolean): void;
  11370. /**
  11371. * Returns the Light associated shadow generator if any.
  11372. * @return the associated shadow generator.
  11373. */
  11374. getShadowGenerator(): Nullable<IShadowGenerator>;
  11375. /**
  11376. * Returns a Vector3, the absolute light position in the World.
  11377. * @returns the world space position of the light
  11378. */
  11379. getAbsolutePosition(): Vector3;
  11380. /**
  11381. * Specifies if the light will affect the passed mesh.
  11382. * @param mesh The mesh to test against the light
  11383. * @return true the mesh is affected otherwise, false.
  11384. */
  11385. canAffectMesh(mesh: AbstractMesh): boolean;
  11386. /**
  11387. * Sort function to order lights for rendering.
  11388. * @param a First Light object to compare to second.
  11389. * @param b Second Light object to compare first.
  11390. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11391. */
  11392. static CompareLightsPriority(a: Light, b: Light): number;
  11393. /**
  11394. * Releases resources associated with this node.
  11395. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11396. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11397. */
  11398. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11399. /**
  11400. * Returns the light type ID (integer).
  11401. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11402. */
  11403. getTypeID(): number;
  11404. /**
  11405. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11406. * @returns the scaled intensity in intensity mode unit
  11407. */
  11408. getScaledIntensity(): number;
  11409. /**
  11410. * Returns a new Light object, named "name", from the current one.
  11411. * @param name The name of the cloned light
  11412. * @returns the new created light
  11413. */
  11414. clone(name: string): Nullable<Light>;
  11415. /**
  11416. * Serializes the current light into a Serialization object.
  11417. * @returns the serialized object.
  11418. */
  11419. serialize(): any;
  11420. /**
  11421. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  11422. * This new light is named "name" and added to the passed scene.
  11423. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  11424. * @param name The friendly name of the light
  11425. * @param scene The scene the new light will belong to
  11426. * @returns the constructor function
  11427. */
  11428. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  11429. /**
  11430. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  11431. * @param parsedLight The JSON representation of the light
  11432. * @param scene The scene to create the parsed light in
  11433. * @returns the created light after parsing
  11434. */
  11435. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  11436. private _hookArrayForExcluded;
  11437. private _hookArrayForIncludedOnly;
  11438. private _resyncMeshes;
  11439. /**
  11440. * Forces the meshes to update their light related information in their rendering used effects
  11441. * @hidden Internal Use Only
  11442. */
  11443. _markMeshesAsLightDirty(): void;
  11444. /**
  11445. * Recomputes the cached photometric scale if needed.
  11446. */
  11447. private _computePhotometricScale;
  11448. /**
  11449. * Returns the Photometric Scale according to the light type and intensity mode.
  11450. */
  11451. private _getPhotometricScale;
  11452. /**
  11453. * Reorder the light in the scene according to their defined priority.
  11454. * @hidden Internal Use Only
  11455. */
  11456. _reorderLightsInScene(): void;
  11457. /**
  11458. * Prepares the list of defines specific to the light type.
  11459. * @param defines the list of defines
  11460. * @param lightIndex defines the index of the light for the effect
  11461. */
  11462. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11463. }
  11464. }
  11465. declare module BABYLON {
  11466. /**
  11467. * The HemisphericLight simulates the ambient environment light,
  11468. * so the passed direction is the light reflection direction, not the incoming direction.
  11469. */
  11470. export class HemisphericLight extends Light {
  11471. /**
  11472. * The groundColor is the light in the opposite direction to the one specified during creation.
  11473. * 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.
  11474. */
  11475. groundColor: Color3;
  11476. /**
  11477. * The light reflection direction, not the incoming direction.
  11478. */
  11479. direction: Vector3;
  11480. /**
  11481. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  11482. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  11483. * The HemisphericLight can't cast shadows.
  11484. * Documentation : https://doc.babylonjs.com/babylon101/lights
  11485. * @param name The friendly name of the light
  11486. * @param direction The direction of the light reflection
  11487. * @param scene The scene the light belongs to
  11488. */
  11489. constructor(name: string, direction: Vector3, scene: Scene);
  11490. protected _buildUniformLayout(): void;
  11491. /**
  11492. * Returns the string "HemisphericLight".
  11493. * @return The class name
  11494. */
  11495. getClassName(): string;
  11496. /**
  11497. * Sets the HemisphericLight direction towards the passed target (Vector3).
  11498. * Returns the updated direction.
  11499. * @param target The target the direction should point to
  11500. * @return The computed direction
  11501. */
  11502. setDirectionToTarget(target: Vector3): Vector3;
  11503. /**
  11504. * Returns the shadow generator associated to the light.
  11505. * @returns Always null for hemispheric lights because it does not support shadows.
  11506. */
  11507. getShadowGenerator(): Nullable<IShadowGenerator>;
  11508. /**
  11509. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  11510. * @param effect The effect to update
  11511. * @param lightIndex The index of the light in the effect to update
  11512. * @returns The hemispheric light
  11513. */
  11514. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  11515. /**
  11516. * Computes the world matrix of the node
  11517. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  11518. * @param useWasUpdatedFlag defines a reserved property
  11519. * @returns the world matrix
  11520. */
  11521. computeWorldMatrix(): Matrix;
  11522. /**
  11523. * Returns the integer 3.
  11524. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11525. */
  11526. getTypeID(): number;
  11527. /**
  11528. * Prepares the list of defines specific to the light type.
  11529. * @param defines the list of defines
  11530. * @param lightIndex defines the index of the light for the effect
  11531. */
  11532. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11533. }
  11534. }
  11535. declare module BABYLON {
  11536. /**
  11537. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  11538. * IMPORTANT!! The data is right-hand data.
  11539. * @export
  11540. * @interface DevicePose
  11541. */
  11542. export interface DevicePose {
  11543. /**
  11544. * The position of the device, values in array are [x,y,z].
  11545. */
  11546. readonly position: Nullable<Float32Array>;
  11547. /**
  11548. * The linearVelocity of the device, values in array are [x,y,z].
  11549. */
  11550. readonly linearVelocity: Nullable<Float32Array>;
  11551. /**
  11552. * The linearAcceleration of the device, values in array are [x,y,z].
  11553. */
  11554. readonly linearAcceleration: Nullable<Float32Array>;
  11555. /**
  11556. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  11557. */
  11558. readonly orientation: Nullable<Float32Array>;
  11559. /**
  11560. * The angularVelocity of the device, values in array are [x,y,z].
  11561. */
  11562. readonly angularVelocity: Nullable<Float32Array>;
  11563. /**
  11564. * The angularAcceleration of the device, values in array are [x,y,z].
  11565. */
  11566. readonly angularAcceleration: Nullable<Float32Array>;
  11567. }
  11568. /**
  11569. * Interface representing a pose controlled object in Babylon.
  11570. * A pose controlled object has both regular pose values as well as pose values
  11571. * from an external device such as a VR head mounted display
  11572. */
  11573. export interface PoseControlled {
  11574. /**
  11575. * The position of the object in babylon space.
  11576. */
  11577. position: Vector3;
  11578. /**
  11579. * The rotation quaternion of the object in babylon space.
  11580. */
  11581. rotationQuaternion: Quaternion;
  11582. /**
  11583. * The position of the device in babylon space.
  11584. */
  11585. devicePosition?: Vector3;
  11586. /**
  11587. * The rotation quaternion of the device in babylon space.
  11588. */
  11589. deviceRotationQuaternion: Quaternion;
  11590. /**
  11591. * The raw pose coming from the device.
  11592. */
  11593. rawPose: Nullable<DevicePose>;
  11594. /**
  11595. * The scale of the device to be used when translating from device space to babylon space.
  11596. */
  11597. deviceScaleFactor: number;
  11598. /**
  11599. * Updates the poseControlled values based on the input device pose.
  11600. * @param poseData the pose data to update the object with
  11601. */
  11602. updateFromDevice(poseData: DevicePose): void;
  11603. }
  11604. /**
  11605. * Set of options to customize the webVRCamera
  11606. */
  11607. export interface WebVROptions {
  11608. /**
  11609. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  11610. */
  11611. trackPosition?: boolean;
  11612. /**
  11613. * Sets the scale of the vrDevice in babylon space. (default: 1)
  11614. */
  11615. positionScale?: number;
  11616. /**
  11617. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  11618. */
  11619. displayName?: string;
  11620. /**
  11621. * Should the native controller meshes be initialized. (default: true)
  11622. */
  11623. controllerMeshes?: boolean;
  11624. /**
  11625. * Creating a default HemiLight only on controllers. (default: true)
  11626. */
  11627. defaultLightingOnControllers?: boolean;
  11628. /**
  11629. * If you don't want to use the default VR button of the helper. (default: false)
  11630. */
  11631. useCustomVRButton?: boolean;
  11632. /**
  11633. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  11634. */
  11635. customVRButton?: HTMLButtonElement;
  11636. /**
  11637. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  11638. */
  11639. rayLength?: number;
  11640. /**
  11641. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  11642. */
  11643. defaultHeight?: number;
  11644. }
  11645. /**
  11646. * This represents a WebVR camera.
  11647. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  11648. * @example http://doc.babylonjs.com/how_to/webvr_camera
  11649. */
  11650. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  11651. private webVROptions;
  11652. /**
  11653. * @hidden
  11654. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  11655. */
  11656. _vrDevice: any;
  11657. /**
  11658. * The rawPose of the vrDevice.
  11659. */
  11660. rawPose: Nullable<DevicePose>;
  11661. private _onVREnabled;
  11662. private _specsVersion;
  11663. private _attached;
  11664. private _frameData;
  11665. protected _descendants: Array<Node>;
  11666. private _deviceRoomPosition;
  11667. /** @hidden */
  11668. _deviceRoomRotationQuaternion: Quaternion;
  11669. private _standingMatrix;
  11670. /**
  11671. * Represents device position in babylon space.
  11672. */
  11673. devicePosition: Vector3;
  11674. /**
  11675. * Represents device rotation in babylon space.
  11676. */
  11677. deviceRotationQuaternion: Quaternion;
  11678. /**
  11679. * The scale of the device to be used when translating from device space to babylon space.
  11680. */
  11681. deviceScaleFactor: number;
  11682. private _deviceToWorld;
  11683. private _worldToDevice;
  11684. /**
  11685. * References to the webVR controllers for the vrDevice.
  11686. */
  11687. controllers: Array<WebVRController>;
  11688. /**
  11689. * Emits an event when a controller is attached.
  11690. */
  11691. onControllersAttachedObservable: Observable<WebVRController[]>;
  11692. /**
  11693. * Emits an event when a controller's mesh has been loaded;
  11694. */
  11695. onControllerMeshLoadedObservable: Observable<WebVRController>;
  11696. /**
  11697. * Emits an event when the HMD's pose has been updated.
  11698. */
  11699. onPoseUpdatedFromDeviceObservable: Observable<any>;
  11700. private _poseSet;
  11701. /**
  11702. * If the rig cameras be used as parent instead of this camera.
  11703. */
  11704. rigParenting: boolean;
  11705. private _lightOnControllers;
  11706. private _defaultHeight?;
  11707. /**
  11708. * Instantiates a WebVRFreeCamera.
  11709. * @param name The name of the WebVRFreeCamera
  11710. * @param position The starting anchor position for the camera
  11711. * @param scene The scene the camera belongs to
  11712. * @param webVROptions a set of customizable options for the webVRCamera
  11713. */
  11714. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  11715. /**
  11716. * Gets the device distance from the ground in meters.
  11717. * @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.
  11718. */
  11719. deviceDistanceToRoomGround(): number;
  11720. /**
  11721. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  11722. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  11723. */
  11724. useStandingMatrix(callback?: (bool: boolean) => void): void;
  11725. /**
  11726. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  11727. * @returns A promise with a boolean set to if the standing matrix is supported.
  11728. */
  11729. useStandingMatrixAsync(): Promise<boolean>;
  11730. /**
  11731. * Disposes the camera
  11732. */
  11733. dispose(): void;
  11734. /**
  11735. * Gets a vrController by name.
  11736. * @param name The name of the controller to retreive
  11737. * @returns the controller matching the name specified or null if not found
  11738. */
  11739. getControllerByName(name: string): Nullable<WebVRController>;
  11740. private _leftController;
  11741. /**
  11742. * The controller corrisponding to the users left hand.
  11743. */
  11744. readonly leftController: Nullable<WebVRController>;
  11745. private _rightController;
  11746. /**
  11747. * The controller corrisponding to the users right hand.
  11748. */
  11749. readonly rightController: Nullable<WebVRController>;
  11750. /**
  11751. * Casts a ray forward from the vrCamera's gaze.
  11752. * @param length Length of the ray (default: 100)
  11753. * @returns the ray corrisponding to the gaze
  11754. */
  11755. getForwardRay(length?: number): Ray;
  11756. /**
  11757. * @hidden
  11758. * Updates the camera based on device's frame data
  11759. */
  11760. _checkInputs(): void;
  11761. /**
  11762. * Updates the poseControlled values based on the input device pose.
  11763. * @param poseData Pose coming from the device
  11764. */
  11765. updateFromDevice(poseData: DevicePose): void;
  11766. private _htmlElementAttached;
  11767. private _detachIfAttached;
  11768. /**
  11769. * WebVR's attach control will start broadcasting frames to the device.
  11770. * Note that in certain browsers (chrome for example) this function must be called
  11771. * within a user-interaction callback. Example:
  11772. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  11773. *
  11774. * @param element html element to attach the vrDevice to
  11775. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  11776. */
  11777. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11778. /**
  11779. * Detaches the camera from the html element and disables VR
  11780. *
  11781. * @param element html element to detach from
  11782. */
  11783. detachControl(element: HTMLElement): void;
  11784. /**
  11785. * @returns the name of this class
  11786. */
  11787. getClassName(): string;
  11788. /**
  11789. * Calls resetPose on the vrDisplay
  11790. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  11791. */
  11792. resetToCurrentRotation(): void;
  11793. /**
  11794. * @hidden
  11795. * Updates the rig cameras (left and right eye)
  11796. */
  11797. _updateRigCameras(): void;
  11798. private _workingVector;
  11799. private _oneVector;
  11800. private _workingMatrix;
  11801. private updateCacheCalled;
  11802. private _correctPositionIfNotTrackPosition;
  11803. /**
  11804. * @hidden
  11805. * Updates the cached values of the camera
  11806. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  11807. */
  11808. _updateCache(ignoreParentClass?: boolean): void;
  11809. /**
  11810. * @hidden
  11811. * Get current device position in babylon world
  11812. */
  11813. _computeDevicePosition(): void;
  11814. /**
  11815. * Updates the current device position and rotation in the babylon world
  11816. */
  11817. update(): void;
  11818. /**
  11819. * @hidden
  11820. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  11821. * @returns an identity matrix
  11822. */
  11823. _getViewMatrix(): Matrix;
  11824. private _tmpMatrix;
  11825. /**
  11826. * This function is called by the two RIG cameras.
  11827. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  11828. * @hidden
  11829. */
  11830. _getWebVRViewMatrix(): Matrix;
  11831. /** @hidden */
  11832. _getWebVRProjectionMatrix(): Matrix;
  11833. private _onGamepadConnectedObserver;
  11834. private _onGamepadDisconnectedObserver;
  11835. private _updateCacheWhenTrackingDisabledObserver;
  11836. /**
  11837. * Initializes the controllers and their meshes
  11838. */
  11839. initControllers(): void;
  11840. }
  11841. }
  11842. declare module BABYLON {
  11843. /**
  11844. * Size options for a post process
  11845. */
  11846. export type PostProcessOptions = {
  11847. width: number;
  11848. height: number;
  11849. };
  11850. /**
  11851. * PostProcess can be used to apply a shader to a texture after it has been rendered
  11852. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  11853. */
  11854. export class PostProcess {
  11855. /** Name of the PostProcess. */
  11856. name: string;
  11857. /**
  11858. * Width of the texture to apply the post process on
  11859. */
  11860. width: number;
  11861. /**
  11862. * Height of the texture to apply the post process on
  11863. */
  11864. height: number;
  11865. /**
  11866. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  11867. * @hidden
  11868. */
  11869. _outputTexture: Nullable<InternalTexture>;
  11870. /**
  11871. * Sampling mode used by the shader
  11872. * See https://doc.babylonjs.com/classes/3.1/texture
  11873. */
  11874. renderTargetSamplingMode: number;
  11875. /**
  11876. * Clear color to use when screen clearing
  11877. */
  11878. clearColor: Color4;
  11879. /**
  11880. * If the buffer needs to be cleared before applying the post process. (default: true)
  11881. * Should be set to false if shader will overwrite all previous pixels.
  11882. */
  11883. autoClear: boolean;
  11884. /**
  11885. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  11886. */
  11887. alphaMode: number;
  11888. /**
  11889. * Sets the setAlphaBlendConstants of the babylon engine
  11890. */
  11891. alphaConstants: Color4;
  11892. /**
  11893. * Animations to be used for the post processing
  11894. */
  11895. animations: Animation[];
  11896. /**
  11897. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  11898. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  11899. */
  11900. enablePixelPerfectMode: boolean;
  11901. /**
  11902. * Force the postprocess to be applied without taking in account viewport
  11903. */
  11904. forceFullscreenViewport: boolean;
  11905. /**
  11906. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  11907. *
  11908. * | Value | Type | Description |
  11909. * | ----- | ----------------------------------- | ----------- |
  11910. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  11911. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  11912. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  11913. *
  11914. */
  11915. scaleMode: number;
  11916. /**
  11917. * Force textures to be a power of two (default: false)
  11918. */
  11919. alwaysForcePOT: boolean;
  11920. private _samples;
  11921. /**
  11922. * Number of sample textures (default: 1)
  11923. */
  11924. samples: number;
  11925. /**
  11926. * Modify the scale of the post process to be the same as the viewport (default: false)
  11927. */
  11928. adaptScaleToCurrentViewport: boolean;
  11929. private _camera;
  11930. private _scene;
  11931. private _engine;
  11932. private _options;
  11933. private _reusable;
  11934. private _textureType;
  11935. /**
  11936. * Smart array of input and output textures for the post process.
  11937. * @hidden
  11938. */
  11939. _textures: SmartArray<InternalTexture>;
  11940. /**
  11941. * The index in _textures that corresponds to the output texture.
  11942. * @hidden
  11943. */
  11944. _currentRenderTextureInd: number;
  11945. private _effect;
  11946. private _samplers;
  11947. private _fragmentUrl;
  11948. private _vertexUrl;
  11949. private _parameters;
  11950. private _scaleRatio;
  11951. protected _indexParameters: any;
  11952. private _shareOutputWithPostProcess;
  11953. private _texelSize;
  11954. private _forcedOutputTexture;
  11955. /**
  11956. * Returns the fragment url or shader name used in the post process.
  11957. * @returns the fragment url or name in the shader store.
  11958. */
  11959. getEffectName(): string;
  11960. /**
  11961. * An event triggered when the postprocess is activated.
  11962. */
  11963. onActivateObservable: Observable<Camera>;
  11964. private _onActivateObserver;
  11965. /**
  11966. * A function that is added to the onActivateObservable
  11967. */
  11968. onActivate: Nullable<(camera: Camera) => void>;
  11969. /**
  11970. * An event triggered when the postprocess changes its size.
  11971. */
  11972. onSizeChangedObservable: Observable<PostProcess>;
  11973. private _onSizeChangedObserver;
  11974. /**
  11975. * A function that is added to the onSizeChangedObservable
  11976. */
  11977. onSizeChanged: (postProcess: PostProcess) => void;
  11978. /**
  11979. * An event triggered when the postprocess applies its effect.
  11980. */
  11981. onApplyObservable: Observable<Effect>;
  11982. private _onApplyObserver;
  11983. /**
  11984. * A function that is added to the onApplyObservable
  11985. */
  11986. onApply: (effect: Effect) => void;
  11987. /**
  11988. * An event triggered before rendering the postprocess
  11989. */
  11990. onBeforeRenderObservable: Observable<Effect>;
  11991. private _onBeforeRenderObserver;
  11992. /**
  11993. * A function that is added to the onBeforeRenderObservable
  11994. */
  11995. onBeforeRender: (effect: Effect) => void;
  11996. /**
  11997. * An event triggered after rendering the postprocess
  11998. */
  11999. onAfterRenderObservable: Observable<Effect>;
  12000. private _onAfterRenderObserver;
  12001. /**
  12002. * A function that is added to the onAfterRenderObservable
  12003. */
  12004. onAfterRender: (efect: Effect) => void;
  12005. /**
  12006. * 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
  12007. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  12008. */
  12009. inputTexture: InternalTexture;
  12010. /**
  12011. * Gets the camera which post process is applied to.
  12012. * @returns The camera the post process is applied to.
  12013. */
  12014. getCamera(): Camera;
  12015. /**
  12016. * Gets the texel size of the postprocess.
  12017. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  12018. */
  12019. readonly texelSize: Vector2;
  12020. /**
  12021. * Creates a new instance PostProcess
  12022. * @param name The name of the PostProcess.
  12023. * @param fragmentUrl The url of the fragment shader to be used.
  12024. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  12025. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  12026. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  12027. * @param camera The camera to apply the render pass to.
  12028. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  12029. * @param engine The engine which the post process will be applied. (default: current engine)
  12030. * @param reusable If the post process can be reused on the same frame. (default: false)
  12031. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  12032. * @param textureType Type of textures used when performing the post process. (default: 0)
  12033. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  12034. * @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
  12035. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  12036. */
  12037. constructor(
  12038. /** Name of the PostProcess. */
  12039. 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);
  12040. /**
  12041. * Gets the engine which this post process belongs to.
  12042. * @returns The engine the post process was enabled with.
  12043. */
  12044. getEngine(): Engine;
  12045. /**
  12046. * The effect that is created when initializing the post process.
  12047. * @returns The created effect corrisponding the the postprocess.
  12048. */
  12049. getEffect(): Effect;
  12050. /**
  12051. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  12052. * @param postProcess The post process to share the output with.
  12053. * @returns This post process.
  12054. */
  12055. shareOutputWith(postProcess: PostProcess): PostProcess;
  12056. /**
  12057. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  12058. * This should be called if the post process that shares output with this post process is disabled/disposed.
  12059. */
  12060. useOwnOutput(): void;
  12061. /**
  12062. * Updates the effect with the current post process compile time values and recompiles the shader.
  12063. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  12064. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  12065. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  12066. * @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
  12067. * @param onCompiled Called when the shader has been compiled.
  12068. * @param onError Called if there is an error when compiling a shader.
  12069. */
  12070. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  12071. /**
  12072. * The post process is reusable if it can be used multiple times within one frame.
  12073. * @returns If the post process is reusable
  12074. */
  12075. isReusable(): boolean;
  12076. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  12077. markTextureDirty(): void;
  12078. /**
  12079. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  12080. * 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.
  12081. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  12082. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  12083. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  12084. * @returns The target texture that was bound to be written to.
  12085. */
  12086. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  12087. /**
  12088. * If the post process is supported.
  12089. */
  12090. readonly isSupported: boolean;
  12091. /**
  12092. * The aspect ratio of the output texture.
  12093. */
  12094. readonly aspectRatio: number;
  12095. /**
  12096. * Get a value indicating if the post-process is ready to be used
  12097. * @returns true if the post-process is ready (shader is compiled)
  12098. */
  12099. isReady(): boolean;
  12100. /**
  12101. * Binds all textures and uniforms to the shader, this will be run on every pass.
  12102. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  12103. */
  12104. apply(): Nullable<Effect>;
  12105. private _disposeTextures;
  12106. /**
  12107. * Disposes the post process.
  12108. * @param camera The camera to dispose the post process on.
  12109. */
  12110. dispose(camera?: Camera): void;
  12111. }
  12112. }
  12113. declare module BABYLON {
  12114. /** @hidden */
  12115. export var kernelBlurVaryingDeclaration: {
  12116. name: string;
  12117. shader: string;
  12118. };
  12119. }
  12120. declare module BABYLON {
  12121. /** @hidden */
  12122. export var kernelBlurFragment: {
  12123. name: string;
  12124. shader: string;
  12125. };
  12126. }
  12127. declare module BABYLON {
  12128. /** @hidden */
  12129. export var kernelBlurFragment2: {
  12130. name: string;
  12131. shader: string;
  12132. };
  12133. }
  12134. declare module BABYLON {
  12135. /** @hidden */
  12136. export var kernelBlurPixelShader: {
  12137. name: string;
  12138. shader: string;
  12139. };
  12140. }
  12141. declare module BABYLON {
  12142. /** @hidden */
  12143. export var kernelBlurVertex: {
  12144. name: string;
  12145. shader: string;
  12146. };
  12147. }
  12148. declare module BABYLON {
  12149. /** @hidden */
  12150. export var kernelBlurVertexShader: {
  12151. name: string;
  12152. shader: string;
  12153. };
  12154. }
  12155. declare module BABYLON {
  12156. /**
  12157. * The Blur Post Process which blurs an image based on a kernel and direction.
  12158. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  12159. */
  12160. export class BlurPostProcess extends PostProcess {
  12161. /** The direction in which to blur the image. */
  12162. direction: Vector2;
  12163. private blockCompilation;
  12164. protected _kernel: number;
  12165. protected _idealKernel: number;
  12166. protected _packedFloat: boolean;
  12167. private _staticDefines;
  12168. /**
  12169. * Sets the length in pixels of the blur sample region
  12170. */
  12171. /**
  12172. * Gets the length in pixels of the blur sample region
  12173. */
  12174. kernel: number;
  12175. /**
  12176. * Sets wether or not the blur needs to unpack/repack floats
  12177. */
  12178. /**
  12179. * Gets wether or not the blur is unpacking/repacking floats
  12180. */
  12181. packedFloat: boolean;
  12182. /**
  12183. * Creates a new instance BlurPostProcess
  12184. * @param name The name of the effect.
  12185. * @param direction The direction in which to blur the image.
  12186. * @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.
  12187. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  12188. * @param camera The camera to apply the render pass to.
  12189. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  12190. * @param engine The engine which the post process will be applied. (default: current engine)
  12191. * @param reusable If the post process can be reused on the same frame. (default: false)
  12192. * @param textureType Type of textures used when performing the post process. (default: 0)
  12193. * @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)
  12194. */
  12195. constructor(name: string,
  12196. /** The direction in which to blur the image. */
  12197. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  12198. /**
  12199. * Updates the effect with the current post process compile time values and recompiles the shader.
  12200. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  12201. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  12202. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  12203. * @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
  12204. * @param onCompiled Called when the shader has been compiled.
  12205. * @param onError Called if there is an error when compiling a shader.
  12206. */
  12207. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  12208. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  12209. /**
  12210. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  12211. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  12212. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  12213. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  12214. * The gaps between physical kernels are compensated for in the weighting of the samples
  12215. * @param idealKernel Ideal blur kernel.
  12216. * @return Nearest best kernel.
  12217. */
  12218. protected _nearestBestKernel(idealKernel: number): number;
  12219. /**
  12220. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  12221. * @param x The point on the Gaussian distribution to sample.
  12222. * @return the value of the Gaussian function at x.
  12223. */
  12224. protected _gaussianWeight(x: number): number;
  12225. /**
  12226. * Generates a string that can be used as a floating point number in GLSL.
  12227. * @param x Value to print.
  12228. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  12229. * @return GLSL float string.
  12230. */
  12231. protected _glslFloat(x: number, decimalFigures?: number): string;
  12232. }
  12233. }
  12234. declare module BABYLON {
  12235. /**
  12236. * Mirror texture can be used to simulate the view from a mirror in a scene.
  12237. * It will dynamically be rendered every frame to adapt to the camera point of view.
  12238. * You can then easily use it as a reflectionTexture on a flat surface.
  12239. * In case the surface is not a plane, please consider relying on reflection probes.
  12240. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  12241. */
  12242. export class MirrorTexture extends RenderTargetTexture {
  12243. private scene;
  12244. /**
  12245. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  12246. * 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.
  12247. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  12248. */
  12249. mirrorPlane: Plane;
  12250. /**
  12251. * Define the blur ratio used to blur the reflection if needed.
  12252. */
  12253. blurRatio: number;
  12254. /**
  12255. * Define the adaptive blur kernel used to blur the reflection if needed.
  12256. * This will autocompute the closest best match for the `blurKernel`
  12257. */
  12258. adaptiveBlurKernel: number;
  12259. /**
  12260. * Define the blur kernel used to blur the reflection if needed.
  12261. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  12262. */
  12263. blurKernel: number;
  12264. /**
  12265. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  12266. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  12267. */
  12268. blurKernelX: number;
  12269. /**
  12270. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  12271. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  12272. */
  12273. blurKernelY: number;
  12274. private _autoComputeBlurKernel;
  12275. protected _onRatioRescale(): void;
  12276. private _updateGammaSpace;
  12277. private _imageProcessingConfigChangeObserver;
  12278. private _transformMatrix;
  12279. private _mirrorMatrix;
  12280. private _savedViewMatrix;
  12281. private _blurX;
  12282. private _blurY;
  12283. private _adaptiveBlurKernel;
  12284. private _blurKernelX;
  12285. private _blurKernelY;
  12286. private _blurRatio;
  12287. /**
  12288. * Instantiates a Mirror Texture.
  12289. * Mirror texture can be used to simulate the view from a mirror in a scene.
  12290. * It will dynamically be rendered every frame to adapt to the camera point of view.
  12291. * You can then easily use it as a reflectionTexture on a flat surface.
  12292. * In case the surface is not a plane, please consider relying on reflection probes.
  12293. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  12294. * @param name
  12295. * @param size
  12296. * @param scene
  12297. * @param generateMipMaps
  12298. * @param type
  12299. * @param samplingMode
  12300. * @param generateDepthBuffer
  12301. */
  12302. constructor(name: string, size: number | {
  12303. width: number;
  12304. height: number;
  12305. } | {
  12306. ratio: number;
  12307. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  12308. private _preparePostProcesses;
  12309. /**
  12310. * Clone the mirror texture.
  12311. * @returns the cloned texture
  12312. */
  12313. clone(): MirrorTexture;
  12314. /**
  12315. * Serialize the texture to a JSON representation you could use in Parse later on
  12316. * @returns the serialized JSON representation
  12317. */
  12318. serialize(): any;
  12319. /**
  12320. * Dispose the texture and release its associated resources.
  12321. */
  12322. dispose(): void;
  12323. }
  12324. }
  12325. declare module BABYLON {
  12326. /**
  12327. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  12328. * @see http://doc.babylonjs.com/babylon101/materials#texture
  12329. */
  12330. export class Texture extends BaseTexture {
  12331. /** @hidden */
  12332. static _AnimationParser: (jsonAnimation: any) => Animation;
  12333. /** @hidden */
  12334. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  12335. /** @hidden */
  12336. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  12337. /** @hidden */
  12338. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  12339. /** nearest is mag = nearest and min = nearest and mip = linear */
  12340. static readonly NEAREST_SAMPLINGMODE: number;
  12341. /** nearest is mag = nearest and min = nearest and mip = linear */
  12342. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  12343. /** Bilinear is mag = linear and min = linear and mip = nearest */
  12344. static readonly BILINEAR_SAMPLINGMODE: number;
  12345. /** Bilinear is mag = linear and min = linear and mip = nearest */
  12346. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  12347. /** Trilinear is mag = linear and min = linear and mip = linear */
  12348. static readonly TRILINEAR_SAMPLINGMODE: number;
  12349. /** Trilinear is mag = linear and min = linear and mip = linear */
  12350. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  12351. /** mag = nearest and min = nearest and mip = nearest */
  12352. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  12353. /** mag = nearest and min = linear and mip = nearest */
  12354. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  12355. /** mag = nearest and min = linear and mip = linear */
  12356. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  12357. /** mag = nearest and min = linear and mip = none */
  12358. static readonly NEAREST_LINEAR: number;
  12359. /** mag = nearest and min = nearest and mip = none */
  12360. static readonly NEAREST_NEAREST: number;
  12361. /** mag = linear and min = nearest and mip = nearest */
  12362. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  12363. /** mag = linear and min = nearest and mip = linear */
  12364. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  12365. /** mag = linear and min = linear and mip = none */
  12366. static readonly LINEAR_LINEAR: number;
  12367. /** mag = linear and min = nearest and mip = none */
  12368. static readonly LINEAR_NEAREST: number;
  12369. /** Explicit coordinates mode */
  12370. static readonly EXPLICIT_MODE: number;
  12371. /** Spherical coordinates mode */
  12372. static readonly SPHERICAL_MODE: number;
  12373. /** Planar coordinates mode */
  12374. static readonly PLANAR_MODE: number;
  12375. /** Cubic coordinates mode */
  12376. static readonly CUBIC_MODE: number;
  12377. /** Projection coordinates mode */
  12378. static readonly PROJECTION_MODE: number;
  12379. /** Inverse Cubic coordinates mode */
  12380. static readonly SKYBOX_MODE: number;
  12381. /** Inverse Cubic coordinates mode */
  12382. static readonly INVCUBIC_MODE: number;
  12383. /** Equirectangular coordinates mode */
  12384. static readonly EQUIRECTANGULAR_MODE: number;
  12385. /** Equirectangular Fixed coordinates mode */
  12386. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  12387. /** Equirectangular Fixed Mirrored coordinates mode */
  12388. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  12389. /** Texture is not repeating outside of 0..1 UVs */
  12390. static readonly CLAMP_ADDRESSMODE: number;
  12391. /** Texture is repeating outside of 0..1 UVs */
  12392. static readonly WRAP_ADDRESSMODE: number;
  12393. /** Texture is repeating and mirrored */
  12394. static readonly MIRROR_ADDRESSMODE: number;
  12395. /**
  12396. * 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
  12397. */
  12398. static UseSerializedUrlIfAny: boolean;
  12399. /**
  12400. * Define the url of the texture.
  12401. */
  12402. url: Nullable<string>;
  12403. /**
  12404. * Define an offset on the texture to offset the u coordinates of the UVs
  12405. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  12406. */
  12407. uOffset: number;
  12408. /**
  12409. * Define an offset on the texture to offset the v coordinates of the UVs
  12410. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  12411. */
  12412. vOffset: number;
  12413. /**
  12414. * Define an offset on the texture to scale the u coordinates of the UVs
  12415. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  12416. */
  12417. uScale: number;
  12418. /**
  12419. * Define an offset on the texture to scale the v coordinates of the UVs
  12420. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  12421. */
  12422. vScale: number;
  12423. /**
  12424. * Define an offset on the texture to rotate around the u coordinates of the UVs
  12425. * @see http://doc.babylonjs.com/how_to/more_materials
  12426. */
  12427. uAng: number;
  12428. /**
  12429. * Define an offset on the texture to rotate around the v coordinates of the UVs
  12430. * @see http://doc.babylonjs.com/how_to/more_materials
  12431. */
  12432. vAng: number;
  12433. /**
  12434. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  12435. * @see http://doc.babylonjs.com/how_to/more_materials
  12436. */
  12437. wAng: number;
  12438. /**
  12439. * Defines the center of rotation (U)
  12440. */
  12441. uRotationCenter: number;
  12442. /**
  12443. * Defines the center of rotation (V)
  12444. */
  12445. vRotationCenter: number;
  12446. /**
  12447. * Defines the center of rotation (W)
  12448. */
  12449. wRotationCenter: number;
  12450. /**
  12451. * Are mip maps generated for this texture or not.
  12452. */
  12453. readonly noMipmap: boolean;
  12454. private _noMipmap;
  12455. /** @hidden */
  12456. _invertY: boolean;
  12457. private _rowGenerationMatrix;
  12458. private _cachedTextureMatrix;
  12459. private _projectionModeMatrix;
  12460. private _t0;
  12461. private _t1;
  12462. private _t2;
  12463. private _cachedUOffset;
  12464. private _cachedVOffset;
  12465. private _cachedUScale;
  12466. private _cachedVScale;
  12467. private _cachedUAng;
  12468. private _cachedVAng;
  12469. private _cachedWAng;
  12470. private _cachedProjectionMatrixId;
  12471. private _cachedCoordinatesMode;
  12472. /** @hidden */
  12473. protected _initialSamplingMode: number;
  12474. /** @hidden */
  12475. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  12476. private _deleteBuffer;
  12477. protected _format: Nullable<number>;
  12478. private _delayedOnLoad;
  12479. private _delayedOnError;
  12480. /**
  12481. * Observable triggered once the texture has been loaded.
  12482. */
  12483. onLoadObservable: Observable<Texture>;
  12484. protected _isBlocking: boolean;
  12485. /**
  12486. * Is the texture preventing material to render while loading.
  12487. * If false, a default texture will be used instead of the loading one during the preparation step.
  12488. */
  12489. isBlocking: boolean;
  12490. /**
  12491. * Get the current sampling mode associated with the texture.
  12492. */
  12493. readonly samplingMode: number;
  12494. /**
  12495. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  12496. */
  12497. readonly invertY: boolean;
  12498. /**
  12499. * Instantiates a new texture.
  12500. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  12501. * @see http://doc.babylonjs.com/babylon101/materials#texture
  12502. * @param url define the url of the picture to load as a texture
  12503. * @param scene define the scene the texture will belong to
  12504. * @param noMipmap define if the texture will require mip maps or not
  12505. * @param invertY define if the texture needs to be inverted on the y axis during loading
  12506. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  12507. * @param onLoad define a callback triggered when the texture has been loaded
  12508. * @param onError define a callback triggered when an error occurred during the loading session
  12509. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  12510. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  12511. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  12512. */
  12513. 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);
  12514. /**
  12515. * Update the url (and optional buffer) of this texture if url was null during construction.
  12516. * @param url the url of the texture
  12517. * @param buffer the buffer of the texture (defaults to null)
  12518. * @param onLoad callback called when the texture is loaded (defaults to null)
  12519. */
  12520. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  12521. /**
  12522. * Finish the loading sequence of a texture flagged as delayed load.
  12523. * @hidden
  12524. */
  12525. delayLoad(): void;
  12526. private _prepareRowForTextureGeneration;
  12527. /**
  12528. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  12529. * @returns the transform matrix of the texture.
  12530. */
  12531. getTextureMatrix(): Matrix;
  12532. /**
  12533. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  12534. * @returns The reflection texture transform
  12535. */
  12536. getReflectionTextureMatrix(): Matrix;
  12537. /**
  12538. * Clones the texture.
  12539. * @returns the cloned texture
  12540. */
  12541. clone(): Texture;
  12542. /**
  12543. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  12544. * @returns The JSON representation of the texture
  12545. */
  12546. serialize(): any;
  12547. /**
  12548. * Get the current class name of the texture useful for serialization or dynamic coding.
  12549. * @returns "Texture"
  12550. */
  12551. getClassName(): string;
  12552. /**
  12553. * Dispose the texture and release its associated resources.
  12554. */
  12555. dispose(): void;
  12556. /**
  12557. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  12558. * @param parsedTexture Define the JSON representation of the texture
  12559. * @param scene Define the scene the parsed texture should be instantiated in
  12560. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  12561. * @returns The parsed texture if successful
  12562. */
  12563. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  12564. /**
  12565. * Creates a texture from its base 64 representation.
  12566. * @param data Define the base64 payload without the data: prefix
  12567. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  12568. * @param scene Define the scene the texture should belong to
  12569. * @param noMipmap Forces the texture to not create mip map information if true
  12570. * @param invertY define if the texture needs to be inverted on the y axis during loading
  12571. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  12572. * @param onLoad define a callback triggered when the texture has been loaded
  12573. * @param onError define a callback triggered when an error occurred during the loading session
  12574. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  12575. * @returns the created texture
  12576. */
  12577. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  12578. /**
  12579. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  12580. * @param data Define the base64 payload without the data: prefix
  12581. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  12582. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  12583. * @param scene Define the scene the texture should belong to
  12584. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  12585. * @param noMipmap Forces the texture to not create mip map information if true
  12586. * @param invertY define if the texture needs to be inverted on the y axis during loading
  12587. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  12588. * @param onLoad define a callback triggered when the texture has been loaded
  12589. * @param onError define a callback triggered when an error occurred during the loading session
  12590. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  12591. * @returns the created texture
  12592. */
  12593. 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;
  12594. }
  12595. }
  12596. declare module BABYLON {
  12597. /**
  12598. * PostProcessManager is used to manage one or more post processes or post process pipelines
  12599. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  12600. */
  12601. export class PostProcessManager {
  12602. private _scene;
  12603. private _indexBuffer;
  12604. private _vertexBuffers;
  12605. /**
  12606. * Creates a new instance PostProcess
  12607. * @param scene The scene that the post process is associated with.
  12608. */
  12609. constructor(scene: Scene);
  12610. private _prepareBuffers;
  12611. private _buildIndexBuffer;
  12612. /**
  12613. * Rebuilds the vertex buffers of the manager.
  12614. * @hidden
  12615. */
  12616. _rebuild(): void;
  12617. /**
  12618. * Prepares a frame to be run through a post process.
  12619. * @param sourceTexture The input texture to the post procesess. (default: null)
  12620. * @param postProcesses An array of post processes to be run. (default: null)
  12621. * @returns True if the post processes were able to be run.
  12622. * @hidden
  12623. */
  12624. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  12625. /**
  12626. * Manually render a set of post processes to a texture.
  12627. * @param postProcesses An array of post processes to be run.
  12628. * @param targetTexture The target texture to render to.
  12629. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  12630. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  12631. * @param lodLevel defines which lod of the texture to render to
  12632. */
  12633. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  12634. /**
  12635. * Finalize the result of the output of the postprocesses.
  12636. * @param doNotPresent If true the result will not be displayed to the screen.
  12637. * @param targetTexture The target texture to render to.
  12638. * @param faceIndex The index of the face to bind the target texture to.
  12639. * @param postProcesses The array of post processes to render.
  12640. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  12641. * @hidden
  12642. */
  12643. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  12644. /**
  12645. * Disposes of the post process manager.
  12646. */
  12647. dispose(): void;
  12648. }
  12649. }
  12650. declare module BABYLON {
  12651. /**
  12652. * Groups all the scene component constants in one place to ease maintenance.
  12653. * @hidden
  12654. */
  12655. export class SceneComponentConstants {
  12656. static readonly NAME_EFFECTLAYER: string;
  12657. static readonly NAME_LAYER: string;
  12658. static readonly NAME_LENSFLARESYSTEM: string;
  12659. static readonly NAME_BOUNDINGBOXRENDERER: string;
  12660. static readonly NAME_PARTICLESYSTEM: string;
  12661. static readonly NAME_GAMEPAD: string;
  12662. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  12663. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  12664. static readonly NAME_DEPTHRENDERER: string;
  12665. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  12666. static readonly NAME_SPRITE: string;
  12667. static readonly NAME_OUTLINERENDERER: string;
  12668. static readonly NAME_PROCEDURALTEXTURE: string;
  12669. static readonly NAME_SHADOWGENERATOR: string;
  12670. static readonly NAME_OCTREE: string;
  12671. static readonly NAME_PHYSICSENGINE: string;
  12672. static readonly NAME_AUDIO: string;
  12673. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  12674. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  12675. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  12676. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  12677. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  12678. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  12679. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  12680. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  12681. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  12682. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  12683. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  12684. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  12685. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  12686. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  12687. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  12688. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  12689. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  12690. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  12691. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  12692. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  12693. static readonly STEP_AFTERRENDER_AUDIO: number;
  12694. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  12695. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  12696. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  12697. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  12698. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  12699. static readonly STEP_POINTERMOVE_SPRITE: number;
  12700. static readonly STEP_POINTERDOWN_SPRITE: number;
  12701. static readonly STEP_POINTERUP_SPRITE: number;
  12702. }
  12703. /**
  12704. * This represents a scene component.
  12705. *
  12706. * This is used to decouple the dependency the scene is having on the different workloads like
  12707. * layers, post processes...
  12708. */
  12709. export interface ISceneComponent {
  12710. /**
  12711. * The name of the component. Each component must have a unique name.
  12712. */
  12713. name: string;
  12714. /**
  12715. * The scene the component belongs to.
  12716. */
  12717. scene: Scene;
  12718. /**
  12719. * Register the component to one instance of a scene.
  12720. */
  12721. register(): void;
  12722. /**
  12723. * Rebuilds the elements related to this component in case of
  12724. * context lost for instance.
  12725. */
  12726. rebuild(): void;
  12727. /**
  12728. * Disposes the component and the associated ressources.
  12729. */
  12730. dispose(): void;
  12731. }
  12732. /**
  12733. * This represents a SERIALIZABLE scene component.
  12734. *
  12735. * This extends Scene Component to add Serialization methods on top.
  12736. */
  12737. export interface ISceneSerializableComponent extends ISceneComponent {
  12738. /**
  12739. * Adds all the element from the container to the scene
  12740. * @param container the container holding the elements
  12741. */
  12742. addFromContainer(container: AbstractScene): void;
  12743. /**
  12744. * Removes all the elements in the container from the scene
  12745. * @param container contains the elements to remove
  12746. */
  12747. removeFromContainer(container: AbstractScene): void;
  12748. /**
  12749. * Serializes the component data to the specified json object
  12750. * @param serializationObject The object to serialize to
  12751. */
  12752. serialize(serializationObject: any): void;
  12753. }
  12754. /**
  12755. * Strong typing of a Mesh related stage step action
  12756. */
  12757. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  12758. /**
  12759. * Strong typing of a Evaluate Sub Mesh related stage step action
  12760. */
  12761. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  12762. /**
  12763. * Strong typing of a Active Mesh related stage step action
  12764. */
  12765. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  12766. /**
  12767. * Strong typing of a Camera related stage step action
  12768. */
  12769. export type CameraStageAction = (camera: Camera) => void;
  12770. /**
  12771. * Strong typing of a Render Target related stage step action
  12772. */
  12773. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  12774. /**
  12775. * Strong typing of a RenderingGroup related stage step action
  12776. */
  12777. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  12778. /**
  12779. * Strong typing of a Mesh Render related stage step action
  12780. */
  12781. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  12782. /**
  12783. * Strong typing of a simple stage step action
  12784. */
  12785. export type SimpleStageAction = () => void;
  12786. /**
  12787. * Strong typing of a render target action.
  12788. */
  12789. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  12790. /**
  12791. * Strong typing of a pointer move action.
  12792. */
  12793. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  12794. /**
  12795. * Strong typing of a pointer up/down action.
  12796. */
  12797. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  12798. /**
  12799. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  12800. * @hidden
  12801. */
  12802. export class Stage<T extends Function> extends Array<{
  12803. index: number;
  12804. component: ISceneComponent;
  12805. action: T;
  12806. }> {
  12807. /**
  12808. * Hide ctor from the rest of the world.
  12809. * @param items The items to add.
  12810. */
  12811. private constructor();
  12812. /**
  12813. * Creates a new Stage.
  12814. * @returns A new instance of a Stage
  12815. */
  12816. static Create<T extends Function>(): Stage<T>;
  12817. /**
  12818. * Registers a step in an ordered way in the targeted stage.
  12819. * @param index Defines the position to register the step in
  12820. * @param component Defines the component attached to the step
  12821. * @param action Defines the action to launch during the step
  12822. */
  12823. registerStep(index: number, component: ISceneComponent, action: T): void;
  12824. /**
  12825. * Clears all the steps from the stage.
  12826. */
  12827. clear(): void;
  12828. }
  12829. }
  12830. declare module BABYLON {
  12831. interface Scene {
  12832. /** @hidden */
  12833. _pointerOverSprite: Nullable<Sprite>;
  12834. /** @hidden */
  12835. _pickedDownSprite: Nullable<Sprite>;
  12836. /** @hidden */
  12837. _tempSpritePickingRay: Nullable<Ray>;
  12838. /**
  12839. * All of the sprite managers added to this scene
  12840. * @see http://doc.babylonjs.com/babylon101/sprites
  12841. */
  12842. spriteManagers: Array<ISpriteManager>;
  12843. /**
  12844. * An event triggered when sprites rendering is about to start
  12845. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  12846. */
  12847. onBeforeSpritesRenderingObservable: Observable<Scene>;
  12848. /**
  12849. * An event triggered when sprites rendering is done
  12850. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  12851. */
  12852. onAfterSpritesRenderingObservable: Observable<Scene>;
  12853. /** @hidden */
  12854. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12855. /** Launch a ray to try to pick a sprite in the scene
  12856. * @param x position on screen
  12857. * @param y position on screen
  12858. * @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
  12859. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  12860. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  12861. * @returns a PickingInfo
  12862. */
  12863. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12864. /** Use the given ray to pick a sprite in the scene
  12865. * @param ray The ray (in world space) to use to pick meshes
  12866. * @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
  12867. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  12868. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  12869. * @returns a PickingInfo
  12870. */
  12871. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12872. /**
  12873. * Force the sprite under the pointer
  12874. * @param sprite defines the sprite to use
  12875. */
  12876. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  12877. /**
  12878. * Gets the sprite under the pointer
  12879. * @returns a Sprite or null if no sprite is under the pointer
  12880. */
  12881. getPointerOverSprite(): Nullable<Sprite>;
  12882. }
  12883. /**
  12884. * Defines the sprite scene component responsible to manage sprites
  12885. * in a given scene.
  12886. */
  12887. export class SpriteSceneComponent implements ISceneComponent {
  12888. /**
  12889. * The component name helpfull to identify the component in the list of scene components.
  12890. */
  12891. readonly name: string;
  12892. /**
  12893. * The scene the component belongs to.
  12894. */
  12895. scene: Scene;
  12896. /** @hidden */
  12897. private _spritePredicate;
  12898. /**
  12899. * Creates a new instance of the component for the given scene
  12900. * @param scene Defines the scene to register the component in
  12901. */
  12902. constructor(scene: Scene);
  12903. /**
  12904. * Registers the component in a given scene
  12905. */
  12906. register(): void;
  12907. /**
  12908. * Rebuilds the elements related to this component in case of
  12909. * context lost for instance.
  12910. */
  12911. rebuild(): void;
  12912. /**
  12913. * Disposes the component and the associated ressources.
  12914. */
  12915. dispose(): void;
  12916. private _pickSpriteButKeepRay;
  12917. private _pointerMove;
  12918. private _pointerDown;
  12919. private _pointerUp;
  12920. }
  12921. }
  12922. declare module BABYLON {
  12923. /** @hidden */
  12924. export var fogFragmentDeclaration: {
  12925. name: string;
  12926. shader: string;
  12927. };
  12928. }
  12929. declare module BABYLON {
  12930. /** @hidden */
  12931. export var fogFragment: {
  12932. name: string;
  12933. shader: string;
  12934. };
  12935. }
  12936. declare module BABYLON {
  12937. /** @hidden */
  12938. export var spritesPixelShader: {
  12939. name: string;
  12940. shader: string;
  12941. };
  12942. }
  12943. declare module BABYLON {
  12944. /** @hidden */
  12945. export var fogVertexDeclaration: {
  12946. name: string;
  12947. shader: string;
  12948. };
  12949. }
  12950. declare module BABYLON {
  12951. /** @hidden */
  12952. export var spritesVertexShader: {
  12953. name: string;
  12954. shader: string;
  12955. };
  12956. }
  12957. declare module BABYLON {
  12958. /**
  12959. * Defines the minimum interface to fullfil in order to be a sprite manager.
  12960. */
  12961. export interface ISpriteManager extends IDisposable {
  12962. /**
  12963. * Restricts the camera to viewing objects with the same layerMask.
  12964. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  12965. */
  12966. layerMask: number;
  12967. /**
  12968. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  12969. */
  12970. isPickable: boolean;
  12971. /**
  12972. * Specifies the rendering group id for this mesh (0 by default)
  12973. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  12974. */
  12975. renderingGroupId: number;
  12976. /**
  12977. * Defines the list of sprites managed by the manager.
  12978. */
  12979. sprites: Array<Sprite>;
  12980. /**
  12981. * Tests the intersection of a sprite with a specific ray.
  12982. * @param ray The ray we are sending to test the collision
  12983. * @param camera The camera space we are sending rays in
  12984. * @param predicate A predicate allowing excluding sprites from the list of object to test
  12985. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  12986. * @returns picking info or null.
  12987. */
  12988. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12989. /**
  12990. * Renders the list of sprites on screen.
  12991. */
  12992. render(): void;
  12993. }
  12994. /**
  12995. * Class used to manage multiple sprites on the same spritesheet
  12996. * @see http://doc.babylonjs.com/babylon101/sprites
  12997. */
  12998. export class SpriteManager implements ISpriteManager {
  12999. /** defines the manager's name */
  13000. name: string;
  13001. /** Gets the list of sprites */
  13002. sprites: Sprite[];
  13003. /** Gets or sets the rendering group id (0 by default) */
  13004. renderingGroupId: number;
  13005. /** Gets or sets camera layer mask */
  13006. layerMask: number;
  13007. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  13008. fogEnabled: boolean;
  13009. /** Gets or sets a boolean indicating if the sprites are pickable */
  13010. isPickable: boolean;
  13011. /** Defines the default width of a cell in the spritesheet */
  13012. cellWidth: number;
  13013. /** Defines the default height of a cell in the spritesheet */
  13014. cellHeight: number;
  13015. /**
  13016. * An event triggered when the manager is disposed.
  13017. */
  13018. onDisposeObservable: Observable<SpriteManager>;
  13019. private _onDisposeObserver;
  13020. /**
  13021. * Callback called when the manager is disposed
  13022. */
  13023. onDispose: () => void;
  13024. private _capacity;
  13025. private _spriteTexture;
  13026. private _epsilon;
  13027. private _scene;
  13028. private _vertexData;
  13029. private _buffer;
  13030. private _vertexBuffers;
  13031. private _indexBuffer;
  13032. private _effectBase;
  13033. private _effectFog;
  13034. /**
  13035. * Gets or sets the spritesheet texture
  13036. */
  13037. texture: Texture;
  13038. /**
  13039. * Creates a new sprite manager
  13040. * @param name defines the manager's name
  13041. * @param imgUrl defines the sprite sheet url
  13042. * @param capacity defines the maximum allowed number of sprites
  13043. * @param cellSize defines the size of a sprite cell
  13044. * @param scene defines the hosting scene
  13045. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  13046. * @param samplingMode defines the smapling mode to use with spritesheet
  13047. */
  13048. constructor(
  13049. /** defines the manager's name */
  13050. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  13051. private _appendSpriteVertex;
  13052. /**
  13053. * Intersects the sprites with a ray
  13054. * @param ray defines the ray to intersect with
  13055. * @param camera defines the current active camera
  13056. * @param predicate defines a predicate used to select candidate sprites
  13057. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  13058. * @returns null if no hit or a PickingInfo
  13059. */
  13060. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  13061. /**
  13062. * Render all child sprites
  13063. */
  13064. render(): void;
  13065. /**
  13066. * Release associated resources
  13067. */
  13068. dispose(): void;
  13069. }
  13070. }
  13071. declare module BABYLON {
  13072. interface AbstractScene {
  13073. /**
  13074. * The list of layers (background and foreground) of the scene
  13075. */
  13076. layers: Array<Layer>;
  13077. }
  13078. /**
  13079. * Defines the layer scene component responsible to manage any layers
  13080. * in a given scene.
  13081. */
  13082. export class LayerSceneComponent implements ISceneComponent {
  13083. /**
  13084. * The component name helpfull to identify the component in the list of scene components.
  13085. */
  13086. readonly name: string;
  13087. /**
  13088. * The scene the component belongs to.
  13089. */
  13090. scene: Scene;
  13091. private _engine;
  13092. /**
  13093. * Creates a new instance of the component for the given scene
  13094. * @param scene Defines the scene to register the component in
  13095. */
  13096. constructor(scene: Scene);
  13097. /**
  13098. * Registers the component in a given scene
  13099. */
  13100. register(): void;
  13101. /**
  13102. * Rebuilds the elements related to this component in case of
  13103. * context lost for instance.
  13104. */
  13105. rebuild(): void;
  13106. /**
  13107. * Disposes the component and the associated ressources.
  13108. */
  13109. dispose(): void;
  13110. private _draw;
  13111. private _drawCameraPredicate;
  13112. private _drawCameraBackground;
  13113. private _drawCameraForeground;
  13114. private _drawRenderTargetPredicate;
  13115. private _drawRenderTargetBackground;
  13116. private _drawRenderTargetForeground;
  13117. }
  13118. }
  13119. declare module BABYLON {
  13120. /** @hidden */
  13121. export var layerPixelShader: {
  13122. name: string;
  13123. shader: string;
  13124. };
  13125. }
  13126. declare module BABYLON {
  13127. /** @hidden */
  13128. export var layerVertexShader: {
  13129. name: string;
  13130. shader: string;
  13131. };
  13132. }
  13133. declare module BABYLON {
  13134. /**
  13135. * This represents a full screen 2d layer.
  13136. * This can be useful to display a picture in the background of your scene for instance.
  13137. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13138. */
  13139. export class Layer {
  13140. /**
  13141. * Define the name of the layer.
  13142. */
  13143. name: string;
  13144. /**
  13145. * Define the texture the layer should display.
  13146. */
  13147. texture: Nullable<Texture>;
  13148. /**
  13149. * Is the layer in background or foreground.
  13150. */
  13151. isBackground: boolean;
  13152. /**
  13153. * Define the color of the layer (instead of texture).
  13154. */
  13155. color: Color4;
  13156. /**
  13157. * Define the scale of the layer in order to zoom in out of the texture.
  13158. */
  13159. scale: Vector2;
  13160. /**
  13161. * Define an offset for the layer in order to shift the texture.
  13162. */
  13163. offset: Vector2;
  13164. /**
  13165. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13166. */
  13167. alphaBlendingMode: number;
  13168. /**
  13169. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13170. * Alpha test will not mix with the background color in case of transparency.
  13171. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13172. */
  13173. alphaTest: boolean;
  13174. /**
  13175. * Define a mask to restrict the layer to only some of the scene cameras.
  13176. */
  13177. layerMask: number;
  13178. /**
  13179. * Define the list of render target the layer is visible into.
  13180. */
  13181. renderTargetTextures: RenderTargetTexture[];
  13182. /**
  13183. * Define if the layer is only used in renderTarget or if it also
  13184. * renders in the main frame buffer of the canvas.
  13185. */
  13186. renderOnlyInRenderTargetTextures: boolean;
  13187. private _scene;
  13188. private _vertexBuffers;
  13189. private _indexBuffer;
  13190. private _effect;
  13191. private _alphaTestEffect;
  13192. /**
  13193. * An event triggered when the layer is disposed.
  13194. */
  13195. onDisposeObservable: Observable<Layer>;
  13196. private _onDisposeObserver;
  13197. /**
  13198. * Back compatibility with callback before the onDisposeObservable existed.
  13199. * The set callback will be triggered when the layer has been disposed.
  13200. */
  13201. onDispose: () => void;
  13202. /**
  13203. * An event triggered before rendering the scene
  13204. */
  13205. onBeforeRenderObservable: Observable<Layer>;
  13206. private _onBeforeRenderObserver;
  13207. /**
  13208. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13209. * The set callback will be triggered just before rendering the layer.
  13210. */
  13211. onBeforeRender: () => void;
  13212. /**
  13213. * An event triggered after rendering the scene
  13214. */
  13215. onAfterRenderObservable: Observable<Layer>;
  13216. private _onAfterRenderObserver;
  13217. /**
  13218. * Back compatibility with callback before the onAfterRenderObservable existed.
  13219. * The set callback will be triggered just after rendering the layer.
  13220. */
  13221. onAfterRender: () => void;
  13222. /**
  13223. * Instantiates a new layer.
  13224. * This represents a full screen 2d layer.
  13225. * This can be useful to display a picture in the background of your scene for instance.
  13226. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13227. * @param name Define the name of the layer in the scene
  13228. * @param imgUrl Define the url of the texture to display in the layer
  13229. * @param scene Define the scene the layer belongs to
  13230. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13231. * @param color Defines a color for the layer
  13232. */
  13233. constructor(
  13234. /**
  13235. * Define the name of the layer.
  13236. */
  13237. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13238. private _createIndexBuffer;
  13239. /** @hidden */
  13240. _rebuild(): void;
  13241. /**
  13242. * Renders the layer in the scene.
  13243. */
  13244. render(): void;
  13245. /**
  13246. * Disposes and releases the associated ressources.
  13247. */
  13248. dispose(): void;
  13249. }
  13250. }
  13251. declare module BABYLON {
  13252. interface AbstractScene {
  13253. /**
  13254. * The list of procedural textures added to the scene
  13255. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13256. */
  13257. proceduralTextures: Array<ProceduralTexture>;
  13258. }
  13259. /**
  13260. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13261. * in a given scene.
  13262. */
  13263. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13264. /**
  13265. * The component name helpfull to identify the component in the list of scene components.
  13266. */
  13267. readonly name: string;
  13268. /**
  13269. * The scene the component belongs to.
  13270. */
  13271. scene: Scene;
  13272. /**
  13273. * Creates a new instance of the component for the given scene
  13274. * @param scene Defines the scene to register the component in
  13275. */
  13276. constructor(scene: Scene);
  13277. /**
  13278. * Registers the component in a given scene
  13279. */
  13280. register(): void;
  13281. /**
  13282. * Rebuilds the elements related to this component in case of
  13283. * context lost for instance.
  13284. */
  13285. rebuild(): void;
  13286. /**
  13287. * Disposes the component and the associated ressources.
  13288. */
  13289. dispose(): void;
  13290. private _beforeClear;
  13291. }
  13292. }
  13293. declare module BABYLON {
  13294. /** @hidden */
  13295. export var proceduralVertexShader: {
  13296. name: string;
  13297. shader: string;
  13298. };
  13299. }
  13300. declare module BABYLON {
  13301. /**
  13302. * 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.
  13303. * This is the base class of any Procedural texture and contains most of the shareable code.
  13304. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13305. */
  13306. export class ProceduralTexture extends Texture {
  13307. isCube: boolean;
  13308. /**
  13309. * Define if the texture is enabled or not (disabled texture will not render)
  13310. */
  13311. isEnabled: boolean;
  13312. /**
  13313. * Define if the texture must be cleared before rendering (default is true)
  13314. */
  13315. autoClear: boolean;
  13316. /**
  13317. * Callback called when the texture is generated
  13318. */
  13319. onGenerated: () => void;
  13320. /**
  13321. * Event raised when the texture is generated
  13322. */
  13323. onGeneratedObservable: Observable<ProceduralTexture>;
  13324. /** @hidden */
  13325. _generateMipMaps: boolean;
  13326. /** @hidden **/
  13327. _effect: Effect;
  13328. /** @hidden */
  13329. _textures: {
  13330. [key: string]: Texture;
  13331. };
  13332. private _size;
  13333. private _currentRefreshId;
  13334. private _refreshRate;
  13335. private _vertexBuffers;
  13336. private _indexBuffer;
  13337. private _uniforms;
  13338. private _samplers;
  13339. private _fragment;
  13340. private _floats;
  13341. private _ints;
  13342. private _floatsArrays;
  13343. private _colors3;
  13344. private _colors4;
  13345. private _vectors2;
  13346. private _vectors3;
  13347. private _matrices;
  13348. private _fallbackTexture;
  13349. private _fallbackTextureUsed;
  13350. private _engine;
  13351. private _cachedDefines;
  13352. private _contentUpdateId;
  13353. private _contentData;
  13354. /**
  13355. * Instantiates a new procedural texture.
  13356. * 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.
  13357. * This is the base class of any Procedural texture and contains most of the shareable code.
  13358. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13359. * @param name Define the name of the texture
  13360. * @param size Define the size of the texture to create
  13361. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13362. * @param scene Define the scene the texture belongs to
  13363. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13364. * @param generateMipMaps Define if the texture should creates mip maps or not
  13365. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13366. */
  13367. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13368. /**
  13369. * The effect that is created when initializing the post process.
  13370. * @returns The created effect corrisponding the the postprocess.
  13371. */
  13372. getEffect(): Effect;
  13373. /**
  13374. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13375. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13376. */
  13377. getContent(): Nullable<ArrayBufferView>;
  13378. private _createIndexBuffer;
  13379. /** @hidden */
  13380. _rebuild(): void;
  13381. /**
  13382. * Resets the texture in order to recreate its associated resources.
  13383. * This can be called in case of context loss
  13384. */
  13385. reset(): void;
  13386. protected _getDefines(): string;
  13387. /**
  13388. * Is the texture ready to be used ? (rendered at least once)
  13389. * @returns true if ready, otherwise, false.
  13390. */
  13391. isReady(): boolean;
  13392. /**
  13393. * Resets the refresh counter of the texture and start bak from scratch.
  13394. * Could be useful to regenerate the texture if it is setup to render only once.
  13395. */
  13396. resetRefreshCounter(): void;
  13397. /**
  13398. * Set the fragment shader to use in order to render the texture.
  13399. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13400. */
  13401. setFragment(fragment: any): void;
  13402. /**
  13403. * Define the refresh rate of the texture or the rendering frequency.
  13404. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13405. */
  13406. refreshRate: number;
  13407. /** @hidden */
  13408. _shouldRender(): boolean;
  13409. /**
  13410. * Get the size the texture is rendering at.
  13411. * @returns the size (texture is always squared)
  13412. */
  13413. getRenderSize(): number;
  13414. /**
  13415. * Resize the texture to new value.
  13416. * @param size Define the new size the texture should have
  13417. * @param generateMipMaps Define whether the new texture should create mip maps
  13418. */
  13419. resize(size: number, generateMipMaps: boolean): void;
  13420. private _checkUniform;
  13421. /**
  13422. * Set a texture in the shader program used to render.
  13423. * @param name Define the name of the uniform samplers as defined in the shader
  13424. * @param texture Define the texture to bind to this sampler
  13425. * @return the texture itself allowing "fluent" like uniform updates
  13426. */
  13427. setTexture(name: string, texture: Texture): ProceduralTexture;
  13428. /**
  13429. * Set a float in the shader.
  13430. * @param name Define the name of the uniform as defined in the shader
  13431. * @param value Define the value to give to the uniform
  13432. * @return the texture itself allowing "fluent" like uniform updates
  13433. */
  13434. setFloat(name: string, value: number): ProceduralTexture;
  13435. /**
  13436. * Set a int in the shader.
  13437. * @param name Define the name of the uniform as defined in the shader
  13438. * @param value Define the value to give to the uniform
  13439. * @return the texture itself allowing "fluent" like uniform updates
  13440. */
  13441. setInt(name: string, value: number): ProceduralTexture;
  13442. /**
  13443. * Set an array of floats in the shader.
  13444. * @param name Define the name of the uniform as defined in the shader
  13445. * @param value Define the value to give to the uniform
  13446. * @return the texture itself allowing "fluent" like uniform updates
  13447. */
  13448. setFloats(name: string, value: number[]): ProceduralTexture;
  13449. /**
  13450. * Set a vec3 in the shader from a Color3.
  13451. * @param name Define the name of the uniform as defined in the shader
  13452. * @param value Define the value to give to the uniform
  13453. * @return the texture itself allowing "fluent" like uniform updates
  13454. */
  13455. setColor3(name: string, value: Color3): ProceduralTexture;
  13456. /**
  13457. * Set a vec4 in the shader from a Color4.
  13458. * @param name Define the name of the uniform as defined in the shader
  13459. * @param value Define the value to give to the uniform
  13460. * @return the texture itself allowing "fluent" like uniform updates
  13461. */
  13462. setColor4(name: string, value: Color4): ProceduralTexture;
  13463. /**
  13464. * Set a vec2 in the shader from a Vector2.
  13465. * @param name Define the name of the uniform as defined in the shader
  13466. * @param value Define the value to give to the uniform
  13467. * @return the texture itself allowing "fluent" like uniform updates
  13468. */
  13469. setVector2(name: string, value: Vector2): ProceduralTexture;
  13470. /**
  13471. * Set a vec3 in the shader from a Vector3.
  13472. * @param name Define the name of the uniform as defined in the shader
  13473. * @param value Define the value to give to the uniform
  13474. * @return the texture itself allowing "fluent" like uniform updates
  13475. */
  13476. setVector3(name: string, value: Vector3): ProceduralTexture;
  13477. /**
  13478. * Set a mat4 in the shader from a MAtrix.
  13479. * @param name Define the name of the uniform as defined in the shader
  13480. * @param value Define the value to give to the uniform
  13481. * @return the texture itself allowing "fluent" like uniform updates
  13482. */
  13483. setMatrix(name: string, value: Matrix): ProceduralTexture;
  13484. /**
  13485. * Render the texture to its associated render target.
  13486. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  13487. */
  13488. render(useCameraPostProcess?: boolean): void;
  13489. /**
  13490. * Clone the texture.
  13491. * @returns the cloned texture
  13492. */
  13493. clone(): ProceduralTexture;
  13494. /**
  13495. * Dispose the texture and release its asoociated resources.
  13496. */
  13497. dispose(): void;
  13498. }
  13499. }
  13500. declare module BABYLON {
  13501. /**
  13502. * This represents the base class for particle system in Babylon.
  13503. * 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.
  13504. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  13505. * @example https://doc.babylonjs.com/babylon101/particles
  13506. */
  13507. export class BaseParticleSystem {
  13508. /**
  13509. * Source color is added to the destination color without alpha affecting the result
  13510. */
  13511. static BLENDMODE_ONEONE: number;
  13512. /**
  13513. * Blend current color and particle color using particle’s alpha
  13514. */
  13515. static BLENDMODE_STANDARD: number;
  13516. /**
  13517. * Add current color and particle color multiplied by particle’s alpha
  13518. */
  13519. static BLENDMODE_ADD: number;
  13520. /**
  13521. * Multiply current color with particle color
  13522. */
  13523. static BLENDMODE_MULTIPLY: number;
  13524. /**
  13525. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  13526. */
  13527. static BLENDMODE_MULTIPLYADD: number;
  13528. /**
  13529. * List of animations used by the particle system.
  13530. */
  13531. animations: Animation[];
  13532. /**
  13533. * The id of the Particle system.
  13534. */
  13535. id: string;
  13536. /**
  13537. * The friendly name of the Particle system.
  13538. */
  13539. name: string;
  13540. /**
  13541. * The rendering group used by the Particle system to chose when to render.
  13542. */
  13543. renderingGroupId: number;
  13544. /**
  13545. * The emitter represents the Mesh or position we are attaching the particle system to.
  13546. */
  13547. emitter: Nullable<AbstractMesh | Vector3>;
  13548. /**
  13549. * The maximum number of particles to emit per frame
  13550. */
  13551. emitRate: number;
  13552. /**
  13553. * If you want to launch only a few particles at once, that can be done, as well.
  13554. */
  13555. manualEmitCount: number;
  13556. /**
  13557. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13558. */
  13559. updateSpeed: number;
  13560. /**
  13561. * The amount of time the particle system is running (depends of the overall update speed).
  13562. */
  13563. targetStopDuration: number;
  13564. /**
  13565. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13566. */
  13567. disposeOnStop: boolean;
  13568. /**
  13569. * Minimum power of emitting particles.
  13570. */
  13571. minEmitPower: number;
  13572. /**
  13573. * Maximum power of emitting particles.
  13574. */
  13575. maxEmitPower: number;
  13576. /**
  13577. * Minimum life time of emitting particles.
  13578. */
  13579. minLifeTime: number;
  13580. /**
  13581. * Maximum life time of emitting particles.
  13582. */
  13583. maxLifeTime: number;
  13584. /**
  13585. * Minimum Size of emitting particles.
  13586. */
  13587. minSize: number;
  13588. /**
  13589. * Maximum Size of emitting particles.
  13590. */
  13591. maxSize: number;
  13592. /**
  13593. * Minimum scale of emitting particles on X axis.
  13594. */
  13595. minScaleX: number;
  13596. /**
  13597. * Maximum scale of emitting particles on X axis.
  13598. */
  13599. maxScaleX: number;
  13600. /**
  13601. * Minimum scale of emitting particles on Y axis.
  13602. */
  13603. minScaleY: number;
  13604. /**
  13605. * Maximum scale of emitting particles on Y axis.
  13606. */
  13607. maxScaleY: number;
  13608. /**
  13609. * Gets or sets the minimal initial rotation in radians.
  13610. */
  13611. minInitialRotation: number;
  13612. /**
  13613. * Gets or sets the maximal initial rotation in radians.
  13614. */
  13615. maxInitialRotation: number;
  13616. /**
  13617. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13618. */
  13619. minAngularSpeed: number;
  13620. /**
  13621. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13622. */
  13623. maxAngularSpeed: number;
  13624. /**
  13625. * The texture used to render each particle. (this can be a spritesheet)
  13626. */
  13627. particleTexture: Nullable<Texture>;
  13628. /**
  13629. * The layer mask we are rendering the particles through.
  13630. */
  13631. layerMask: number;
  13632. /**
  13633. * This can help using your own shader to render the particle system.
  13634. * The according effect will be created
  13635. */
  13636. customShader: any;
  13637. /**
  13638. * By default particle system starts as soon as they are created. This prevents the
  13639. * automatic start to happen and let you decide when to start emitting particles.
  13640. */
  13641. preventAutoStart: boolean;
  13642. private _noiseTexture;
  13643. /**
  13644. * Gets or sets a texture used to add random noise to particle positions
  13645. */
  13646. noiseTexture: Nullable<ProceduralTexture>;
  13647. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13648. noiseStrength: Vector3;
  13649. /**
  13650. * Callback triggered when the particle animation is ending.
  13651. */
  13652. onAnimationEnd: Nullable<() => void>;
  13653. /**
  13654. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  13655. */
  13656. blendMode: number;
  13657. /**
  13658. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  13659. * to override the particles.
  13660. */
  13661. forceDepthWrite: boolean;
  13662. /** 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 */
  13663. preWarmCycles: number;
  13664. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  13665. preWarmStepOffset: number;
  13666. /**
  13667. * 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)
  13668. */
  13669. spriteCellChangeSpeed: number;
  13670. /**
  13671. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13672. */
  13673. startSpriteCellID: number;
  13674. /**
  13675. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13676. */
  13677. endSpriteCellID: number;
  13678. /**
  13679. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13680. */
  13681. spriteCellWidth: number;
  13682. /**
  13683. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13684. */
  13685. spriteCellHeight: number;
  13686. /**
  13687. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13688. */
  13689. spriteRandomStartCell: boolean;
  13690. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13691. translationPivot: Vector2;
  13692. /** @hidden */
  13693. protected _isAnimationSheetEnabled: boolean;
  13694. /**
  13695. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13696. */
  13697. beginAnimationOnStart: boolean;
  13698. /**
  13699. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13700. */
  13701. beginAnimationFrom: number;
  13702. /**
  13703. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13704. */
  13705. beginAnimationTo: number;
  13706. /**
  13707. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13708. */
  13709. beginAnimationLoop: boolean;
  13710. /**
  13711. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  13712. */
  13713. isAnimationSheetEnabled: boolean;
  13714. /**
  13715. * Get hosting scene
  13716. * @returns the scene
  13717. */
  13718. getScene(): Scene;
  13719. /**
  13720. * You can use gravity if you want to give an orientation to your particles.
  13721. */
  13722. gravity: Vector3;
  13723. protected _colorGradients: Nullable<Array<ColorGradient>>;
  13724. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  13725. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  13726. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  13727. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  13728. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  13729. protected _dragGradients: Nullable<Array<FactorGradient>>;
  13730. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  13731. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  13732. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  13733. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  13734. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  13735. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  13736. /**
  13737. * Defines the delay in milliseconds before starting the system (0 by default)
  13738. */
  13739. startDelay: number;
  13740. /**
  13741. * Gets the current list of drag gradients.
  13742. * You must use addDragGradient and removeDragGradient to udpate this list
  13743. * @returns the list of drag gradients
  13744. */
  13745. getDragGradients(): Nullable<Array<FactorGradient>>;
  13746. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13747. limitVelocityDamping: number;
  13748. /**
  13749. * Gets the current list of limit velocity gradients.
  13750. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13751. * @returns the list of limit velocity gradients
  13752. */
  13753. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13754. /**
  13755. * Gets the current list of color gradients.
  13756. * You must use addColorGradient and removeColorGradient to udpate this list
  13757. * @returns the list of color gradients
  13758. */
  13759. getColorGradients(): Nullable<Array<ColorGradient>>;
  13760. /**
  13761. * Gets the current list of size gradients.
  13762. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13763. * @returns the list of size gradients
  13764. */
  13765. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13766. /**
  13767. * Gets the current list of color remap gradients.
  13768. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13769. * @returns the list of color remap gradients
  13770. */
  13771. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13772. /**
  13773. * Gets the current list of alpha remap gradients.
  13774. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13775. * @returns the list of alpha remap gradients
  13776. */
  13777. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13778. /**
  13779. * Gets the current list of life time gradients.
  13780. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13781. * @returns the list of life time gradients
  13782. */
  13783. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13784. /**
  13785. * Gets the current list of angular speed gradients.
  13786. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13787. * @returns the list of angular speed gradients
  13788. */
  13789. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13790. /**
  13791. * Gets the current list of velocity gradients.
  13792. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13793. * @returns the list of velocity gradients
  13794. */
  13795. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13796. /**
  13797. * Gets the current list of start size gradients.
  13798. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13799. * @returns the list of start size gradients
  13800. */
  13801. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13802. /**
  13803. * Gets the current list of emit rate gradients.
  13804. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13805. * @returns the list of emit rate gradients
  13806. */
  13807. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13808. /**
  13809. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13810. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13811. */
  13812. direction1: Vector3;
  13813. /**
  13814. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13815. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13816. */
  13817. direction2: Vector3;
  13818. /**
  13819. * 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.
  13820. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13821. */
  13822. minEmitBox: Vector3;
  13823. /**
  13824. * 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.
  13825. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13826. */
  13827. maxEmitBox: Vector3;
  13828. /**
  13829. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  13830. */
  13831. color1: Color4;
  13832. /**
  13833. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  13834. */
  13835. color2: Color4;
  13836. /**
  13837. * Color the particle will have at the end of its lifetime
  13838. */
  13839. colorDead: Color4;
  13840. /**
  13841. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  13842. */
  13843. textureMask: Color4;
  13844. /**
  13845. * The particle emitter type defines the emitter used by the particle system.
  13846. * It can be for example box, sphere, or cone...
  13847. */
  13848. particleEmitterType: IParticleEmitterType;
  13849. /** @hidden */
  13850. _isSubEmitter: boolean;
  13851. /**
  13852. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13853. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13854. */
  13855. billboardMode: number;
  13856. protected _isBillboardBased: boolean;
  13857. /**
  13858. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13859. */
  13860. isBillboardBased: boolean;
  13861. /**
  13862. * The scene the particle system belongs to.
  13863. */
  13864. protected _scene: Scene;
  13865. /**
  13866. * Local cache of defines for image processing.
  13867. */
  13868. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  13869. /**
  13870. * Default configuration related to image processing available in the standard Material.
  13871. */
  13872. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  13873. /**
  13874. * Gets the image processing configuration used either in this material.
  13875. */
  13876. /**
  13877. * Sets the Default image processing configuration used either in the this material.
  13878. *
  13879. * If sets to null, the scene one is in use.
  13880. */
  13881. imageProcessingConfiguration: ImageProcessingConfiguration;
  13882. /**
  13883. * Attaches a new image processing configuration to the Standard Material.
  13884. * @param configuration
  13885. */
  13886. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  13887. /** @hidden */
  13888. protected _reset(): void;
  13889. /** @hidden */
  13890. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  13891. /**
  13892. * Instantiates a particle system.
  13893. * 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.
  13894. * @param name The name of the particle system
  13895. */
  13896. constructor(name: string);
  13897. /**
  13898. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13899. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13900. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13901. * @returns the emitter
  13902. */
  13903. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13904. /**
  13905. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13906. * @param radius The radius of the hemisphere to emit from
  13907. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13908. * @returns the emitter
  13909. */
  13910. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  13911. /**
  13912. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13913. * @param radius The radius of the sphere to emit from
  13914. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13915. * @returns the emitter
  13916. */
  13917. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  13918. /**
  13919. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13920. * @param radius The radius of the sphere to emit from
  13921. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13922. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13923. * @returns the emitter
  13924. */
  13925. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  13926. /**
  13927. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13928. * @param radius The radius of the emission cylinder
  13929. * @param height The height of the emission cylinder
  13930. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13931. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13932. * @returns the emitter
  13933. */
  13934. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  13935. /**
  13936. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13937. * @param radius The radius of the cylinder to emit from
  13938. * @param height The height of the emission cylinder
  13939. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13940. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13941. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13942. * @returns the emitter
  13943. */
  13944. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  13945. /**
  13946. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13947. * @param radius The radius of the cone to emit from
  13948. * @param angle The base angle of the cone
  13949. * @returns the emitter
  13950. */
  13951. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  13952. /**
  13953. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13954. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13955. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13956. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13957. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13958. * @returns the emitter
  13959. */
  13960. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13961. }
  13962. }
  13963. declare module BABYLON {
  13964. /**
  13965. * Type of sub emitter
  13966. */
  13967. export enum SubEmitterType {
  13968. /**
  13969. * Attached to the particle over it's lifetime
  13970. */
  13971. ATTACHED = 0,
  13972. /**
  13973. * Created when the particle dies
  13974. */
  13975. END = 1
  13976. }
  13977. /**
  13978. * Sub emitter class used to emit particles from an existing particle
  13979. */
  13980. export class SubEmitter {
  13981. /**
  13982. * the particle system to be used by the sub emitter
  13983. */
  13984. particleSystem: ParticleSystem;
  13985. /**
  13986. * Type of the submitter (Default: END)
  13987. */
  13988. type: SubEmitterType;
  13989. /**
  13990. * 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)
  13991. * Note: This only is supported when using an emitter of type Mesh
  13992. */
  13993. inheritDirection: boolean;
  13994. /**
  13995. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  13996. */
  13997. inheritedVelocityAmount: number;
  13998. /**
  13999. * Creates a sub emitter
  14000. * @param particleSystem the particle system to be used by the sub emitter
  14001. */
  14002. constructor(
  14003. /**
  14004. * the particle system to be used by the sub emitter
  14005. */
  14006. particleSystem: ParticleSystem);
  14007. /**
  14008. * Clones the sub emitter
  14009. * @returns the cloned sub emitter
  14010. */
  14011. clone(): SubEmitter;
  14012. /**
  14013. * Serialize current object to a JSON object
  14014. * @returns the serialized object
  14015. */
  14016. serialize(): any;
  14017. /** @hidden */
  14018. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14019. /**
  14020. * Creates a new SubEmitter from a serialized JSON version
  14021. * @param serializationObject defines the JSON object to read from
  14022. * @param scene defines the hosting scene
  14023. * @param rootUrl defines the rootUrl for data loading
  14024. * @returns a new SubEmitter
  14025. */
  14026. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14027. /** Release associated resources */
  14028. dispose(): void;
  14029. }
  14030. }
  14031. declare module BABYLON {
  14032. /** @hidden */
  14033. export var clipPlaneFragmentDeclaration: {
  14034. name: string;
  14035. shader: string;
  14036. };
  14037. }
  14038. declare module BABYLON {
  14039. /** @hidden */
  14040. export var imageProcessingDeclaration: {
  14041. name: string;
  14042. shader: string;
  14043. };
  14044. }
  14045. declare module BABYLON {
  14046. /** @hidden */
  14047. export var imageProcessingFunctions: {
  14048. name: string;
  14049. shader: string;
  14050. };
  14051. }
  14052. declare module BABYLON {
  14053. /** @hidden */
  14054. export var clipPlaneFragment: {
  14055. name: string;
  14056. shader: string;
  14057. };
  14058. }
  14059. declare module BABYLON {
  14060. /** @hidden */
  14061. export var particlesPixelShader: {
  14062. name: string;
  14063. shader: string;
  14064. };
  14065. }
  14066. declare module BABYLON {
  14067. /** @hidden */
  14068. export var clipPlaneVertexDeclaration: {
  14069. name: string;
  14070. shader: string;
  14071. };
  14072. }
  14073. declare module BABYLON {
  14074. /** @hidden */
  14075. export var clipPlaneVertex: {
  14076. name: string;
  14077. shader: string;
  14078. };
  14079. }
  14080. declare module BABYLON {
  14081. /** @hidden */
  14082. export var particlesVertexShader: {
  14083. name: string;
  14084. shader: string;
  14085. };
  14086. }
  14087. declare module BABYLON {
  14088. /**
  14089. * This represents a particle system in Babylon.
  14090. * 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.
  14091. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14092. * @example https://doc.babylonjs.com/babylon101/particles
  14093. */
  14094. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14095. /**
  14096. * Billboard mode will only apply to Y axis
  14097. */
  14098. static readonly BILLBOARDMODE_Y: number;
  14099. /**
  14100. * Billboard mode will apply to all axes
  14101. */
  14102. static readonly BILLBOARDMODE_ALL: number;
  14103. /**
  14104. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14105. */
  14106. static readonly BILLBOARDMODE_STRETCHED: number;
  14107. /**
  14108. * This function can be defined to provide custom update for active particles.
  14109. * This function will be called instead of regular update (age, position, color, etc.).
  14110. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14111. */
  14112. updateFunction: (particles: Particle[]) => void;
  14113. private _emitterWorldMatrix;
  14114. /**
  14115. * This function can be defined to specify initial direction for every new particle.
  14116. * It by default use the emitterType defined function
  14117. */
  14118. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14119. /**
  14120. * This function can be defined to specify initial position for every new particle.
  14121. * It by default use the emitterType defined function
  14122. */
  14123. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14124. /**
  14125. * @hidden
  14126. */
  14127. _inheritedVelocityOffset: Vector3;
  14128. /**
  14129. * An event triggered when the system is disposed
  14130. */
  14131. onDisposeObservable: Observable<ParticleSystem>;
  14132. private _onDisposeObserver;
  14133. /**
  14134. * Sets a callback that will be triggered when the system is disposed
  14135. */
  14136. onDispose: () => void;
  14137. private _particles;
  14138. private _epsilon;
  14139. private _capacity;
  14140. private _stockParticles;
  14141. private _newPartsExcess;
  14142. private _vertexData;
  14143. private _vertexBuffer;
  14144. private _vertexBuffers;
  14145. private _spriteBuffer;
  14146. private _indexBuffer;
  14147. private _effect;
  14148. private _customEffect;
  14149. private _cachedDefines;
  14150. private _scaledColorStep;
  14151. private _colorDiff;
  14152. private _scaledDirection;
  14153. private _scaledGravity;
  14154. private _currentRenderId;
  14155. private _alive;
  14156. private _useInstancing;
  14157. private _started;
  14158. private _stopped;
  14159. private _actualFrame;
  14160. private _scaledUpdateSpeed;
  14161. private _vertexBufferSize;
  14162. /** @hidden */
  14163. _currentEmitRateGradient: Nullable<FactorGradient>;
  14164. /** @hidden */
  14165. _currentEmitRate1: number;
  14166. /** @hidden */
  14167. _currentEmitRate2: number;
  14168. /** @hidden */
  14169. _currentStartSizeGradient: Nullable<FactorGradient>;
  14170. /** @hidden */
  14171. _currentStartSize1: number;
  14172. /** @hidden */
  14173. _currentStartSize2: number;
  14174. private readonly _rawTextureWidth;
  14175. private _rampGradientsTexture;
  14176. private _useRampGradients;
  14177. /** Gets or sets a boolean indicating that ramp gradients must be used
  14178. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14179. */
  14180. useRampGradients: boolean;
  14181. /**
  14182. * 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.
  14183. * 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: [])
  14184. */
  14185. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14186. private _subEmitters;
  14187. /**
  14188. * @hidden
  14189. * If the particle systems emitter should be disposed when the particle system is disposed
  14190. */
  14191. _disposeEmitterOnDispose: boolean;
  14192. /**
  14193. * The current active Sub-systems, this property is used by the root particle system only.
  14194. */
  14195. activeSubSystems: Array<ParticleSystem>;
  14196. private _rootParticleSystem;
  14197. /**
  14198. * Gets the current list of active particles
  14199. */
  14200. readonly particles: Particle[];
  14201. /**
  14202. * Returns the string "ParticleSystem"
  14203. * @returns a string containing the class name
  14204. */
  14205. getClassName(): string;
  14206. /**
  14207. * Instantiates a particle system.
  14208. * 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.
  14209. * @param name The name of the particle system
  14210. * @param capacity The max number of particles alive at the same time
  14211. * @param scene The scene the particle system belongs to
  14212. * @param customEffect a custom effect used to change the way particles are rendered by default
  14213. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14214. * @param epsilon Offset used to render the particles
  14215. */
  14216. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14217. private _addFactorGradient;
  14218. private _removeFactorGradient;
  14219. /**
  14220. * Adds a new life time gradient
  14221. * @param gradient defines the gradient to use (between 0 and 1)
  14222. * @param factor defines the life time factor to affect to the specified gradient
  14223. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14224. * @returns the current particle system
  14225. */
  14226. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14227. /**
  14228. * Remove a specific life time gradient
  14229. * @param gradient defines the gradient to remove
  14230. * @returns the current particle system
  14231. */
  14232. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14233. /**
  14234. * Adds a new size gradient
  14235. * @param gradient defines the gradient to use (between 0 and 1)
  14236. * @param factor defines the size factor to affect to the specified gradient
  14237. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14238. * @returns the current particle system
  14239. */
  14240. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14241. /**
  14242. * Remove a specific size gradient
  14243. * @param gradient defines the gradient to remove
  14244. * @returns the current particle system
  14245. */
  14246. removeSizeGradient(gradient: number): IParticleSystem;
  14247. /**
  14248. * Adds a new color remap gradient
  14249. * @param gradient defines the gradient to use (between 0 and 1)
  14250. * @param min defines the color remap minimal range
  14251. * @param max defines the color remap maximal range
  14252. * @returns the current particle system
  14253. */
  14254. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14255. /**
  14256. * Remove a specific color remap gradient
  14257. * @param gradient defines the gradient to remove
  14258. * @returns the current particle system
  14259. */
  14260. removeColorRemapGradient(gradient: number): IParticleSystem;
  14261. /**
  14262. * Adds a new alpha remap gradient
  14263. * @param gradient defines the gradient to use (between 0 and 1)
  14264. * @param min defines the alpha remap minimal range
  14265. * @param max defines the alpha remap maximal range
  14266. * @returns the current particle system
  14267. */
  14268. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14269. /**
  14270. * Remove a specific alpha remap gradient
  14271. * @param gradient defines the gradient to remove
  14272. * @returns the current particle system
  14273. */
  14274. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14275. /**
  14276. * Adds a new angular speed gradient
  14277. * @param gradient defines the gradient to use (between 0 and 1)
  14278. * @param factor defines the angular speed to affect to the specified gradient
  14279. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14280. * @returns the current particle system
  14281. */
  14282. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14283. /**
  14284. * Remove a specific angular speed gradient
  14285. * @param gradient defines the gradient to remove
  14286. * @returns the current particle system
  14287. */
  14288. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14289. /**
  14290. * Adds a new velocity gradient
  14291. * @param gradient defines the gradient to use (between 0 and 1)
  14292. * @param factor defines the velocity to affect to the specified gradient
  14293. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14294. * @returns the current particle system
  14295. */
  14296. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14297. /**
  14298. * Remove a specific velocity gradient
  14299. * @param gradient defines the gradient to remove
  14300. * @returns the current particle system
  14301. */
  14302. removeVelocityGradient(gradient: number): IParticleSystem;
  14303. /**
  14304. * Adds a new limit velocity gradient
  14305. * @param gradient defines the gradient to use (between 0 and 1)
  14306. * @param factor defines the limit velocity value to affect to the specified gradient
  14307. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14308. * @returns the current particle system
  14309. */
  14310. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14311. /**
  14312. * Remove a specific limit velocity gradient
  14313. * @param gradient defines the gradient to remove
  14314. * @returns the current particle system
  14315. */
  14316. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14317. /**
  14318. * Adds a new drag gradient
  14319. * @param gradient defines the gradient to use (between 0 and 1)
  14320. * @param factor defines the drag value to affect to the specified gradient
  14321. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14322. * @returns the current particle system
  14323. */
  14324. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14325. /**
  14326. * Remove a specific drag gradient
  14327. * @param gradient defines the gradient to remove
  14328. * @returns the current particle system
  14329. */
  14330. removeDragGradient(gradient: number): IParticleSystem;
  14331. /**
  14332. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14333. * @param gradient defines the gradient to use (between 0 and 1)
  14334. * @param factor defines the emit rate value to affect to the specified gradient
  14335. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14336. * @returns the current particle system
  14337. */
  14338. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14339. /**
  14340. * Remove a specific emit rate gradient
  14341. * @param gradient defines the gradient to remove
  14342. * @returns the current particle system
  14343. */
  14344. removeEmitRateGradient(gradient: number): IParticleSystem;
  14345. /**
  14346. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14347. * @param gradient defines the gradient to use (between 0 and 1)
  14348. * @param factor defines the start size value to affect to the specified gradient
  14349. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14350. * @returns the current particle system
  14351. */
  14352. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14353. /**
  14354. * Remove a specific start size gradient
  14355. * @param gradient defines the gradient to remove
  14356. * @returns the current particle system
  14357. */
  14358. removeStartSizeGradient(gradient: number): IParticleSystem;
  14359. private _createRampGradientTexture;
  14360. /**
  14361. * Gets the current list of ramp gradients.
  14362. * You must use addRampGradient and removeRampGradient to udpate this list
  14363. * @returns the list of ramp gradients
  14364. */
  14365. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14366. /**
  14367. * Adds a new ramp gradient used to remap particle colors
  14368. * @param gradient defines the gradient to use (between 0 and 1)
  14369. * @param color defines the color to affect to the specified gradient
  14370. * @returns the current particle system
  14371. */
  14372. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14373. /**
  14374. * Remove a specific ramp gradient
  14375. * @param gradient defines the gradient to remove
  14376. * @returns the current particle system
  14377. */
  14378. removeRampGradient(gradient: number): ParticleSystem;
  14379. /**
  14380. * Adds a new color gradient
  14381. * @param gradient defines the gradient to use (between 0 and 1)
  14382. * @param color1 defines the color to affect to the specified gradient
  14383. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14384. * @returns this particle system
  14385. */
  14386. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14387. /**
  14388. * Remove a specific color gradient
  14389. * @param gradient defines the gradient to remove
  14390. * @returns this particle system
  14391. */
  14392. removeColorGradient(gradient: number): IParticleSystem;
  14393. private _fetchR;
  14394. protected _reset(): void;
  14395. private _resetEffect;
  14396. private _createVertexBuffers;
  14397. private _createIndexBuffer;
  14398. /**
  14399. * Gets the maximum number of particles active at the same time.
  14400. * @returns The max number of active particles.
  14401. */
  14402. getCapacity(): number;
  14403. /**
  14404. * Gets whether there are still active particles in the system.
  14405. * @returns True if it is alive, otherwise false.
  14406. */
  14407. isAlive(): boolean;
  14408. /**
  14409. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14410. * @returns True if it has been started, otherwise false.
  14411. */
  14412. isStarted(): boolean;
  14413. private _prepareSubEmitterInternalArray;
  14414. /**
  14415. * Starts the particle system and begins to emit
  14416. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  14417. */
  14418. start(delay?: number): void;
  14419. /**
  14420. * Stops the particle system.
  14421. * @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.
  14422. */
  14423. stop(stopSubEmitters?: boolean): void;
  14424. /**
  14425. * Remove all active particles
  14426. */
  14427. reset(): void;
  14428. /**
  14429. * @hidden (for internal use only)
  14430. */
  14431. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14432. /**
  14433. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14434. * Its lifetime will start back at 0.
  14435. */
  14436. recycleParticle: (particle: Particle) => void;
  14437. private _stopSubEmitters;
  14438. private _createParticle;
  14439. private _removeFromRoot;
  14440. private _emitFromParticle;
  14441. private _update;
  14442. /** @hidden */
  14443. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  14444. /** @hidden */
  14445. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  14446. /** @hidden */
  14447. private _getEffect;
  14448. /**
  14449. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  14450. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  14451. */
  14452. animate(preWarmOnly?: boolean): void;
  14453. private _appendParticleVertices;
  14454. /**
  14455. * Rebuilds the particle system.
  14456. */
  14457. rebuild(): void;
  14458. /**
  14459. * Is this system ready to be used/rendered
  14460. * @return true if the system is ready
  14461. */
  14462. isReady(): boolean;
  14463. private _render;
  14464. /**
  14465. * Renders the particle system in its current state.
  14466. * @returns the current number of particles
  14467. */
  14468. render(): number;
  14469. /**
  14470. * Disposes the particle system and free the associated resources
  14471. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14472. */
  14473. dispose(disposeTexture?: boolean): void;
  14474. /**
  14475. * Clones the particle system.
  14476. * @param name The name of the cloned object
  14477. * @param newEmitter The new emitter to use
  14478. * @returns the cloned particle system
  14479. */
  14480. clone(name: string, newEmitter: any): ParticleSystem;
  14481. /**
  14482. * Serializes the particle system to a JSON object.
  14483. * @returns the JSON object
  14484. */
  14485. serialize(): any;
  14486. /** @hidden */
  14487. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  14488. /** @hidden */
  14489. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  14490. /**
  14491. * Parses a JSON object to create a particle system.
  14492. * @param parsedParticleSystem The JSON object to parse
  14493. * @param scene The scene to create the particle system in
  14494. * @param rootUrl The root url to use to load external dependencies like texture
  14495. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  14496. * @returns the Parsed particle system
  14497. */
  14498. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  14499. }
  14500. }
  14501. declare module BABYLON {
  14502. /**
  14503. * A particle represents one of the element emitted by a particle system.
  14504. * This is mainly define by its coordinates, direction, velocity and age.
  14505. */
  14506. export class Particle {
  14507. /**
  14508. * The particle system the particle belongs to.
  14509. */
  14510. particleSystem: ParticleSystem;
  14511. private static _Count;
  14512. /**
  14513. * Unique ID of the particle
  14514. */
  14515. id: number;
  14516. /**
  14517. * The world position of the particle in the scene.
  14518. */
  14519. position: Vector3;
  14520. /**
  14521. * The world direction of the particle in the scene.
  14522. */
  14523. direction: Vector3;
  14524. /**
  14525. * The color of the particle.
  14526. */
  14527. color: Color4;
  14528. /**
  14529. * The color change of the particle per step.
  14530. */
  14531. colorStep: Color4;
  14532. /**
  14533. * Defines how long will the life of the particle be.
  14534. */
  14535. lifeTime: number;
  14536. /**
  14537. * The current age of the particle.
  14538. */
  14539. age: number;
  14540. /**
  14541. * The current size of the particle.
  14542. */
  14543. size: number;
  14544. /**
  14545. * The current scale of the particle.
  14546. */
  14547. scale: Vector2;
  14548. /**
  14549. * The current angle of the particle.
  14550. */
  14551. angle: number;
  14552. /**
  14553. * Defines how fast is the angle changing.
  14554. */
  14555. angularSpeed: number;
  14556. /**
  14557. * Defines the cell index used by the particle to be rendered from a sprite.
  14558. */
  14559. cellIndex: number;
  14560. /**
  14561. * The information required to support color remapping
  14562. */
  14563. remapData: Vector4;
  14564. /** @hidden */
  14565. _randomCellOffset?: number;
  14566. /** @hidden */
  14567. _initialDirection: Nullable<Vector3>;
  14568. /** @hidden */
  14569. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  14570. /** @hidden */
  14571. _initialStartSpriteCellID: number;
  14572. /** @hidden */
  14573. _initialEndSpriteCellID: number;
  14574. /** @hidden */
  14575. _currentColorGradient: Nullable<ColorGradient>;
  14576. /** @hidden */
  14577. _currentColor1: Color4;
  14578. /** @hidden */
  14579. _currentColor2: Color4;
  14580. /** @hidden */
  14581. _currentSizeGradient: Nullable<FactorGradient>;
  14582. /** @hidden */
  14583. _currentSize1: number;
  14584. /** @hidden */
  14585. _currentSize2: number;
  14586. /** @hidden */
  14587. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  14588. /** @hidden */
  14589. _currentAngularSpeed1: number;
  14590. /** @hidden */
  14591. _currentAngularSpeed2: number;
  14592. /** @hidden */
  14593. _currentVelocityGradient: Nullable<FactorGradient>;
  14594. /** @hidden */
  14595. _currentVelocity1: number;
  14596. /** @hidden */
  14597. _currentVelocity2: number;
  14598. /** @hidden */
  14599. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  14600. /** @hidden */
  14601. _currentLimitVelocity1: number;
  14602. /** @hidden */
  14603. _currentLimitVelocity2: number;
  14604. /** @hidden */
  14605. _currentDragGradient: Nullable<FactorGradient>;
  14606. /** @hidden */
  14607. _currentDrag1: number;
  14608. /** @hidden */
  14609. _currentDrag2: number;
  14610. /** @hidden */
  14611. _randomNoiseCoordinates1: Vector3;
  14612. /** @hidden */
  14613. _randomNoiseCoordinates2: Vector3;
  14614. /**
  14615. * Creates a new instance Particle
  14616. * @param particleSystem the particle system the particle belongs to
  14617. */
  14618. constructor(
  14619. /**
  14620. * The particle system the particle belongs to.
  14621. */
  14622. particleSystem: ParticleSystem);
  14623. private updateCellInfoFromSystem;
  14624. /**
  14625. * Defines how the sprite cell index is updated for the particle
  14626. */
  14627. updateCellIndex(): void;
  14628. /** @hidden */
  14629. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  14630. /** @hidden */
  14631. _inheritParticleInfoToSubEmitters(): void;
  14632. /** @hidden */
  14633. _reset(): void;
  14634. /**
  14635. * Copy the properties of particle to another one.
  14636. * @param other the particle to copy the information to.
  14637. */
  14638. copyTo(other: Particle): void;
  14639. }
  14640. }
  14641. declare module BABYLON {
  14642. /**
  14643. * Particle emitter represents a volume emitting particles.
  14644. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  14645. */
  14646. export interface IParticleEmitterType {
  14647. /**
  14648. * Called by the particle System when the direction is computed for the created particle.
  14649. * @param worldMatrix is the world matrix of the particle system
  14650. * @param directionToUpdate is the direction vector to update with the result
  14651. * @param particle is the particle we are computed the direction for
  14652. */
  14653. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14654. /**
  14655. * Called by the particle System when the position is computed for the created particle.
  14656. * @param worldMatrix is the world matrix of the particle system
  14657. * @param positionToUpdate is the position vector to update with the result
  14658. * @param particle is the particle we are computed the position for
  14659. */
  14660. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14661. /**
  14662. * Clones the current emitter and returns a copy of it
  14663. * @returns the new emitter
  14664. */
  14665. clone(): IParticleEmitterType;
  14666. /**
  14667. * Called by the GPUParticleSystem to setup the update shader
  14668. * @param effect defines the update shader
  14669. */
  14670. applyToShader(effect: Effect): void;
  14671. /**
  14672. * Returns a string to use to update the GPU particles update shader
  14673. * @returns the effect defines string
  14674. */
  14675. getEffectDefines(): string;
  14676. /**
  14677. * Returns a string representing the class name
  14678. * @returns a string containing the class name
  14679. */
  14680. getClassName(): string;
  14681. /**
  14682. * Serializes the particle system to a JSON object.
  14683. * @returns the JSON object
  14684. */
  14685. serialize(): any;
  14686. /**
  14687. * Parse properties from a JSON object
  14688. * @param serializationObject defines the JSON object
  14689. */
  14690. parse(serializationObject: any): void;
  14691. }
  14692. }
  14693. declare module BABYLON {
  14694. /**
  14695. * Particle emitter emitting particles from the inside of a box.
  14696. * It emits the particles randomly between 2 given directions.
  14697. */
  14698. export class BoxParticleEmitter implements IParticleEmitterType {
  14699. /**
  14700. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14701. */
  14702. direction1: Vector3;
  14703. /**
  14704. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14705. */
  14706. direction2: Vector3;
  14707. /**
  14708. * 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.
  14709. */
  14710. minEmitBox: Vector3;
  14711. /**
  14712. * 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.
  14713. */
  14714. maxEmitBox: Vector3;
  14715. /**
  14716. * Creates a new instance BoxParticleEmitter
  14717. */
  14718. constructor();
  14719. /**
  14720. * Called by the particle System when the direction is computed for the created particle.
  14721. * @param worldMatrix is the world matrix of the particle system
  14722. * @param directionToUpdate is the direction vector to update with the result
  14723. * @param particle is the particle we are computed the direction for
  14724. */
  14725. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14726. /**
  14727. * Called by the particle System when the position is computed for the created particle.
  14728. * @param worldMatrix is the world matrix of the particle system
  14729. * @param positionToUpdate is the position vector to update with the result
  14730. * @param particle is the particle we are computed the position for
  14731. */
  14732. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14733. /**
  14734. * Clones the current emitter and returns a copy of it
  14735. * @returns the new emitter
  14736. */
  14737. clone(): BoxParticleEmitter;
  14738. /**
  14739. * Called by the GPUParticleSystem to setup the update shader
  14740. * @param effect defines the update shader
  14741. */
  14742. applyToShader(effect: Effect): void;
  14743. /**
  14744. * Returns a string to use to update the GPU particles update shader
  14745. * @returns a string containng the defines string
  14746. */
  14747. getEffectDefines(): string;
  14748. /**
  14749. * Returns the string "BoxParticleEmitter"
  14750. * @returns a string containing the class name
  14751. */
  14752. getClassName(): string;
  14753. /**
  14754. * Serializes the particle system to a JSON object.
  14755. * @returns the JSON object
  14756. */
  14757. serialize(): any;
  14758. /**
  14759. * Parse properties from a JSON object
  14760. * @param serializationObject defines the JSON object
  14761. */
  14762. parse(serializationObject: any): void;
  14763. }
  14764. }
  14765. declare module BABYLON {
  14766. /**
  14767. * Particle emitter emitting particles from the inside of a cone.
  14768. * It emits the particles alongside the cone volume from the base to the particle.
  14769. * The emission direction might be randomized.
  14770. */
  14771. export class ConeParticleEmitter implements IParticleEmitterType {
  14772. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  14773. directionRandomizer: number;
  14774. private _radius;
  14775. private _angle;
  14776. private _height;
  14777. /**
  14778. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  14779. */
  14780. radiusRange: number;
  14781. /**
  14782. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  14783. */
  14784. heightRange: number;
  14785. /**
  14786. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  14787. */
  14788. emitFromSpawnPointOnly: boolean;
  14789. /**
  14790. * Gets or sets the radius of the emission cone
  14791. */
  14792. radius: number;
  14793. /**
  14794. * Gets or sets the angle of the emission cone
  14795. */
  14796. angle: number;
  14797. private _buildHeight;
  14798. /**
  14799. * Creates a new instance ConeParticleEmitter
  14800. * @param radius the radius of the emission cone (1 by default)
  14801. * @param angles the cone base angle (PI by default)
  14802. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  14803. */
  14804. constructor(radius?: number, angle?: number,
  14805. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  14806. directionRandomizer?: number);
  14807. /**
  14808. * Called by the particle System when the direction is computed for the created particle.
  14809. * @param worldMatrix is the world matrix of the particle system
  14810. * @param directionToUpdate is the direction vector to update with the result
  14811. * @param particle is the particle we are computed the direction for
  14812. */
  14813. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14814. /**
  14815. * Called by the particle System when the position is computed for the created particle.
  14816. * @param worldMatrix is the world matrix of the particle system
  14817. * @param positionToUpdate is the position vector to update with the result
  14818. * @param particle is the particle we are computed the position for
  14819. */
  14820. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14821. /**
  14822. * Clones the current emitter and returns a copy of it
  14823. * @returns the new emitter
  14824. */
  14825. clone(): ConeParticleEmitter;
  14826. /**
  14827. * Called by the GPUParticleSystem to setup the update shader
  14828. * @param effect defines the update shader
  14829. */
  14830. applyToShader(effect: Effect): void;
  14831. /**
  14832. * Returns a string to use to update the GPU particles update shader
  14833. * @returns a string containng the defines string
  14834. */
  14835. getEffectDefines(): string;
  14836. /**
  14837. * Returns the string "ConeParticleEmitter"
  14838. * @returns a string containing the class name
  14839. */
  14840. getClassName(): string;
  14841. /**
  14842. * Serializes the particle system to a JSON object.
  14843. * @returns the JSON object
  14844. */
  14845. serialize(): any;
  14846. /**
  14847. * Parse properties from a JSON object
  14848. * @param serializationObject defines the JSON object
  14849. */
  14850. parse(serializationObject: any): void;
  14851. }
  14852. }
  14853. declare module BABYLON {
  14854. /**
  14855. * Particle emitter emitting particles from the inside of a cylinder.
  14856. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  14857. */
  14858. export class CylinderParticleEmitter implements IParticleEmitterType {
  14859. /**
  14860. * The radius of the emission cylinder.
  14861. */
  14862. radius: number;
  14863. /**
  14864. * The height of the emission cylinder.
  14865. */
  14866. height: number;
  14867. /**
  14868. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14869. */
  14870. radiusRange: number;
  14871. /**
  14872. * How much to randomize the particle direction [0-1].
  14873. */
  14874. directionRandomizer: number;
  14875. /**
  14876. * Creates a new instance CylinderParticleEmitter
  14877. * @param radius the radius of the emission cylinder (1 by default)
  14878. * @param height the height of the emission cylinder (1 by default)
  14879. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14880. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14881. */
  14882. constructor(
  14883. /**
  14884. * The radius of the emission cylinder.
  14885. */
  14886. radius?: number,
  14887. /**
  14888. * The height of the emission cylinder.
  14889. */
  14890. height?: number,
  14891. /**
  14892. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14893. */
  14894. radiusRange?: number,
  14895. /**
  14896. * How much to randomize the particle direction [0-1].
  14897. */
  14898. directionRandomizer?: number);
  14899. /**
  14900. * Called by the particle System when the direction is computed for the created particle.
  14901. * @param worldMatrix is the world matrix of the particle system
  14902. * @param directionToUpdate is the direction vector to update with the result
  14903. * @param particle is the particle we are computed the direction for
  14904. */
  14905. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14906. /**
  14907. * Called by the particle System when the position is computed for the created particle.
  14908. * @param worldMatrix is the world matrix of the particle system
  14909. * @param positionToUpdate is the position vector to update with the result
  14910. * @param particle is the particle we are computed the position for
  14911. */
  14912. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14913. /**
  14914. * Clones the current emitter and returns a copy of it
  14915. * @returns the new emitter
  14916. */
  14917. clone(): CylinderParticleEmitter;
  14918. /**
  14919. * Called by the GPUParticleSystem to setup the update shader
  14920. * @param effect defines the update shader
  14921. */
  14922. applyToShader(effect: Effect): void;
  14923. /**
  14924. * Returns a string to use to update the GPU particles update shader
  14925. * @returns a string containng the defines string
  14926. */
  14927. getEffectDefines(): string;
  14928. /**
  14929. * Returns the string "CylinderParticleEmitter"
  14930. * @returns a string containing the class name
  14931. */
  14932. getClassName(): string;
  14933. /**
  14934. * Serializes the particle system to a JSON object.
  14935. * @returns the JSON object
  14936. */
  14937. serialize(): any;
  14938. /**
  14939. * Parse properties from a JSON object
  14940. * @param serializationObject defines the JSON object
  14941. */
  14942. parse(serializationObject: any): void;
  14943. }
  14944. /**
  14945. * Particle emitter emitting particles from the inside of a cylinder.
  14946. * It emits the particles randomly between two vectors.
  14947. */
  14948. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  14949. /**
  14950. * The min limit of the emission direction.
  14951. */
  14952. direction1: Vector3;
  14953. /**
  14954. * The max limit of the emission direction.
  14955. */
  14956. direction2: Vector3;
  14957. /**
  14958. * Creates a new instance CylinderDirectedParticleEmitter
  14959. * @param radius the radius of the emission cylinder (1 by default)
  14960. * @param height the height of the emission cylinder (1 by default)
  14961. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14962. * @param direction1 the min limit of the emission direction (up vector by default)
  14963. * @param direction2 the max limit of the emission direction (up vector by default)
  14964. */
  14965. constructor(radius?: number, height?: number, radiusRange?: number,
  14966. /**
  14967. * The min limit of the emission direction.
  14968. */
  14969. direction1?: Vector3,
  14970. /**
  14971. * The max limit of the emission direction.
  14972. */
  14973. direction2?: Vector3);
  14974. /**
  14975. * Called by the particle System when the direction is computed for the created particle.
  14976. * @param worldMatrix is the world matrix of the particle system
  14977. * @param directionToUpdate is the direction vector to update with the result
  14978. * @param particle is the particle we are computed the direction for
  14979. */
  14980. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14981. /**
  14982. * Clones the current emitter and returns a copy of it
  14983. * @returns the new emitter
  14984. */
  14985. clone(): CylinderDirectedParticleEmitter;
  14986. /**
  14987. * Called by the GPUParticleSystem to setup the update shader
  14988. * @param effect defines the update shader
  14989. */
  14990. applyToShader(effect: Effect): void;
  14991. /**
  14992. * Returns a string to use to update the GPU particles update shader
  14993. * @returns a string containng the defines string
  14994. */
  14995. getEffectDefines(): string;
  14996. /**
  14997. * Returns the string "CylinderDirectedParticleEmitter"
  14998. * @returns a string containing the class name
  14999. */
  15000. getClassName(): string;
  15001. /**
  15002. * Serializes the particle system to a JSON object.
  15003. * @returns the JSON object
  15004. */
  15005. serialize(): any;
  15006. /**
  15007. * Parse properties from a JSON object
  15008. * @param serializationObject defines the JSON object
  15009. */
  15010. parse(serializationObject: any): void;
  15011. }
  15012. }
  15013. declare module BABYLON {
  15014. /**
  15015. * Particle emitter emitting particles from the inside of a hemisphere.
  15016. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15017. */
  15018. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15019. /**
  15020. * The radius of the emission hemisphere.
  15021. */
  15022. radius: number;
  15023. /**
  15024. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15025. */
  15026. radiusRange: number;
  15027. /**
  15028. * How much to randomize the particle direction [0-1].
  15029. */
  15030. directionRandomizer: number;
  15031. /**
  15032. * Creates a new instance HemisphericParticleEmitter
  15033. * @param radius the radius of the emission hemisphere (1 by default)
  15034. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15035. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15036. */
  15037. constructor(
  15038. /**
  15039. * The radius of the emission hemisphere.
  15040. */
  15041. radius?: number,
  15042. /**
  15043. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15044. */
  15045. radiusRange?: number,
  15046. /**
  15047. * How much to randomize the particle direction [0-1].
  15048. */
  15049. directionRandomizer?: number);
  15050. /**
  15051. * Called by the particle System when the direction is computed for the created particle.
  15052. * @param worldMatrix is the world matrix of the particle system
  15053. * @param directionToUpdate is the direction vector to update with the result
  15054. * @param particle is the particle we are computed the direction for
  15055. */
  15056. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15057. /**
  15058. * Called by the particle System when the position is computed for the created particle.
  15059. * @param worldMatrix is the world matrix of the particle system
  15060. * @param positionToUpdate is the position vector to update with the result
  15061. * @param particle is the particle we are computed the position for
  15062. */
  15063. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15064. /**
  15065. * Clones the current emitter and returns a copy of it
  15066. * @returns the new emitter
  15067. */
  15068. clone(): HemisphericParticleEmitter;
  15069. /**
  15070. * Called by the GPUParticleSystem to setup the update shader
  15071. * @param effect defines the update shader
  15072. */
  15073. applyToShader(effect: Effect): void;
  15074. /**
  15075. * Returns a string to use to update the GPU particles update shader
  15076. * @returns a string containng the defines string
  15077. */
  15078. getEffectDefines(): string;
  15079. /**
  15080. * Returns the string "HemisphericParticleEmitter"
  15081. * @returns a string containing the class name
  15082. */
  15083. getClassName(): string;
  15084. /**
  15085. * Serializes the particle system to a JSON object.
  15086. * @returns the JSON object
  15087. */
  15088. serialize(): any;
  15089. /**
  15090. * Parse properties from a JSON object
  15091. * @param serializationObject defines the JSON object
  15092. */
  15093. parse(serializationObject: any): void;
  15094. }
  15095. }
  15096. declare module BABYLON {
  15097. /**
  15098. * Particle emitter emitting particles from a point.
  15099. * It emits the particles randomly between 2 given directions.
  15100. */
  15101. export class PointParticleEmitter implements IParticleEmitterType {
  15102. /**
  15103. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15104. */
  15105. direction1: Vector3;
  15106. /**
  15107. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15108. */
  15109. direction2: Vector3;
  15110. /**
  15111. * Creates a new instance PointParticleEmitter
  15112. */
  15113. constructor();
  15114. /**
  15115. * Called by the particle System when the direction is computed for the created particle.
  15116. * @param worldMatrix is the world matrix of the particle system
  15117. * @param directionToUpdate is the direction vector to update with the result
  15118. * @param particle is the particle we are computed the direction for
  15119. */
  15120. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15121. /**
  15122. * Called by the particle System when the position is computed for the created particle.
  15123. * @param worldMatrix is the world matrix of the particle system
  15124. * @param positionToUpdate is the position vector to update with the result
  15125. * @param particle is the particle we are computed the position for
  15126. */
  15127. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15128. /**
  15129. * Clones the current emitter and returns a copy of it
  15130. * @returns the new emitter
  15131. */
  15132. clone(): PointParticleEmitter;
  15133. /**
  15134. * Called by the GPUParticleSystem to setup the update shader
  15135. * @param effect defines the update shader
  15136. */
  15137. applyToShader(effect: Effect): void;
  15138. /**
  15139. * Returns a string to use to update the GPU particles update shader
  15140. * @returns a string containng the defines string
  15141. */
  15142. getEffectDefines(): string;
  15143. /**
  15144. * Returns the string "PointParticleEmitter"
  15145. * @returns a string containing the class name
  15146. */
  15147. getClassName(): string;
  15148. /**
  15149. * Serializes the particle system to a JSON object.
  15150. * @returns the JSON object
  15151. */
  15152. serialize(): any;
  15153. /**
  15154. * Parse properties from a JSON object
  15155. * @param serializationObject defines the JSON object
  15156. */
  15157. parse(serializationObject: any): void;
  15158. }
  15159. }
  15160. declare module BABYLON {
  15161. /**
  15162. * Particle emitter emitting particles from the inside of a sphere.
  15163. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15164. */
  15165. export class SphereParticleEmitter implements IParticleEmitterType {
  15166. /**
  15167. * The radius of the emission sphere.
  15168. */
  15169. radius: number;
  15170. /**
  15171. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15172. */
  15173. radiusRange: number;
  15174. /**
  15175. * How much to randomize the particle direction [0-1].
  15176. */
  15177. directionRandomizer: number;
  15178. /**
  15179. * Creates a new instance SphereParticleEmitter
  15180. * @param radius the radius of the emission sphere (1 by default)
  15181. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15182. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15183. */
  15184. constructor(
  15185. /**
  15186. * The radius of the emission sphere.
  15187. */
  15188. radius?: number,
  15189. /**
  15190. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15191. */
  15192. radiusRange?: number,
  15193. /**
  15194. * How much to randomize the particle direction [0-1].
  15195. */
  15196. directionRandomizer?: number);
  15197. /**
  15198. * Called by the particle System when the direction is computed for the created particle.
  15199. * @param worldMatrix is the world matrix of the particle system
  15200. * @param directionToUpdate is the direction vector to update with the result
  15201. * @param particle is the particle we are computed the direction for
  15202. */
  15203. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15204. /**
  15205. * Called by the particle System when the position is computed for the created particle.
  15206. * @param worldMatrix is the world matrix of the particle system
  15207. * @param positionToUpdate is the position vector to update with the result
  15208. * @param particle is the particle we are computed the position for
  15209. */
  15210. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15211. /**
  15212. * Clones the current emitter and returns a copy of it
  15213. * @returns the new emitter
  15214. */
  15215. clone(): SphereParticleEmitter;
  15216. /**
  15217. * Called by the GPUParticleSystem to setup the update shader
  15218. * @param effect defines the update shader
  15219. */
  15220. applyToShader(effect: Effect): void;
  15221. /**
  15222. * Returns a string to use to update the GPU particles update shader
  15223. * @returns a string containng the defines string
  15224. */
  15225. getEffectDefines(): string;
  15226. /**
  15227. * Returns the string "SphereParticleEmitter"
  15228. * @returns a string containing the class name
  15229. */
  15230. getClassName(): string;
  15231. /**
  15232. * Serializes the particle system to a JSON object.
  15233. * @returns the JSON object
  15234. */
  15235. serialize(): any;
  15236. /**
  15237. * Parse properties from a JSON object
  15238. * @param serializationObject defines the JSON object
  15239. */
  15240. parse(serializationObject: any): void;
  15241. }
  15242. /**
  15243. * Particle emitter emitting particles from the inside of a sphere.
  15244. * It emits the particles randomly between two vectors.
  15245. */
  15246. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15247. /**
  15248. * The min limit of the emission direction.
  15249. */
  15250. direction1: Vector3;
  15251. /**
  15252. * The max limit of the emission direction.
  15253. */
  15254. direction2: Vector3;
  15255. /**
  15256. * Creates a new instance SphereDirectedParticleEmitter
  15257. * @param radius the radius of the emission sphere (1 by default)
  15258. * @param direction1 the min limit of the emission direction (up vector by default)
  15259. * @param direction2 the max limit of the emission direction (up vector by default)
  15260. */
  15261. constructor(radius?: number,
  15262. /**
  15263. * The min limit of the emission direction.
  15264. */
  15265. direction1?: Vector3,
  15266. /**
  15267. * The max limit of the emission direction.
  15268. */
  15269. direction2?: Vector3);
  15270. /**
  15271. * Called by the particle System when the direction is computed for the created particle.
  15272. * @param worldMatrix is the world matrix of the particle system
  15273. * @param directionToUpdate is the direction vector to update with the result
  15274. * @param particle is the particle we are computed the direction for
  15275. */
  15276. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15277. /**
  15278. * Clones the current emitter and returns a copy of it
  15279. * @returns the new emitter
  15280. */
  15281. clone(): SphereDirectedParticleEmitter;
  15282. /**
  15283. * Called by the GPUParticleSystem to setup the update shader
  15284. * @param effect defines the update shader
  15285. */
  15286. applyToShader(effect: Effect): void;
  15287. /**
  15288. * Returns a string to use to update the GPU particles update shader
  15289. * @returns a string containng the defines string
  15290. */
  15291. getEffectDefines(): string;
  15292. /**
  15293. * Returns the string "SphereDirectedParticleEmitter"
  15294. * @returns a string containing the class name
  15295. */
  15296. getClassName(): string;
  15297. /**
  15298. * Serializes the particle system to a JSON object.
  15299. * @returns the JSON object
  15300. */
  15301. serialize(): any;
  15302. /**
  15303. * Parse properties from a JSON object
  15304. * @param serializationObject defines the JSON object
  15305. */
  15306. parse(serializationObject: any): void;
  15307. }
  15308. }
  15309. declare module BABYLON {
  15310. /**
  15311. * Interface representing a particle system in Babylon.js.
  15312. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15313. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15314. */
  15315. export interface IParticleSystem {
  15316. /**
  15317. * List of animations used by the particle system.
  15318. */
  15319. animations: Animation[];
  15320. /**
  15321. * The id of the Particle system.
  15322. */
  15323. id: string;
  15324. /**
  15325. * The name of the Particle system.
  15326. */
  15327. name: string;
  15328. /**
  15329. * The emitter represents the Mesh or position we are attaching the particle system to.
  15330. */
  15331. emitter: Nullable<AbstractMesh | Vector3>;
  15332. /**
  15333. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15334. */
  15335. isBillboardBased: boolean;
  15336. /**
  15337. * The rendering group used by the Particle system to chose when to render.
  15338. */
  15339. renderingGroupId: number;
  15340. /**
  15341. * The layer mask we are rendering the particles through.
  15342. */
  15343. layerMask: number;
  15344. /**
  15345. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15346. */
  15347. updateSpeed: number;
  15348. /**
  15349. * The amount of time the particle system is running (depends of the overall update speed).
  15350. */
  15351. targetStopDuration: number;
  15352. /**
  15353. * The texture used to render each particle. (this can be a spritesheet)
  15354. */
  15355. particleTexture: Nullable<Texture>;
  15356. /**
  15357. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15358. */
  15359. blendMode: number;
  15360. /**
  15361. * Minimum life time of emitting particles.
  15362. */
  15363. minLifeTime: number;
  15364. /**
  15365. * Maximum life time of emitting particles.
  15366. */
  15367. maxLifeTime: number;
  15368. /**
  15369. * Minimum Size of emitting particles.
  15370. */
  15371. minSize: number;
  15372. /**
  15373. * Maximum Size of emitting particles.
  15374. */
  15375. maxSize: number;
  15376. /**
  15377. * Minimum scale of emitting particles on X axis.
  15378. */
  15379. minScaleX: number;
  15380. /**
  15381. * Maximum scale of emitting particles on X axis.
  15382. */
  15383. maxScaleX: number;
  15384. /**
  15385. * Minimum scale of emitting particles on Y axis.
  15386. */
  15387. minScaleY: number;
  15388. /**
  15389. * Maximum scale of emitting particles on Y axis.
  15390. */
  15391. maxScaleY: number;
  15392. /**
  15393. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15394. */
  15395. color1: Color4;
  15396. /**
  15397. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15398. */
  15399. color2: Color4;
  15400. /**
  15401. * Color the particle will have at the end of its lifetime.
  15402. */
  15403. colorDead: Color4;
  15404. /**
  15405. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15406. */
  15407. emitRate: number;
  15408. /**
  15409. * You can use gravity if you want to give an orientation to your particles.
  15410. */
  15411. gravity: Vector3;
  15412. /**
  15413. * Minimum power of emitting particles.
  15414. */
  15415. minEmitPower: number;
  15416. /**
  15417. * Maximum power of emitting particles.
  15418. */
  15419. maxEmitPower: number;
  15420. /**
  15421. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15422. */
  15423. minAngularSpeed: number;
  15424. /**
  15425. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15426. */
  15427. maxAngularSpeed: number;
  15428. /**
  15429. * Gets or sets the minimal initial rotation in radians.
  15430. */
  15431. minInitialRotation: number;
  15432. /**
  15433. * Gets or sets the maximal initial rotation in radians.
  15434. */
  15435. maxInitialRotation: number;
  15436. /**
  15437. * The particle emitter type defines the emitter used by the particle system.
  15438. * It can be for example box, sphere, or cone...
  15439. */
  15440. particleEmitterType: Nullable<IParticleEmitterType>;
  15441. /**
  15442. * Defines the delay in milliseconds before starting the system (0 by default)
  15443. */
  15444. startDelay: number;
  15445. /**
  15446. * 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
  15447. */
  15448. preWarmCycles: number;
  15449. /**
  15450. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  15451. */
  15452. preWarmStepOffset: number;
  15453. /**
  15454. * 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)
  15455. */
  15456. spriteCellChangeSpeed: number;
  15457. /**
  15458. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15459. */
  15460. startSpriteCellID: number;
  15461. /**
  15462. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15463. */
  15464. endSpriteCellID: number;
  15465. /**
  15466. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15467. */
  15468. spriteCellWidth: number;
  15469. /**
  15470. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15471. */
  15472. spriteCellHeight: number;
  15473. /**
  15474. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15475. */
  15476. spriteRandomStartCell: boolean;
  15477. /**
  15478. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  15479. */
  15480. isAnimationSheetEnabled: boolean;
  15481. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15482. translationPivot: Vector2;
  15483. /**
  15484. * Gets or sets a texture used to add random noise to particle positions
  15485. */
  15486. noiseTexture: Nullable<BaseTexture>;
  15487. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15488. noiseStrength: Vector3;
  15489. /**
  15490. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15491. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15492. */
  15493. billboardMode: number;
  15494. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15495. limitVelocityDamping: number;
  15496. /**
  15497. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15498. */
  15499. beginAnimationOnStart: boolean;
  15500. /**
  15501. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15502. */
  15503. beginAnimationFrom: number;
  15504. /**
  15505. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15506. */
  15507. beginAnimationTo: number;
  15508. /**
  15509. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15510. */
  15511. beginAnimationLoop: boolean;
  15512. /**
  15513. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15514. */
  15515. disposeOnStop: boolean;
  15516. /**
  15517. * Gets the maximum number of particles active at the same time.
  15518. * @returns The max number of active particles.
  15519. */
  15520. getCapacity(): number;
  15521. /**
  15522. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15523. * @returns True if it has been started, otherwise false.
  15524. */
  15525. isStarted(): boolean;
  15526. /**
  15527. * Animates the particle system for this frame.
  15528. */
  15529. animate(): void;
  15530. /**
  15531. * Renders the particle system in its current state.
  15532. * @returns the current number of particles
  15533. */
  15534. render(): number;
  15535. /**
  15536. * Dispose the particle system and frees its associated resources.
  15537. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15538. */
  15539. dispose(disposeTexture?: boolean): void;
  15540. /**
  15541. * Clones the particle system.
  15542. * @param name The name of the cloned object
  15543. * @param newEmitter The new emitter to use
  15544. * @returns the cloned particle system
  15545. */
  15546. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  15547. /**
  15548. * Serializes the particle system to a JSON object.
  15549. * @returns the JSON object
  15550. */
  15551. serialize(): any;
  15552. /**
  15553. * Rebuild the particle system
  15554. */
  15555. rebuild(): void;
  15556. /**
  15557. * Starts the particle system and begins to emit
  15558. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  15559. */
  15560. start(delay?: number): void;
  15561. /**
  15562. * Stops the particle system.
  15563. */
  15564. stop(): void;
  15565. /**
  15566. * Remove all active particles
  15567. */
  15568. reset(): void;
  15569. /**
  15570. * Is this system ready to be used/rendered
  15571. * @return true if the system is ready
  15572. */
  15573. isReady(): boolean;
  15574. /**
  15575. * Adds a new color gradient
  15576. * @param gradient defines the gradient to use (between 0 and 1)
  15577. * @param color1 defines the color to affect to the specified gradient
  15578. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15579. * @returns the current particle system
  15580. */
  15581. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15582. /**
  15583. * Remove a specific color gradient
  15584. * @param gradient defines the gradient to remove
  15585. * @returns the current particle system
  15586. */
  15587. removeColorGradient(gradient: number): IParticleSystem;
  15588. /**
  15589. * Adds a new size gradient
  15590. * @param gradient defines the gradient to use (between 0 and 1)
  15591. * @param factor defines the size factor to affect to the specified gradient
  15592. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15593. * @returns the current particle system
  15594. */
  15595. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15596. /**
  15597. * Remove a specific size gradient
  15598. * @param gradient defines the gradient to remove
  15599. * @returns the current particle system
  15600. */
  15601. removeSizeGradient(gradient: number): IParticleSystem;
  15602. /**
  15603. * Gets the current list of color gradients.
  15604. * You must use addColorGradient and removeColorGradient to udpate this list
  15605. * @returns the list of color gradients
  15606. */
  15607. getColorGradients(): Nullable<Array<ColorGradient>>;
  15608. /**
  15609. * Gets the current list of size gradients.
  15610. * You must use addSizeGradient and removeSizeGradient to udpate this list
  15611. * @returns the list of size gradients
  15612. */
  15613. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15614. /**
  15615. * Gets the current list of angular speed gradients.
  15616. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15617. * @returns the list of angular speed gradients
  15618. */
  15619. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15620. /**
  15621. * Adds a new angular speed gradient
  15622. * @param gradient defines the gradient to use (between 0 and 1)
  15623. * @param factor defines the angular speed to affect to the specified gradient
  15624. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15625. * @returns the current particle system
  15626. */
  15627. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15628. /**
  15629. * Remove a specific angular speed gradient
  15630. * @param gradient defines the gradient to remove
  15631. * @returns the current particle system
  15632. */
  15633. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15634. /**
  15635. * Gets the current list of velocity gradients.
  15636. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15637. * @returns the list of velocity gradients
  15638. */
  15639. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15640. /**
  15641. * Adds a new velocity gradient
  15642. * @param gradient defines the gradient to use (between 0 and 1)
  15643. * @param factor defines the velocity to affect to the specified gradient
  15644. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15645. * @returns the current particle system
  15646. */
  15647. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15648. /**
  15649. * Remove a specific velocity gradient
  15650. * @param gradient defines the gradient to remove
  15651. * @returns the current particle system
  15652. */
  15653. removeVelocityGradient(gradient: number): IParticleSystem;
  15654. /**
  15655. * Gets the current list of limit velocity gradients.
  15656. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  15657. * @returns the list of limit velocity gradients
  15658. */
  15659. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15660. /**
  15661. * Adds a new limit velocity gradient
  15662. * @param gradient defines the gradient to use (between 0 and 1)
  15663. * @param factor defines the limit velocity to affect to the specified gradient
  15664. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15665. * @returns the current particle system
  15666. */
  15667. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15668. /**
  15669. * Remove a specific limit velocity gradient
  15670. * @param gradient defines the gradient to remove
  15671. * @returns the current particle system
  15672. */
  15673. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15674. /**
  15675. * Adds a new drag gradient
  15676. * @param gradient defines the gradient to use (between 0 and 1)
  15677. * @param factor defines the drag to affect to the specified gradient
  15678. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15679. * @returns the current particle system
  15680. */
  15681. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15682. /**
  15683. * Remove a specific drag gradient
  15684. * @param gradient defines the gradient to remove
  15685. * @returns the current particle system
  15686. */
  15687. removeDragGradient(gradient: number): IParticleSystem;
  15688. /**
  15689. * Gets the current list of drag gradients.
  15690. * You must use addDragGradient and removeDragGradient to udpate this list
  15691. * @returns the list of drag gradients
  15692. */
  15693. getDragGradients(): Nullable<Array<FactorGradient>>;
  15694. /**
  15695. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15696. * @param gradient defines the gradient to use (between 0 and 1)
  15697. * @param factor defines the emit rate to affect to the specified gradient
  15698. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15699. * @returns the current particle system
  15700. */
  15701. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15702. /**
  15703. * Remove a specific emit rate gradient
  15704. * @param gradient defines the gradient to remove
  15705. * @returns the current particle system
  15706. */
  15707. removeEmitRateGradient(gradient: number): IParticleSystem;
  15708. /**
  15709. * Gets the current list of emit rate gradients.
  15710. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15711. * @returns the list of emit rate gradients
  15712. */
  15713. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15714. /**
  15715. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15716. * @param gradient defines the gradient to use (between 0 and 1)
  15717. * @param factor defines the start size to affect to the specified gradient
  15718. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15719. * @returns the current particle system
  15720. */
  15721. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15722. /**
  15723. * Remove a specific start size gradient
  15724. * @param gradient defines the gradient to remove
  15725. * @returns the current particle system
  15726. */
  15727. removeStartSizeGradient(gradient: number): IParticleSystem;
  15728. /**
  15729. * Gets the current list of start size gradients.
  15730. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15731. * @returns the list of start size gradients
  15732. */
  15733. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15734. /**
  15735. * Adds a new life time gradient
  15736. * @param gradient defines the gradient to use (between 0 and 1)
  15737. * @param factor defines the life time factor to affect to the specified gradient
  15738. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15739. * @returns the current particle system
  15740. */
  15741. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15742. /**
  15743. * Remove a specific life time gradient
  15744. * @param gradient defines the gradient to remove
  15745. * @returns the current particle system
  15746. */
  15747. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15748. /**
  15749. * Gets the current list of life time gradients.
  15750. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  15751. * @returns the list of life time gradients
  15752. */
  15753. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15754. /**
  15755. * Gets the current list of color gradients.
  15756. * You must use addColorGradient and removeColorGradient to udpate this list
  15757. * @returns the list of color gradients
  15758. */
  15759. getColorGradients(): Nullable<Array<ColorGradient>>;
  15760. /**
  15761. * Adds a new ramp gradient used to remap particle colors
  15762. * @param gradient defines the gradient to use (between 0 and 1)
  15763. * @param color defines the color to affect to the specified gradient
  15764. * @returns the current particle system
  15765. */
  15766. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  15767. /**
  15768. * Gets the current list of ramp gradients.
  15769. * You must use addRampGradient and removeRampGradient to udpate this list
  15770. * @returns the list of ramp gradients
  15771. */
  15772. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15773. /** Gets or sets a boolean indicating that ramp gradients must be used
  15774. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15775. */
  15776. useRampGradients: boolean;
  15777. /**
  15778. * Adds a new color remap gradient
  15779. * @param gradient defines the gradient to use (between 0 and 1)
  15780. * @param min defines the color remap minimal range
  15781. * @param max defines the color remap maximal range
  15782. * @returns the current particle system
  15783. */
  15784. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15785. /**
  15786. * Gets the current list of color remap gradients.
  15787. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15788. * @returns the list of color remap gradients
  15789. */
  15790. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15791. /**
  15792. * Adds a new alpha remap gradient
  15793. * @param gradient defines the gradient to use (between 0 and 1)
  15794. * @param min defines the alpha remap minimal range
  15795. * @param max defines the alpha remap maximal range
  15796. * @returns the current particle system
  15797. */
  15798. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15799. /**
  15800. * Gets the current list of alpha remap gradients.
  15801. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15802. * @returns the list of alpha remap gradients
  15803. */
  15804. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15805. /**
  15806. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15807. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15808. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15809. * @returns the emitter
  15810. */
  15811. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15812. /**
  15813. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15814. * @param radius The radius of the hemisphere to emit from
  15815. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15816. * @returns the emitter
  15817. */
  15818. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  15819. /**
  15820. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15821. * @param radius The radius of the sphere to emit from
  15822. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15823. * @returns the emitter
  15824. */
  15825. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  15826. /**
  15827. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15828. * @param radius The radius of the sphere to emit from
  15829. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15830. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15831. * @returns the emitter
  15832. */
  15833. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15834. /**
  15835. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15836. * @param radius The radius of the emission cylinder
  15837. * @param height The height of the emission cylinder
  15838. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15839. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15840. * @returns the emitter
  15841. */
  15842. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15843. /**
  15844. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15845. * @param radius The radius of the cylinder to emit from
  15846. * @param height The height of the emission cylinder
  15847. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15848. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15849. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15850. * @returns the emitter
  15851. */
  15852. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15853. /**
  15854. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15855. * @param radius The radius of the cone to emit from
  15856. * @param angle The base angle of the cone
  15857. * @returns the emitter
  15858. */
  15859. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15860. /**
  15861. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15862. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15863. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15864. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15865. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15866. * @returns the emitter
  15867. */
  15868. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15869. /**
  15870. * Get hosting scene
  15871. * @returns the scene
  15872. */
  15873. getScene(): Scene;
  15874. }
  15875. }
  15876. declare module BABYLON {
  15877. /**
  15878. * Creates an instance based on a source mesh.
  15879. */
  15880. export class InstancedMesh extends AbstractMesh {
  15881. private _sourceMesh;
  15882. private _currentLOD;
  15883. /** @hidden */
  15884. _indexInSourceMeshInstanceArray: number;
  15885. constructor(name: string, source: Mesh);
  15886. /**
  15887. * Returns the string "InstancedMesh".
  15888. */
  15889. getClassName(): string;
  15890. /**
  15891. * If the source mesh receives shadows
  15892. */
  15893. readonly receiveShadows: boolean;
  15894. /**
  15895. * The material of the source mesh
  15896. */
  15897. readonly material: Nullable<Material>;
  15898. /**
  15899. * Visibility of the source mesh
  15900. */
  15901. readonly visibility: number;
  15902. /**
  15903. * Skeleton of the source mesh
  15904. */
  15905. readonly skeleton: Nullable<Skeleton>;
  15906. /**
  15907. * Rendering ground id of the source mesh
  15908. */
  15909. renderingGroupId: number;
  15910. /**
  15911. * Returns the total number of vertices (integer).
  15912. */
  15913. getTotalVertices(): number;
  15914. /**
  15915. * Returns a positive integer : the total number of indices in this mesh geometry.
  15916. * @returns the numner of indices or zero if the mesh has no geometry.
  15917. */
  15918. getTotalIndices(): number;
  15919. /**
  15920. * The source mesh of the instance
  15921. */
  15922. readonly sourceMesh: Mesh;
  15923. /**
  15924. * Is this node ready to be used/rendered
  15925. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15926. * @return {boolean} is it ready
  15927. */
  15928. isReady(completeCheck?: boolean): boolean;
  15929. /**
  15930. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15931. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15932. * @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.
  15933. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15934. */
  15935. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15936. /**
  15937. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15938. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15939. * The `data` are either a numeric array either a Float32Array.
  15940. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15941. * 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).
  15942. * Note that a new underlying VertexBuffer object is created each call.
  15943. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15944. *
  15945. * Possible `kind` values :
  15946. * - VertexBuffer.PositionKind
  15947. * - VertexBuffer.UVKind
  15948. * - VertexBuffer.UV2Kind
  15949. * - VertexBuffer.UV3Kind
  15950. * - VertexBuffer.UV4Kind
  15951. * - VertexBuffer.UV5Kind
  15952. * - VertexBuffer.UV6Kind
  15953. * - VertexBuffer.ColorKind
  15954. * - VertexBuffer.MatricesIndicesKind
  15955. * - VertexBuffer.MatricesIndicesExtraKind
  15956. * - VertexBuffer.MatricesWeightsKind
  15957. * - VertexBuffer.MatricesWeightsExtraKind
  15958. *
  15959. * Returns the Mesh.
  15960. */
  15961. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  15962. /**
  15963. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15964. * If the mesh has no geometry, it is simply returned as it is.
  15965. * The `data` are either a numeric array either a Float32Array.
  15966. * No new underlying VertexBuffer object is created.
  15967. * 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.
  15968. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15969. *
  15970. * Possible `kind` values :
  15971. * - VertexBuffer.PositionKind
  15972. * - VertexBuffer.UVKind
  15973. * - VertexBuffer.UV2Kind
  15974. * - VertexBuffer.UV3Kind
  15975. * - VertexBuffer.UV4Kind
  15976. * - VertexBuffer.UV5Kind
  15977. * - VertexBuffer.UV6Kind
  15978. * - VertexBuffer.ColorKind
  15979. * - VertexBuffer.MatricesIndicesKind
  15980. * - VertexBuffer.MatricesIndicesExtraKind
  15981. * - VertexBuffer.MatricesWeightsKind
  15982. * - VertexBuffer.MatricesWeightsExtraKind
  15983. *
  15984. * Returns the Mesh.
  15985. */
  15986. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15987. /**
  15988. * Sets the mesh indices.
  15989. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15990. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15991. * This method creates a new index buffer each call.
  15992. * Returns the Mesh.
  15993. */
  15994. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15995. /**
  15996. * Boolean : True if the mesh owns the requested kind of data.
  15997. */
  15998. isVerticesDataPresent(kind: string): boolean;
  15999. /**
  16000. * Returns an array of indices (IndicesArray).
  16001. */
  16002. getIndices(): Nullable<IndicesArray>;
  16003. readonly _positions: Nullable<Vector3[]>;
  16004. /**
  16005. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16006. * This means the mesh underlying bounding box and sphere are recomputed.
  16007. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16008. * @returns the current mesh
  16009. */
  16010. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16011. /** @hidden */
  16012. _preActivate(): InstancedMesh;
  16013. /** @hidden */
  16014. _activate(renderId: number): InstancedMesh;
  16015. /**
  16016. * Returns the current associated LOD AbstractMesh.
  16017. */
  16018. getLOD(camera: Camera): AbstractMesh;
  16019. /** @hidden */
  16020. _syncSubMeshes(): InstancedMesh;
  16021. /** @hidden */
  16022. _generatePointsArray(): boolean;
  16023. /**
  16024. * Creates a new InstancedMesh from the current mesh.
  16025. * - name (string) : the cloned mesh name
  16026. * - newParent (optional Node) : the optional Node to parent the clone to.
  16027. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16028. *
  16029. * Returns the clone.
  16030. */
  16031. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16032. /**
  16033. * Disposes the InstancedMesh.
  16034. * Returns nothing.
  16035. */
  16036. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16037. }
  16038. }
  16039. declare module BABYLON {
  16040. /**
  16041. * Defines the options associated with the creation of a shader material.
  16042. */
  16043. export interface IShaderMaterialOptions {
  16044. /**
  16045. * Does the material work in alpha blend mode
  16046. */
  16047. needAlphaBlending: boolean;
  16048. /**
  16049. * Does the material work in alpha test mode
  16050. */
  16051. needAlphaTesting: boolean;
  16052. /**
  16053. * The list of attribute names used in the shader
  16054. */
  16055. attributes: string[];
  16056. /**
  16057. * The list of unifrom names used in the shader
  16058. */
  16059. uniforms: string[];
  16060. /**
  16061. * The list of UBO names used in the shader
  16062. */
  16063. uniformBuffers: string[];
  16064. /**
  16065. * The list of sampler names used in the shader
  16066. */
  16067. samplers: string[];
  16068. /**
  16069. * The list of defines used in the shader
  16070. */
  16071. defines: string[];
  16072. }
  16073. /**
  16074. * 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.
  16075. *
  16076. * This returned material effects how the mesh will look based on the code in the shaders.
  16077. *
  16078. * @see http://doc.babylonjs.com/how_to/shader_material
  16079. */
  16080. export class ShaderMaterial extends Material {
  16081. private _shaderPath;
  16082. private _options;
  16083. private _textures;
  16084. private _textureArrays;
  16085. private _floats;
  16086. private _ints;
  16087. private _floatsArrays;
  16088. private _colors3;
  16089. private _colors3Arrays;
  16090. private _colors4;
  16091. private _vectors2;
  16092. private _vectors3;
  16093. private _vectors4;
  16094. private _matrices;
  16095. private _matrices3x3;
  16096. private _matrices2x2;
  16097. private _vectors2Arrays;
  16098. private _vectors3Arrays;
  16099. private _cachedWorldViewMatrix;
  16100. private _renderId;
  16101. /**
  16102. * Instantiate a new shader material.
  16103. * 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.
  16104. * This returned material effects how the mesh will look based on the code in the shaders.
  16105. * @see http://doc.babylonjs.com/how_to/shader_material
  16106. * @param name Define the name of the material in the scene
  16107. * @param scene Define the scene the material belongs to
  16108. * @param shaderPath Defines the route to the shader code in one of three ways:
  16109. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16110. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16111. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16112. * @param options Define the options used to create the shader
  16113. */
  16114. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16115. /**
  16116. * Gets the current class name of the material e.g. "ShaderMaterial"
  16117. * Mainly use in serialization.
  16118. * @returns the class name
  16119. */
  16120. getClassName(): string;
  16121. /**
  16122. * Specifies if the material will require alpha blending
  16123. * @returns a boolean specifying if alpha blending is needed
  16124. */
  16125. needAlphaBlending(): boolean;
  16126. /**
  16127. * Specifies if this material should be rendered in alpha test mode
  16128. * @returns a boolean specifying if an alpha test is needed.
  16129. */
  16130. needAlphaTesting(): boolean;
  16131. private _checkUniform;
  16132. /**
  16133. * Set a texture in the shader.
  16134. * @param name Define the name of the uniform samplers as defined in the shader
  16135. * @param texture Define the texture to bind to this sampler
  16136. * @return the material itself allowing "fluent" like uniform updates
  16137. */
  16138. setTexture(name: string, texture: Texture): ShaderMaterial;
  16139. /**
  16140. * Set a texture array in the shader.
  16141. * @param name Define the name of the uniform sampler array as defined in the shader
  16142. * @param textures Define the list of textures to bind to this sampler
  16143. * @return the material itself allowing "fluent" like uniform updates
  16144. */
  16145. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16146. /**
  16147. * Set a float in the shader.
  16148. * @param name Define the name of the uniform as defined in the shader
  16149. * @param value Define the value to give to the uniform
  16150. * @return the material itself allowing "fluent" like uniform updates
  16151. */
  16152. setFloat(name: string, value: number): ShaderMaterial;
  16153. /**
  16154. * Set a int in the shader.
  16155. * @param name Define the name of the uniform as defined in the shader
  16156. * @param value Define the value to give to the uniform
  16157. * @return the material itself allowing "fluent" like uniform updates
  16158. */
  16159. setInt(name: string, value: number): ShaderMaterial;
  16160. /**
  16161. * Set an array of floats in the shader.
  16162. * @param name Define the name of the uniform as defined in the shader
  16163. * @param value Define the value to give to the uniform
  16164. * @return the material itself allowing "fluent" like uniform updates
  16165. */
  16166. setFloats(name: string, value: number[]): ShaderMaterial;
  16167. /**
  16168. * Set a vec3 in the shader from a Color3.
  16169. * @param name Define the name of the uniform as defined in the shader
  16170. * @param value Define the value to give to the uniform
  16171. * @return the material itself allowing "fluent" like uniform updates
  16172. */
  16173. setColor3(name: string, value: Color3): ShaderMaterial;
  16174. /**
  16175. * Set a vec3 array in the shader from a Color3 array.
  16176. * @param name Define the name of the uniform as defined in the shader
  16177. * @param value Define the value to give to the uniform
  16178. * @return the material itself allowing "fluent" like uniform updates
  16179. */
  16180. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16181. /**
  16182. * Set a vec4 in the shader from a Color4.
  16183. * @param name Define the name of the uniform as defined in the shader
  16184. * @param value Define the value to give to the uniform
  16185. * @return the material itself allowing "fluent" like uniform updates
  16186. */
  16187. setColor4(name: string, value: Color4): ShaderMaterial;
  16188. /**
  16189. * Set a vec2 in the shader from a Vector2.
  16190. * @param name Define the name of the uniform as defined in the shader
  16191. * @param value Define the value to give to the uniform
  16192. * @return the material itself allowing "fluent" like uniform updates
  16193. */
  16194. setVector2(name: string, value: Vector2): ShaderMaterial;
  16195. /**
  16196. * Set a vec3 in the shader from a Vector3.
  16197. * @param name Define the name of the uniform as defined in the shader
  16198. * @param value Define the value to give to the uniform
  16199. * @return the material itself allowing "fluent" like uniform updates
  16200. */
  16201. setVector3(name: string, value: Vector3): ShaderMaterial;
  16202. /**
  16203. * Set a vec4 in the shader from a Vector4.
  16204. * @param name Define the name of the uniform as defined in the shader
  16205. * @param value Define the value to give to the uniform
  16206. * @return the material itself allowing "fluent" like uniform updates
  16207. */
  16208. setVector4(name: string, value: Vector4): ShaderMaterial;
  16209. /**
  16210. * Set a mat4 in the shader from a Matrix.
  16211. * @param name Define the name of the uniform as defined in the shader
  16212. * @param value Define the value to give to the uniform
  16213. * @return the material itself allowing "fluent" like uniform updates
  16214. */
  16215. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16216. /**
  16217. * Set a mat3 in the shader from a Float32Array.
  16218. * @param name Define the name of the uniform as defined in the shader
  16219. * @param value Define the value to give to the uniform
  16220. * @return the material itself allowing "fluent" like uniform updates
  16221. */
  16222. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16223. /**
  16224. * Set a mat2 in the shader from a Float32Array.
  16225. * @param name Define the name of the uniform as defined in the shader
  16226. * @param value Define the value to give to the uniform
  16227. * @return the material itself allowing "fluent" like uniform updates
  16228. */
  16229. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16230. /**
  16231. * Set a vec2 array in the shader from a number array.
  16232. * @param name Define the name of the uniform as defined in the shader
  16233. * @param value Define the value to give to the uniform
  16234. * @return the material itself allowing "fluent" like uniform updates
  16235. */
  16236. setArray2(name: string, value: number[]): ShaderMaterial;
  16237. /**
  16238. * Set a vec3 array in the shader from a number array.
  16239. * @param name Define the name of the uniform as defined in the shader
  16240. * @param value Define the value to give to the uniform
  16241. * @return the material itself allowing "fluent" like uniform updates
  16242. */
  16243. setArray3(name: string, value: number[]): ShaderMaterial;
  16244. private _checkCache;
  16245. /**
  16246. * Checks if the material is ready to render the requested mesh
  16247. * @param mesh Define the mesh to render
  16248. * @param useInstances Define whether or not the material is used with instances
  16249. * @returns true if ready, otherwise false
  16250. */
  16251. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16252. /**
  16253. * Binds the world matrix to the material
  16254. * @param world defines the world transformation matrix
  16255. */
  16256. bindOnlyWorldMatrix(world: Matrix): void;
  16257. /**
  16258. * Binds the material to the mesh
  16259. * @param world defines the world transformation matrix
  16260. * @param mesh defines the mesh to bind the material to
  16261. */
  16262. bind(world: Matrix, mesh?: Mesh): void;
  16263. /**
  16264. * Gets the active textures from the material
  16265. * @returns an array of textures
  16266. */
  16267. getActiveTextures(): BaseTexture[];
  16268. /**
  16269. * Specifies if the material uses a texture
  16270. * @param texture defines the texture to check against the material
  16271. * @returns a boolean specifying if the material uses the texture
  16272. */
  16273. hasTexture(texture: BaseTexture): boolean;
  16274. /**
  16275. * Makes a duplicate of the material, and gives it a new name
  16276. * @param name defines the new name for the duplicated material
  16277. * @returns the cloned material
  16278. */
  16279. clone(name: string): ShaderMaterial;
  16280. /**
  16281. * Disposes the material
  16282. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16283. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16284. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16285. */
  16286. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16287. /**
  16288. * Serializes this material in a JSON representation
  16289. * @returns the serialized material object
  16290. */
  16291. serialize(): any;
  16292. /**
  16293. * Creates a shader material from parsed shader material data
  16294. * @param source defines the JSON represnetation of the material
  16295. * @param scene defines the hosting scene
  16296. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16297. * @returns a new material
  16298. */
  16299. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16300. }
  16301. }
  16302. declare module BABYLON {
  16303. /** @hidden */
  16304. export var colorPixelShader: {
  16305. name: string;
  16306. shader: string;
  16307. };
  16308. }
  16309. declare module BABYLON {
  16310. /** @hidden */
  16311. export var colorVertexShader: {
  16312. name: string;
  16313. shader: string;
  16314. };
  16315. }
  16316. declare module BABYLON {
  16317. /**
  16318. * Line mesh
  16319. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16320. */
  16321. export class LinesMesh extends Mesh {
  16322. /**
  16323. * If vertex color should be applied to the mesh
  16324. */
  16325. useVertexColor?: boolean | undefined;
  16326. /**
  16327. * If vertex alpha should be applied to the mesh
  16328. */
  16329. useVertexAlpha?: boolean | undefined;
  16330. /**
  16331. * Color of the line (Default: White)
  16332. */
  16333. color: Color3;
  16334. /**
  16335. * Alpha of the line (Default: 1)
  16336. */
  16337. alpha: number;
  16338. /**
  16339. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16340. * This margin is expressed in world space coordinates, so its value may vary.
  16341. * Default value is 0.1
  16342. */
  16343. intersectionThreshold: number;
  16344. private _colorShader;
  16345. /**
  16346. * Creates a new LinesMesh
  16347. * @param name defines the name
  16348. * @param scene defines the hosting scene
  16349. * @param parent defines the parent mesh if any
  16350. * @param source defines the optional source LinesMesh used to clone data from
  16351. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16352. * When false, achieved by calling a clone(), also passing False.
  16353. * This will make creation of children, recursive.
  16354. * @param useVertexColor defines if this LinesMesh supports vertex color
  16355. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16356. */
  16357. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16358. /**
  16359. * If vertex color should be applied to the mesh
  16360. */
  16361. useVertexColor?: boolean | undefined,
  16362. /**
  16363. * If vertex alpha should be applied to the mesh
  16364. */
  16365. useVertexAlpha?: boolean | undefined);
  16366. /**
  16367. * Returns the string "LineMesh"
  16368. */
  16369. getClassName(): string;
  16370. /**
  16371. * @hidden
  16372. */
  16373. /**
  16374. * @hidden
  16375. */
  16376. material: Material;
  16377. /**
  16378. * @hidden
  16379. */
  16380. readonly checkCollisions: boolean;
  16381. /** @hidden */
  16382. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16383. /** @hidden */
  16384. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16385. /**
  16386. * Disposes of the line mesh
  16387. * @param doNotRecurse If children should be disposed
  16388. */
  16389. dispose(doNotRecurse?: boolean): void;
  16390. /**
  16391. * Returns a new LineMesh object cloned from the current one.
  16392. */
  16393. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16394. /**
  16395. * Creates a new InstancedLinesMesh object from the mesh model.
  16396. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16397. * @param name defines the name of the new instance
  16398. * @returns a new InstancedLinesMesh
  16399. */
  16400. createInstance(name: string): InstancedLinesMesh;
  16401. }
  16402. /**
  16403. * Creates an instance based on a source LinesMesh
  16404. */
  16405. export class InstancedLinesMesh extends InstancedMesh {
  16406. /**
  16407. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16408. * This margin is expressed in world space coordinates, so its value may vary.
  16409. * Initilized with the intersectionThreshold value of the source LinesMesh
  16410. */
  16411. intersectionThreshold: number;
  16412. constructor(name: string, source: LinesMesh);
  16413. /**
  16414. * Returns the string "InstancedLinesMesh".
  16415. */
  16416. getClassName(): string;
  16417. }
  16418. }
  16419. declare module BABYLON {
  16420. /** @hidden */
  16421. export var linePixelShader: {
  16422. name: string;
  16423. shader: string;
  16424. };
  16425. }
  16426. declare module BABYLON {
  16427. /** @hidden */
  16428. export var lineVertexShader: {
  16429. name: string;
  16430. shader: string;
  16431. };
  16432. }
  16433. declare module BABYLON {
  16434. interface AbstractMesh {
  16435. /**
  16436. * Disables the mesh edge rendering mode
  16437. * @returns the currentAbstractMesh
  16438. */
  16439. disableEdgesRendering(): AbstractMesh;
  16440. /**
  16441. * Enables the edge rendering mode on the mesh.
  16442. * This mode makes the mesh edges visible
  16443. * @param epsilon defines the maximal distance between two angles to detect a face
  16444. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16445. * @returns the currentAbstractMesh
  16446. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16447. */
  16448. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16449. /**
  16450. * Gets the edgesRenderer associated with the mesh
  16451. */
  16452. edgesRenderer: Nullable<EdgesRenderer>;
  16453. }
  16454. interface LinesMesh {
  16455. /**
  16456. * Enables the edge rendering mode on the mesh.
  16457. * This mode makes the mesh edges visible
  16458. * @param epsilon defines the maximal distance between two angles to detect a face
  16459. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16460. * @returns the currentAbstractMesh
  16461. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16462. */
  16463. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16464. }
  16465. interface InstancedLinesMesh {
  16466. /**
  16467. * Enables the edge rendering mode on the mesh.
  16468. * This mode makes the mesh edges visible
  16469. * @param epsilon defines the maximal distance between two angles to detect a face
  16470. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16471. * @returns the current InstancedLinesMesh
  16472. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16473. */
  16474. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16475. }
  16476. /**
  16477. * Defines the minimum contract an Edges renderer should follow.
  16478. */
  16479. export interface IEdgesRenderer extends IDisposable {
  16480. /**
  16481. * Gets or sets a boolean indicating if the edgesRenderer is active
  16482. */
  16483. isEnabled: boolean;
  16484. /**
  16485. * Renders the edges of the attached mesh,
  16486. */
  16487. render(): void;
  16488. /**
  16489. * Checks wether or not the edges renderer is ready to render.
  16490. * @return true if ready, otherwise false.
  16491. */
  16492. isReady(): boolean;
  16493. }
  16494. /**
  16495. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16496. */
  16497. export class EdgesRenderer implements IEdgesRenderer {
  16498. /**
  16499. * Define the size of the edges with an orthographic camera
  16500. */
  16501. edgesWidthScalerForOrthographic: number;
  16502. /**
  16503. * Define the size of the edges with a perspective camera
  16504. */
  16505. edgesWidthScalerForPerspective: number;
  16506. protected _source: AbstractMesh;
  16507. protected _linesPositions: number[];
  16508. protected _linesNormals: number[];
  16509. protected _linesIndices: number[];
  16510. protected _epsilon: number;
  16511. protected _indicesCount: number;
  16512. protected _lineShader: ShaderMaterial;
  16513. protected _ib: WebGLBuffer;
  16514. protected _buffers: {
  16515. [key: string]: Nullable<VertexBuffer>;
  16516. };
  16517. protected _checkVerticesInsteadOfIndices: boolean;
  16518. private _meshRebuildObserver;
  16519. private _meshDisposeObserver;
  16520. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16521. isEnabled: boolean;
  16522. /**
  16523. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16524. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16525. * @param source Mesh used to create edges
  16526. * @param epsilon sum of angles in adjacency to check for edge
  16527. * @param checkVerticesInsteadOfIndices
  16528. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16529. */
  16530. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16531. protected _prepareRessources(): void;
  16532. /** @hidden */
  16533. _rebuild(): void;
  16534. /**
  16535. * Releases the required resources for the edges renderer
  16536. */
  16537. dispose(): void;
  16538. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16539. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16540. /**
  16541. * Checks if the pair of p0 and p1 is en edge
  16542. * @param faceIndex
  16543. * @param edge
  16544. * @param faceNormals
  16545. * @param p0
  16546. * @param p1
  16547. * @private
  16548. */
  16549. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16550. /**
  16551. * push line into the position, normal and index buffer
  16552. * @protected
  16553. */
  16554. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16555. /**
  16556. * Generates lines edges from adjacencjes
  16557. * @private
  16558. */
  16559. _generateEdgesLines(): void;
  16560. /**
  16561. * Checks wether or not the edges renderer is ready to render.
  16562. * @return true if ready, otherwise false.
  16563. */
  16564. isReady(): boolean;
  16565. /**
  16566. * Renders the edges of the attached mesh,
  16567. */
  16568. render(): void;
  16569. }
  16570. /**
  16571. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16572. */
  16573. export class LineEdgesRenderer extends EdgesRenderer {
  16574. /**
  16575. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16576. * @param source LineMesh used to generate edges
  16577. * @param epsilon not important (specified angle for edge detection)
  16578. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16579. */
  16580. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16581. /**
  16582. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16583. */
  16584. _generateEdgesLines(): void;
  16585. }
  16586. }
  16587. declare module BABYLON {
  16588. /**
  16589. * This represents the object necessary to create a rendering group.
  16590. * This is exclusively used and created by the rendering manager.
  16591. * To modify the behavior, you use the available helpers in your scene or meshes.
  16592. * @hidden
  16593. */
  16594. export class RenderingGroup {
  16595. index: number;
  16596. private _scene;
  16597. private _opaqueSubMeshes;
  16598. private _transparentSubMeshes;
  16599. private _alphaTestSubMeshes;
  16600. private _depthOnlySubMeshes;
  16601. private _particleSystems;
  16602. private _spriteManagers;
  16603. private _opaqueSortCompareFn;
  16604. private _alphaTestSortCompareFn;
  16605. private _transparentSortCompareFn;
  16606. private _renderOpaque;
  16607. private _renderAlphaTest;
  16608. private _renderTransparent;
  16609. private _edgesRenderers;
  16610. onBeforeTransparentRendering: () => void;
  16611. /**
  16612. * Set the opaque sort comparison function.
  16613. * If null the sub meshes will be render in the order they were created
  16614. */
  16615. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16616. /**
  16617. * Set the alpha test sort comparison function.
  16618. * If null the sub meshes will be render in the order they were created
  16619. */
  16620. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16621. /**
  16622. * Set the transparent sort comparison function.
  16623. * If null the sub meshes will be render in the order they were created
  16624. */
  16625. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16626. /**
  16627. * Creates a new rendering group.
  16628. * @param index The rendering group index
  16629. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16630. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16631. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16632. */
  16633. 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>);
  16634. /**
  16635. * Render all the sub meshes contained in the group.
  16636. * @param customRenderFunction Used to override the default render behaviour of the group.
  16637. * @returns true if rendered some submeshes.
  16638. */
  16639. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16640. /**
  16641. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16642. * @param subMeshes The submeshes to render
  16643. */
  16644. private renderOpaqueSorted;
  16645. /**
  16646. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16647. * @param subMeshes The submeshes to render
  16648. */
  16649. private renderAlphaTestSorted;
  16650. /**
  16651. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16652. * @param subMeshes The submeshes to render
  16653. */
  16654. private renderTransparentSorted;
  16655. /**
  16656. * Renders the submeshes in a specified order.
  16657. * @param subMeshes The submeshes to sort before render
  16658. * @param sortCompareFn The comparison function use to sort
  16659. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16660. * @param transparent Specifies to activate blending if true
  16661. */
  16662. private static renderSorted;
  16663. /**
  16664. * Renders the submeshes in the order they were dispatched (no sort applied).
  16665. * @param subMeshes The submeshes to render
  16666. */
  16667. private static renderUnsorted;
  16668. /**
  16669. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16670. * are rendered back to front if in the same alpha index.
  16671. *
  16672. * @param a The first submesh
  16673. * @param b The second submesh
  16674. * @returns The result of the comparison
  16675. */
  16676. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16677. /**
  16678. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16679. * are rendered back to front.
  16680. *
  16681. * @param a The first submesh
  16682. * @param b The second submesh
  16683. * @returns The result of the comparison
  16684. */
  16685. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16686. /**
  16687. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16688. * are rendered front to back (prevent overdraw).
  16689. *
  16690. * @param a The first submesh
  16691. * @param b The second submesh
  16692. * @returns The result of the comparison
  16693. */
  16694. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16695. /**
  16696. * Resets the different lists of submeshes to prepare a new frame.
  16697. */
  16698. prepare(): void;
  16699. dispose(): void;
  16700. /**
  16701. * Inserts the submesh in its correct queue depending on its material.
  16702. * @param subMesh The submesh to dispatch
  16703. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16704. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16705. */
  16706. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16707. dispatchSprites(spriteManager: ISpriteManager): void;
  16708. dispatchParticles(particleSystem: IParticleSystem): void;
  16709. private _renderParticles;
  16710. private _renderSprites;
  16711. }
  16712. }
  16713. declare module BABYLON {
  16714. /**
  16715. * Interface describing the different options available in the rendering manager
  16716. * regarding Auto Clear between groups.
  16717. */
  16718. export interface IRenderingManagerAutoClearSetup {
  16719. /**
  16720. * Defines whether or not autoclear is enable.
  16721. */
  16722. autoClear: boolean;
  16723. /**
  16724. * Defines whether or not to autoclear the depth buffer.
  16725. */
  16726. depth: boolean;
  16727. /**
  16728. * Defines whether or not to autoclear the stencil buffer.
  16729. */
  16730. stencil: boolean;
  16731. }
  16732. /**
  16733. * This class is used by the onRenderingGroupObservable
  16734. */
  16735. export class RenderingGroupInfo {
  16736. /**
  16737. * The Scene that being rendered
  16738. */
  16739. scene: Scene;
  16740. /**
  16741. * The camera currently used for the rendering pass
  16742. */
  16743. camera: Nullable<Camera>;
  16744. /**
  16745. * The ID of the renderingGroup being processed
  16746. */
  16747. renderingGroupId: number;
  16748. }
  16749. /**
  16750. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16751. * It is enable to manage the different groups as well as the different necessary sort functions.
  16752. * This should not be used directly aside of the few static configurations
  16753. */
  16754. export class RenderingManager {
  16755. /**
  16756. * The max id used for rendering groups (not included)
  16757. */
  16758. static MAX_RENDERINGGROUPS: number;
  16759. /**
  16760. * The min id used for rendering groups (included)
  16761. */
  16762. static MIN_RENDERINGGROUPS: number;
  16763. /**
  16764. * Used to globally prevent autoclearing scenes.
  16765. */
  16766. static AUTOCLEAR: boolean;
  16767. /**
  16768. * @hidden
  16769. */
  16770. _useSceneAutoClearSetup: boolean;
  16771. private _scene;
  16772. private _renderingGroups;
  16773. private _depthStencilBufferAlreadyCleaned;
  16774. private _autoClearDepthStencil;
  16775. private _customOpaqueSortCompareFn;
  16776. private _customAlphaTestSortCompareFn;
  16777. private _customTransparentSortCompareFn;
  16778. private _renderingGroupInfo;
  16779. /**
  16780. * Instantiates a new rendering group for a particular scene
  16781. * @param scene Defines the scene the groups belongs to
  16782. */
  16783. constructor(scene: Scene);
  16784. private _clearDepthStencilBuffer;
  16785. /**
  16786. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16787. * @hidden
  16788. */
  16789. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16790. /**
  16791. * Resets the different information of the group to prepare a new frame
  16792. * @hidden
  16793. */
  16794. reset(): void;
  16795. /**
  16796. * Dispose and release the group and its associated resources.
  16797. * @hidden
  16798. */
  16799. dispose(): void;
  16800. /**
  16801. * Clear the info related to rendering groups preventing retention points during dispose.
  16802. */
  16803. freeRenderingGroups(): void;
  16804. private _prepareRenderingGroup;
  16805. /**
  16806. * Add a sprite manager to the rendering manager in order to render it this frame.
  16807. * @param spriteManager Define the sprite manager to render
  16808. */
  16809. dispatchSprites(spriteManager: ISpriteManager): void;
  16810. /**
  16811. * Add a particle system to the rendering manager in order to render it this frame.
  16812. * @param particleSystem Define the particle system to render
  16813. */
  16814. dispatchParticles(particleSystem: IParticleSystem): void;
  16815. /**
  16816. * Add a submesh to the manager in order to render it this frame
  16817. * @param subMesh The submesh to dispatch
  16818. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16819. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16820. */
  16821. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16822. /**
  16823. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16824. * This allowed control for front to back rendering or reversly depending of the special needs.
  16825. *
  16826. * @param renderingGroupId The rendering group id corresponding to its index
  16827. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16828. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16829. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16830. */
  16831. 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;
  16832. /**
  16833. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16834. *
  16835. * @param renderingGroupId The rendering group id corresponding to its index
  16836. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16837. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16838. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16839. */
  16840. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16841. /**
  16842. * Gets the current auto clear configuration for one rendering group of the rendering
  16843. * manager.
  16844. * @param index the rendering group index to get the information for
  16845. * @returns The auto clear setup for the requested rendering group
  16846. */
  16847. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16848. }
  16849. }
  16850. declare module BABYLON {
  16851. /**
  16852. * This Helps creating a texture that will be created from a camera in your scene.
  16853. * It is basically a dynamic texture that could be used to create special effects for instance.
  16854. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  16855. */
  16856. export class RenderTargetTexture extends Texture {
  16857. isCube: boolean;
  16858. /**
  16859. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  16860. */
  16861. static readonly REFRESHRATE_RENDER_ONCE: number;
  16862. /**
  16863. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  16864. */
  16865. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  16866. /**
  16867. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  16868. * the central point of your effect and can save a lot of performances.
  16869. */
  16870. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  16871. /**
  16872. * Use this predicate to dynamically define the list of mesh you want to render.
  16873. * If set, the renderList property will be overwritten.
  16874. */
  16875. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  16876. private _renderList;
  16877. /**
  16878. * Use this list to define the list of mesh you want to render.
  16879. */
  16880. renderList: Nullable<Array<AbstractMesh>>;
  16881. private _hookArray;
  16882. /**
  16883. * Define if particles should be rendered in your texture.
  16884. */
  16885. renderParticles: boolean;
  16886. /**
  16887. * Define if sprites should be rendered in your texture.
  16888. */
  16889. renderSprites: boolean;
  16890. /**
  16891. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  16892. */
  16893. coordinatesMode: number;
  16894. /**
  16895. * Define the camera used to render the texture.
  16896. */
  16897. activeCamera: Nullable<Camera>;
  16898. /**
  16899. * Override the render function of the texture with your own one.
  16900. */
  16901. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  16902. /**
  16903. * Define if camera post processes should be use while rendering the texture.
  16904. */
  16905. useCameraPostProcesses: boolean;
  16906. /**
  16907. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  16908. */
  16909. ignoreCameraViewport: boolean;
  16910. private _postProcessManager;
  16911. private _postProcesses;
  16912. private _resizeObserver;
  16913. /**
  16914. * An event triggered when the texture is unbind.
  16915. */
  16916. onBeforeBindObservable: Observable<RenderTargetTexture>;
  16917. /**
  16918. * An event triggered when the texture is unbind.
  16919. */
  16920. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  16921. private _onAfterUnbindObserver;
  16922. /**
  16923. * Set a after unbind callback in the texture.
  16924. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  16925. */
  16926. onAfterUnbind: () => void;
  16927. /**
  16928. * An event triggered before rendering the texture
  16929. */
  16930. onBeforeRenderObservable: Observable<number>;
  16931. private _onBeforeRenderObserver;
  16932. /**
  16933. * Set a before render callback in the texture.
  16934. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  16935. */
  16936. onBeforeRender: (faceIndex: number) => void;
  16937. /**
  16938. * An event triggered after rendering the texture
  16939. */
  16940. onAfterRenderObservable: Observable<number>;
  16941. private _onAfterRenderObserver;
  16942. /**
  16943. * Set a after render callback in the texture.
  16944. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  16945. */
  16946. onAfterRender: (faceIndex: number) => void;
  16947. /**
  16948. * An event triggered after the texture clear
  16949. */
  16950. onClearObservable: Observable<Engine>;
  16951. private _onClearObserver;
  16952. /**
  16953. * Set a clear callback in the texture.
  16954. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  16955. */
  16956. onClear: (Engine: Engine) => void;
  16957. /**
  16958. * Define the clear color of the Render Target if it should be different from the scene.
  16959. */
  16960. clearColor: Color4;
  16961. protected _size: number | {
  16962. width: number;
  16963. height: number;
  16964. };
  16965. protected _initialSizeParameter: number | {
  16966. width: number;
  16967. height: number;
  16968. } | {
  16969. ratio: number;
  16970. };
  16971. protected _sizeRatio: Nullable<number>;
  16972. /** @hidden */
  16973. _generateMipMaps: boolean;
  16974. protected _renderingManager: RenderingManager;
  16975. /** @hidden */
  16976. _waitingRenderList: string[];
  16977. protected _doNotChangeAspectRatio: boolean;
  16978. protected _currentRefreshId: number;
  16979. protected _refreshRate: number;
  16980. protected _textureMatrix: Matrix;
  16981. protected _samples: number;
  16982. protected _renderTargetOptions: RenderTargetCreationOptions;
  16983. /**
  16984. * Gets render target creation options that were used.
  16985. */
  16986. readonly renderTargetOptions: RenderTargetCreationOptions;
  16987. protected _engine: Engine;
  16988. protected _onRatioRescale(): void;
  16989. /**
  16990. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  16991. * It must define where the camera used to render the texture is set
  16992. */
  16993. boundingBoxPosition: Vector3;
  16994. private _boundingBoxSize;
  16995. /**
  16996. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  16997. * When defined, the cubemap will switch to local mode
  16998. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  16999. * @example https://www.babylonjs-playground.com/#RNASML
  17000. */
  17001. boundingBoxSize: Vector3;
  17002. /**
  17003. * In case the RTT has been created with a depth texture, get the associated
  17004. * depth texture.
  17005. * Otherwise, return null.
  17006. */
  17007. depthStencilTexture: Nullable<InternalTexture>;
  17008. /**
  17009. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17010. * or used a shadow, depth texture...
  17011. * @param name The friendly name of the texture
  17012. * @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)
  17013. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17014. * @param generateMipMaps True if mip maps need to be generated after render.
  17015. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17016. * @param type The type of the buffer in the RTT (int, half float, float...)
  17017. * @param isCube True if a cube texture needs to be created
  17018. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17019. * @param generateDepthBuffer True to generate a depth buffer
  17020. * @param generateStencilBuffer True to generate a stencil buffer
  17021. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17022. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17023. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17024. */
  17025. constructor(name: string, size: number | {
  17026. width: number;
  17027. height: number;
  17028. } | {
  17029. ratio: number;
  17030. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17031. /**
  17032. * Creates a depth stencil texture.
  17033. * This is only available in WebGL 2 or with the depth texture extension available.
  17034. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17035. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17036. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17037. */
  17038. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17039. private _processSizeParameter;
  17040. /**
  17041. * Define the number of samples to use in case of MSAA.
  17042. * It defaults to one meaning no MSAA has been enabled.
  17043. */
  17044. samples: number;
  17045. /**
  17046. * Resets the refresh counter of the texture and start bak from scratch.
  17047. * Could be useful to regenerate the texture if it is setup to render only once.
  17048. */
  17049. resetRefreshCounter(): void;
  17050. /**
  17051. * Define the refresh rate of the texture or the rendering frequency.
  17052. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17053. */
  17054. refreshRate: number;
  17055. /**
  17056. * Adds a post process to the render target rendering passes.
  17057. * @param postProcess define the post process to add
  17058. */
  17059. addPostProcess(postProcess: PostProcess): void;
  17060. /**
  17061. * Clear all the post processes attached to the render target
  17062. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17063. */
  17064. clearPostProcesses(dispose?: boolean): void;
  17065. /**
  17066. * Remove one of the post process from the list of attached post processes to the texture
  17067. * @param postProcess define the post process to remove from the list
  17068. */
  17069. removePostProcess(postProcess: PostProcess): void;
  17070. /** @hidden */
  17071. _shouldRender(): boolean;
  17072. /**
  17073. * Gets the actual render size of the texture.
  17074. * @returns the width of the render size
  17075. */
  17076. getRenderSize(): number;
  17077. /**
  17078. * Gets the actual render width of the texture.
  17079. * @returns the width of the render size
  17080. */
  17081. getRenderWidth(): number;
  17082. /**
  17083. * Gets the actual render height of the texture.
  17084. * @returns the height of the render size
  17085. */
  17086. getRenderHeight(): number;
  17087. /**
  17088. * Get if the texture can be rescaled or not.
  17089. */
  17090. readonly canRescale: boolean;
  17091. /**
  17092. * Resize the texture using a ratio.
  17093. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17094. */
  17095. scale(ratio: number): void;
  17096. /**
  17097. * Get the texture reflection matrix used to rotate/transform the reflection.
  17098. * @returns the reflection matrix
  17099. */
  17100. getReflectionTextureMatrix(): Matrix;
  17101. /**
  17102. * Resize the texture to a new desired size.
  17103. * Be carrefull as it will recreate all the data in the new texture.
  17104. * @param size Define the new size. It can be:
  17105. * - a number for squared texture,
  17106. * - an object containing { width: number, height: number }
  17107. * - or an object containing a ratio { ratio: number }
  17108. */
  17109. resize(size: number | {
  17110. width: number;
  17111. height: number;
  17112. } | {
  17113. ratio: number;
  17114. }): void;
  17115. /**
  17116. * Renders all the objects from the render list into the texture.
  17117. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17118. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17119. */
  17120. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17121. private _bestReflectionRenderTargetDimension;
  17122. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17123. private renderToTarget;
  17124. /**
  17125. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17126. * This allowed control for front to back rendering or reversly depending of the special needs.
  17127. *
  17128. * @param renderingGroupId The rendering group id corresponding to its index
  17129. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17130. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17131. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17132. */
  17133. 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;
  17134. /**
  17135. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17136. *
  17137. * @param renderingGroupId The rendering group id corresponding to its index
  17138. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17139. */
  17140. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17141. /**
  17142. * Clones the texture.
  17143. * @returns the cloned texture
  17144. */
  17145. clone(): RenderTargetTexture;
  17146. /**
  17147. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17148. * @returns The JSON representation of the texture
  17149. */
  17150. serialize(): any;
  17151. /**
  17152. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17153. */
  17154. disposeFramebufferObjects(): void;
  17155. /**
  17156. * Dispose the texture and release its associated resources.
  17157. */
  17158. dispose(): void;
  17159. /** @hidden */
  17160. _rebuild(): void;
  17161. /**
  17162. * Clear the info related to rendering groups preventing retention point in material dispose.
  17163. */
  17164. freeRenderingGroups(): void;
  17165. }
  17166. }
  17167. declare module BABYLON {
  17168. /**
  17169. * Base class for the main features of a material in Babylon.js
  17170. */
  17171. export class Material implements IAnimatable {
  17172. /**
  17173. * Returns the triangle fill mode
  17174. */
  17175. static readonly TriangleFillMode: number;
  17176. /**
  17177. * Returns the wireframe mode
  17178. */
  17179. static readonly WireFrameFillMode: number;
  17180. /**
  17181. * Returns the point fill mode
  17182. */
  17183. static readonly PointFillMode: number;
  17184. /**
  17185. * Returns the point list draw mode
  17186. */
  17187. static readonly PointListDrawMode: number;
  17188. /**
  17189. * Returns the line list draw mode
  17190. */
  17191. static readonly LineListDrawMode: number;
  17192. /**
  17193. * Returns the line loop draw mode
  17194. */
  17195. static readonly LineLoopDrawMode: number;
  17196. /**
  17197. * Returns the line strip draw mode
  17198. */
  17199. static readonly LineStripDrawMode: number;
  17200. /**
  17201. * Returns the triangle strip draw mode
  17202. */
  17203. static readonly TriangleStripDrawMode: number;
  17204. /**
  17205. * Returns the triangle fan draw mode
  17206. */
  17207. static readonly TriangleFanDrawMode: number;
  17208. /**
  17209. * Stores the clock-wise side orientation
  17210. */
  17211. static readonly ClockWiseSideOrientation: number;
  17212. /**
  17213. * Stores the counter clock-wise side orientation
  17214. */
  17215. static readonly CounterClockWiseSideOrientation: number;
  17216. /**
  17217. * The dirty texture flag value
  17218. */
  17219. static readonly TextureDirtyFlag: number;
  17220. /**
  17221. * The dirty light flag value
  17222. */
  17223. static readonly LightDirtyFlag: number;
  17224. /**
  17225. * The dirty fresnel flag value
  17226. */
  17227. static readonly FresnelDirtyFlag: number;
  17228. /**
  17229. * The dirty attribute flag value
  17230. */
  17231. static readonly AttributesDirtyFlag: number;
  17232. /**
  17233. * The dirty misc flag value
  17234. */
  17235. static readonly MiscDirtyFlag: number;
  17236. /**
  17237. * The all dirty flag value
  17238. */
  17239. static readonly AllDirtyFlag: number;
  17240. /**
  17241. * The ID of the material
  17242. */
  17243. id: string;
  17244. /**
  17245. * Gets or sets the unique id of the material
  17246. */
  17247. uniqueId: number;
  17248. /**
  17249. * The name of the material
  17250. */
  17251. name: string;
  17252. /**
  17253. * Gets or sets user defined metadata
  17254. */
  17255. metadata: any;
  17256. /**
  17257. * For internal use only. Please do not use.
  17258. */
  17259. reservedDataStore: any;
  17260. /**
  17261. * Specifies if the ready state should be checked on each call
  17262. */
  17263. checkReadyOnEveryCall: boolean;
  17264. /**
  17265. * Specifies if the ready state should be checked once
  17266. */
  17267. checkReadyOnlyOnce: boolean;
  17268. /**
  17269. * The state of the material
  17270. */
  17271. state: string;
  17272. /**
  17273. * The alpha value of the material
  17274. */
  17275. protected _alpha: number;
  17276. /**
  17277. * Sets the alpha value of the material
  17278. */
  17279. /**
  17280. * Gets the alpha value of the material
  17281. */
  17282. alpha: number;
  17283. /**
  17284. * Specifies if back face culling is enabled
  17285. */
  17286. protected _backFaceCulling: boolean;
  17287. /**
  17288. * Sets the back-face culling state
  17289. */
  17290. /**
  17291. * Gets the back-face culling state
  17292. */
  17293. backFaceCulling: boolean;
  17294. /**
  17295. * Stores the value for side orientation
  17296. */
  17297. sideOrientation: number;
  17298. /**
  17299. * Callback triggered when the material is compiled
  17300. */
  17301. onCompiled: (effect: Effect) => void;
  17302. /**
  17303. * Callback triggered when an error occurs
  17304. */
  17305. onError: (effect: Effect, errors: string) => void;
  17306. /**
  17307. * Callback triggered to get the render target textures
  17308. */
  17309. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  17310. /**
  17311. * Gets a boolean indicating that current material needs to register RTT
  17312. */
  17313. readonly hasRenderTargetTextures: boolean;
  17314. /**
  17315. * Specifies if the material should be serialized
  17316. */
  17317. doNotSerialize: boolean;
  17318. /**
  17319. * @hidden
  17320. */
  17321. _storeEffectOnSubMeshes: boolean;
  17322. /**
  17323. * Stores the animations for the material
  17324. */
  17325. animations: Array<Animation>;
  17326. /**
  17327. * An event triggered when the material is disposed
  17328. */
  17329. onDisposeObservable: Observable<Material>;
  17330. /**
  17331. * An observer which watches for dispose events
  17332. */
  17333. private _onDisposeObserver;
  17334. private _onUnBindObservable;
  17335. /**
  17336. * Called during a dispose event
  17337. */
  17338. onDispose: () => void;
  17339. private _onBindObservable;
  17340. /**
  17341. * An event triggered when the material is bound
  17342. */
  17343. readonly onBindObservable: Observable<AbstractMesh>;
  17344. /**
  17345. * An observer which watches for bind events
  17346. */
  17347. private _onBindObserver;
  17348. /**
  17349. * Called during a bind event
  17350. */
  17351. onBind: (Mesh: AbstractMesh) => void;
  17352. /**
  17353. * An event triggered when the material is unbound
  17354. */
  17355. readonly onUnBindObservable: Observable<Material>;
  17356. /**
  17357. * Stores the value of the alpha mode
  17358. */
  17359. private _alphaMode;
  17360. /**
  17361. * Sets the value of the alpha mode.
  17362. *
  17363. * | Value | Type | Description |
  17364. * | --- | --- | --- |
  17365. * | 0 | ALPHA_DISABLE | |
  17366. * | 1 | ALPHA_ADD | |
  17367. * | 2 | ALPHA_COMBINE | |
  17368. * | 3 | ALPHA_SUBTRACT | |
  17369. * | 4 | ALPHA_MULTIPLY | |
  17370. * | 5 | ALPHA_MAXIMIZED | |
  17371. * | 6 | ALPHA_ONEONE | |
  17372. * | 7 | ALPHA_PREMULTIPLIED | |
  17373. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  17374. * | 9 | ALPHA_INTERPOLATE | |
  17375. * | 10 | ALPHA_SCREENMODE | |
  17376. *
  17377. */
  17378. /**
  17379. * Gets the value of the alpha mode
  17380. */
  17381. alphaMode: number;
  17382. /**
  17383. * Stores the state of the need depth pre-pass value
  17384. */
  17385. private _needDepthPrePass;
  17386. /**
  17387. * Sets the need depth pre-pass value
  17388. */
  17389. /**
  17390. * Gets the depth pre-pass value
  17391. */
  17392. needDepthPrePass: boolean;
  17393. /**
  17394. * Specifies if depth writing should be disabled
  17395. */
  17396. disableDepthWrite: boolean;
  17397. /**
  17398. * Specifies if depth writing should be forced
  17399. */
  17400. forceDepthWrite: boolean;
  17401. /**
  17402. * Specifies if there should be a separate pass for culling
  17403. */
  17404. separateCullingPass: boolean;
  17405. /**
  17406. * Stores the state specifing if fog should be enabled
  17407. */
  17408. private _fogEnabled;
  17409. /**
  17410. * Sets the state for enabling fog
  17411. */
  17412. /**
  17413. * Gets the value of the fog enabled state
  17414. */
  17415. fogEnabled: boolean;
  17416. /**
  17417. * Stores the size of points
  17418. */
  17419. pointSize: number;
  17420. /**
  17421. * Stores the z offset value
  17422. */
  17423. zOffset: number;
  17424. /**
  17425. * Gets a value specifying if wireframe mode is enabled
  17426. */
  17427. /**
  17428. * Sets the state of wireframe mode
  17429. */
  17430. wireframe: boolean;
  17431. /**
  17432. * Gets the value specifying if point clouds are enabled
  17433. */
  17434. /**
  17435. * Sets the state of point cloud mode
  17436. */
  17437. pointsCloud: boolean;
  17438. /**
  17439. * Gets the material fill mode
  17440. */
  17441. /**
  17442. * Sets the material fill mode
  17443. */
  17444. fillMode: number;
  17445. /**
  17446. * @hidden
  17447. * Stores the effects for the material
  17448. */
  17449. _effect: Nullable<Effect>;
  17450. /**
  17451. * @hidden
  17452. * Specifies if the material was previously ready
  17453. */
  17454. _wasPreviouslyReady: boolean;
  17455. /**
  17456. * Specifies if uniform buffers should be used
  17457. */
  17458. private _useUBO;
  17459. /**
  17460. * Stores a reference to the scene
  17461. */
  17462. private _scene;
  17463. /**
  17464. * Stores the fill mode state
  17465. */
  17466. private _fillMode;
  17467. /**
  17468. * Specifies if the depth write state should be cached
  17469. */
  17470. private _cachedDepthWriteState;
  17471. /**
  17472. * Stores the uniform buffer
  17473. */
  17474. protected _uniformBuffer: UniformBuffer;
  17475. /** @hidden */
  17476. _indexInSceneMaterialArray: number;
  17477. /** @hidden */
  17478. meshMap: Nullable<{
  17479. [id: string]: AbstractMesh | undefined;
  17480. }>;
  17481. /**
  17482. * Creates a material instance
  17483. * @param name defines the name of the material
  17484. * @param scene defines the scene to reference
  17485. * @param doNotAdd specifies if the material should be added to the scene
  17486. */
  17487. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  17488. /**
  17489. * Returns a string representation of the current material
  17490. * @param fullDetails defines a boolean indicating which levels of logging is desired
  17491. * @returns a string with material information
  17492. */
  17493. toString(fullDetails?: boolean): string;
  17494. /**
  17495. * Gets the class name of the material
  17496. * @returns a string with the class name of the material
  17497. */
  17498. getClassName(): string;
  17499. /**
  17500. * Specifies if updates for the material been locked
  17501. */
  17502. readonly isFrozen: boolean;
  17503. /**
  17504. * Locks updates for the material
  17505. */
  17506. freeze(): void;
  17507. /**
  17508. * Unlocks updates for the material
  17509. */
  17510. unfreeze(): void;
  17511. /**
  17512. * Specifies if the material is ready to be used
  17513. * @param mesh defines the mesh to check
  17514. * @param useInstances specifies if instances should be used
  17515. * @returns a boolean indicating if the material is ready to be used
  17516. */
  17517. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17518. /**
  17519. * Specifies that the submesh is ready to be used
  17520. * @param mesh defines the mesh to check
  17521. * @param subMesh defines which submesh to check
  17522. * @param useInstances specifies that instances should be used
  17523. * @returns a boolean indicating that the submesh is ready or not
  17524. */
  17525. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17526. /**
  17527. * Returns the material effect
  17528. * @returns the effect associated with the material
  17529. */
  17530. getEffect(): Nullable<Effect>;
  17531. /**
  17532. * Returns the current scene
  17533. * @returns a Scene
  17534. */
  17535. getScene(): Scene;
  17536. /**
  17537. * Specifies if the material will require alpha blending
  17538. * @returns a boolean specifying if alpha blending is needed
  17539. */
  17540. needAlphaBlending(): boolean;
  17541. /**
  17542. * Specifies if the mesh will require alpha blending
  17543. * @param mesh defines the mesh to check
  17544. * @returns a boolean specifying if alpha blending is needed for the mesh
  17545. */
  17546. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  17547. /**
  17548. * Specifies if this material should be rendered in alpha test mode
  17549. * @returns a boolean specifying if an alpha test is needed.
  17550. */
  17551. needAlphaTesting(): boolean;
  17552. /**
  17553. * Gets the texture used for the alpha test
  17554. * @returns the texture to use for alpha testing
  17555. */
  17556. getAlphaTestTexture(): Nullable<BaseTexture>;
  17557. /**
  17558. * Marks the material to indicate that it needs to be re-calculated
  17559. */
  17560. markDirty(): void;
  17561. /** @hidden */
  17562. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  17563. /**
  17564. * Binds the material to the mesh
  17565. * @param world defines the world transformation matrix
  17566. * @param mesh defines the mesh to bind the material to
  17567. */
  17568. bind(world: Matrix, mesh?: Mesh): void;
  17569. /**
  17570. * Binds the submesh to the material
  17571. * @param world defines the world transformation matrix
  17572. * @param mesh defines the mesh containing the submesh
  17573. * @param subMesh defines the submesh to bind the material to
  17574. */
  17575. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17576. /**
  17577. * Binds the world matrix to the material
  17578. * @param world defines the world transformation matrix
  17579. */
  17580. bindOnlyWorldMatrix(world: Matrix): void;
  17581. /**
  17582. * Binds the scene's uniform buffer to the effect.
  17583. * @param effect defines the effect to bind to the scene uniform buffer
  17584. * @param sceneUbo defines the uniform buffer storing scene data
  17585. */
  17586. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  17587. /**
  17588. * Binds the view matrix to the effect
  17589. * @param effect defines the effect to bind the view matrix to
  17590. */
  17591. bindView(effect: Effect): void;
  17592. /**
  17593. * Binds the view projection matrix to the effect
  17594. * @param effect defines the effect to bind the view projection matrix to
  17595. */
  17596. bindViewProjection(effect: Effect): void;
  17597. /**
  17598. * Specifies if material alpha testing should be turned on for the mesh
  17599. * @param mesh defines the mesh to check
  17600. */
  17601. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  17602. /**
  17603. * Processes to execute after binding the material to a mesh
  17604. * @param mesh defines the rendered mesh
  17605. */
  17606. protected _afterBind(mesh?: Mesh): void;
  17607. /**
  17608. * Unbinds the material from the mesh
  17609. */
  17610. unbind(): void;
  17611. /**
  17612. * Gets the active textures from the material
  17613. * @returns an array of textures
  17614. */
  17615. getActiveTextures(): BaseTexture[];
  17616. /**
  17617. * Specifies if the material uses a texture
  17618. * @param texture defines the texture to check against the material
  17619. * @returns a boolean specifying if the material uses the texture
  17620. */
  17621. hasTexture(texture: BaseTexture): boolean;
  17622. /**
  17623. * Makes a duplicate of the material, and gives it a new name
  17624. * @param name defines the new name for the duplicated material
  17625. * @returns the cloned material
  17626. */
  17627. clone(name: string): Nullable<Material>;
  17628. /**
  17629. * Gets the meshes bound to the material
  17630. * @returns an array of meshes bound to the material
  17631. */
  17632. getBindedMeshes(): AbstractMesh[];
  17633. /**
  17634. * Force shader compilation
  17635. * @param mesh defines the mesh associated with this material
  17636. * @param onCompiled defines a function to execute once the material is compiled
  17637. * @param options defines the options to configure the compilation
  17638. */
  17639. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  17640. clipPlane: boolean;
  17641. }>): void;
  17642. /**
  17643. * Force shader compilation
  17644. * @param mesh defines the mesh that will use this material
  17645. * @param options defines additional options for compiling the shaders
  17646. * @returns a promise that resolves when the compilation completes
  17647. */
  17648. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  17649. clipPlane: boolean;
  17650. }>): Promise<void>;
  17651. private static readonly _ImageProcessingDirtyCallBack;
  17652. private static readonly _TextureDirtyCallBack;
  17653. private static readonly _FresnelDirtyCallBack;
  17654. private static readonly _MiscDirtyCallBack;
  17655. private static readonly _LightsDirtyCallBack;
  17656. private static readonly _AttributeDirtyCallBack;
  17657. private static _FresnelAndMiscDirtyCallBack;
  17658. private static _TextureAndMiscDirtyCallBack;
  17659. private static readonly _DirtyCallbackArray;
  17660. private static readonly _RunDirtyCallBacks;
  17661. /**
  17662. * Marks a define in the material to indicate that it needs to be re-computed
  17663. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  17664. */
  17665. markAsDirty(flag: number): void;
  17666. /**
  17667. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  17668. * @param func defines a function which checks material defines against the submeshes
  17669. */
  17670. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  17671. /**
  17672. * Indicates that image processing needs to be re-calculated for all submeshes
  17673. */
  17674. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  17675. /**
  17676. * Indicates that textures need to be re-calculated for all submeshes
  17677. */
  17678. protected _markAllSubMeshesAsTexturesDirty(): void;
  17679. /**
  17680. * Indicates that fresnel needs to be re-calculated for all submeshes
  17681. */
  17682. protected _markAllSubMeshesAsFresnelDirty(): void;
  17683. /**
  17684. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  17685. */
  17686. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  17687. /**
  17688. * Indicates that lights need to be re-calculated for all submeshes
  17689. */
  17690. protected _markAllSubMeshesAsLightsDirty(): void;
  17691. /**
  17692. * Indicates that attributes need to be re-calculated for all submeshes
  17693. */
  17694. protected _markAllSubMeshesAsAttributesDirty(): void;
  17695. /**
  17696. * Indicates that misc needs to be re-calculated for all submeshes
  17697. */
  17698. protected _markAllSubMeshesAsMiscDirty(): void;
  17699. /**
  17700. * Indicates that textures and misc need to be re-calculated for all submeshes
  17701. */
  17702. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  17703. /**
  17704. * Disposes the material
  17705. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17706. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17707. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17708. */
  17709. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17710. /** @hidden */
  17711. private releaseVertexArrayObject;
  17712. /**
  17713. * Serializes this material
  17714. * @returns the serialized material object
  17715. */
  17716. serialize(): any;
  17717. /**
  17718. * Creates a material from parsed material data
  17719. * @param parsedMaterial defines parsed material data
  17720. * @param scene defines the hosting scene
  17721. * @param rootUrl defines the root URL to use to load textures
  17722. * @returns a new material
  17723. */
  17724. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  17725. }
  17726. }
  17727. declare module BABYLON {
  17728. /**
  17729. * Class used to represent data loading progression
  17730. */
  17731. export class SceneLoaderFlags {
  17732. private static _ForceFullSceneLoadingForIncremental;
  17733. private static _ShowLoadingScreen;
  17734. private static _CleanBoneMatrixWeights;
  17735. private static _loggingLevel;
  17736. /**
  17737. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  17738. */
  17739. static ForceFullSceneLoadingForIncremental: boolean;
  17740. /**
  17741. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  17742. */
  17743. static ShowLoadingScreen: boolean;
  17744. /**
  17745. * Defines the current logging level (while loading the scene)
  17746. * @ignorenaming
  17747. */
  17748. static loggingLevel: number;
  17749. /**
  17750. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  17751. */
  17752. static CleanBoneMatrixWeights: boolean;
  17753. }
  17754. }
  17755. declare module BABYLON {
  17756. /**
  17757. * Defines a target to use with MorphTargetManager
  17758. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  17759. */
  17760. export class MorphTarget implements IAnimatable {
  17761. /** defines the name of the target */
  17762. name: string;
  17763. /**
  17764. * Gets or sets the list of animations
  17765. */
  17766. animations: Animation[];
  17767. private _scene;
  17768. private _positions;
  17769. private _normals;
  17770. private _tangents;
  17771. private _influence;
  17772. /**
  17773. * Observable raised when the influence changes
  17774. */
  17775. onInfluenceChanged: Observable<boolean>;
  17776. /** @hidden */
  17777. _onDataLayoutChanged: Observable<void>;
  17778. /**
  17779. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  17780. */
  17781. influence: number;
  17782. /**
  17783. * Gets or sets the id of the morph Target
  17784. */
  17785. id: string;
  17786. private _animationPropertiesOverride;
  17787. /**
  17788. * Gets or sets the animation properties override
  17789. */
  17790. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  17791. /**
  17792. * Creates a new MorphTarget
  17793. * @param name defines the name of the target
  17794. * @param influence defines the influence to use
  17795. */
  17796. constructor(
  17797. /** defines the name of the target */
  17798. name: string, influence?: number, scene?: Nullable<Scene>);
  17799. /**
  17800. * Gets a boolean defining if the target contains position data
  17801. */
  17802. readonly hasPositions: boolean;
  17803. /**
  17804. * Gets a boolean defining if the target contains normal data
  17805. */
  17806. readonly hasNormals: boolean;
  17807. /**
  17808. * Gets a boolean defining if the target contains tangent data
  17809. */
  17810. readonly hasTangents: boolean;
  17811. /**
  17812. * Affects position data to this target
  17813. * @param data defines the position data to use
  17814. */
  17815. setPositions(data: Nullable<FloatArray>): void;
  17816. /**
  17817. * Gets the position data stored in this target
  17818. * @returns a FloatArray containing the position data (or null if not present)
  17819. */
  17820. getPositions(): Nullable<FloatArray>;
  17821. /**
  17822. * Affects normal data to this target
  17823. * @param data defines the normal data to use
  17824. */
  17825. setNormals(data: Nullable<FloatArray>): void;
  17826. /**
  17827. * Gets the normal data stored in this target
  17828. * @returns a FloatArray containing the normal data (or null if not present)
  17829. */
  17830. getNormals(): Nullable<FloatArray>;
  17831. /**
  17832. * Affects tangent data to this target
  17833. * @param data defines the tangent data to use
  17834. */
  17835. setTangents(data: Nullable<FloatArray>): void;
  17836. /**
  17837. * Gets the tangent data stored in this target
  17838. * @returns a FloatArray containing the tangent data (or null if not present)
  17839. */
  17840. getTangents(): Nullable<FloatArray>;
  17841. /**
  17842. * Serializes the current target into a Serialization object
  17843. * @returns the serialized object
  17844. */
  17845. serialize(): any;
  17846. /**
  17847. * Returns the string "MorphTarget"
  17848. * @returns "MorphTarget"
  17849. */
  17850. getClassName(): string;
  17851. /**
  17852. * Creates a new target from serialized data
  17853. * @param serializationObject defines the serialized data to use
  17854. * @returns a new MorphTarget
  17855. */
  17856. static Parse(serializationObject: any): MorphTarget;
  17857. /**
  17858. * Creates a MorphTarget from mesh data
  17859. * @param mesh defines the source mesh
  17860. * @param name defines the name to use for the new target
  17861. * @param influence defines the influence to attach to the target
  17862. * @returns a new MorphTarget
  17863. */
  17864. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  17865. }
  17866. }
  17867. declare module BABYLON {
  17868. /**
  17869. * This class is used to deform meshes using morphing between different targets
  17870. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  17871. */
  17872. export class MorphTargetManager {
  17873. private _targets;
  17874. private _targetInfluenceChangedObservers;
  17875. private _targetDataLayoutChangedObservers;
  17876. private _activeTargets;
  17877. private _scene;
  17878. private _influences;
  17879. private _supportsNormals;
  17880. private _supportsTangents;
  17881. private _vertexCount;
  17882. private _uniqueId;
  17883. private _tempInfluences;
  17884. /**
  17885. * Creates a new MorphTargetManager
  17886. * @param scene defines the current scene
  17887. */
  17888. constructor(scene?: Nullable<Scene>);
  17889. /**
  17890. * Gets the unique ID of this manager
  17891. */
  17892. readonly uniqueId: number;
  17893. /**
  17894. * Gets the number of vertices handled by this manager
  17895. */
  17896. readonly vertexCount: number;
  17897. /**
  17898. * Gets a boolean indicating if this manager supports morphing of normals
  17899. */
  17900. readonly supportsNormals: boolean;
  17901. /**
  17902. * Gets a boolean indicating if this manager supports morphing of tangents
  17903. */
  17904. readonly supportsTangents: boolean;
  17905. /**
  17906. * Gets the number of targets stored in this manager
  17907. */
  17908. readonly numTargets: number;
  17909. /**
  17910. * Gets the number of influencers (ie. the number of targets with influences > 0)
  17911. */
  17912. readonly numInfluencers: number;
  17913. /**
  17914. * Gets the list of influences (one per target)
  17915. */
  17916. readonly influences: Float32Array;
  17917. /**
  17918. * Gets the active target at specified index. An active target is a target with an influence > 0
  17919. * @param index defines the index to check
  17920. * @returns the requested target
  17921. */
  17922. getActiveTarget(index: number): MorphTarget;
  17923. /**
  17924. * Gets the target at specified index
  17925. * @param index defines the index to check
  17926. * @returns the requested target
  17927. */
  17928. getTarget(index: number): MorphTarget;
  17929. /**
  17930. * Add a new target to this manager
  17931. * @param target defines the target to add
  17932. */
  17933. addTarget(target: MorphTarget): void;
  17934. /**
  17935. * Removes a target from the manager
  17936. * @param target defines the target to remove
  17937. */
  17938. removeTarget(target: MorphTarget): void;
  17939. /**
  17940. * Serializes the current manager into a Serialization object
  17941. * @returns the serialized object
  17942. */
  17943. serialize(): any;
  17944. private _syncActiveTargets;
  17945. /**
  17946. * Syncrhonize the targets with all the meshes using this morph target manager
  17947. */
  17948. synchronize(): void;
  17949. /**
  17950. * Creates a new MorphTargetManager from serialized data
  17951. * @param serializationObject defines the serialized data
  17952. * @param scene defines the hosting scene
  17953. * @returns the new MorphTargetManager
  17954. */
  17955. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  17956. }
  17957. }
  17958. declare module BABYLON {
  17959. /**
  17960. * Interface for Physics-Joint data
  17961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17962. */
  17963. export interface PhysicsJointData {
  17964. /**
  17965. * The main pivot of the joint
  17966. */
  17967. mainPivot?: Vector3;
  17968. /**
  17969. * The connected pivot of the joint
  17970. */
  17971. connectedPivot?: Vector3;
  17972. /**
  17973. * The main axis of the joint
  17974. */
  17975. mainAxis?: Vector3;
  17976. /**
  17977. * The connected axis of the joint
  17978. */
  17979. connectedAxis?: Vector3;
  17980. /**
  17981. * The collision of the joint
  17982. */
  17983. collision?: boolean;
  17984. /**
  17985. * Native Oimo/Cannon/Energy data
  17986. */
  17987. nativeParams?: any;
  17988. }
  17989. /**
  17990. * This is a holder class for the physics joint created by the physics plugin
  17991. * It holds a set of functions to control the underlying joint
  17992. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17993. */
  17994. export class PhysicsJoint {
  17995. /**
  17996. * The type of the physics joint
  17997. */
  17998. type: number;
  17999. /**
  18000. * The data for the physics joint
  18001. */
  18002. jointData: PhysicsJointData;
  18003. private _physicsJoint;
  18004. protected _physicsPlugin: IPhysicsEnginePlugin;
  18005. /**
  18006. * Initializes the physics joint
  18007. * @param type The type of the physics joint
  18008. * @param jointData The data for the physics joint
  18009. */
  18010. constructor(
  18011. /**
  18012. * The type of the physics joint
  18013. */
  18014. type: number,
  18015. /**
  18016. * The data for the physics joint
  18017. */
  18018. jointData: PhysicsJointData);
  18019. /**
  18020. * Gets the physics joint
  18021. */
  18022. /**
  18023. * Sets the physics joint
  18024. */
  18025. physicsJoint: any;
  18026. /**
  18027. * Sets the physics plugin
  18028. */
  18029. physicsPlugin: IPhysicsEnginePlugin;
  18030. /**
  18031. * Execute a function that is physics-plugin specific.
  18032. * @param {Function} func the function that will be executed.
  18033. * It accepts two parameters: the physics world and the physics joint
  18034. */
  18035. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  18036. /**
  18037. * Distance-Joint type
  18038. */
  18039. static DistanceJoint: number;
  18040. /**
  18041. * Hinge-Joint type
  18042. */
  18043. static HingeJoint: number;
  18044. /**
  18045. * Ball-and-Socket joint type
  18046. */
  18047. static BallAndSocketJoint: number;
  18048. /**
  18049. * Wheel-Joint type
  18050. */
  18051. static WheelJoint: number;
  18052. /**
  18053. * Slider-Joint type
  18054. */
  18055. static SliderJoint: number;
  18056. /**
  18057. * Prismatic-Joint type
  18058. */
  18059. static PrismaticJoint: number;
  18060. /**
  18061. * Universal-Joint type
  18062. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  18063. */
  18064. static UniversalJoint: number;
  18065. /**
  18066. * Hinge-Joint 2 type
  18067. */
  18068. static Hinge2Joint: number;
  18069. /**
  18070. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  18071. */
  18072. static PointToPointJoint: number;
  18073. /**
  18074. * Spring-Joint type
  18075. */
  18076. static SpringJoint: number;
  18077. /**
  18078. * Lock-Joint type
  18079. */
  18080. static LockJoint: number;
  18081. }
  18082. /**
  18083. * A class representing a physics distance joint
  18084. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18085. */
  18086. export class DistanceJoint extends PhysicsJoint {
  18087. /**
  18088. *
  18089. * @param jointData The data for the Distance-Joint
  18090. */
  18091. constructor(jointData: DistanceJointData);
  18092. /**
  18093. * Update the predefined distance.
  18094. * @param maxDistance The maximum preferred distance
  18095. * @param minDistance The minimum preferred distance
  18096. */
  18097. updateDistance(maxDistance: number, minDistance?: number): void;
  18098. }
  18099. /**
  18100. * Represents a Motor-Enabled Joint
  18101. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18102. */
  18103. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  18104. /**
  18105. * Initializes the Motor-Enabled Joint
  18106. * @param type The type of the joint
  18107. * @param jointData The physica joint data for the joint
  18108. */
  18109. constructor(type: number, jointData: PhysicsJointData);
  18110. /**
  18111. * Set the motor values.
  18112. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18113. * @param force the force to apply
  18114. * @param maxForce max force for this motor.
  18115. */
  18116. setMotor(force?: number, maxForce?: number): void;
  18117. /**
  18118. * Set the motor's limits.
  18119. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18120. * @param upperLimit The upper limit of the motor
  18121. * @param lowerLimit The lower limit of the motor
  18122. */
  18123. setLimit(upperLimit: number, lowerLimit?: number): void;
  18124. }
  18125. /**
  18126. * This class represents a single physics Hinge-Joint
  18127. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18128. */
  18129. export class HingeJoint extends MotorEnabledJoint {
  18130. /**
  18131. * Initializes the Hinge-Joint
  18132. * @param jointData The joint data for the Hinge-Joint
  18133. */
  18134. constructor(jointData: PhysicsJointData);
  18135. /**
  18136. * Set the motor values.
  18137. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18138. * @param {number} force the force to apply
  18139. * @param {number} maxForce max force for this motor.
  18140. */
  18141. setMotor(force?: number, maxForce?: number): void;
  18142. /**
  18143. * Set the motor's limits.
  18144. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18145. * @param upperLimit The upper limit of the motor
  18146. * @param lowerLimit The lower limit of the motor
  18147. */
  18148. setLimit(upperLimit: number, lowerLimit?: number): void;
  18149. }
  18150. /**
  18151. * This class represents a dual hinge physics joint (same as wheel joint)
  18152. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18153. */
  18154. export class Hinge2Joint extends MotorEnabledJoint {
  18155. /**
  18156. * Initializes the Hinge2-Joint
  18157. * @param jointData The joint data for the Hinge2-Joint
  18158. */
  18159. constructor(jointData: PhysicsJointData);
  18160. /**
  18161. * Set the motor values.
  18162. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18163. * @param {number} force the force to apply
  18164. * @param {number} maxForce max force for this motor.
  18165. * @param {motorIndex} the motor's index, 0 or 1.
  18166. */
  18167. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18168. /**
  18169. * Set the motor limits.
  18170. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18171. * @param {number} upperLimit the upper limit
  18172. * @param {number} lowerLimit lower limit
  18173. * @param {motorIndex} the motor's index, 0 or 1.
  18174. */
  18175. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18176. }
  18177. /**
  18178. * Interface for a motor enabled joint
  18179. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18180. */
  18181. export interface IMotorEnabledJoint {
  18182. /**
  18183. * Physics joint
  18184. */
  18185. physicsJoint: any;
  18186. /**
  18187. * Sets the motor of the motor-enabled joint
  18188. * @param force The force of the motor
  18189. * @param maxForce The maximum force of the motor
  18190. * @param motorIndex The index of the motor
  18191. */
  18192. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18193. /**
  18194. * Sets the limit of the motor
  18195. * @param upperLimit The upper limit of the motor
  18196. * @param lowerLimit The lower limit of the motor
  18197. * @param motorIndex The index of the motor
  18198. */
  18199. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18200. }
  18201. /**
  18202. * Joint data for a Distance-Joint
  18203. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18204. */
  18205. export interface DistanceJointData extends PhysicsJointData {
  18206. /**
  18207. * Max distance the 2 joint objects can be apart
  18208. */
  18209. maxDistance: number;
  18210. }
  18211. /**
  18212. * Joint data from a spring joint
  18213. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18214. */
  18215. export interface SpringJointData extends PhysicsJointData {
  18216. /**
  18217. * Length of the spring
  18218. */
  18219. length: number;
  18220. /**
  18221. * Stiffness of the spring
  18222. */
  18223. stiffness: number;
  18224. /**
  18225. * Damping of the spring
  18226. */
  18227. damping: number;
  18228. /** this callback will be called when applying the force to the impostors. */
  18229. forceApplicationCallback: () => void;
  18230. }
  18231. }
  18232. declare module BABYLON {
  18233. /**
  18234. * Interface used to describe a physics joint
  18235. */
  18236. export interface PhysicsImpostorJoint {
  18237. /** Defines the main impostor to which the joint is linked */
  18238. mainImpostor: PhysicsImpostor;
  18239. /** Defines the impostor that is connected to the main impostor using this joint */
  18240. connectedImpostor: PhysicsImpostor;
  18241. /** Defines the joint itself */
  18242. joint: PhysicsJoint;
  18243. }
  18244. /** @hidden */
  18245. export interface IPhysicsEnginePlugin {
  18246. world: any;
  18247. name: string;
  18248. setGravity(gravity: Vector3): void;
  18249. setTimeStep(timeStep: number): void;
  18250. getTimeStep(): number;
  18251. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  18252. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18253. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18254. generatePhysicsBody(impostor: PhysicsImpostor): void;
  18255. removePhysicsBody(impostor: PhysicsImpostor): void;
  18256. generateJoint(joint: PhysicsImpostorJoint): void;
  18257. removeJoint(joint: PhysicsImpostorJoint): void;
  18258. isSupported(): boolean;
  18259. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  18260. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  18261. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18262. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18263. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18264. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18265. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  18266. getBodyMass(impostor: PhysicsImpostor): number;
  18267. getBodyFriction(impostor: PhysicsImpostor): number;
  18268. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  18269. getBodyRestitution(impostor: PhysicsImpostor): number;
  18270. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  18271. sleepBody(impostor: PhysicsImpostor): void;
  18272. wakeUpBody(impostor: PhysicsImpostor): void;
  18273. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  18274. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  18275. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18276. getRadius(impostor: PhysicsImpostor): number;
  18277. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  18278. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  18279. dispose(): void;
  18280. }
  18281. /**
  18282. * Interface used to define a physics engine
  18283. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  18284. */
  18285. export interface IPhysicsEngine {
  18286. /**
  18287. * Gets the gravity vector used by the simulation
  18288. */
  18289. gravity: Vector3;
  18290. /**
  18291. * Sets the gravity vector used by the simulation
  18292. * @param gravity defines the gravity vector to use
  18293. */
  18294. setGravity(gravity: Vector3): void;
  18295. /**
  18296. * Set the time step of the physics engine.
  18297. * Default is 1/60.
  18298. * To slow it down, enter 1/600 for example.
  18299. * To speed it up, 1/30
  18300. * @param newTimeStep the new timestep to apply to this world.
  18301. */
  18302. setTimeStep(newTimeStep: number): void;
  18303. /**
  18304. * Get the time step of the physics engine.
  18305. * @returns the current time step
  18306. */
  18307. getTimeStep(): number;
  18308. /**
  18309. * Release all resources
  18310. */
  18311. dispose(): void;
  18312. /**
  18313. * Gets the name of the current physics plugin
  18314. * @returns the name of the plugin
  18315. */
  18316. getPhysicsPluginName(): string;
  18317. /**
  18318. * Adding a new impostor for the impostor tracking.
  18319. * This will be done by the impostor itself.
  18320. * @param impostor the impostor to add
  18321. */
  18322. addImpostor(impostor: PhysicsImpostor): void;
  18323. /**
  18324. * Remove an impostor from the engine.
  18325. * This impostor and its mesh will not longer be updated by the physics engine.
  18326. * @param impostor the impostor to remove
  18327. */
  18328. removeImpostor(impostor: PhysicsImpostor): void;
  18329. /**
  18330. * Add a joint to the physics engine
  18331. * @param mainImpostor defines the main impostor to which the joint is added.
  18332. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  18333. * @param joint defines the joint that will connect both impostors.
  18334. */
  18335. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18336. /**
  18337. * Removes a joint from the simulation
  18338. * @param mainImpostor defines the impostor used with the joint
  18339. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  18340. * @param joint defines the joint to remove
  18341. */
  18342. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18343. /**
  18344. * Gets the current plugin used to run the simulation
  18345. * @returns current plugin
  18346. */
  18347. getPhysicsPlugin(): IPhysicsEnginePlugin;
  18348. /**
  18349. * Gets the list of physic impostors
  18350. * @returns an array of PhysicsImpostor
  18351. */
  18352. getImpostors(): Array<PhysicsImpostor>;
  18353. /**
  18354. * Gets the impostor for a physics enabled object
  18355. * @param object defines the object impersonated by the impostor
  18356. * @returns the PhysicsImpostor or null if not found
  18357. */
  18358. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  18359. /**
  18360. * Gets the impostor for a physics body object
  18361. * @param body defines physics body used by the impostor
  18362. * @returns the PhysicsImpostor or null if not found
  18363. */
  18364. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  18365. /**
  18366. * Called by the scene. No need to call it.
  18367. * @param delta defines the timespam between frames
  18368. */
  18369. _step(delta: number): void;
  18370. }
  18371. }
  18372. declare module BABYLON {
  18373. /**
  18374. * The interface for the physics imposter parameters
  18375. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18376. */
  18377. export interface PhysicsImpostorParameters {
  18378. /**
  18379. * The mass of the physics imposter
  18380. */
  18381. mass: number;
  18382. /**
  18383. * The friction of the physics imposter
  18384. */
  18385. friction?: number;
  18386. /**
  18387. * The coefficient of restitution of the physics imposter
  18388. */
  18389. restitution?: number;
  18390. /**
  18391. * The native options of the physics imposter
  18392. */
  18393. nativeOptions?: any;
  18394. /**
  18395. * Specifies if the parent should be ignored
  18396. */
  18397. ignoreParent?: boolean;
  18398. /**
  18399. * Specifies if bi-directional transformations should be disabled
  18400. */
  18401. disableBidirectionalTransformation?: boolean;
  18402. }
  18403. /**
  18404. * Interface for a physics-enabled object
  18405. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18406. */
  18407. export interface IPhysicsEnabledObject {
  18408. /**
  18409. * The position of the physics-enabled object
  18410. */
  18411. position: Vector3;
  18412. /**
  18413. * The rotation of the physics-enabled object
  18414. */
  18415. rotationQuaternion: Nullable<Quaternion>;
  18416. /**
  18417. * The scale of the physics-enabled object
  18418. */
  18419. scaling: Vector3;
  18420. /**
  18421. * The rotation of the physics-enabled object
  18422. */
  18423. rotation?: Vector3;
  18424. /**
  18425. * The parent of the physics-enabled object
  18426. */
  18427. parent?: any;
  18428. /**
  18429. * The bounding info of the physics-enabled object
  18430. * @returns The bounding info of the physics-enabled object
  18431. */
  18432. getBoundingInfo(): BoundingInfo;
  18433. /**
  18434. * Computes the world matrix
  18435. * @param force Specifies if the world matrix should be computed by force
  18436. * @returns A world matrix
  18437. */
  18438. computeWorldMatrix(force: boolean): Matrix;
  18439. /**
  18440. * Gets the world matrix
  18441. * @returns A world matrix
  18442. */
  18443. getWorldMatrix?(): Matrix;
  18444. /**
  18445. * Gets the child meshes
  18446. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  18447. * @returns An array of abstract meshes
  18448. */
  18449. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  18450. /**
  18451. * Gets the vertex data
  18452. * @param kind The type of vertex data
  18453. * @returns A nullable array of numbers, or a float32 array
  18454. */
  18455. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  18456. /**
  18457. * Gets the indices from the mesh
  18458. * @returns A nullable array of index arrays
  18459. */
  18460. getIndices?(): Nullable<IndicesArray>;
  18461. /**
  18462. * Gets the scene from the mesh
  18463. * @returns the indices array or null
  18464. */
  18465. getScene?(): Scene;
  18466. /**
  18467. * Gets the absolute position from the mesh
  18468. * @returns the absolute position
  18469. */
  18470. getAbsolutePosition(): Vector3;
  18471. /**
  18472. * Gets the absolute pivot point from the mesh
  18473. * @returns the absolute pivot point
  18474. */
  18475. getAbsolutePivotPoint(): Vector3;
  18476. /**
  18477. * Rotates the mesh
  18478. * @param axis The axis of rotation
  18479. * @param amount The amount of rotation
  18480. * @param space The space of the rotation
  18481. * @returns The rotation transform node
  18482. */
  18483. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  18484. /**
  18485. * Translates the mesh
  18486. * @param axis The axis of translation
  18487. * @param distance The distance of translation
  18488. * @param space The space of the translation
  18489. * @returns The transform node
  18490. */
  18491. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  18492. /**
  18493. * Sets the absolute position of the mesh
  18494. * @param absolutePosition The absolute position of the mesh
  18495. * @returns The transform node
  18496. */
  18497. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  18498. /**
  18499. * Gets the class name of the mesh
  18500. * @returns The class name
  18501. */
  18502. getClassName(): string;
  18503. }
  18504. /**
  18505. * Represents a physics imposter
  18506. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18507. */
  18508. export class PhysicsImpostor {
  18509. /**
  18510. * The physics-enabled object used as the physics imposter
  18511. */
  18512. object: IPhysicsEnabledObject;
  18513. /**
  18514. * The type of the physics imposter
  18515. */
  18516. type: number;
  18517. private _options;
  18518. private _scene?;
  18519. /**
  18520. * The default object size of the imposter
  18521. */
  18522. static DEFAULT_OBJECT_SIZE: Vector3;
  18523. /**
  18524. * The identity quaternion of the imposter
  18525. */
  18526. static IDENTITY_QUATERNION: Quaternion;
  18527. /** @hidden */
  18528. _pluginData: any;
  18529. private _physicsEngine;
  18530. private _physicsBody;
  18531. private _bodyUpdateRequired;
  18532. private _onBeforePhysicsStepCallbacks;
  18533. private _onAfterPhysicsStepCallbacks;
  18534. /** @hidden */
  18535. _onPhysicsCollideCallbacks: Array<{
  18536. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  18537. otherImpostors: Array<PhysicsImpostor>;
  18538. }>;
  18539. private _deltaPosition;
  18540. private _deltaRotation;
  18541. private _deltaRotationConjugated;
  18542. private _parent;
  18543. private _isDisposed;
  18544. private static _tmpVecs;
  18545. private static _tmpQuat;
  18546. /**
  18547. * Specifies if the physics imposter is disposed
  18548. */
  18549. readonly isDisposed: boolean;
  18550. /**
  18551. * Gets the mass of the physics imposter
  18552. */
  18553. mass: number;
  18554. /**
  18555. * Gets the coefficient of friction
  18556. */
  18557. /**
  18558. * Sets the coefficient of friction
  18559. */
  18560. friction: number;
  18561. /**
  18562. * Gets the coefficient of restitution
  18563. */
  18564. /**
  18565. * Sets the coefficient of restitution
  18566. */
  18567. restitution: number;
  18568. /**
  18569. * The unique id of the physics imposter
  18570. * set by the physics engine when adding this impostor to the array
  18571. */
  18572. uniqueId: number;
  18573. private _joints;
  18574. /**
  18575. * Initializes the physics imposter
  18576. * @param object The physics-enabled object used as the physics imposter
  18577. * @param type The type of the physics imposter
  18578. * @param _options The options for the physics imposter
  18579. * @param _scene The Babylon scene
  18580. */
  18581. constructor(
  18582. /**
  18583. * The physics-enabled object used as the physics imposter
  18584. */
  18585. object: IPhysicsEnabledObject,
  18586. /**
  18587. * The type of the physics imposter
  18588. */
  18589. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  18590. /**
  18591. * This function will completly initialize this impostor.
  18592. * It will create a new body - but only if this mesh has no parent.
  18593. * If it has, this impostor will not be used other than to define the impostor
  18594. * of the child mesh.
  18595. * @hidden
  18596. */
  18597. _init(): void;
  18598. private _getPhysicsParent;
  18599. /**
  18600. * Should a new body be generated.
  18601. * @returns boolean specifying if body initialization is required
  18602. */
  18603. isBodyInitRequired(): boolean;
  18604. /**
  18605. * Sets the updated scaling
  18606. * @param updated Specifies if the scaling is updated
  18607. */
  18608. setScalingUpdated(): void;
  18609. /**
  18610. * Force a regeneration of this or the parent's impostor's body.
  18611. * Use under cautious - This will remove all joints already implemented.
  18612. */
  18613. forceUpdate(): void;
  18614. /**
  18615. * Gets the body that holds this impostor. Either its own, or its parent.
  18616. */
  18617. /**
  18618. * Set the physics body. Used mainly by the physics engine/plugin
  18619. */
  18620. physicsBody: any;
  18621. /**
  18622. * Get the parent of the physics imposter
  18623. * @returns Physics imposter or null
  18624. */
  18625. /**
  18626. * Sets the parent of the physics imposter
  18627. */
  18628. parent: Nullable<PhysicsImpostor>;
  18629. /**
  18630. * Resets the update flags
  18631. */
  18632. resetUpdateFlags(): void;
  18633. /**
  18634. * Gets the object extend size
  18635. * @returns the object extend size
  18636. */
  18637. getObjectExtendSize(): Vector3;
  18638. /**
  18639. * Gets the object center
  18640. * @returns The object center
  18641. */
  18642. getObjectCenter(): Vector3;
  18643. /**
  18644. * Get a specific parametes from the options parameter
  18645. * @param paramName The object parameter name
  18646. * @returns The object parameter
  18647. */
  18648. getParam(paramName: string): any;
  18649. /**
  18650. * Sets a specific parameter in the options given to the physics plugin
  18651. * @param paramName The parameter name
  18652. * @param value The value of the parameter
  18653. */
  18654. setParam(paramName: string, value: number): void;
  18655. /**
  18656. * Specifically change the body's mass option. Won't recreate the physics body object
  18657. * @param mass The mass of the physics imposter
  18658. */
  18659. setMass(mass: number): void;
  18660. /**
  18661. * Gets the linear velocity
  18662. * @returns linear velocity or null
  18663. */
  18664. getLinearVelocity(): Nullable<Vector3>;
  18665. /**
  18666. * Sets the linear velocity
  18667. * @param velocity linear velocity or null
  18668. */
  18669. setLinearVelocity(velocity: Nullable<Vector3>): void;
  18670. /**
  18671. * Gets the angular velocity
  18672. * @returns angular velocity or null
  18673. */
  18674. getAngularVelocity(): Nullable<Vector3>;
  18675. /**
  18676. * Sets the angular velocity
  18677. * @param velocity The velocity or null
  18678. */
  18679. setAngularVelocity(velocity: Nullable<Vector3>): void;
  18680. /**
  18681. * Execute a function with the physics plugin native code
  18682. * Provide a function the will have two variables - the world object and the physics body object
  18683. * @param func The function to execute with the physics plugin native code
  18684. */
  18685. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  18686. /**
  18687. * Register a function that will be executed before the physics world is stepping forward
  18688. * @param func The function to execute before the physics world is stepped forward
  18689. */
  18690. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18691. /**
  18692. * Unregister a function that will be executed before the physics world is stepping forward
  18693. * @param func The function to execute before the physics world is stepped forward
  18694. */
  18695. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18696. /**
  18697. * Register a function that will be executed after the physics step
  18698. * @param func The function to execute after physics step
  18699. */
  18700. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18701. /**
  18702. * Unregisters a function that will be executed after the physics step
  18703. * @param func The function to execute after physics step
  18704. */
  18705. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18706. /**
  18707. * register a function that will be executed when this impostor collides against a different body
  18708. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  18709. * @param func Callback that is executed on collision
  18710. */
  18711. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  18712. /**
  18713. * Unregisters the physics imposter on contact
  18714. * @param collideAgainst The physics object to collide against
  18715. * @param func Callback to execute on collision
  18716. */
  18717. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  18718. private _tmpQuat;
  18719. private _tmpQuat2;
  18720. /**
  18721. * Get the parent rotation
  18722. * @returns The parent rotation
  18723. */
  18724. getParentsRotation(): Quaternion;
  18725. /**
  18726. * this function is executed by the physics engine.
  18727. */
  18728. beforeStep: () => void;
  18729. /**
  18730. * this function is executed by the physics engine
  18731. */
  18732. afterStep: () => void;
  18733. /**
  18734. * Legacy collision detection event support
  18735. */
  18736. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  18737. /**
  18738. * event and body object due to cannon's event-based architecture.
  18739. */
  18740. onCollide: (e: {
  18741. body: any;
  18742. }) => void;
  18743. /**
  18744. * Apply a force
  18745. * @param force The force to apply
  18746. * @param contactPoint The contact point for the force
  18747. * @returns The physics imposter
  18748. */
  18749. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  18750. /**
  18751. * Apply an impulse
  18752. * @param force The impulse force
  18753. * @param contactPoint The contact point for the impulse force
  18754. * @returns The physics imposter
  18755. */
  18756. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  18757. /**
  18758. * A help function to create a joint
  18759. * @param otherImpostor A physics imposter used to create a joint
  18760. * @param jointType The type of joint
  18761. * @param jointData The data for the joint
  18762. * @returns The physics imposter
  18763. */
  18764. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  18765. /**
  18766. * Add a joint to this impostor with a different impostor
  18767. * @param otherImpostor A physics imposter used to add a joint
  18768. * @param joint The joint to add
  18769. * @returns The physics imposter
  18770. */
  18771. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  18772. /**
  18773. * Will keep this body still, in a sleep mode.
  18774. * @returns the physics imposter
  18775. */
  18776. sleep(): PhysicsImpostor;
  18777. /**
  18778. * Wake the body up.
  18779. * @returns The physics imposter
  18780. */
  18781. wakeUp(): PhysicsImpostor;
  18782. /**
  18783. * Clones the physics imposter
  18784. * @param newObject The physics imposter clones to this physics-enabled object
  18785. * @returns A nullable physics imposter
  18786. */
  18787. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  18788. /**
  18789. * Disposes the physics imposter
  18790. */
  18791. dispose(): void;
  18792. /**
  18793. * Sets the delta position
  18794. * @param position The delta position amount
  18795. */
  18796. setDeltaPosition(position: Vector3): void;
  18797. /**
  18798. * Sets the delta rotation
  18799. * @param rotation The delta rotation amount
  18800. */
  18801. setDeltaRotation(rotation: Quaternion): void;
  18802. /**
  18803. * Gets the box size of the physics imposter and stores the result in the input parameter
  18804. * @param result Stores the box size
  18805. * @returns The physics imposter
  18806. */
  18807. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  18808. /**
  18809. * Gets the radius of the physics imposter
  18810. * @returns Radius of the physics imposter
  18811. */
  18812. getRadius(): number;
  18813. /**
  18814. * Sync a bone with this impostor
  18815. * @param bone The bone to sync to the impostor.
  18816. * @param boneMesh The mesh that the bone is influencing.
  18817. * @param jointPivot The pivot of the joint / bone in local space.
  18818. * @param distToJoint Optional distance from the impostor to the joint.
  18819. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  18820. */
  18821. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  18822. /**
  18823. * Sync impostor to a bone
  18824. * @param bone The bone that the impostor will be synced to.
  18825. * @param boneMesh The mesh that the bone is influencing.
  18826. * @param jointPivot The pivot of the joint / bone in local space.
  18827. * @param distToJoint Optional distance from the impostor to the joint.
  18828. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  18829. * @param boneAxis Optional vector3 axis the bone is aligned with
  18830. */
  18831. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  18832. /**
  18833. * No-Imposter type
  18834. */
  18835. static NoImpostor: number;
  18836. /**
  18837. * Sphere-Imposter type
  18838. */
  18839. static SphereImpostor: number;
  18840. /**
  18841. * Box-Imposter type
  18842. */
  18843. static BoxImpostor: number;
  18844. /**
  18845. * Plane-Imposter type
  18846. */
  18847. static PlaneImpostor: number;
  18848. /**
  18849. * Mesh-imposter type
  18850. */
  18851. static MeshImpostor: number;
  18852. /**
  18853. * Cylinder-Imposter type
  18854. */
  18855. static CylinderImpostor: number;
  18856. /**
  18857. * Particle-Imposter type
  18858. */
  18859. static ParticleImpostor: number;
  18860. /**
  18861. * Heightmap-Imposter type
  18862. */
  18863. static HeightmapImpostor: number;
  18864. }
  18865. }
  18866. declare module BABYLON {
  18867. /**
  18868. * Mesh representing the gorund
  18869. */
  18870. export class GroundMesh extends Mesh {
  18871. /** If octree should be generated */
  18872. generateOctree: boolean;
  18873. private _heightQuads;
  18874. /** @hidden */
  18875. _subdivisionsX: number;
  18876. /** @hidden */
  18877. _subdivisionsY: number;
  18878. /** @hidden */
  18879. _width: number;
  18880. /** @hidden */
  18881. _height: number;
  18882. /** @hidden */
  18883. _minX: number;
  18884. /** @hidden */
  18885. _maxX: number;
  18886. /** @hidden */
  18887. _minZ: number;
  18888. /** @hidden */
  18889. _maxZ: number;
  18890. constructor(name: string, scene: Scene);
  18891. /**
  18892. * "GroundMesh"
  18893. * @returns "GroundMesh"
  18894. */
  18895. getClassName(): string;
  18896. /**
  18897. * The minimum of x and y subdivisions
  18898. */
  18899. readonly subdivisions: number;
  18900. /**
  18901. * X subdivisions
  18902. */
  18903. readonly subdivisionsX: number;
  18904. /**
  18905. * Y subdivisions
  18906. */
  18907. readonly subdivisionsY: number;
  18908. /**
  18909. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  18910. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  18911. * @param chunksCount the number of subdivisions for x and y
  18912. * @param octreeBlocksSize (Default: 32)
  18913. */
  18914. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  18915. /**
  18916. * Returns a height (y) value in the Worl system :
  18917. * the ground altitude at the coordinates (x, z) expressed in the World system.
  18918. * @param x x coordinate
  18919. * @param z z coordinate
  18920. * @returns the ground y position if (x, z) are outside the ground surface.
  18921. */
  18922. getHeightAtCoordinates(x: number, z: number): number;
  18923. /**
  18924. * Returns a normalized vector (Vector3) orthogonal to the ground
  18925. * at the ground coordinates (x, z) expressed in the World system.
  18926. * @param x x coordinate
  18927. * @param z z coordinate
  18928. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  18929. */
  18930. getNormalAtCoordinates(x: number, z: number): Vector3;
  18931. /**
  18932. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  18933. * at the ground coordinates (x, z) expressed in the World system.
  18934. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  18935. * @param x x coordinate
  18936. * @param z z coordinate
  18937. * @param ref vector to store the result
  18938. * @returns the GroundMesh.
  18939. */
  18940. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  18941. /**
  18942. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  18943. * if the ground has been updated.
  18944. * This can be used in the render loop.
  18945. * @returns the GroundMesh.
  18946. */
  18947. updateCoordinateHeights(): GroundMesh;
  18948. private _getFacetAt;
  18949. private _initHeightQuads;
  18950. private _computeHeightQuads;
  18951. /**
  18952. * Serializes this ground mesh
  18953. * @param serializationObject object to write serialization to
  18954. */
  18955. serialize(serializationObject: any): void;
  18956. /**
  18957. * Parses a serialized ground mesh
  18958. * @param parsedMesh the serialized mesh
  18959. * @param scene the scene to create the ground mesh in
  18960. * @returns the created ground mesh
  18961. */
  18962. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  18963. }
  18964. }
  18965. declare module BABYLON {
  18966. /**
  18967. * Class used to represent a specific level of detail of a mesh
  18968. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  18969. */
  18970. export class MeshLODLevel {
  18971. /** Defines the distance where this level should star being displayed */
  18972. distance: number;
  18973. /** Defines the mesh to use to render this level */
  18974. mesh: Nullable<Mesh>;
  18975. /**
  18976. * Creates a new LOD level
  18977. * @param distance defines the distance where this level should star being displayed
  18978. * @param mesh defines the mesh to use to render this level
  18979. */
  18980. constructor(
  18981. /** Defines the distance where this level should star being displayed */
  18982. distance: number,
  18983. /** Defines the mesh to use to render this level */
  18984. mesh: Nullable<Mesh>);
  18985. }
  18986. /**
  18987. * @hidden
  18988. **/
  18989. export class _CreationDataStorage {
  18990. closePath?: boolean;
  18991. closeArray?: boolean;
  18992. idx: number[];
  18993. dashSize: number;
  18994. gapSize: number;
  18995. path3D: Path3D;
  18996. pathArray: Vector3[][];
  18997. arc: number;
  18998. radius: number;
  18999. cap: number;
  19000. tessellation: number;
  19001. }
  19002. /**
  19003. * @hidden
  19004. **/
  19005. class _InstanceDataStorage {
  19006. visibleInstances: any;
  19007. renderIdForInstances: number[];
  19008. batchCache: _InstancesBatch;
  19009. instancesBufferSize: number;
  19010. instancesBuffer: Nullable<Buffer>;
  19011. instancesData: Float32Array;
  19012. overridenInstanceCount: number;
  19013. }
  19014. /**
  19015. * @hidden
  19016. **/
  19017. export class _InstancesBatch {
  19018. mustReturn: boolean;
  19019. visibleInstances: Nullable<InstancedMesh[]>[];
  19020. renderSelf: boolean[];
  19021. }
  19022. /**
  19023. * Class used to represent renderable models
  19024. */
  19025. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  19026. /**
  19027. * Mesh side orientation : usually the external or front surface
  19028. */
  19029. static readonly FRONTSIDE: number;
  19030. /**
  19031. * Mesh side orientation : usually the internal or back surface
  19032. */
  19033. static readonly BACKSIDE: number;
  19034. /**
  19035. * Mesh side orientation : both internal and external or front and back surfaces
  19036. */
  19037. static readonly DOUBLESIDE: number;
  19038. /**
  19039. * Mesh side orientation : by default, `FRONTSIDE`
  19040. */
  19041. static readonly DEFAULTSIDE: number;
  19042. /**
  19043. * Mesh cap setting : no cap
  19044. */
  19045. static readonly NO_CAP: number;
  19046. /**
  19047. * Mesh cap setting : one cap at the beginning of the mesh
  19048. */
  19049. static readonly CAP_START: number;
  19050. /**
  19051. * Mesh cap setting : one cap at the end of the mesh
  19052. */
  19053. static readonly CAP_END: number;
  19054. /**
  19055. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  19056. */
  19057. static readonly CAP_ALL: number;
  19058. private _onBeforeRenderObservable;
  19059. private _onBeforeBindObservable;
  19060. private _onAfterRenderObservable;
  19061. private _onBeforeDrawObservable;
  19062. /**
  19063. * An event triggered before rendering the mesh
  19064. */
  19065. readonly onBeforeRenderObservable: Observable<Mesh>;
  19066. /**
  19067. * An event triggered before binding the mesh
  19068. */
  19069. readonly onBeforeBindObservable: Observable<Mesh>;
  19070. /**
  19071. * An event triggered after rendering the mesh
  19072. */
  19073. readonly onAfterRenderObservable: Observable<Mesh>;
  19074. /**
  19075. * An event triggered before drawing the mesh
  19076. */
  19077. readonly onBeforeDrawObservable: Observable<Mesh>;
  19078. private _onBeforeDrawObserver;
  19079. /**
  19080. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  19081. */
  19082. onBeforeDraw: () => void;
  19083. /**
  19084. * Gets the delay loading state of the mesh (when delay loading is turned on)
  19085. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  19086. */
  19087. delayLoadState: number;
  19088. /**
  19089. * Gets the list of instances created from this mesh
  19090. * it is not supposed to be modified manually.
  19091. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  19092. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19093. */
  19094. instances: InstancedMesh[];
  19095. /**
  19096. * Gets the file containing delay loading data for this mesh
  19097. */
  19098. delayLoadingFile: string;
  19099. /** @hidden */
  19100. _binaryInfo: any;
  19101. private _LODLevels;
  19102. /**
  19103. * User defined function used to change how LOD level selection is done
  19104. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19105. */
  19106. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  19107. private _morphTargetManager;
  19108. /**
  19109. * Gets or sets the morph target manager
  19110. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19111. */
  19112. morphTargetManager: Nullable<MorphTargetManager>;
  19113. /** @hidden */
  19114. _creationDataStorage: Nullable<_CreationDataStorage>;
  19115. /** @hidden */
  19116. _geometry: Nullable<Geometry>;
  19117. /** @hidden */
  19118. _delayInfo: Array<string>;
  19119. /** @hidden */
  19120. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  19121. /** @hidden */
  19122. _instanceDataStorage: _InstanceDataStorage;
  19123. private _effectiveMaterial;
  19124. /** @hidden */
  19125. _shouldGenerateFlatShading: boolean;
  19126. private _preActivateId;
  19127. /** @hidden */
  19128. _originalBuilderSideOrientation: number;
  19129. /**
  19130. * Use this property to change the original side orientation defined at construction time
  19131. */
  19132. overrideMaterialSideOrientation: Nullable<number>;
  19133. private _areNormalsFrozen;
  19134. private _sourcePositions;
  19135. private _sourceNormals;
  19136. private _source;
  19137. private meshMap;
  19138. /**
  19139. * Gets the source mesh (the one used to clone this one from)
  19140. */
  19141. readonly source: Nullable<Mesh>;
  19142. /**
  19143. * Gets or sets a boolean indicating that this mesh does not use index buffer
  19144. */
  19145. isUnIndexed: boolean;
  19146. /**
  19147. * @constructor
  19148. * @param name The value used by scene.getMeshByName() to do a lookup.
  19149. * @param scene The scene to add this mesh to.
  19150. * @param parent The parent of this mesh, if it has one
  19151. * @param source An optional Mesh from which geometry is shared, cloned.
  19152. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19153. * When false, achieved by calling a clone(), also passing False.
  19154. * This will make creation of children, recursive.
  19155. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  19156. */
  19157. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  19158. /**
  19159. * Gets the class name
  19160. * @returns the string "Mesh".
  19161. */
  19162. getClassName(): string;
  19163. /** @hidden */
  19164. readonly _isMesh: boolean;
  19165. /**
  19166. * Returns a description of this mesh
  19167. * @param fullDetails define if full details about this mesh must be used
  19168. * @returns a descriptive string representing this mesh
  19169. */
  19170. toString(fullDetails?: boolean): string;
  19171. /** @hidden */
  19172. _unBindEffect(): void;
  19173. /**
  19174. * Gets a boolean indicating if this mesh has LOD
  19175. */
  19176. readonly hasLODLevels: boolean;
  19177. /**
  19178. * Gets the list of MeshLODLevel associated with the current mesh
  19179. * @returns an array of MeshLODLevel
  19180. */
  19181. getLODLevels(): MeshLODLevel[];
  19182. private _sortLODLevels;
  19183. /**
  19184. * Add a mesh as LOD level triggered at the given distance.
  19185. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19186. * @param distance The distance from the center of the object to show this level
  19187. * @param mesh The mesh to be added as LOD level (can be null)
  19188. * @return This mesh (for chaining)
  19189. */
  19190. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  19191. /**
  19192. * Returns the LOD level mesh at the passed distance or null if not found.
  19193. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19194. * @param distance The distance from the center of the object to show this level
  19195. * @returns a Mesh or `null`
  19196. */
  19197. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  19198. /**
  19199. * Remove a mesh from the LOD array
  19200. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19201. * @param mesh defines the mesh to be removed
  19202. * @return This mesh (for chaining)
  19203. */
  19204. removeLODLevel(mesh: Mesh): Mesh;
  19205. /**
  19206. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  19207. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19208. * @param camera defines the camera to use to compute distance
  19209. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  19210. * @return This mesh (for chaining)
  19211. */
  19212. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  19213. /**
  19214. * Gets the mesh internal Geometry object
  19215. */
  19216. readonly geometry: Nullable<Geometry>;
  19217. /**
  19218. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  19219. * @returns the total number of vertices
  19220. */
  19221. getTotalVertices(): number;
  19222. /**
  19223. * Returns the content of an associated vertex buffer
  19224. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19225. * - VertexBuffer.PositionKind
  19226. * - VertexBuffer.UVKind
  19227. * - VertexBuffer.UV2Kind
  19228. * - VertexBuffer.UV3Kind
  19229. * - VertexBuffer.UV4Kind
  19230. * - VertexBuffer.UV5Kind
  19231. * - VertexBuffer.UV6Kind
  19232. * - VertexBuffer.ColorKind
  19233. * - VertexBuffer.MatricesIndicesKind
  19234. * - VertexBuffer.MatricesIndicesExtraKind
  19235. * - VertexBuffer.MatricesWeightsKind
  19236. * - VertexBuffer.MatricesWeightsExtraKind
  19237. * @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
  19238. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  19239. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  19240. */
  19241. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19242. /**
  19243. * Returns the mesh VertexBuffer object from the requested `kind`
  19244. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19245. * - VertexBuffer.PositionKind
  19246. * - VertexBuffer.UVKind
  19247. * - VertexBuffer.UV2Kind
  19248. * - VertexBuffer.UV3Kind
  19249. * - VertexBuffer.UV4Kind
  19250. * - VertexBuffer.UV5Kind
  19251. * - VertexBuffer.UV6Kind
  19252. * - VertexBuffer.ColorKind
  19253. * - VertexBuffer.MatricesIndicesKind
  19254. * - VertexBuffer.MatricesIndicesExtraKind
  19255. * - VertexBuffer.MatricesWeightsKind
  19256. * - VertexBuffer.MatricesWeightsExtraKind
  19257. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  19258. */
  19259. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19260. /**
  19261. * Tests if a specific vertex buffer is associated with this mesh
  19262. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19263. * - VertexBuffer.PositionKind
  19264. * - VertexBuffer.UVKind
  19265. * - VertexBuffer.UV2Kind
  19266. * - VertexBuffer.UV3Kind
  19267. * - VertexBuffer.UV4Kind
  19268. * - VertexBuffer.UV5Kind
  19269. * - VertexBuffer.UV6Kind
  19270. * - VertexBuffer.ColorKind
  19271. * - VertexBuffer.MatricesIndicesKind
  19272. * - VertexBuffer.MatricesIndicesExtraKind
  19273. * - VertexBuffer.MatricesWeightsKind
  19274. * - VertexBuffer.MatricesWeightsExtraKind
  19275. * @returns a boolean
  19276. */
  19277. isVerticesDataPresent(kind: string): boolean;
  19278. /**
  19279. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  19280. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19281. * - VertexBuffer.PositionKind
  19282. * - VertexBuffer.UVKind
  19283. * - VertexBuffer.UV2Kind
  19284. * - VertexBuffer.UV3Kind
  19285. * - VertexBuffer.UV4Kind
  19286. * - VertexBuffer.UV5Kind
  19287. * - VertexBuffer.UV6Kind
  19288. * - VertexBuffer.ColorKind
  19289. * - VertexBuffer.MatricesIndicesKind
  19290. * - VertexBuffer.MatricesIndicesExtraKind
  19291. * - VertexBuffer.MatricesWeightsKind
  19292. * - VertexBuffer.MatricesWeightsExtraKind
  19293. * @returns a boolean
  19294. */
  19295. isVertexBufferUpdatable(kind: string): boolean;
  19296. /**
  19297. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  19298. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19299. * - VertexBuffer.PositionKind
  19300. * - VertexBuffer.UVKind
  19301. * - VertexBuffer.UV2Kind
  19302. * - VertexBuffer.UV3Kind
  19303. * - VertexBuffer.UV4Kind
  19304. * - VertexBuffer.UV5Kind
  19305. * - VertexBuffer.UV6Kind
  19306. * - VertexBuffer.ColorKind
  19307. * - VertexBuffer.MatricesIndicesKind
  19308. * - VertexBuffer.MatricesIndicesExtraKind
  19309. * - VertexBuffer.MatricesWeightsKind
  19310. * - VertexBuffer.MatricesWeightsExtraKind
  19311. * @returns an array of strings
  19312. */
  19313. getVerticesDataKinds(): string[];
  19314. /**
  19315. * Returns a positive integer : the total number of indices in this mesh geometry.
  19316. * @returns the numner of indices or zero if the mesh has no geometry.
  19317. */
  19318. getTotalIndices(): number;
  19319. /**
  19320. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19321. * @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.
  19322. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  19323. * @returns the indices array or an empty array if the mesh has no geometry
  19324. */
  19325. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  19326. readonly isBlocked: boolean;
  19327. /**
  19328. * Determine if the current mesh is ready to be rendered
  19329. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19330. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  19331. * @returns true if all associated assets are ready (material, textures, shaders)
  19332. */
  19333. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  19334. /**
  19335. * 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.
  19336. */
  19337. readonly areNormalsFrozen: boolean;
  19338. /**
  19339. * 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.
  19340. * @returns the current mesh
  19341. */
  19342. freezeNormals(): Mesh;
  19343. /**
  19344. * 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
  19345. * @returns the current mesh
  19346. */
  19347. unfreezeNormals(): Mesh;
  19348. /**
  19349. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  19350. */
  19351. overridenInstanceCount: number;
  19352. /** @hidden */
  19353. _preActivate(): Mesh;
  19354. /** @hidden */
  19355. _preActivateForIntermediateRendering(renderId: number): Mesh;
  19356. /** @hidden */
  19357. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  19358. /**
  19359. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19360. * This means the mesh underlying bounding box and sphere are recomputed.
  19361. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19362. * @returns the current mesh
  19363. */
  19364. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  19365. /** @hidden */
  19366. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  19367. /**
  19368. * This function will subdivide the mesh into multiple submeshes
  19369. * @param count defines the expected number of submeshes
  19370. */
  19371. subdivide(count: number): void;
  19372. /**
  19373. * Copy a FloatArray into a specific associated vertex buffer
  19374. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19375. * - VertexBuffer.PositionKind
  19376. * - VertexBuffer.UVKind
  19377. * - VertexBuffer.UV2Kind
  19378. * - VertexBuffer.UV3Kind
  19379. * - VertexBuffer.UV4Kind
  19380. * - VertexBuffer.UV5Kind
  19381. * - VertexBuffer.UV6Kind
  19382. * - VertexBuffer.ColorKind
  19383. * - VertexBuffer.MatricesIndicesKind
  19384. * - VertexBuffer.MatricesIndicesExtraKind
  19385. * - VertexBuffer.MatricesWeightsKind
  19386. * - VertexBuffer.MatricesWeightsExtraKind
  19387. * @param data defines the data source
  19388. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  19389. * @param stride defines the data stride size (can be null)
  19390. * @returns the current mesh
  19391. */
  19392. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19393. /**
  19394. * Flags an associated vertex buffer as updatable
  19395. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  19396. * - VertexBuffer.PositionKind
  19397. * - VertexBuffer.UVKind
  19398. * - VertexBuffer.UV2Kind
  19399. * - VertexBuffer.UV3Kind
  19400. * - VertexBuffer.UV4Kind
  19401. * - VertexBuffer.UV5Kind
  19402. * - VertexBuffer.UV6Kind
  19403. * - VertexBuffer.ColorKind
  19404. * - VertexBuffer.MatricesIndicesKind
  19405. * - VertexBuffer.MatricesIndicesExtraKind
  19406. * - VertexBuffer.MatricesWeightsKind
  19407. * - VertexBuffer.MatricesWeightsExtraKind
  19408. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  19409. */
  19410. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  19411. /**
  19412. * Sets the mesh global Vertex Buffer
  19413. * @param buffer defines the buffer to use
  19414. * @returns the current mesh
  19415. */
  19416. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  19417. /**
  19418. * Update a specific associated vertex buffer
  19419. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19420. * - VertexBuffer.PositionKind
  19421. * - VertexBuffer.UVKind
  19422. * - VertexBuffer.UV2Kind
  19423. * - VertexBuffer.UV3Kind
  19424. * - VertexBuffer.UV4Kind
  19425. * - VertexBuffer.UV5Kind
  19426. * - VertexBuffer.UV6Kind
  19427. * - VertexBuffer.ColorKind
  19428. * - VertexBuffer.MatricesIndicesKind
  19429. * - VertexBuffer.MatricesIndicesExtraKind
  19430. * - VertexBuffer.MatricesWeightsKind
  19431. * - VertexBuffer.MatricesWeightsExtraKind
  19432. * @param data defines the data source
  19433. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  19434. * @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)
  19435. * @returns the current mesh
  19436. */
  19437. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19438. /**
  19439. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  19440. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  19441. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  19442. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  19443. * @returns the current mesh
  19444. */
  19445. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  19446. /**
  19447. * Creates a un-shared specific occurence of the geometry for the mesh.
  19448. * @returns the current mesh
  19449. */
  19450. makeGeometryUnique(): Mesh;
  19451. /**
  19452. * Set the index buffer of this mesh
  19453. * @param indices defines the source data
  19454. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  19455. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  19456. * @returns the current mesh
  19457. */
  19458. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  19459. /**
  19460. * Update the current index buffer
  19461. * @param indices defines the source data
  19462. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  19463. * @returns the current mesh
  19464. */
  19465. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  19466. /**
  19467. * Invert the geometry to move from a right handed system to a left handed one.
  19468. * @returns the current mesh
  19469. */
  19470. toLeftHanded(): Mesh;
  19471. /** @hidden */
  19472. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19473. /** @hidden */
  19474. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  19475. /**
  19476. * Registers for this mesh a javascript function called just before the rendering process
  19477. * @param func defines the function to call before rendering this mesh
  19478. * @returns the current mesh
  19479. */
  19480. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  19481. /**
  19482. * Disposes a previously registered javascript function called before the rendering
  19483. * @param func defines the function to remove
  19484. * @returns the current mesh
  19485. */
  19486. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  19487. /**
  19488. * Registers for this mesh a javascript function called just after the rendering is complete
  19489. * @param func defines the function to call after rendering this mesh
  19490. * @returns the current mesh
  19491. */
  19492. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  19493. /**
  19494. * Disposes a previously registered javascript function called after the rendering.
  19495. * @param func defines the function to remove
  19496. * @returns the current mesh
  19497. */
  19498. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  19499. /** @hidden */
  19500. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  19501. /** @hidden */
  19502. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  19503. /** @hidden */
  19504. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  19505. /**
  19506. * 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
  19507. * @param subMesh defines the subMesh to render
  19508. * @param enableAlphaMode defines if alpha mode can be changed
  19509. * @returns the current mesh
  19510. */
  19511. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  19512. private _onBeforeDraw;
  19513. /**
  19514. * Renormalize the mesh and patch it up if there are no weights
  19515. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  19516. * However in the case of zero weights then we set just a single influence to 1.
  19517. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  19518. */
  19519. cleanMatrixWeights(): void;
  19520. private normalizeSkinFourWeights;
  19521. private normalizeSkinWeightsAndExtra;
  19522. /**
  19523. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  19524. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  19525. * the user know there was an issue with importing the mesh
  19526. * @returns a validation object with skinned, valid and report string
  19527. */
  19528. validateSkinning(): {
  19529. skinned: boolean;
  19530. valid: boolean;
  19531. report: string;
  19532. };
  19533. /** @hidden */
  19534. _checkDelayState(): Mesh;
  19535. private _queueLoad;
  19536. /**
  19537. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  19538. * A mesh is in the frustum if its bounding box intersects the frustum
  19539. * @param frustumPlanes defines the frustum to test
  19540. * @returns true if the mesh is in the frustum planes
  19541. */
  19542. isInFrustum(frustumPlanes: Plane[]): boolean;
  19543. /**
  19544. * Sets the mesh material by the material or multiMaterial `id` property
  19545. * @param id is a string identifying the material or the multiMaterial
  19546. * @returns the current mesh
  19547. */
  19548. setMaterialByID(id: string): Mesh;
  19549. /**
  19550. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  19551. * @returns an array of IAnimatable
  19552. */
  19553. getAnimatables(): IAnimatable[];
  19554. /**
  19555. * Modifies the mesh geometry according to the passed transformation matrix.
  19556. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  19557. * The mesh normals are modified using the same transformation.
  19558. * Note that, under the hood, this method sets a new VertexBuffer each call.
  19559. * @param transform defines the transform matrix to use
  19560. * @see http://doc.babylonjs.com/resources/baking_transformations
  19561. * @returns the current mesh
  19562. */
  19563. bakeTransformIntoVertices(transform: Matrix): Mesh;
  19564. /**
  19565. * Modifies the mesh geometry according to its own current World Matrix.
  19566. * The mesh World Matrix is then reset.
  19567. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  19568. * Note that, under the hood, this method sets a new VertexBuffer each call.
  19569. * @see http://doc.babylonjs.com/resources/baking_transformations
  19570. * @returns the current mesh
  19571. */
  19572. bakeCurrentTransformIntoVertices(): Mesh;
  19573. /** @hidden */
  19574. readonly _positions: Nullable<Vector3[]>;
  19575. /** @hidden */
  19576. _resetPointsArrayCache(): Mesh;
  19577. /** @hidden */
  19578. _generatePointsArray(): boolean;
  19579. /**
  19580. * Returns a new Mesh object generated from the current mesh properties.
  19581. * This method must not get confused with createInstance()
  19582. * @param name is a string, the name given to the new mesh
  19583. * @param newParent can be any Node object (default `null`)
  19584. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  19585. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  19586. * @returns a new mesh
  19587. */
  19588. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  19589. /**
  19590. * Releases resources associated with this mesh.
  19591. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19592. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19593. */
  19594. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19595. /**
  19596. * Modifies the mesh geometry according to a displacement map.
  19597. * 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.
  19598. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  19599. * @param url is a string, the URL from the image file is to be downloaded.
  19600. * @param minHeight is the lower limit of the displacement.
  19601. * @param maxHeight is the upper limit of the displacement.
  19602. * @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.
  19603. * @param uvOffset is an optional vector2 used to offset UV.
  19604. * @param uvScale is an optional vector2 used to scale UV.
  19605. * @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.
  19606. * @returns the Mesh.
  19607. */
  19608. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  19609. /**
  19610. * Modifies the mesh geometry according to a displacementMap buffer.
  19611. * 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.
  19612. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  19613. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  19614. * @param heightMapWidth is the width of the buffer image.
  19615. * @param heightMapHeight is the height of the buffer image.
  19616. * @param minHeight is the lower limit of the displacement.
  19617. * @param maxHeight is the upper limit of the displacement.
  19618. * @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.
  19619. * @param uvOffset is an optional vector2 used to offset UV.
  19620. * @param uvScale is an optional vector2 used to scale UV.
  19621. * @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.
  19622. * @returns the Mesh.
  19623. */
  19624. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  19625. /**
  19626. * Modify the mesh to get a flat shading rendering.
  19627. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  19628. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  19629. * @returns current mesh
  19630. */
  19631. convertToFlatShadedMesh(): Mesh;
  19632. /**
  19633. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  19634. * In other words, more vertices, no more indices and a single bigger VBO.
  19635. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  19636. * @returns current mesh
  19637. */
  19638. convertToUnIndexedMesh(): Mesh;
  19639. /**
  19640. * Inverses facet orientations.
  19641. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  19642. * @param flipNormals will also inverts the normals
  19643. * @returns current mesh
  19644. */
  19645. flipFaces(flipNormals?: boolean): Mesh;
  19646. /** @hidden */
  19647. static _instancedMeshFactory: (name: string, mesh: Mesh) => InstancedMesh;
  19648. /**
  19649. * Creates a new InstancedMesh object from the mesh model.
  19650. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19651. * @param name defines the name of the new instance
  19652. * @returns a new InstancedMesh
  19653. */
  19654. createInstance(name: string): InstancedMesh;
  19655. /**
  19656. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  19657. * After this call, all the mesh instances have the same submeshes than the current mesh.
  19658. * @returns the current mesh
  19659. */
  19660. synchronizeInstances(): Mesh;
  19661. /**
  19662. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  19663. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  19664. * This should be used together with the simplification to avoid disappearing triangles.
  19665. * @param successCallback an optional success callback to be called after the optimization finished.
  19666. * @returns the current mesh
  19667. */
  19668. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  19669. /**
  19670. * Serialize current mesh
  19671. * @param serializationObject defines the object which will receive the serialization data
  19672. */
  19673. serialize(serializationObject: any): void;
  19674. /** @hidden */
  19675. _syncGeometryWithMorphTargetManager(): void;
  19676. /** @hidden */
  19677. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  19678. /**
  19679. * Returns a new Mesh object parsed from the source provided.
  19680. * @param parsedMesh is the source
  19681. * @param scene defines the hosting scene
  19682. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  19683. * @returns a new Mesh
  19684. */
  19685. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  19686. /**
  19687. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  19688. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  19689. * @param name defines the name of the mesh to create
  19690. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  19691. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  19692. * @param closePath creates a seam between the first and the last points of each path of the path array
  19693. * @param offset is taken in account only if the `pathArray` is containing a single path
  19694. * @param scene defines the hosting scene
  19695. * @param updatable defines if the mesh must be flagged as updatable
  19696. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19697. * @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)
  19698. * @returns a new Mesh
  19699. */
  19700. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  19701. /**
  19702. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  19703. * @param name defines the name of the mesh to create
  19704. * @param radius sets the radius size (float) of the polygon (default 0.5)
  19705. * @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
  19706. * @param scene defines the hosting scene
  19707. * @param updatable defines if the mesh must be flagged as updatable
  19708. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19709. * @returns a new Mesh
  19710. */
  19711. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  19712. /**
  19713. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  19714. * @param name defines the name of the mesh to create
  19715. * @param size sets the size (float) of each box side (default 1)
  19716. * @param scene defines the hosting scene
  19717. * @param updatable defines if the mesh must be flagged as updatable
  19718. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19719. * @returns a new Mesh
  19720. */
  19721. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  19722. /**
  19723. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  19724. * @param name defines the name of the mesh to create
  19725. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  19726. * @param diameter sets the diameter size (float) of the sphere (default 1)
  19727. * @param scene defines the hosting scene
  19728. * @param updatable defines if the mesh must be flagged as updatable
  19729. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19730. * @returns a new Mesh
  19731. */
  19732. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19733. /**
  19734. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  19735. * @param name defines the name of the mesh to create
  19736. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  19737. * @param diameterTop set the top cap diameter (floats, default 1)
  19738. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  19739. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  19740. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  19741. * @param scene defines the hosting scene
  19742. * @param updatable defines if the mesh must be flagged as updatable
  19743. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19744. * @returns a new Mesh
  19745. */
  19746. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  19747. /**
  19748. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  19749. * @param name defines the name of the mesh to create
  19750. * @param diameter sets the diameter size (float) of the torus (default 1)
  19751. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  19752. * @param tessellation sets the number of torus sides (postive integer, default 16)
  19753. * @param scene defines the hosting scene
  19754. * @param updatable defines if the mesh must be flagged as updatable
  19755. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19756. * @returns a new Mesh
  19757. */
  19758. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19759. /**
  19760. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  19761. * @param name defines the name of the mesh to create
  19762. * @param radius sets the global radius size (float) of the torus knot (default 2)
  19763. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  19764. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  19765. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  19766. * @param p the number of windings on X axis (positive integers, default 2)
  19767. * @param q the number of windings on Y axis (positive integers, default 3)
  19768. * @param scene defines the hosting scene
  19769. * @param updatable defines if the mesh must be flagged as updatable
  19770. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19771. * @returns a new Mesh
  19772. */
  19773. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19774. /**
  19775. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  19776. * @param name defines the name of the mesh to create
  19777. * @param points is an array successive Vector3
  19778. * @param scene defines the hosting scene
  19779. * @param updatable defines if the mesh must be flagged as updatable
  19780. * @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).
  19781. * @returns a new Mesh
  19782. */
  19783. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  19784. /**
  19785. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  19786. * @param name defines the name of the mesh to create
  19787. * @param points is an array successive Vector3
  19788. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  19789. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  19790. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  19791. * @param scene defines the hosting scene
  19792. * @param updatable defines if the mesh must be flagged as updatable
  19793. * @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)
  19794. * @returns a new Mesh
  19795. */
  19796. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  19797. /**
  19798. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  19799. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  19800. * 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.
  19801. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  19802. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19803. * Remember you can only change the shape positions, not their number when updating a polygon.
  19804. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  19805. * @param name defines the name of the mesh to create
  19806. * @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
  19807. * @param scene defines the hosting scene
  19808. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  19809. * @param updatable defines if the mesh must be flagged as updatable
  19810. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19811. * @returns a new Mesh
  19812. */
  19813. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  19814. /**
  19815. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  19816. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  19817. * @param name defines the name of the mesh to create
  19818. * @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
  19819. * @param depth defines the height of extrusion
  19820. * @param scene defines the hosting scene
  19821. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  19822. * @param updatable defines if the mesh must be flagged as updatable
  19823. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19824. * @returns a new Mesh
  19825. */
  19826. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  19827. /**
  19828. * Creates an extruded shape mesh.
  19829. * 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
  19830. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  19831. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  19832. * @param name defines the name of the mesh to create
  19833. * @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
  19834. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  19835. * @param scale is the value to scale the shape
  19836. * @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
  19837. * @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
  19838. * @param scene defines the hosting scene
  19839. * @param updatable defines if the mesh must be flagged as updatable
  19840. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19841. * @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)
  19842. * @returns a new Mesh
  19843. */
  19844. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  19845. /**
  19846. * Creates an custom extruded shape mesh.
  19847. * The custom extrusion is a parametric shape.
  19848. * It has no predefined shape. Its final shape will depend on the input parameters.
  19849. * Please consider using the same method from the MeshBuilder class instead
  19850. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  19851. * @param name defines the name of the mesh to create
  19852. * @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
  19853. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  19854. * @param scaleFunction is a custom Javascript function called on each path point
  19855. * @param rotationFunction is a custom Javascript function called on each path point
  19856. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  19857. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  19858. * @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
  19859. * @param scene defines the hosting scene
  19860. * @param updatable defines if the mesh must be flagged as updatable
  19861. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19862. * @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)
  19863. * @returns a new Mesh
  19864. */
  19865. 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;
  19866. /**
  19867. * Creates lathe mesh.
  19868. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  19869. * Please consider using the same method from the MeshBuilder class instead
  19870. * @param name defines the name of the mesh to create
  19871. * @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
  19872. * @param radius is the radius value of the lathe
  19873. * @param tessellation is the side number of the lathe.
  19874. * @param scene defines the hosting scene
  19875. * @param updatable defines if the mesh must be flagged as updatable
  19876. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19877. * @returns a new Mesh
  19878. */
  19879. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19880. /**
  19881. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  19882. * @param name defines the name of the mesh to create
  19883. * @param size sets the size (float) of both sides of the plane at once (default 1)
  19884. * @param scene defines the hosting scene
  19885. * @param updatable defines if the mesh must be flagged as updatable
  19886. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19887. * @returns a new Mesh
  19888. */
  19889. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19890. /**
  19891. * Creates a ground mesh.
  19892. * Please consider using the same method from the MeshBuilder class instead
  19893. * @param name defines the name of the mesh to create
  19894. * @param width set the width of the ground
  19895. * @param height set the height of the ground
  19896. * @param subdivisions sets the number of subdivisions per side
  19897. * @param scene defines the hosting scene
  19898. * @param updatable defines if the mesh must be flagged as updatable
  19899. * @returns a new Mesh
  19900. */
  19901. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  19902. /**
  19903. * Creates a tiled ground mesh.
  19904. * Please consider using the same method from the MeshBuilder class instead
  19905. * @param name defines the name of the mesh to create
  19906. * @param xmin set the ground minimum X coordinate
  19907. * @param zmin set the ground minimum Y coordinate
  19908. * @param xmax set the ground maximum X coordinate
  19909. * @param zmax set the ground maximum Z coordinate
  19910. * @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
  19911. * @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
  19912. * @param scene defines the hosting scene
  19913. * @param updatable defines if the mesh must be flagged as updatable
  19914. * @returns a new Mesh
  19915. */
  19916. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  19917. w: number;
  19918. h: number;
  19919. }, precision: {
  19920. w: number;
  19921. h: number;
  19922. }, scene: Scene, updatable?: boolean): Mesh;
  19923. /**
  19924. * Creates a ground mesh from a height map.
  19925. * Please consider using the same method from the MeshBuilder class instead
  19926. * @see http://doc.babylonjs.com/babylon101/height_map
  19927. * @param name defines the name of the mesh to create
  19928. * @param url sets the URL of the height map image resource
  19929. * @param width set the ground width size
  19930. * @param height set the ground height size
  19931. * @param subdivisions sets the number of subdivision per side
  19932. * @param minHeight is the minimum altitude on the ground
  19933. * @param maxHeight is the maximum altitude on the ground
  19934. * @param scene defines the hosting scene
  19935. * @param updatable defines if the mesh must be flagged as updatable
  19936. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  19937. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  19938. * @returns a new Mesh
  19939. */
  19940. 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;
  19941. /**
  19942. * Creates a tube mesh.
  19943. * The tube is a parametric shape.
  19944. * It has no predefined shape. Its final shape will depend on the input parameters.
  19945. * Please consider using the same method from the MeshBuilder class instead
  19946. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  19947. * @param name defines the name of the mesh to create
  19948. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  19949. * @param radius sets the tube radius size
  19950. * @param tessellation is the number of sides on the tubular surface
  19951. * @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
  19952. * @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
  19953. * @param scene defines the hosting scene
  19954. * @param updatable defines if the mesh must be flagged as updatable
  19955. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19956. * @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)
  19957. * @returns a new Mesh
  19958. */
  19959. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  19960. (i: number, distance: number): number;
  19961. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  19962. /**
  19963. * Creates a polyhedron mesh.
  19964. * Please consider using the same method from the MeshBuilder class instead.
  19965. * * 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
  19966. * * The parameter `size` (positive float, default 1) sets the polygon size
  19967. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  19968. * * 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`
  19969. * * 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
  19970. * * 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)`)
  19971. * * 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
  19972. * * 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
  19973. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  19974. * * 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
  19975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19976. * @param name defines the name of the mesh to create
  19977. * @param options defines the options used to create the mesh
  19978. * @param scene defines the hosting scene
  19979. * @returns a new Mesh
  19980. */
  19981. static CreatePolyhedron(name: string, options: {
  19982. type?: number;
  19983. size?: number;
  19984. sizeX?: number;
  19985. sizeY?: number;
  19986. sizeZ?: number;
  19987. custom?: any;
  19988. faceUV?: Vector4[];
  19989. faceColors?: Color4[];
  19990. updatable?: boolean;
  19991. sideOrientation?: number;
  19992. }, scene: Scene): Mesh;
  19993. /**
  19994. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  19995. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  19996. * * 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`)
  19997. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  19998. * * 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
  19999. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20000. * * 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
  20001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20002. * @param name defines the name of the mesh
  20003. * @param options defines the options used to create the mesh
  20004. * @param scene defines the hosting scene
  20005. * @returns a new Mesh
  20006. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  20007. */
  20008. static CreateIcoSphere(name: string, options: {
  20009. radius?: number;
  20010. flat?: boolean;
  20011. subdivisions?: number;
  20012. sideOrientation?: number;
  20013. updatable?: boolean;
  20014. }, scene: Scene): Mesh;
  20015. /**
  20016. * Creates a decal mesh.
  20017. * Please consider using the same method from the MeshBuilder class instead.
  20018. * A decal is a mesh usually applied as a model onto the surface of another mesh
  20019. * @param name defines the name of the mesh
  20020. * @param sourceMesh defines the mesh receiving the decal
  20021. * @param position sets the position of the decal in world coordinates
  20022. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  20023. * @param size sets the decal scaling
  20024. * @param angle sets the angle to rotate the decal
  20025. * @returns a new Mesh
  20026. */
  20027. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  20028. /**
  20029. * Prepare internal position array for software CPU skinning
  20030. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  20031. */
  20032. setPositionsForCPUSkinning(): Float32Array;
  20033. /**
  20034. * Prepare internal normal array for software CPU skinning
  20035. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  20036. */
  20037. setNormalsForCPUSkinning(): Float32Array;
  20038. /**
  20039. * Updates the vertex buffer by applying transformation from the bones
  20040. * @param skeleton defines the skeleton to apply to current mesh
  20041. * @returns the current mesh
  20042. */
  20043. applySkeleton(skeleton: Skeleton): Mesh;
  20044. /**
  20045. * 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
  20046. * @param meshes defines the list of meshes to scan
  20047. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  20048. */
  20049. static MinMax(meshes: AbstractMesh[]): {
  20050. min: Vector3;
  20051. max: Vector3;
  20052. };
  20053. /**
  20054. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  20055. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  20056. * @returns a vector3
  20057. */
  20058. static Center(meshesOrMinMaxVector: {
  20059. min: Vector3;
  20060. max: Vector3;
  20061. } | AbstractMesh[]): Vector3;
  20062. /**
  20063. * Merge the array of meshes into a single mesh for performance reasons.
  20064. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  20065. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  20066. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  20067. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  20068. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  20069. * @returns a new mesh
  20070. */
  20071. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  20072. /** @hidden */
  20073. addInstance(instance: InstancedMesh): void;
  20074. /** @hidden */
  20075. removeInstance(instance: InstancedMesh): void;
  20076. }
  20077. }
  20078. declare module BABYLON {
  20079. /**
  20080. * The action to be carried out following a trigger
  20081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  20082. */
  20083. export class Action {
  20084. /** the trigger, with or without parameters, for the action */
  20085. triggerOptions: any;
  20086. /**
  20087. * Trigger for the action
  20088. */
  20089. trigger: number;
  20090. /**
  20091. * Internal only - manager for action
  20092. * @hidden
  20093. */
  20094. _actionManager: ActionManager;
  20095. private _nextActiveAction;
  20096. private _child;
  20097. private _condition?;
  20098. private _triggerParameter;
  20099. /**
  20100. * An event triggered prior to action being executed.
  20101. */
  20102. onBeforeExecuteObservable: Observable<Action>;
  20103. /**
  20104. * Creates a new Action
  20105. * @param triggerOptions the trigger, with or without parameters, for the action
  20106. * @param condition an optional determinant of action
  20107. */
  20108. constructor(
  20109. /** the trigger, with or without parameters, for the action */
  20110. triggerOptions: any, condition?: Condition);
  20111. /**
  20112. * Internal only
  20113. * @hidden
  20114. */
  20115. _prepare(): void;
  20116. /**
  20117. * Gets the trigger parameters
  20118. * @returns the trigger parameters
  20119. */
  20120. getTriggerParameter(): any;
  20121. /**
  20122. * Internal only - executes current action event
  20123. * @hidden
  20124. */
  20125. _executeCurrent(evt?: ActionEvent): void;
  20126. /**
  20127. * Execute placeholder for child classes
  20128. * @param evt optional action event
  20129. */
  20130. execute(evt?: ActionEvent): void;
  20131. /**
  20132. * Skips to next active action
  20133. */
  20134. skipToNextActiveAction(): void;
  20135. /**
  20136. * Adds action to chain of actions, may be a DoNothingAction
  20137. * @param action defines the next action to execute
  20138. * @returns The action passed in
  20139. * @see https://www.babylonjs-playground.com/#1T30HR#0
  20140. */
  20141. then(action: Action): Action;
  20142. /**
  20143. * Internal only
  20144. * @hidden
  20145. */
  20146. _getProperty(propertyPath: string): string;
  20147. /**
  20148. * Internal only
  20149. * @hidden
  20150. */
  20151. _getEffectiveTarget(target: any, propertyPath: string): any;
  20152. /**
  20153. * Serialize placeholder for child classes
  20154. * @param parent of child
  20155. * @returns the serialized object
  20156. */
  20157. serialize(parent: any): any;
  20158. /**
  20159. * Internal only called by serialize
  20160. * @hidden
  20161. */
  20162. protected _serialize(serializedAction: any, parent?: any): any;
  20163. /**
  20164. * Internal only
  20165. * @hidden
  20166. */
  20167. static _SerializeValueAsString: (value: any) => string;
  20168. /**
  20169. * Internal only
  20170. * @hidden
  20171. */
  20172. static _GetTargetProperty: (target: Scene | Node) => {
  20173. name: string;
  20174. targetType: string;
  20175. value: string;
  20176. };
  20177. }
  20178. }
  20179. declare module BABYLON {
  20180. /**
  20181. * A Condition applied to an Action
  20182. */
  20183. export class Condition {
  20184. /**
  20185. * Internal only - manager for action
  20186. * @hidden
  20187. */
  20188. _actionManager: ActionManager;
  20189. /**
  20190. * Internal only
  20191. * @hidden
  20192. */
  20193. _evaluationId: number;
  20194. /**
  20195. * Internal only
  20196. * @hidden
  20197. */
  20198. _currentResult: boolean;
  20199. /**
  20200. * Creates a new Condition
  20201. * @param actionManager the manager of the action the condition is applied to
  20202. */
  20203. constructor(actionManager: ActionManager);
  20204. /**
  20205. * Check if the current condition is valid
  20206. * @returns a boolean
  20207. */
  20208. isValid(): boolean;
  20209. /**
  20210. * Internal only
  20211. * @hidden
  20212. */
  20213. _getProperty(propertyPath: string): string;
  20214. /**
  20215. * Internal only
  20216. * @hidden
  20217. */
  20218. _getEffectiveTarget(target: any, propertyPath: string): any;
  20219. /**
  20220. * Serialize placeholder for child classes
  20221. * @returns the serialized object
  20222. */
  20223. serialize(): any;
  20224. /**
  20225. * Internal only
  20226. * @hidden
  20227. */
  20228. protected _serialize(serializedCondition: any): any;
  20229. }
  20230. /**
  20231. * Defines specific conditional operators as extensions of Condition
  20232. */
  20233. export class ValueCondition extends Condition {
  20234. /** path to specify the property of the target the conditional operator uses */
  20235. propertyPath: string;
  20236. /** the value compared by the conditional operator against the current value of the property */
  20237. value: any;
  20238. /** the conditional operator, default ValueCondition.IsEqual */
  20239. operator: number;
  20240. /**
  20241. * Internal only
  20242. * @hidden
  20243. */
  20244. private static _IsEqual;
  20245. /**
  20246. * Internal only
  20247. * @hidden
  20248. */
  20249. private static _IsDifferent;
  20250. /**
  20251. * Internal only
  20252. * @hidden
  20253. */
  20254. private static _IsGreater;
  20255. /**
  20256. * Internal only
  20257. * @hidden
  20258. */
  20259. private static _IsLesser;
  20260. /**
  20261. * returns the number for IsEqual
  20262. */
  20263. static readonly IsEqual: number;
  20264. /**
  20265. * Returns the number for IsDifferent
  20266. */
  20267. static readonly IsDifferent: number;
  20268. /**
  20269. * Returns the number for IsGreater
  20270. */
  20271. static readonly IsGreater: number;
  20272. /**
  20273. * Returns the number for IsLesser
  20274. */
  20275. static readonly IsLesser: number;
  20276. /**
  20277. * Internal only The action manager for the condition
  20278. * @hidden
  20279. */
  20280. _actionManager: ActionManager;
  20281. /**
  20282. * Internal only
  20283. * @hidden
  20284. */
  20285. private _target;
  20286. /**
  20287. * Internal only
  20288. * @hidden
  20289. */
  20290. private _effectiveTarget;
  20291. /**
  20292. * Internal only
  20293. * @hidden
  20294. */
  20295. private _property;
  20296. /**
  20297. * Creates a new ValueCondition
  20298. * @param actionManager manager for the action the condition applies to
  20299. * @param target for the action
  20300. * @param propertyPath path to specify the property of the target the conditional operator uses
  20301. * @param value the value compared by the conditional operator against the current value of the property
  20302. * @param operator the conditional operator, default ValueCondition.IsEqual
  20303. */
  20304. constructor(actionManager: ActionManager, target: any,
  20305. /** path to specify the property of the target the conditional operator uses */
  20306. propertyPath: string,
  20307. /** the value compared by the conditional operator against the current value of the property */
  20308. value: any,
  20309. /** the conditional operator, default ValueCondition.IsEqual */
  20310. operator?: number);
  20311. /**
  20312. * Compares the given value with the property value for the specified conditional operator
  20313. * @returns the result of the comparison
  20314. */
  20315. isValid(): boolean;
  20316. /**
  20317. * Serialize the ValueCondition into a JSON compatible object
  20318. * @returns serialization object
  20319. */
  20320. serialize(): any;
  20321. /**
  20322. * Gets the name of the conditional operator for the ValueCondition
  20323. * @param operator the conditional operator
  20324. * @returns the name
  20325. */
  20326. static GetOperatorName(operator: number): string;
  20327. }
  20328. /**
  20329. * Defines a predicate condition as an extension of Condition
  20330. */
  20331. export class PredicateCondition extends Condition {
  20332. /** defines the predicate function used to validate the condition */
  20333. predicate: () => boolean;
  20334. /**
  20335. * Internal only - manager for action
  20336. * @hidden
  20337. */
  20338. _actionManager: ActionManager;
  20339. /**
  20340. * Creates a new PredicateCondition
  20341. * @param actionManager manager for the action the condition applies to
  20342. * @param predicate defines the predicate function used to validate the condition
  20343. */
  20344. constructor(actionManager: ActionManager,
  20345. /** defines the predicate function used to validate the condition */
  20346. predicate: () => boolean);
  20347. /**
  20348. * @returns the validity of the predicate condition
  20349. */
  20350. isValid(): boolean;
  20351. }
  20352. /**
  20353. * Defines a state condition as an extension of Condition
  20354. */
  20355. export class StateCondition extends Condition {
  20356. /** Value to compare with target state */
  20357. value: string;
  20358. /**
  20359. * Internal only - manager for action
  20360. * @hidden
  20361. */
  20362. _actionManager: ActionManager;
  20363. /**
  20364. * Internal only
  20365. * @hidden
  20366. */
  20367. private _target;
  20368. /**
  20369. * Creates a new StateCondition
  20370. * @param actionManager manager for the action the condition applies to
  20371. * @param target of the condition
  20372. * @param value to compare with target state
  20373. */
  20374. constructor(actionManager: ActionManager, target: any,
  20375. /** Value to compare with target state */
  20376. value: string);
  20377. /**
  20378. * Gets a boolean indicating if the current condition is met
  20379. * @returns the validity of the state
  20380. */
  20381. isValid(): boolean;
  20382. /**
  20383. * Serialize the StateCondition into a JSON compatible object
  20384. * @returns serialization object
  20385. */
  20386. serialize(): any;
  20387. }
  20388. }
  20389. declare module BABYLON {
  20390. /**
  20391. * This defines an action responsible to toggle a boolean once triggered.
  20392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20393. */
  20394. export class SwitchBooleanAction extends Action {
  20395. /**
  20396. * The path to the boolean property in the target object
  20397. */
  20398. propertyPath: string;
  20399. private _target;
  20400. private _effectiveTarget;
  20401. private _property;
  20402. /**
  20403. * Instantiate the action
  20404. * @param triggerOptions defines the trigger options
  20405. * @param target defines the object containing the boolean
  20406. * @param propertyPath defines the path to the boolean property in the target object
  20407. * @param condition defines the trigger related conditions
  20408. */
  20409. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  20410. /** @hidden */
  20411. _prepare(): void;
  20412. /**
  20413. * Execute the action toggle the boolean value.
  20414. */
  20415. execute(): void;
  20416. /**
  20417. * Serializes the actions and its related information.
  20418. * @param parent defines the object to serialize in
  20419. * @returns the serialized object
  20420. */
  20421. serialize(parent: any): any;
  20422. }
  20423. /**
  20424. * This defines an action responsible to set a the state field of the target
  20425. * to a desired value once triggered.
  20426. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20427. */
  20428. export class SetStateAction extends Action {
  20429. /**
  20430. * The value to store in the state field.
  20431. */
  20432. value: string;
  20433. private _target;
  20434. /**
  20435. * Instantiate the action
  20436. * @param triggerOptions defines the trigger options
  20437. * @param target defines the object containing the state property
  20438. * @param value defines the value to store in the state field
  20439. * @param condition defines the trigger related conditions
  20440. */
  20441. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  20442. /**
  20443. * Execute the action and store the value on the target state property.
  20444. */
  20445. execute(): void;
  20446. /**
  20447. * Serializes the actions and its related information.
  20448. * @param parent defines the object to serialize in
  20449. * @returns the serialized object
  20450. */
  20451. serialize(parent: any): any;
  20452. }
  20453. /**
  20454. * This defines an action responsible to set a property of the target
  20455. * to a desired value once triggered.
  20456. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20457. */
  20458. export class SetValueAction extends Action {
  20459. /**
  20460. * The path of the property to set in the target.
  20461. */
  20462. propertyPath: string;
  20463. /**
  20464. * The value to set in the property
  20465. */
  20466. value: any;
  20467. private _target;
  20468. private _effectiveTarget;
  20469. private _property;
  20470. /**
  20471. * Instantiate the action
  20472. * @param triggerOptions defines the trigger options
  20473. * @param target defines the object containing the property
  20474. * @param propertyPath defines the path of the property to set in the target
  20475. * @param value defines the value to set in the property
  20476. * @param condition defines the trigger related conditions
  20477. */
  20478. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  20479. /** @hidden */
  20480. _prepare(): void;
  20481. /**
  20482. * Execute the action and set the targetted property to the desired value.
  20483. */
  20484. execute(): void;
  20485. /**
  20486. * Serializes the actions and its related information.
  20487. * @param parent defines the object to serialize in
  20488. * @returns the serialized object
  20489. */
  20490. serialize(parent: any): any;
  20491. }
  20492. /**
  20493. * This defines an action responsible to increment the target value
  20494. * to a desired value once triggered.
  20495. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20496. */
  20497. export class IncrementValueAction extends Action {
  20498. /**
  20499. * The path of the property to increment in the target.
  20500. */
  20501. propertyPath: string;
  20502. /**
  20503. * The value we should increment the property by.
  20504. */
  20505. value: any;
  20506. private _target;
  20507. private _effectiveTarget;
  20508. private _property;
  20509. /**
  20510. * Instantiate the action
  20511. * @param triggerOptions defines the trigger options
  20512. * @param target defines the object containing the property
  20513. * @param propertyPath defines the path of the property to increment in the target
  20514. * @param value defines the value value we should increment the property by
  20515. * @param condition defines the trigger related conditions
  20516. */
  20517. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  20518. /** @hidden */
  20519. _prepare(): void;
  20520. /**
  20521. * Execute the action and increment the target of the value amount.
  20522. */
  20523. execute(): void;
  20524. /**
  20525. * Serializes the actions and its related information.
  20526. * @param parent defines the object to serialize in
  20527. * @returns the serialized object
  20528. */
  20529. serialize(parent: any): any;
  20530. }
  20531. /**
  20532. * This defines an action responsible to start an animation once triggered.
  20533. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20534. */
  20535. export class PlayAnimationAction extends Action {
  20536. /**
  20537. * Where the animation should start (animation frame)
  20538. */
  20539. from: number;
  20540. /**
  20541. * Where the animation should stop (animation frame)
  20542. */
  20543. to: number;
  20544. /**
  20545. * Define if the animation should loop or stop after the first play.
  20546. */
  20547. loop?: boolean;
  20548. private _target;
  20549. /**
  20550. * Instantiate the action
  20551. * @param triggerOptions defines the trigger options
  20552. * @param target defines the target animation or animation name
  20553. * @param from defines from where the animation should start (animation frame)
  20554. * @param end defines where the animation should stop (animation frame)
  20555. * @param loop defines if the animation should loop or stop after the first play
  20556. * @param condition defines the trigger related conditions
  20557. */
  20558. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  20559. /** @hidden */
  20560. _prepare(): void;
  20561. /**
  20562. * Execute the action and play the animation.
  20563. */
  20564. execute(): void;
  20565. /**
  20566. * Serializes the actions and its related information.
  20567. * @param parent defines the object to serialize in
  20568. * @returns the serialized object
  20569. */
  20570. serialize(parent: any): any;
  20571. }
  20572. /**
  20573. * This defines an action responsible to stop an animation once triggered.
  20574. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20575. */
  20576. export class StopAnimationAction extends Action {
  20577. private _target;
  20578. /**
  20579. * Instantiate the action
  20580. * @param triggerOptions defines the trigger options
  20581. * @param target defines the target animation or animation name
  20582. * @param condition defines the trigger related conditions
  20583. */
  20584. constructor(triggerOptions: any, target: any, condition?: Condition);
  20585. /** @hidden */
  20586. _prepare(): void;
  20587. /**
  20588. * Execute the action and stop the animation.
  20589. */
  20590. execute(): void;
  20591. /**
  20592. * Serializes the actions and its related information.
  20593. * @param parent defines the object to serialize in
  20594. * @returns the serialized object
  20595. */
  20596. serialize(parent: any): any;
  20597. }
  20598. /**
  20599. * This defines an action responsible that does nothing once triggered.
  20600. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20601. */
  20602. export class DoNothingAction extends Action {
  20603. /**
  20604. * Instantiate the action
  20605. * @param triggerOptions defines the trigger options
  20606. * @param condition defines the trigger related conditions
  20607. */
  20608. constructor(triggerOptions?: any, condition?: Condition);
  20609. /**
  20610. * Execute the action and do nothing.
  20611. */
  20612. execute(): void;
  20613. /**
  20614. * Serializes the actions and its related information.
  20615. * @param parent defines the object to serialize in
  20616. * @returns the serialized object
  20617. */
  20618. serialize(parent: any): any;
  20619. }
  20620. /**
  20621. * This defines an action responsible to trigger several actions once triggered.
  20622. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20623. */
  20624. export class CombineAction extends Action {
  20625. /**
  20626. * The list of aggregated animations to run.
  20627. */
  20628. children: Action[];
  20629. /**
  20630. * Instantiate the action
  20631. * @param triggerOptions defines the trigger options
  20632. * @param children defines the list of aggregated animations to run
  20633. * @param condition defines the trigger related conditions
  20634. */
  20635. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  20636. /** @hidden */
  20637. _prepare(): void;
  20638. /**
  20639. * Execute the action and executes all the aggregated actions.
  20640. */
  20641. execute(evt: ActionEvent): void;
  20642. /**
  20643. * Serializes the actions and its related information.
  20644. * @param parent defines the object to serialize in
  20645. * @returns the serialized object
  20646. */
  20647. serialize(parent: any): any;
  20648. }
  20649. /**
  20650. * This defines an action responsible to run code (external event) once triggered.
  20651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20652. */
  20653. export class ExecuteCodeAction extends Action {
  20654. /**
  20655. * The callback function to run.
  20656. */
  20657. func: (evt: ActionEvent) => void;
  20658. /**
  20659. * Instantiate the action
  20660. * @param triggerOptions defines the trigger options
  20661. * @param func defines the callback function to run
  20662. * @param condition defines the trigger related conditions
  20663. */
  20664. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  20665. /**
  20666. * Execute the action and run the attached code.
  20667. */
  20668. execute(evt: ActionEvent): void;
  20669. }
  20670. /**
  20671. * This defines an action responsible to set the parent property of the target once triggered.
  20672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20673. */
  20674. export class SetParentAction extends Action {
  20675. private _parent;
  20676. private _target;
  20677. /**
  20678. * Instantiate the action
  20679. * @param triggerOptions defines the trigger options
  20680. * @param target defines the target containing the parent property
  20681. * @param parent defines from where the animation should start (animation frame)
  20682. * @param condition defines the trigger related conditions
  20683. */
  20684. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  20685. /** @hidden */
  20686. _prepare(): void;
  20687. /**
  20688. * Execute the action and set the parent property.
  20689. */
  20690. execute(): void;
  20691. /**
  20692. * Serializes the actions and its related information.
  20693. * @param parent defines the object to serialize in
  20694. * @returns the serialized object
  20695. */
  20696. serialize(parent: any): any;
  20697. }
  20698. }
  20699. declare module BABYLON {
  20700. /**
  20701. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  20702. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  20703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20704. */
  20705. export class ActionManager {
  20706. /**
  20707. * Nothing
  20708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20709. */
  20710. static readonly NothingTrigger: number;
  20711. /**
  20712. * On pick
  20713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20714. */
  20715. static readonly OnPickTrigger: number;
  20716. /**
  20717. * On left pick
  20718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20719. */
  20720. static readonly OnLeftPickTrigger: number;
  20721. /**
  20722. * On right pick
  20723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20724. */
  20725. static readonly OnRightPickTrigger: number;
  20726. /**
  20727. * On center pick
  20728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20729. */
  20730. static readonly OnCenterPickTrigger: number;
  20731. /**
  20732. * On pick down
  20733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20734. */
  20735. static readonly OnPickDownTrigger: number;
  20736. /**
  20737. * On double pick
  20738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20739. */
  20740. static readonly OnDoublePickTrigger: number;
  20741. /**
  20742. * On pick up
  20743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20744. */
  20745. static readonly OnPickUpTrigger: number;
  20746. /**
  20747. * On pick out.
  20748. * This trigger will only be raised if you also declared a OnPickDown
  20749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20750. */
  20751. static readonly OnPickOutTrigger: number;
  20752. /**
  20753. * On long press
  20754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20755. */
  20756. static readonly OnLongPressTrigger: number;
  20757. /**
  20758. * On pointer over
  20759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20760. */
  20761. static readonly OnPointerOverTrigger: number;
  20762. /**
  20763. * On pointer out
  20764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20765. */
  20766. static readonly OnPointerOutTrigger: number;
  20767. /**
  20768. * On every frame
  20769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20770. */
  20771. static readonly OnEveryFrameTrigger: number;
  20772. /**
  20773. * On intersection enter
  20774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20775. */
  20776. static readonly OnIntersectionEnterTrigger: number;
  20777. /**
  20778. * On intersection exit
  20779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20780. */
  20781. static readonly OnIntersectionExitTrigger: number;
  20782. /**
  20783. * On key down
  20784. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20785. */
  20786. static readonly OnKeyDownTrigger: number;
  20787. /**
  20788. * On key up
  20789. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20790. */
  20791. static readonly OnKeyUpTrigger: number;
  20792. /** Gets the list of active triggers */
  20793. static Triggers: {
  20794. [key: string]: number;
  20795. };
  20796. /** Gets the list of actions */
  20797. actions: Action[];
  20798. /** Gets the cursor to use when hovering items */
  20799. hoverCursor: string;
  20800. private _scene;
  20801. /**
  20802. * Creates a new action manager
  20803. * @param scene defines the hosting scene
  20804. */
  20805. constructor(scene: Scene);
  20806. /**
  20807. * Releases all associated resources
  20808. */
  20809. dispose(): void;
  20810. /**
  20811. * Gets hosting scene
  20812. * @returns the hosting scene
  20813. */
  20814. getScene(): Scene;
  20815. /**
  20816. * Does this action manager handles actions of any of the given triggers
  20817. * @param triggers defines the triggers to be tested
  20818. * @return a boolean indicating whether one (or more) of the triggers is handled
  20819. */
  20820. hasSpecificTriggers(triggers: number[]): boolean;
  20821. /**
  20822. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  20823. * speed.
  20824. * @param triggerA defines the trigger to be tested
  20825. * @param triggerB defines the trigger to be tested
  20826. * @return a boolean indicating whether one (or more) of the triggers is handled
  20827. */
  20828. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  20829. /**
  20830. * Does this action manager handles actions of a given trigger
  20831. * @param trigger defines the trigger to be tested
  20832. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  20833. * @return whether the trigger is handled
  20834. */
  20835. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  20836. /**
  20837. * Does this action manager has pointer triggers
  20838. */
  20839. readonly hasPointerTriggers: boolean;
  20840. /**
  20841. * Does this action manager has pick triggers
  20842. */
  20843. readonly hasPickTriggers: boolean;
  20844. /**
  20845. * Does exist one action manager with at least one trigger
  20846. **/
  20847. static readonly HasTriggers: boolean;
  20848. /**
  20849. * Does exist one action manager with at least one pick trigger
  20850. **/
  20851. static readonly HasPickTriggers: boolean;
  20852. /**
  20853. * Does exist one action manager that handles actions of a given trigger
  20854. * @param trigger defines the trigger to be tested
  20855. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  20856. **/
  20857. static HasSpecificTrigger(trigger: number): boolean;
  20858. /**
  20859. * Registers an action to this action manager
  20860. * @param action defines the action to be registered
  20861. * @return the action amended (prepared) after registration
  20862. */
  20863. registerAction(action: Action): Nullable<Action>;
  20864. /**
  20865. * Unregisters an action to this action manager
  20866. * @param action defines the action to be unregistered
  20867. * @return a boolean indicating whether the action has been unregistered
  20868. */
  20869. unregisterAction(action: Action): Boolean;
  20870. /**
  20871. * Process a specific trigger
  20872. * @param trigger defines the trigger to process
  20873. * @param evt defines the event details to be processed
  20874. */
  20875. processTrigger(trigger: number, evt?: ActionEvent): void;
  20876. /** @hidden */
  20877. _getEffectiveTarget(target: any, propertyPath: string): any;
  20878. /** @hidden */
  20879. _getProperty(propertyPath: string): string;
  20880. /**
  20881. * Serialize this manager to a JSON object
  20882. * @param name defines the property name to store this manager
  20883. * @returns a JSON representation of this manager
  20884. */
  20885. serialize(name: string): any;
  20886. /**
  20887. * Creates a new ActionManager from a JSON data
  20888. * @param parsedActions defines the JSON data to read from
  20889. * @param object defines the hosting mesh
  20890. * @param scene defines the hosting scene
  20891. */
  20892. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  20893. /**
  20894. * Get a trigger name by index
  20895. * @param trigger defines the trigger index
  20896. * @returns a trigger name
  20897. */
  20898. static GetTriggerName(trigger: number): string;
  20899. }
  20900. }
  20901. declare module BABYLON {
  20902. /**
  20903. * Class used to represent a sprite
  20904. * @see http://doc.babylonjs.com/babylon101/sprites
  20905. */
  20906. export class Sprite {
  20907. /** defines the name */
  20908. name: string;
  20909. /** Gets or sets the current world position */
  20910. position: Vector3;
  20911. /** Gets or sets the main color */
  20912. color: Color4;
  20913. /** Gets or sets the width */
  20914. width: number;
  20915. /** Gets or sets the height */
  20916. height: number;
  20917. /** Gets or sets rotation angle */
  20918. angle: number;
  20919. /** Gets or sets the cell index in the sprite sheet */
  20920. cellIndex: number;
  20921. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  20922. invertU: number;
  20923. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  20924. invertV: number;
  20925. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  20926. disposeWhenFinishedAnimating: boolean;
  20927. /** Gets the list of attached animations */
  20928. animations: Animation[];
  20929. /** Gets or sets a boolean indicating if the sprite can be picked */
  20930. isPickable: boolean;
  20931. /**
  20932. * Gets or sets the associated action manager
  20933. */
  20934. actionManager: Nullable<ActionManager>;
  20935. private _animationStarted;
  20936. private _loopAnimation;
  20937. private _fromIndex;
  20938. private _toIndex;
  20939. private _delay;
  20940. private _direction;
  20941. private _manager;
  20942. private _time;
  20943. private _onAnimationEnd;
  20944. /**
  20945. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  20946. */
  20947. isVisible: boolean;
  20948. /**
  20949. * Gets or sets the sprite size
  20950. */
  20951. size: number;
  20952. /**
  20953. * Creates a new Sprite
  20954. * @param name defines the name
  20955. * @param manager defines the manager
  20956. */
  20957. constructor(
  20958. /** defines the name */
  20959. name: string, manager: ISpriteManager);
  20960. /**
  20961. * Starts an animation
  20962. * @param from defines the initial key
  20963. * @param to defines the end key
  20964. * @param loop defines if the animation must loop
  20965. * @param delay defines the start delay (in ms)
  20966. * @param onAnimationEnd defines a callback to call when animation ends
  20967. */
  20968. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  20969. /** Stops current animation (if any) */
  20970. stopAnimation(): void;
  20971. /** @hidden */
  20972. _animate(deltaTime: number): void;
  20973. /** Release associated resources */
  20974. dispose(): void;
  20975. }
  20976. }
  20977. declare module BABYLON {
  20978. /**
  20979. * Information about the result of picking within a scene
  20980. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  20981. */
  20982. export class PickingInfo {
  20983. /**
  20984. * If the pick collided with an object
  20985. */
  20986. hit: boolean;
  20987. /**
  20988. * Distance away where the pick collided
  20989. */
  20990. distance: number;
  20991. /**
  20992. * The location of pick collision
  20993. */
  20994. pickedPoint: Nullable<Vector3>;
  20995. /**
  20996. * The mesh corresponding the the pick collision
  20997. */
  20998. pickedMesh: Nullable<AbstractMesh>;
  20999. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  21000. bu: number;
  21001. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  21002. bv: number;
  21003. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  21004. faceId: number;
  21005. /** Id of the the submesh that was picked */
  21006. subMeshId: number;
  21007. /** If a sprite was picked, this will be the sprite the pick collided with */
  21008. pickedSprite: Nullable<Sprite>;
  21009. /**
  21010. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  21011. */
  21012. originMesh: Nullable<AbstractMesh>;
  21013. /**
  21014. * The ray that was used to perform the picking.
  21015. */
  21016. ray: Nullable<Ray>;
  21017. /**
  21018. * Gets the normal correspodning to the face the pick collided with
  21019. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  21020. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  21021. * @returns The normal correspodning to the face the pick collided with
  21022. */
  21023. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  21024. /**
  21025. * Gets the texture coordinates of where the pick occured
  21026. * @returns the vector containing the coordnates of the texture
  21027. */
  21028. getTextureCoordinates(): Nullable<Vector2>;
  21029. }
  21030. }
  21031. declare module BABYLON {
  21032. /**
  21033. * Class representing a ray with position and direction
  21034. */
  21035. export class Ray {
  21036. /** origin point */
  21037. origin: Vector3;
  21038. /** direction */
  21039. direction: Vector3;
  21040. /** length of the ray */
  21041. length: number;
  21042. private static readonly TmpVector3;
  21043. private _tmpRay;
  21044. /**
  21045. * Creates a new ray
  21046. * @param origin origin point
  21047. * @param direction direction
  21048. * @param length length of the ray
  21049. */
  21050. constructor(
  21051. /** origin point */
  21052. origin: Vector3,
  21053. /** direction */
  21054. direction: Vector3,
  21055. /** length of the ray */
  21056. length?: number);
  21057. /**
  21058. * Checks if the ray intersects a box
  21059. * @param minimum bound of the box
  21060. * @param maximum bound of the box
  21061. * @param intersectionTreshold extra extend to be added to the box in all direction
  21062. * @returns if the box was hit
  21063. */
  21064. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  21065. /**
  21066. * Checks if the ray intersects a box
  21067. * @param box the bounding box to check
  21068. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  21069. * @returns if the box was hit
  21070. */
  21071. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  21072. /**
  21073. * If the ray hits a sphere
  21074. * @param sphere the bounding sphere to check
  21075. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  21076. * @returns true if it hits the sphere
  21077. */
  21078. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  21079. /**
  21080. * If the ray hits a triange
  21081. * @param vertex0 triangle vertex
  21082. * @param vertex1 triangle vertex
  21083. * @param vertex2 triangle vertex
  21084. * @returns intersection information if hit
  21085. */
  21086. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  21087. /**
  21088. * Checks if ray intersects a plane
  21089. * @param plane the plane to check
  21090. * @returns the distance away it was hit
  21091. */
  21092. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  21093. /**
  21094. * Checks if ray intersects a mesh
  21095. * @param mesh the mesh to check
  21096. * @param fastCheck if only the bounding box should checked
  21097. * @returns picking info of the intersecton
  21098. */
  21099. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  21100. /**
  21101. * Checks if ray intersects a mesh
  21102. * @param meshes the meshes to check
  21103. * @param fastCheck if only the bounding box should checked
  21104. * @param results array to store result in
  21105. * @returns Array of picking infos
  21106. */
  21107. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  21108. private _comparePickingInfo;
  21109. private static smallnum;
  21110. private static rayl;
  21111. /**
  21112. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  21113. * @param sega the first point of the segment to test the intersection against
  21114. * @param segb the second point of the segment to test the intersection against
  21115. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  21116. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  21117. */
  21118. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  21119. /**
  21120. * Update the ray from viewport position
  21121. * @param x position
  21122. * @param y y position
  21123. * @param viewportWidth viewport width
  21124. * @param viewportHeight viewport height
  21125. * @param world world matrix
  21126. * @param view view matrix
  21127. * @param projection projection matrix
  21128. * @returns this ray updated
  21129. */
  21130. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  21131. /**
  21132. * Creates a ray with origin and direction of 0,0,0
  21133. * @returns the new ray
  21134. */
  21135. static Zero(): Ray;
  21136. /**
  21137. * Creates a new ray from screen space and viewport
  21138. * @param x position
  21139. * @param y y position
  21140. * @param viewportWidth viewport width
  21141. * @param viewportHeight viewport height
  21142. * @param world world matrix
  21143. * @param view view matrix
  21144. * @param projection projection matrix
  21145. * @returns new ray
  21146. */
  21147. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  21148. /**
  21149. * 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
  21150. * transformed to the given world matrix.
  21151. * @param origin The origin point
  21152. * @param end The end point
  21153. * @param world a matrix to transform the ray to. Default is the identity matrix.
  21154. * @returns the new ray
  21155. */
  21156. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  21157. /**
  21158. * Transforms a ray by a matrix
  21159. * @param ray ray to transform
  21160. * @param matrix matrix to apply
  21161. * @returns the resulting new ray
  21162. */
  21163. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  21164. /**
  21165. * Transforms a ray by a matrix
  21166. * @param ray ray to transform
  21167. * @param matrix matrix to apply
  21168. * @param result ray to store result in
  21169. */
  21170. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  21171. /**
  21172. * Unproject a ray from screen space to object space
  21173. * @param sourceX defines the screen space x coordinate to use
  21174. * @param sourceY defines the screen space y coordinate to use
  21175. * @param viewportWidth defines the current width of the viewport
  21176. * @param viewportHeight defines the current height of the viewport
  21177. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21178. * @param view defines the view matrix to use
  21179. * @param projection defines the projection matrix to use
  21180. */
  21181. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  21182. }
  21183. }
  21184. declare module BABYLON {
  21185. /**
  21186. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21187. * separate meshes. This can be use to improve performances.
  21188. * @see http://doc.babylonjs.com/how_to/multi_materials
  21189. */
  21190. export class MultiMaterial extends Material {
  21191. private _subMaterials;
  21192. /**
  21193. * Gets or Sets the list of Materials used within the multi material.
  21194. * They need to be ordered according to the submeshes order in the associated mesh
  21195. */
  21196. subMaterials: Nullable<Material>[];
  21197. /**
  21198. * Function used to align with Node.getChildren()
  21199. * @returns the list of Materials used within the multi material
  21200. */
  21201. getChildren(): Nullable<Material>[];
  21202. /**
  21203. * Instantiates a new Multi Material
  21204. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21205. * separate meshes. This can be use to improve performances.
  21206. * @see http://doc.babylonjs.com/how_to/multi_materials
  21207. * @param name Define the name in the scene
  21208. * @param scene Define the scene the material belongs to
  21209. */
  21210. constructor(name: string, scene: Scene);
  21211. private _hookArray;
  21212. /**
  21213. * Get one of the submaterial by its index in the submaterials array
  21214. * @param index The index to look the sub material at
  21215. * @returns The Material if the index has been defined
  21216. */
  21217. getSubMaterial(index: number): Nullable<Material>;
  21218. /**
  21219. * Get the list of active textures for the whole sub materials list.
  21220. * @returns All the textures that will be used during the rendering
  21221. */
  21222. getActiveTextures(): BaseTexture[];
  21223. /**
  21224. * Gets the current class name of the material e.g. "MultiMaterial"
  21225. * Mainly use in serialization.
  21226. * @returns the class name
  21227. */
  21228. getClassName(): string;
  21229. /**
  21230. * Checks if the material is ready to render the requested sub mesh
  21231. * @param mesh Define the mesh the submesh belongs to
  21232. * @param subMesh Define the sub mesh to look readyness for
  21233. * @param useInstances Define whether or not the material is used with instances
  21234. * @returns true if ready, otherwise false
  21235. */
  21236. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21237. /**
  21238. * Clones the current material and its related sub materials
  21239. * @param name Define the name of the newly cloned material
  21240. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21241. * @returns the cloned material
  21242. */
  21243. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21244. /**
  21245. * Serializes the materials into a JSON representation.
  21246. * @returns the JSON representation
  21247. */
  21248. serialize(): any;
  21249. /**
  21250. * Dispose the material and release its associated resources
  21251. * @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)
  21252. * @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)
  21253. * @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)
  21254. */
  21255. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21256. /**
  21257. * Creates a MultiMaterial from parsed MultiMaterial data.
  21258. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21259. * @param scene defines the hosting scene
  21260. * @returns a new MultiMaterial
  21261. */
  21262. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21263. }
  21264. }
  21265. declare module BABYLON {
  21266. /**
  21267. * Base class for submeshes
  21268. */
  21269. export class BaseSubMesh {
  21270. /** @hidden */
  21271. _materialDefines: Nullable<MaterialDefines>;
  21272. /** @hidden */
  21273. _materialEffect: Nullable<Effect>;
  21274. /**
  21275. * Gets associated effect
  21276. */
  21277. readonly effect: Nullable<Effect>;
  21278. /**
  21279. * Sets associated effect (effect used to render this submesh)
  21280. * @param effect defines the effect to associate with
  21281. * @param defines defines the set of defines used to compile this effect
  21282. */
  21283. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21284. }
  21285. /**
  21286. * Defines a subdivision inside a mesh
  21287. */
  21288. export class SubMesh extends BaseSubMesh implements ICullable {
  21289. /** the material index to use */
  21290. materialIndex: number;
  21291. /** vertex index start */
  21292. verticesStart: number;
  21293. /** vertices count */
  21294. verticesCount: number;
  21295. /** index start */
  21296. indexStart: number;
  21297. /** indices count */
  21298. indexCount: number;
  21299. /** @hidden */
  21300. _linesIndexCount: number;
  21301. private _mesh;
  21302. private _renderingMesh;
  21303. private _boundingInfo;
  21304. private _linesIndexBuffer;
  21305. /** @hidden */
  21306. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21307. /** @hidden */
  21308. _trianglePlanes: Plane[];
  21309. /** @hidden */
  21310. _lastColliderTransformMatrix: Matrix;
  21311. /** @hidden */
  21312. _renderId: number;
  21313. /** @hidden */
  21314. _alphaIndex: number;
  21315. /** @hidden */
  21316. _distanceToCamera: number;
  21317. /** @hidden */
  21318. _id: number;
  21319. private _currentMaterial;
  21320. /**
  21321. * Add a new submesh to a mesh
  21322. * @param materialIndex defines the material index to use
  21323. * @param verticesStart defines vertex index start
  21324. * @param verticesCount defines vertices count
  21325. * @param indexStart defines index start
  21326. * @param indexCount defines indices count
  21327. * @param mesh defines the parent mesh
  21328. * @param renderingMesh defines an optional rendering mesh
  21329. * @param createBoundingBox defines if bounding box should be created for this submesh
  21330. * @returns the new submesh
  21331. */
  21332. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21333. /**
  21334. * Creates a new submesh
  21335. * @param materialIndex defines the material index to use
  21336. * @param verticesStart defines vertex index start
  21337. * @param verticesCount defines vertices count
  21338. * @param indexStart defines index start
  21339. * @param indexCount defines indices count
  21340. * @param mesh defines the parent mesh
  21341. * @param renderingMesh defines an optional rendering mesh
  21342. * @param createBoundingBox defines if bounding box should be created for this submesh
  21343. */
  21344. constructor(
  21345. /** the material index to use */
  21346. materialIndex: number,
  21347. /** vertex index start */
  21348. verticesStart: number,
  21349. /** vertices count */
  21350. verticesCount: number,
  21351. /** index start */
  21352. indexStart: number,
  21353. /** indices count */
  21354. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21355. /**
  21356. * Returns true if this submesh covers the entire parent mesh
  21357. * @ignorenaming
  21358. */
  21359. readonly IsGlobal: boolean;
  21360. /**
  21361. * Returns the submesh BoudingInfo object
  21362. * @returns current bounding info (or mesh's one if the submesh is global)
  21363. */
  21364. getBoundingInfo(): BoundingInfo;
  21365. /**
  21366. * Sets the submesh BoundingInfo
  21367. * @param boundingInfo defines the new bounding info to use
  21368. * @returns the SubMesh
  21369. */
  21370. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21371. /**
  21372. * Returns the mesh of the current submesh
  21373. * @return the parent mesh
  21374. */
  21375. getMesh(): AbstractMesh;
  21376. /**
  21377. * Returns the rendering mesh of the submesh
  21378. * @returns the rendering mesh (could be different from parent mesh)
  21379. */
  21380. getRenderingMesh(): Mesh;
  21381. /**
  21382. * Returns the submesh material
  21383. * @returns null or the current material
  21384. */
  21385. getMaterial(): Nullable<Material>;
  21386. /**
  21387. * Sets a new updated BoundingInfo object to the submesh
  21388. * @returns the SubMesh
  21389. */
  21390. refreshBoundingInfo(): SubMesh;
  21391. /** @hidden */
  21392. _checkCollision(collider: Collider): boolean;
  21393. /**
  21394. * Updates the submesh BoundingInfo
  21395. * @param world defines the world matrix to use to update the bounding info
  21396. * @returns the submesh
  21397. */
  21398. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21399. /**
  21400. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21401. * @param frustumPlanes defines the frustum planes
  21402. * @returns true if the submesh is intersecting with the frustum
  21403. */
  21404. isInFrustum(frustumPlanes: Plane[]): boolean;
  21405. /**
  21406. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21407. * @param frustumPlanes defines the frustum planes
  21408. * @returns true if the submesh is inside the frustum
  21409. */
  21410. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21411. /**
  21412. * Renders the submesh
  21413. * @param enableAlphaMode defines if alpha needs to be used
  21414. * @returns the submesh
  21415. */
  21416. render(enableAlphaMode: boolean): SubMesh;
  21417. /**
  21418. * @hidden
  21419. */
  21420. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  21421. /**
  21422. * Checks if the submesh intersects with a ray
  21423. * @param ray defines the ray to test
  21424. * @returns true is the passed ray intersects the submesh bounding box
  21425. */
  21426. canIntersects(ray: Ray): boolean;
  21427. /**
  21428. * Intersects current submesh with a ray
  21429. * @param ray defines the ray to test
  21430. * @param positions defines mesh's positions array
  21431. * @param indices defines mesh's indices array
  21432. * @param fastCheck defines if only bounding info should be used
  21433. * @returns intersection info or null if no intersection
  21434. */
  21435. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  21436. /** @hidden */
  21437. private _intersectLines;
  21438. /** @hidden */
  21439. private _intersectTriangles;
  21440. /** @hidden */
  21441. _rebuild(): void;
  21442. /**
  21443. * Creates a new submesh from the passed mesh
  21444. * @param newMesh defines the new hosting mesh
  21445. * @param newRenderingMesh defines an optional rendering mesh
  21446. * @returns the new submesh
  21447. */
  21448. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21449. /**
  21450. * Release associated resources
  21451. */
  21452. dispose(): void;
  21453. /**
  21454. * Gets the class name
  21455. * @returns the string "SubMesh".
  21456. */
  21457. getClassName(): string;
  21458. /**
  21459. * Creates a new submesh from indices data
  21460. * @param materialIndex the index of the main mesh material
  21461. * @param startIndex the index where to start the copy in the mesh indices array
  21462. * @param indexCount the number of indices to copy then from the startIndex
  21463. * @param mesh the main mesh to create the submesh from
  21464. * @param renderingMesh the optional rendering mesh
  21465. * @returns a new submesh
  21466. */
  21467. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21468. }
  21469. }
  21470. declare module BABYLON {
  21471. /**
  21472. * Class used to store geometry data (vertex buffers + index buffer)
  21473. */
  21474. export class Geometry implements IGetSetVerticesData {
  21475. /**
  21476. * Gets or sets the ID of the geometry
  21477. */
  21478. id: string;
  21479. /**
  21480. * Gets or sets the unique ID of the geometry
  21481. */
  21482. uniqueId: number;
  21483. /**
  21484. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21485. */
  21486. delayLoadState: number;
  21487. /**
  21488. * Gets the file containing the data to load when running in delay load state
  21489. */
  21490. delayLoadingFile: Nullable<string>;
  21491. /**
  21492. * Callback called when the geometry is updated
  21493. */
  21494. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21495. private _scene;
  21496. private _engine;
  21497. private _meshes;
  21498. private _totalVertices;
  21499. /** @hidden */
  21500. _indices: IndicesArray;
  21501. /** @hidden */
  21502. _vertexBuffers: {
  21503. [key: string]: VertexBuffer;
  21504. };
  21505. private _isDisposed;
  21506. private _extend;
  21507. private _boundingBias;
  21508. /** @hidden */
  21509. _delayInfo: Array<string>;
  21510. private _indexBuffer;
  21511. private _indexBufferIsUpdatable;
  21512. /** @hidden */
  21513. _boundingInfo: Nullable<BoundingInfo>;
  21514. /** @hidden */
  21515. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21516. /** @hidden */
  21517. _softwareSkinningFrameId: number;
  21518. private _vertexArrayObjects;
  21519. private _updatable;
  21520. /** @hidden */
  21521. _positions: Nullable<Vector3[]>;
  21522. /**
  21523. * 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
  21524. */
  21525. /**
  21526. * 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
  21527. */
  21528. boundingBias: Vector2;
  21529. /**
  21530. * Static function used to attach a new empty geometry to a mesh
  21531. * @param mesh defines the mesh to attach the geometry to
  21532. * @returns the new Geometry
  21533. */
  21534. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21535. /**
  21536. * Creates a new geometry
  21537. * @param id defines the unique ID
  21538. * @param scene defines the hosting scene
  21539. * @param vertexData defines the VertexData used to get geometry data
  21540. * @param updatable defines if geometry must be updatable (false by default)
  21541. * @param mesh defines the mesh that will be associated with the geometry
  21542. */
  21543. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21544. /**
  21545. * Gets the current extend of the geometry
  21546. */
  21547. readonly extend: {
  21548. minimum: Vector3;
  21549. maximum: Vector3;
  21550. };
  21551. /**
  21552. * Gets the hosting scene
  21553. * @returns the hosting Scene
  21554. */
  21555. getScene(): Scene;
  21556. /**
  21557. * Gets the hosting engine
  21558. * @returns the hosting Engine
  21559. */
  21560. getEngine(): Engine;
  21561. /**
  21562. * Defines if the geometry is ready to use
  21563. * @returns true if the geometry is ready to be used
  21564. */
  21565. isReady(): boolean;
  21566. /**
  21567. * Gets a value indicating that the geometry should not be serialized
  21568. */
  21569. readonly doNotSerialize: boolean;
  21570. /** @hidden */
  21571. _rebuild(): void;
  21572. /**
  21573. * Affects all geometry data in one call
  21574. * @param vertexData defines the geometry data
  21575. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21576. */
  21577. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21578. /**
  21579. * Set specific vertex data
  21580. * @param kind defines the data kind (Position, normal, etc...)
  21581. * @param data defines the vertex data to use
  21582. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21583. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21584. */
  21585. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21586. /**
  21587. * Removes a specific vertex data
  21588. * @param kind defines the data kind (Position, normal, etc...)
  21589. */
  21590. removeVerticesData(kind: string): void;
  21591. /**
  21592. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21593. * @param buffer defines the vertex buffer to use
  21594. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21595. */
  21596. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21597. /**
  21598. * Update a specific vertex buffer
  21599. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  21600. * It will do nothing if the buffer is not updatable
  21601. * @param kind defines the data kind (Position, normal, etc...)
  21602. * @param data defines the data to use
  21603. * @param offset defines the offset in the target buffer where to store the data
  21604. * @param useBytes set to true if the offset is in bytes
  21605. */
  21606. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21607. /**
  21608. * Update a specific vertex buffer
  21609. * This function will create a new buffer if the current one is not updatable
  21610. * @param kind defines the data kind (Position, normal, etc...)
  21611. * @param data defines the data to use
  21612. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21613. */
  21614. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21615. private _updateBoundingInfo;
  21616. /** @hidden */
  21617. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  21618. /**
  21619. * Gets total number of vertices
  21620. * @returns the total number of vertices
  21621. */
  21622. getTotalVertices(): number;
  21623. /**
  21624. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21625. * @param kind defines the data kind (Position, normal, etc...)
  21626. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21627. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21628. * @returns a float array containing vertex data
  21629. */
  21630. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21631. /**
  21632. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21633. * @param kind defines the data kind (Position, normal, etc...)
  21634. * @returns true if the vertex buffer with the specified kind is updatable
  21635. */
  21636. isVertexBufferUpdatable(kind: string): boolean;
  21637. /**
  21638. * Gets a specific vertex buffer
  21639. * @param kind defines the data kind (Position, normal, etc...)
  21640. * @returns a VertexBuffer
  21641. */
  21642. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21643. /**
  21644. * Returns all vertex buffers
  21645. * @return an object holding all vertex buffers indexed by kind
  21646. */
  21647. getVertexBuffers(): Nullable<{
  21648. [key: string]: VertexBuffer;
  21649. }>;
  21650. /**
  21651. * Gets a boolean indicating if specific vertex buffer is present
  21652. * @param kind defines the data kind (Position, normal, etc...)
  21653. * @returns true if data is present
  21654. */
  21655. isVerticesDataPresent(kind: string): boolean;
  21656. /**
  21657. * Gets a list of all attached data kinds (Position, normal, etc...)
  21658. * @returns a list of string containing all kinds
  21659. */
  21660. getVerticesDataKinds(): string[];
  21661. /**
  21662. * Update index buffer
  21663. * @param indices defines the indices to store in the index buffer
  21664. * @param offset defines the offset in the target buffer where to store the data
  21665. */
  21666. updateIndices(indices: IndicesArray, offset?: number): void;
  21667. /**
  21668. * Creates a new index buffer
  21669. * @param indices defines the indices to store in the index buffer
  21670. * @param totalVertices defines the total number of vertices (could be null)
  21671. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21672. */
  21673. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21674. /**
  21675. * Return the total number of indices
  21676. * @returns the total number of indices
  21677. */
  21678. getTotalIndices(): number;
  21679. /**
  21680. * Gets the index buffer array
  21681. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21682. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21683. * @returns the index buffer array
  21684. */
  21685. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21686. /**
  21687. * Gets the index buffer
  21688. * @return the index buffer
  21689. */
  21690. getIndexBuffer(): Nullable<WebGLBuffer>;
  21691. /** @hidden */
  21692. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21693. /**
  21694. * Release the associated resources for a specific mesh
  21695. * @param mesh defines the source mesh
  21696. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21697. */
  21698. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21699. /**
  21700. * Apply current geometry to a given mesh
  21701. * @param mesh defines the mesh to apply geometry to
  21702. */
  21703. applyToMesh(mesh: Mesh): void;
  21704. private _updateExtend;
  21705. private _applyToMesh;
  21706. private notifyUpdate;
  21707. /**
  21708. * Load the geometry if it was flagged as delay loaded
  21709. * @param scene defines the hosting scene
  21710. * @param onLoaded defines a callback called when the geometry is loaded
  21711. */
  21712. load(scene: Scene, onLoaded?: () => void): void;
  21713. private _queueLoad;
  21714. /**
  21715. * Invert the geometry to move from a right handed system to a left handed one.
  21716. */
  21717. toLeftHanded(): void;
  21718. /** @hidden */
  21719. _resetPointsArrayCache(): void;
  21720. /** @hidden */
  21721. _generatePointsArray(): boolean;
  21722. /**
  21723. * Gets a value indicating if the geometry is disposed
  21724. * @returns true if the geometry was disposed
  21725. */
  21726. isDisposed(): boolean;
  21727. private _disposeVertexArrayObjects;
  21728. /**
  21729. * Free all associated resources
  21730. */
  21731. dispose(): void;
  21732. /**
  21733. * Clone the current geometry into a new geometry
  21734. * @param id defines the unique ID of the new geometry
  21735. * @returns a new geometry object
  21736. */
  21737. copy(id: string): Geometry;
  21738. /**
  21739. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21740. * @return a JSON representation of the current geometry data (without the vertices data)
  21741. */
  21742. serialize(): any;
  21743. private toNumberArray;
  21744. /**
  21745. * Serialize all vertices data into a JSON oject
  21746. * @returns a JSON representation of the current geometry data
  21747. */
  21748. serializeVerticeData(): any;
  21749. /**
  21750. * Extracts a clone of a mesh geometry
  21751. * @param mesh defines the source mesh
  21752. * @param id defines the unique ID of the new geometry object
  21753. * @returns the new geometry object
  21754. */
  21755. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21756. /**
  21757. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21758. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21759. * Be aware Math.random() could cause collisions, but:
  21760. * "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"
  21761. * @returns a string containing a new GUID
  21762. */
  21763. static RandomId(): string;
  21764. /** @hidden */
  21765. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21766. private static _CleanMatricesWeights;
  21767. /**
  21768. * Create a new geometry from persisted data (Using .babylon file format)
  21769. * @param parsedVertexData defines the persisted data
  21770. * @param scene defines the hosting scene
  21771. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21772. * @returns the new geometry object
  21773. */
  21774. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21775. }
  21776. /**
  21777. * Abstract class used to provide common services for all typed geometries
  21778. * @hidden
  21779. */
  21780. export class _PrimitiveGeometry extends Geometry {
  21781. private _canBeRegenerated;
  21782. private _beingRegenerated;
  21783. /**
  21784. * Creates a new typed geometry
  21785. * @param id defines the unique ID of the geometry
  21786. * @param scene defines the hosting scene
  21787. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21788. * @param mesh defines the hosting mesh (can be null)
  21789. */
  21790. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  21791. /**
  21792. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  21793. * @returns true if the geometry can be regenerated
  21794. */
  21795. canBeRegenerated(): boolean;
  21796. /**
  21797. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  21798. */
  21799. regenerate(): void;
  21800. /**
  21801. * Clone the geometry
  21802. * @param id defines the unique ID of the new geometry
  21803. * @returns the new geometry
  21804. */
  21805. asNewGeometry(id: string): Geometry;
  21806. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21807. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  21808. /** @hidden */
  21809. _regenerateVertexData(): VertexData;
  21810. copy(id: string): Geometry;
  21811. serialize(): any;
  21812. }
  21813. /**
  21814. * Creates a ribbon geometry
  21815. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  21816. */
  21817. export class RibbonGeometry extends _PrimitiveGeometry {
  21818. /**
  21819. * Defines the array of paths to use
  21820. */
  21821. pathArray: Vector3[][];
  21822. /**
  21823. * Defines if the last and first points of each path in your pathArray must be joined
  21824. */
  21825. closeArray: boolean;
  21826. /**
  21827. * Defines if the last and first points of each path in your pathArray must be joined
  21828. */
  21829. closePath: boolean;
  21830. /**
  21831. * Defines the offset between points
  21832. */
  21833. offset: number;
  21834. /**
  21835. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  21836. */
  21837. side: number;
  21838. /**
  21839. * Creates a ribbon geometry
  21840. * @param id defines the unique ID of the geometry
  21841. * @param scene defines the hosting scene
  21842. * @param pathArray defines the array of paths to use
  21843. * @param closeArray defines if the last path and the first path must be joined
  21844. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  21845. * @param offset defines the offset between points
  21846. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21847. * @param mesh defines the hosting mesh (can be null)
  21848. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  21849. */
  21850. constructor(id: string, scene: Scene,
  21851. /**
  21852. * Defines the array of paths to use
  21853. */
  21854. pathArray: Vector3[][],
  21855. /**
  21856. * Defines if the last and first points of each path in your pathArray must be joined
  21857. */
  21858. closeArray: boolean,
  21859. /**
  21860. * Defines if the last and first points of each path in your pathArray must be joined
  21861. */
  21862. closePath: boolean,
  21863. /**
  21864. * Defines the offset between points
  21865. */
  21866. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  21867. /**
  21868. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  21869. */
  21870. side?: number);
  21871. /** @hidden */
  21872. _regenerateVertexData(): VertexData;
  21873. copy(id: string): Geometry;
  21874. }
  21875. /**
  21876. * Creates a box geometry
  21877. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  21878. */
  21879. export class BoxGeometry extends _PrimitiveGeometry {
  21880. /**
  21881. * Defines the zise of the box (width, height and depth are the same)
  21882. */
  21883. size: number;
  21884. /**
  21885. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  21886. */
  21887. side: number;
  21888. /**
  21889. * Creates a box geometry
  21890. * @param id defines the unique ID of the geometry
  21891. * @param scene defines the hosting scene
  21892. * @param size defines the zise of the box (width, height and depth are the same)
  21893. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21894. * @param mesh defines the hosting mesh (can be null)
  21895. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  21896. */
  21897. constructor(id: string, scene: Scene,
  21898. /**
  21899. * Defines the zise of the box (width, height and depth are the same)
  21900. */
  21901. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21902. /**
  21903. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  21904. */
  21905. side?: number);
  21906. /** @hidden */
  21907. _regenerateVertexData(): VertexData;
  21908. copy(id: string): Geometry;
  21909. serialize(): any;
  21910. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  21911. }
  21912. /**
  21913. * Creates a sphere geometry
  21914. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  21915. */
  21916. export class SphereGeometry extends _PrimitiveGeometry {
  21917. /**
  21918. * Defines the number of segments to use to create the sphere
  21919. */
  21920. segments: number;
  21921. /**
  21922. * Defines the diameter of the sphere
  21923. */
  21924. diameter: number;
  21925. /**
  21926. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  21927. */
  21928. side: number;
  21929. /**
  21930. * Create a new sphere geometry
  21931. * @param id defines the unique ID of the geometry
  21932. * @param scene defines the hosting scene
  21933. * @param segments defines the number of segments to use to create the sphere
  21934. * @param diameter defines the diameter of the sphere
  21935. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21936. * @param mesh defines the hosting mesh (can be null)
  21937. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  21938. */
  21939. constructor(id: string, scene: Scene,
  21940. /**
  21941. * Defines the number of segments to use to create the sphere
  21942. */
  21943. segments: number,
  21944. /**
  21945. * Defines the diameter of the sphere
  21946. */
  21947. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21948. /**
  21949. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  21950. */
  21951. side?: number);
  21952. /** @hidden */
  21953. _regenerateVertexData(): VertexData;
  21954. copy(id: string): Geometry;
  21955. serialize(): any;
  21956. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  21957. }
  21958. /**
  21959. * Creates a disc geometry
  21960. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  21961. */
  21962. export class DiscGeometry extends _PrimitiveGeometry {
  21963. /**
  21964. * Defines the radius of the disc
  21965. */
  21966. radius: number;
  21967. /**
  21968. * Defines the tesselation factor to apply to the disc
  21969. */
  21970. tessellation: number;
  21971. /**
  21972. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  21973. */
  21974. side: number;
  21975. /**
  21976. * Creates a new disc geometry
  21977. * @param id defines the unique ID of the geometry
  21978. * @param scene defines the hosting scene
  21979. * @param radius defines the radius of the disc
  21980. * @param tessellation defines the tesselation factor to apply to the disc
  21981. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  21982. * @param mesh defines the hosting mesh (can be null)
  21983. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  21984. */
  21985. constructor(id: string, scene: Scene,
  21986. /**
  21987. * Defines the radius of the disc
  21988. */
  21989. radius: number,
  21990. /**
  21991. * Defines the tesselation factor to apply to the disc
  21992. */
  21993. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  21994. /**
  21995. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  21996. */
  21997. side?: number);
  21998. /** @hidden */
  21999. _regenerateVertexData(): VertexData;
  22000. copy(id: string): Geometry;
  22001. }
  22002. /**
  22003. * Creates a new cylinder geometry
  22004. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  22005. */
  22006. export class CylinderGeometry extends _PrimitiveGeometry {
  22007. /**
  22008. * Defines the height of the cylinder
  22009. */
  22010. height: number;
  22011. /**
  22012. * Defines the diameter of the cylinder's top cap
  22013. */
  22014. diameterTop: number;
  22015. /**
  22016. * Defines the diameter of the cylinder's bottom cap
  22017. */
  22018. diameterBottom: number;
  22019. /**
  22020. * Defines the tessellation factor to apply to the cylinder
  22021. */
  22022. tessellation: number;
  22023. /**
  22024. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  22025. */
  22026. subdivisions: number;
  22027. /**
  22028. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22029. */
  22030. side: number;
  22031. /**
  22032. * Creates a new cylinder geometry
  22033. * @param id defines the unique ID of the geometry
  22034. * @param scene defines the hosting scene
  22035. * @param height defines the height of the cylinder
  22036. * @param diameterTop defines the diameter of the cylinder's top cap
  22037. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  22038. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  22039. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  22040. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22041. * @param mesh defines the hosting mesh (can be null)
  22042. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22043. */
  22044. constructor(id: string, scene: Scene,
  22045. /**
  22046. * Defines the height of the cylinder
  22047. */
  22048. height: number,
  22049. /**
  22050. * Defines the diameter of the cylinder's top cap
  22051. */
  22052. diameterTop: number,
  22053. /**
  22054. * Defines the diameter of the cylinder's bottom cap
  22055. */
  22056. diameterBottom: number,
  22057. /**
  22058. * Defines the tessellation factor to apply to the cylinder
  22059. */
  22060. tessellation: number,
  22061. /**
  22062. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  22063. */
  22064. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22065. /**
  22066. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22067. */
  22068. side?: number);
  22069. /** @hidden */
  22070. _regenerateVertexData(): VertexData;
  22071. copy(id: string): Geometry;
  22072. serialize(): any;
  22073. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  22074. }
  22075. /**
  22076. * Creates a new torus geometry
  22077. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  22078. */
  22079. export class TorusGeometry extends _PrimitiveGeometry {
  22080. /**
  22081. * Defines the diameter of the torus
  22082. */
  22083. diameter: number;
  22084. /**
  22085. * Defines the thickness of the torus (ie. internal diameter)
  22086. */
  22087. thickness: number;
  22088. /**
  22089. * Defines the tesselation factor to apply to the torus
  22090. */
  22091. tessellation: number;
  22092. /**
  22093. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22094. */
  22095. side: number;
  22096. /**
  22097. * Creates a new torus geometry
  22098. * @param id defines the unique ID of the geometry
  22099. * @param scene defines the hosting scene
  22100. * @param diameter defines the diameter of the torus
  22101. * @param thickness defines the thickness of the torus (ie. internal diameter)
  22102. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  22103. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22104. * @param mesh defines the hosting mesh (can be null)
  22105. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22106. */
  22107. constructor(id: string, scene: Scene,
  22108. /**
  22109. * Defines the diameter of the torus
  22110. */
  22111. diameter: number,
  22112. /**
  22113. * Defines the thickness of the torus (ie. internal diameter)
  22114. */
  22115. thickness: number,
  22116. /**
  22117. * Defines the tesselation factor to apply to the torus
  22118. */
  22119. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22120. /**
  22121. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22122. */
  22123. side?: number);
  22124. /** @hidden */
  22125. _regenerateVertexData(): VertexData;
  22126. copy(id: string): Geometry;
  22127. serialize(): any;
  22128. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  22129. }
  22130. /**
  22131. * Creates a new ground geometry
  22132. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  22133. */
  22134. export class GroundGeometry extends _PrimitiveGeometry {
  22135. /**
  22136. * Defines the width of the ground
  22137. */
  22138. width: number;
  22139. /**
  22140. * Defines the height of the ground
  22141. */
  22142. height: number;
  22143. /**
  22144. * Defines the subdivisions to apply to the ground
  22145. */
  22146. subdivisions: number;
  22147. /**
  22148. * Creates a new ground geometry
  22149. * @param id defines the unique ID of the geometry
  22150. * @param scene defines the hosting scene
  22151. * @param width defines the width of the ground
  22152. * @param height defines the height of the ground
  22153. * @param subdivisions defines the subdivisions to apply to the ground
  22154. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22155. * @param mesh defines the hosting mesh (can be null)
  22156. */
  22157. constructor(id: string, scene: Scene,
  22158. /**
  22159. * Defines the width of the ground
  22160. */
  22161. width: number,
  22162. /**
  22163. * Defines the height of the ground
  22164. */
  22165. height: number,
  22166. /**
  22167. * Defines the subdivisions to apply to the ground
  22168. */
  22169. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  22170. /** @hidden */
  22171. _regenerateVertexData(): VertexData;
  22172. copy(id: string): Geometry;
  22173. serialize(): any;
  22174. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  22175. }
  22176. /**
  22177. * Creates a tiled ground geometry
  22178. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  22179. */
  22180. export class TiledGroundGeometry extends _PrimitiveGeometry {
  22181. /**
  22182. * Defines the minimum value on X axis
  22183. */
  22184. xmin: number;
  22185. /**
  22186. * Defines the minimum value on Z axis
  22187. */
  22188. zmin: number;
  22189. /**
  22190. * Defines the maximum value on X axis
  22191. */
  22192. xmax: number;
  22193. /**
  22194. * Defines the maximum value on Z axis
  22195. */
  22196. zmax: number;
  22197. /**
  22198. * Defines the subdivisions to apply to the ground
  22199. */
  22200. subdivisions: {
  22201. w: number;
  22202. h: number;
  22203. };
  22204. /**
  22205. * Defines the precision to use when computing the tiles
  22206. */
  22207. precision: {
  22208. w: number;
  22209. h: number;
  22210. };
  22211. /**
  22212. * Creates a tiled ground geometry
  22213. * @param id defines the unique ID of the geometry
  22214. * @param scene defines the hosting scene
  22215. * @param xmin defines the minimum value on X axis
  22216. * @param zmin defines the minimum value on Z axis
  22217. * @param xmax defines the maximum value on X axis
  22218. * @param zmax defines the maximum value on Z axis
  22219. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  22220. * @param precision defines the precision to use when computing the tiles
  22221. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22222. * @param mesh defines the hosting mesh (can be null)
  22223. */
  22224. constructor(id: string, scene: Scene,
  22225. /**
  22226. * Defines the minimum value on X axis
  22227. */
  22228. xmin: number,
  22229. /**
  22230. * Defines the minimum value on Z axis
  22231. */
  22232. zmin: number,
  22233. /**
  22234. * Defines the maximum value on X axis
  22235. */
  22236. xmax: number,
  22237. /**
  22238. * Defines the maximum value on Z axis
  22239. */
  22240. zmax: number,
  22241. /**
  22242. * Defines the subdivisions to apply to the ground
  22243. */
  22244. subdivisions: {
  22245. w: number;
  22246. h: number;
  22247. },
  22248. /**
  22249. * Defines the precision to use when computing the tiles
  22250. */
  22251. precision: {
  22252. w: number;
  22253. h: number;
  22254. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  22255. /** @hidden */
  22256. _regenerateVertexData(): VertexData;
  22257. copy(id: string): Geometry;
  22258. }
  22259. /**
  22260. * Creates a plane geometry
  22261. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  22262. */
  22263. export class PlaneGeometry extends _PrimitiveGeometry {
  22264. /**
  22265. * Defines the size of the plane (width === height)
  22266. */
  22267. size: number;
  22268. /**
  22269. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22270. */
  22271. side: number;
  22272. /**
  22273. * Creates a plane geometry
  22274. * @param id defines the unique ID of the geometry
  22275. * @param scene defines the hosting scene
  22276. * @param size defines the size of the plane (width === height)
  22277. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22278. * @param mesh defines the hosting mesh (can be null)
  22279. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22280. */
  22281. constructor(id: string, scene: Scene,
  22282. /**
  22283. * Defines the size of the plane (width === height)
  22284. */
  22285. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22286. /**
  22287. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22288. */
  22289. side?: number);
  22290. /** @hidden */
  22291. _regenerateVertexData(): VertexData;
  22292. copy(id: string): Geometry;
  22293. serialize(): any;
  22294. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  22295. }
  22296. /**
  22297. * Creates a torus knot geometry
  22298. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  22299. */
  22300. export class TorusKnotGeometry extends _PrimitiveGeometry {
  22301. /**
  22302. * Defines the radius of the torus knot
  22303. */
  22304. radius: number;
  22305. /**
  22306. * Defines the thickness of the torus knot tube
  22307. */
  22308. tube: number;
  22309. /**
  22310. * Defines the number of radial segments
  22311. */
  22312. radialSegments: number;
  22313. /**
  22314. * Defines the number of tubular segments
  22315. */
  22316. tubularSegments: number;
  22317. /**
  22318. * Defines the first number of windings
  22319. */
  22320. p: number;
  22321. /**
  22322. * Defines the second number of windings
  22323. */
  22324. q: number;
  22325. /**
  22326. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22327. */
  22328. side: number;
  22329. /**
  22330. * Creates a torus knot geometry
  22331. * @param id defines the unique ID of the geometry
  22332. * @param scene defines the hosting scene
  22333. * @param radius defines the radius of the torus knot
  22334. * @param tube defines the thickness of the torus knot tube
  22335. * @param radialSegments defines the number of radial segments
  22336. * @param tubularSegments defines the number of tubular segments
  22337. * @param p defines the first number of windings
  22338. * @param q defines the second number of windings
  22339. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  22340. * @param mesh defines the hosting mesh (can be null)
  22341. * @param side defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22342. */
  22343. constructor(id: string, scene: Scene,
  22344. /**
  22345. * Defines the radius of the torus knot
  22346. */
  22347. radius: number,
  22348. /**
  22349. * Defines the thickness of the torus knot tube
  22350. */
  22351. tube: number,
  22352. /**
  22353. * Defines the number of radial segments
  22354. */
  22355. radialSegments: number,
  22356. /**
  22357. * Defines the number of tubular segments
  22358. */
  22359. tubularSegments: number,
  22360. /**
  22361. * Defines the first number of windings
  22362. */
  22363. p: number,
  22364. /**
  22365. * Defines the second number of windings
  22366. */
  22367. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  22368. /**
  22369. * Defines if the created geometry is double sided or not (default is Mesh.DEFAULTSIDE)
  22370. */
  22371. side?: number);
  22372. /** @hidden */
  22373. _regenerateVertexData(): VertexData;
  22374. copy(id: string): Geometry;
  22375. serialize(): any;
  22376. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  22377. }
  22378. }
  22379. declare module BABYLON {
  22380. /**
  22381. * Define an interface for all classes that will get and set the data on vertices
  22382. */
  22383. export interface IGetSetVerticesData {
  22384. /**
  22385. * Gets a boolean indicating if specific vertex data is present
  22386. * @param kind defines the vertex data kind to use
  22387. * @returns true is data kind is present
  22388. */
  22389. isVerticesDataPresent(kind: string): boolean;
  22390. /**
  22391. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22392. * @param kind defines the data kind (Position, normal, etc...)
  22393. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22394. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22395. * @returns a float array containing vertex data
  22396. */
  22397. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22398. /**
  22399. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22400. * @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.
  22401. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22402. * @returns the indices array or an empty array if the mesh has no geometry
  22403. */
  22404. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22405. /**
  22406. * Set specific vertex data
  22407. * @param kind defines the data kind (Position, normal, etc...)
  22408. * @param data defines the vertex data to use
  22409. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22410. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22411. */
  22412. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22413. /**
  22414. * Update a specific associated vertex buffer
  22415. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22416. * - VertexBuffer.PositionKind
  22417. * - VertexBuffer.UVKind
  22418. * - VertexBuffer.UV2Kind
  22419. * - VertexBuffer.UV3Kind
  22420. * - VertexBuffer.UV4Kind
  22421. * - VertexBuffer.UV5Kind
  22422. * - VertexBuffer.UV6Kind
  22423. * - VertexBuffer.ColorKind
  22424. * - VertexBuffer.MatricesIndicesKind
  22425. * - VertexBuffer.MatricesIndicesExtraKind
  22426. * - VertexBuffer.MatricesWeightsKind
  22427. * - VertexBuffer.MatricesWeightsExtraKind
  22428. * @param data defines the data source
  22429. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22430. * @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)
  22431. */
  22432. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22433. /**
  22434. * Creates a new index buffer
  22435. * @param indices defines the indices to store in the index buffer
  22436. * @param totalVertices defines the total number of vertices (could be null)
  22437. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22438. */
  22439. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22440. }
  22441. /**
  22442. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22443. */
  22444. export class VertexData {
  22445. /**
  22446. * Mesh side orientation : usually the external or front surface
  22447. */
  22448. static readonly FRONTSIDE: number;
  22449. /**
  22450. * Mesh side orientation : usually the internal or back surface
  22451. */
  22452. static readonly BACKSIDE: number;
  22453. /**
  22454. * Mesh side orientation : both internal and external or front and back surfaces
  22455. */
  22456. static readonly DOUBLESIDE: number;
  22457. /**
  22458. * Mesh side orientation : by default, `FRONTSIDE`
  22459. */
  22460. static readonly DEFAULTSIDE: number;
  22461. /**
  22462. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22463. */
  22464. positions: Nullable<FloatArray>;
  22465. /**
  22466. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22467. */
  22468. normals: Nullable<FloatArray>;
  22469. /**
  22470. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22471. */
  22472. tangents: Nullable<FloatArray>;
  22473. /**
  22474. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22475. */
  22476. uvs: Nullable<FloatArray>;
  22477. /**
  22478. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22479. */
  22480. uvs2: Nullable<FloatArray>;
  22481. /**
  22482. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22483. */
  22484. uvs3: Nullable<FloatArray>;
  22485. /**
  22486. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22487. */
  22488. uvs4: Nullable<FloatArray>;
  22489. /**
  22490. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22491. */
  22492. uvs5: Nullable<FloatArray>;
  22493. /**
  22494. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22495. */
  22496. uvs6: Nullable<FloatArray>;
  22497. /**
  22498. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22499. */
  22500. colors: Nullable<FloatArray>;
  22501. /**
  22502. * 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).
  22503. */
  22504. matricesIndices: Nullable<FloatArray>;
  22505. /**
  22506. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22507. */
  22508. matricesWeights: Nullable<FloatArray>;
  22509. /**
  22510. * An array extending the number of possible indices
  22511. */
  22512. matricesIndicesExtra: Nullable<FloatArray>;
  22513. /**
  22514. * An array extending the number of possible weights when the number of indices is extended
  22515. */
  22516. matricesWeightsExtra: Nullable<FloatArray>;
  22517. /**
  22518. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22519. */
  22520. indices: Nullable<IndicesArray>;
  22521. /**
  22522. * Uses the passed data array to set the set the values for the specified kind of data
  22523. * @param data a linear array of floating numbers
  22524. * @param kind the type of data that is being set, eg positions, colors etc
  22525. */
  22526. set(data: FloatArray, kind: string): void;
  22527. /**
  22528. * Associates the vertexData to the passed Mesh.
  22529. * Sets it as updatable or not (default `false`)
  22530. * @param mesh the mesh the vertexData is applied to
  22531. * @param updatable when used and having the value true allows new data to update the vertexData
  22532. * @returns the VertexData
  22533. */
  22534. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22535. /**
  22536. * Associates the vertexData to the passed Geometry.
  22537. * Sets it as updatable or not (default `false`)
  22538. * @param geometry the geometry the vertexData is applied to
  22539. * @param updatable when used and having the value true allows new data to update the vertexData
  22540. * @returns VertexData
  22541. */
  22542. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22543. /**
  22544. * Updates the associated mesh
  22545. * @param mesh the mesh to be updated
  22546. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22547. * @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
  22548. * @returns VertexData
  22549. */
  22550. updateMesh(mesh: Mesh): VertexData;
  22551. /**
  22552. * Updates the associated geometry
  22553. * @param geometry the geometry to be updated
  22554. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22555. * @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
  22556. * @returns VertexData.
  22557. */
  22558. updateGeometry(geometry: Geometry): VertexData;
  22559. private _applyTo;
  22560. private _update;
  22561. /**
  22562. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22563. * @param matrix the transforming matrix
  22564. * @returns the VertexData
  22565. */
  22566. transform(matrix: Matrix): VertexData;
  22567. /**
  22568. * Merges the passed VertexData into the current one
  22569. * @param other the VertexData to be merged into the current one
  22570. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22571. * @returns the modified VertexData
  22572. */
  22573. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22574. private _mergeElement;
  22575. private _validate;
  22576. /**
  22577. * Serializes the VertexData
  22578. * @returns a serialized object
  22579. */
  22580. serialize(): any;
  22581. /**
  22582. * Extracts the vertexData from a mesh
  22583. * @param mesh the mesh from which to extract the VertexData
  22584. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22585. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22586. * @returns the object VertexData associated to the passed mesh
  22587. */
  22588. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22589. /**
  22590. * Extracts the vertexData from the geometry
  22591. * @param geometry the geometry from which to extract the VertexData
  22592. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22593. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22594. * @returns the object VertexData associated to the passed mesh
  22595. */
  22596. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22597. private static _ExtractFrom;
  22598. /**
  22599. * Creates the VertexData for a Ribbon
  22600. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22601. * * pathArray array of paths, each of which an array of successive Vector3
  22602. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22603. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22604. * * 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
  22605. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22606. * * 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)
  22607. * * 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)
  22608. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22609. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22610. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22611. * @returns the VertexData of the ribbon
  22612. */
  22613. static CreateRibbon(options: {
  22614. pathArray: Vector3[][];
  22615. closeArray?: boolean;
  22616. closePath?: boolean;
  22617. offset?: number;
  22618. sideOrientation?: number;
  22619. frontUVs?: Vector4;
  22620. backUVs?: Vector4;
  22621. invertUV?: boolean;
  22622. uvs?: Vector2[];
  22623. colors?: Color4[];
  22624. }): VertexData;
  22625. /**
  22626. * Creates the VertexData for a box
  22627. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22628. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22629. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22630. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22631. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22632. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22633. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22634. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22635. * * 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)
  22636. * * 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)
  22637. * @returns the VertexData of the box
  22638. */
  22639. static CreateBox(options: {
  22640. size?: number;
  22641. width?: number;
  22642. height?: number;
  22643. depth?: number;
  22644. faceUV?: Vector4[];
  22645. faceColors?: Color4[];
  22646. sideOrientation?: number;
  22647. frontUVs?: Vector4;
  22648. backUVs?: Vector4;
  22649. }): VertexData;
  22650. /**
  22651. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22652. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22653. * * segments sets the number of horizontal strips optional, default 32
  22654. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22655. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22656. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22657. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22658. * * 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
  22659. * * 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
  22660. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22661. * * 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)
  22662. * * 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)
  22663. * @returns the VertexData of the ellipsoid
  22664. */
  22665. static CreateSphere(options: {
  22666. segments?: number;
  22667. diameter?: number;
  22668. diameterX?: number;
  22669. diameterY?: number;
  22670. diameterZ?: number;
  22671. arc?: number;
  22672. slice?: number;
  22673. sideOrientation?: number;
  22674. frontUVs?: Vector4;
  22675. backUVs?: Vector4;
  22676. }): VertexData;
  22677. /**
  22678. * Creates the VertexData for a cylinder, cone or prism
  22679. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22680. * * height sets the height (y direction) of the cylinder, optional, default 2
  22681. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22682. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22683. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22684. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22685. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22686. * * 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
  22687. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22688. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22689. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22690. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22691. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22692. * * 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)
  22693. * * 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)
  22694. * @returns the VertexData of the cylinder, cone or prism
  22695. */
  22696. static CreateCylinder(options: {
  22697. height?: number;
  22698. diameterTop?: number;
  22699. diameterBottom?: number;
  22700. diameter?: number;
  22701. tessellation?: number;
  22702. subdivisions?: number;
  22703. arc?: number;
  22704. faceColors?: Color4[];
  22705. faceUV?: Vector4[];
  22706. hasRings?: boolean;
  22707. enclose?: boolean;
  22708. sideOrientation?: number;
  22709. frontUVs?: Vector4;
  22710. backUVs?: Vector4;
  22711. }): VertexData;
  22712. /**
  22713. * Creates the VertexData for a torus
  22714. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22715. * * diameter the diameter of the torus, optional default 1
  22716. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22717. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22718. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22719. * * 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)
  22720. * * 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)
  22721. * @returns the VertexData of the torus
  22722. */
  22723. static CreateTorus(options: {
  22724. diameter?: number;
  22725. thickness?: number;
  22726. tessellation?: number;
  22727. sideOrientation?: number;
  22728. frontUVs?: Vector4;
  22729. backUVs?: Vector4;
  22730. }): VertexData;
  22731. /**
  22732. * Creates the VertexData of the LineSystem
  22733. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22734. * - lines an array of lines, each line being an array of successive Vector3
  22735. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22736. * @returns the VertexData of the LineSystem
  22737. */
  22738. static CreateLineSystem(options: {
  22739. lines: Vector3[][];
  22740. colors?: Nullable<Color4[][]>;
  22741. }): VertexData;
  22742. /**
  22743. * Create the VertexData for a DashedLines
  22744. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22745. * - points an array successive Vector3
  22746. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22747. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22748. * - dashNb the intended total number of dashes, optional, default 200
  22749. * @returns the VertexData for the DashedLines
  22750. */
  22751. static CreateDashedLines(options: {
  22752. points: Vector3[];
  22753. dashSize?: number;
  22754. gapSize?: number;
  22755. dashNb?: number;
  22756. }): VertexData;
  22757. /**
  22758. * Creates the VertexData for a Ground
  22759. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22760. * - width the width (x direction) of the ground, optional, default 1
  22761. * - height the height (z direction) of the ground, optional, default 1
  22762. * - subdivisions the number of subdivisions per side, optional, default 1
  22763. * @returns the VertexData of the Ground
  22764. */
  22765. static CreateGround(options: {
  22766. width?: number;
  22767. height?: number;
  22768. subdivisions?: number;
  22769. subdivisionsX?: number;
  22770. subdivisionsY?: number;
  22771. }): VertexData;
  22772. /**
  22773. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22774. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22775. * * xmin the ground minimum X coordinate, optional, default -1
  22776. * * zmin the ground minimum Z coordinate, optional, default -1
  22777. * * xmax the ground maximum X coordinate, optional, default 1
  22778. * * zmax the ground maximum Z coordinate, optional, default 1
  22779. * * 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}
  22780. * * 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}
  22781. * @returns the VertexData of the TiledGround
  22782. */
  22783. static CreateTiledGround(options: {
  22784. xmin: number;
  22785. zmin: number;
  22786. xmax: number;
  22787. zmax: number;
  22788. subdivisions?: {
  22789. w: number;
  22790. h: number;
  22791. };
  22792. precision?: {
  22793. w: number;
  22794. h: number;
  22795. };
  22796. }): VertexData;
  22797. /**
  22798. * Creates the VertexData of the Ground designed from a heightmap
  22799. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22800. * * width the width (x direction) of the ground
  22801. * * height the height (z direction) of the ground
  22802. * * subdivisions the number of subdivisions per side
  22803. * * minHeight the minimum altitude on the ground, optional, default 0
  22804. * * maxHeight the maximum altitude on the ground, optional default 1
  22805. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22806. * * buffer the array holding the image color data
  22807. * * bufferWidth the width of image
  22808. * * bufferHeight the height of image
  22809. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22810. * @returns the VertexData of the Ground designed from a heightmap
  22811. */
  22812. static CreateGroundFromHeightMap(options: {
  22813. width: number;
  22814. height: number;
  22815. subdivisions: number;
  22816. minHeight: number;
  22817. maxHeight: number;
  22818. colorFilter: Color3;
  22819. buffer: Uint8Array;
  22820. bufferWidth: number;
  22821. bufferHeight: number;
  22822. alphaFilter: number;
  22823. }): VertexData;
  22824. /**
  22825. * Creates the VertexData for a Plane
  22826. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22827. * * size sets the width and height of the plane to the value of size, optional default 1
  22828. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22829. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22830. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22831. * * 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)
  22832. * * 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)
  22833. * @returns the VertexData of the box
  22834. */
  22835. static CreatePlane(options: {
  22836. size?: number;
  22837. width?: number;
  22838. height?: number;
  22839. sideOrientation?: number;
  22840. frontUVs?: Vector4;
  22841. backUVs?: Vector4;
  22842. }): VertexData;
  22843. /**
  22844. * Creates the VertexData of the Disc or regular Polygon
  22845. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22846. * * radius the radius of the disc, optional default 0.5
  22847. * * tessellation the number of polygon sides, optional, default 64
  22848. * * 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
  22849. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22850. * * 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)
  22851. * * 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)
  22852. * @returns the VertexData of the box
  22853. */
  22854. static CreateDisc(options: {
  22855. radius?: number;
  22856. tessellation?: number;
  22857. arc?: number;
  22858. sideOrientation?: number;
  22859. frontUVs?: Vector4;
  22860. backUVs?: Vector4;
  22861. }): VertexData;
  22862. /**
  22863. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22864. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22865. * @param polygon a mesh built from polygonTriangulation.build()
  22866. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22867. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22868. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22869. * @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)
  22870. * @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)
  22871. * @returns the VertexData of the Polygon
  22872. */
  22873. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22874. /**
  22875. * Creates the VertexData of the IcoSphere
  22876. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22877. * * radius the radius of the IcoSphere, optional default 1
  22878. * * radiusX allows stretching in the x direction, optional, default radius
  22879. * * radiusY allows stretching in the y direction, optional, default radius
  22880. * * radiusZ allows stretching in the z direction, optional, default radius
  22881. * * flat when true creates a flat shaded mesh, optional, default true
  22882. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22883. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22884. * * 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)
  22885. * * 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)
  22886. * @returns the VertexData of the IcoSphere
  22887. */
  22888. static CreateIcoSphere(options: {
  22889. radius?: number;
  22890. radiusX?: number;
  22891. radiusY?: number;
  22892. radiusZ?: number;
  22893. flat?: boolean;
  22894. subdivisions?: number;
  22895. sideOrientation?: number;
  22896. frontUVs?: Vector4;
  22897. backUVs?: Vector4;
  22898. }): VertexData;
  22899. /**
  22900. * Creates the VertexData for a Polyhedron
  22901. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22902. * * type provided types are:
  22903. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22904. * * 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)
  22905. * * size the size of the IcoSphere, optional default 1
  22906. * * sizeX allows stretching in the x direction, optional, default size
  22907. * * sizeY allows stretching in the y direction, optional, default size
  22908. * * sizeZ allows stretching in the z direction, optional, default size
  22909. * * 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
  22910. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22911. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22912. * * flat when true creates a flat shaded mesh, optional, default true
  22913. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22914. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22915. * * 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)
  22916. * * 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)
  22917. * @returns the VertexData of the Polyhedron
  22918. */
  22919. static CreatePolyhedron(options: {
  22920. type?: number;
  22921. size?: number;
  22922. sizeX?: number;
  22923. sizeY?: number;
  22924. sizeZ?: number;
  22925. custom?: any;
  22926. faceUV?: Vector4[];
  22927. faceColors?: Color4[];
  22928. flat?: boolean;
  22929. sideOrientation?: number;
  22930. frontUVs?: Vector4;
  22931. backUVs?: Vector4;
  22932. }): VertexData;
  22933. /**
  22934. * Creates the VertexData for a TorusKnot
  22935. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22936. * * radius the radius of the torus knot, optional, default 2
  22937. * * tube the thickness of the tube, optional, default 0.5
  22938. * * radialSegments the number of sides on each tube segments, optional, default 32
  22939. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22940. * * p the number of windings around the z axis, optional, default 2
  22941. * * q the number of windings around the x axis, optional, default 3
  22942. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22943. * * 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)
  22944. * * 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)
  22945. * @returns the VertexData of the Torus Knot
  22946. */
  22947. static CreateTorusKnot(options: {
  22948. radius?: number;
  22949. tube?: number;
  22950. radialSegments?: number;
  22951. tubularSegments?: number;
  22952. p?: number;
  22953. q?: number;
  22954. sideOrientation?: number;
  22955. frontUVs?: Vector4;
  22956. backUVs?: Vector4;
  22957. }): VertexData;
  22958. /**
  22959. * Compute normals for given positions and indices
  22960. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22961. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22962. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22963. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22964. * * facetNormals : optional array of facet normals (vector3)
  22965. * * facetPositions : optional array of facet positions (vector3)
  22966. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22967. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22968. * * bInfo : optional bounding info, required for facetPartitioning computation
  22969. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22970. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22971. * * useRightHandedSystem: optional boolean to for right handed system computation
  22972. * * depthSort : optional boolean to enable the facet depth sort computation
  22973. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22974. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22975. */
  22976. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22977. facetNormals?: any;
  22978. facetPositions?: any;
  22979. facetPartitioning?: any;
  22980. ratio?: number;
  22981. bInfo?: any;
  22982. bbSize?: Vector3;
  22983. subDiv?: any;
  22984. useRightHandedSystem?: boolean;
  22985. depthSort?: boolean;
  22986. distanceTo?: Vector3;
  22987. depthSortedFacets?: any;
  22988. }): void;
  22989. private static _ComputeSides;
  22990. /**
  22991. * Applies VertexData created from the imported parameters to the geometry
  22992. * @param parsedVertexData the parsed data from an imported file
  22993. * @param geometry the geometry to apply the VertexData to
  22994. */
  22995. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22996. }
  22997. }
  22998. declare module BABYLON {
  22999. /**
  23000. * Polygon
  23001. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  23002. */
  23003. export class Polygon {
  23004. /**
  23005. * Creates a rectangle
  23006. * @param xmin bottom X coord
  23007. * @param ymin bottom Y coord
  23008. * @param xmax top X coord
  23009. * @param ymax top Y coord
  23010. * @returns points that make the resulting rectation
  23011. */
  23012. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  23013. /**
  23014. * Creates a circle
  23015. * @param radius radius of circle
  23016. * @param cx scale in x
  23017. * @param cy scale in y
  23018. * @param numberOfSides number of sides that make up the circle
  23019. * @returns points that make the resulting circle
  23020. */
  23021. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  23022. /**
  23023. * Creates a polygon from input string
  23024. * @param input Input polygon data
  23025. * @returns the parsed points
  23026. */
  23027. static Parse(input: string): Vector2[];
  23028. /**
  23029. * Starts building a polygon from x and y coordinates
  23030. * @param x x coordinate
  23031. * @param y y coordinate
  23032. * @returns the started path2
  23033. */
  23034. static StartingAt(x: number, y: number): Path2;
  23035. }
  23036. /**
  23037. * Builds a polygon
  23038. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  23039. */
  23040. export class PolygonMeshBuilder {
  23041. private _points;
  23042. private _outlinepoints;
  23043. private _holes;
  23044. private _name;
  23045. private _scene;
  23046. private _epoints;
  23047. private _eholes;
  23048. private _addToepoint;
  23049. /**
  23050. * Babylon reference to the earcut plugin.
  23051. */
  23052. bjsEarcut: any;
  23053. /**
  23054. * Creates a PolygonMeshBuilder
  23055. * @param name name of the builder
  23056. * @param contours Path of the polygon
  23057. * @param scene scene to add to
  23058. */
  23059. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  23060. /**
  23061. * Adds a whole within the polygon
  23062. * @param hole Array of points defining the hole
  23063. * @returns this
  23064. */
  23065. addHole(hole: Vector2[]): PolygonMeshBuilder;
  23066. /**
  23067. * Creates the polygon
  23068. * @param updatable If the mesh should be updatable
  23069. * @param depth The depth of the mesh created
  23070. * @returns the created mesh
  23071. */
  23072. build(updatable?: boolean, depth?: number): Mesh;
  23073. /**
  23074. * Adds a side to the polygon
  23075. * @param positions points that make the polygon
  23076. * @param normals normals of the polygon
  23077. * @param uvs uvs of the polygon
  23078. * @param indices indices of the polygon
  23079. * @param bounds bounds of the polygon
  23080. * @param points points of the polygon
  23081. * @param depth depth of the polygon
  23082. * @param flip flip of the polygon
  23083. */
  23084. private addSide;
  23085. }
  23086. }
  23087. declare module BABYLON {
  23088. /**
  23089. * Class containing static functions to help procedurally build meshes
  23090. */
  23091. export class MeshBuilder {
  23092. private static _UpdateSideOrientation;
  23093. /**
  23094. * Creates a box mesh
  23095. * * The parameter `size` sets the size (float) of each box side (default 1)
  23096. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  23097. * * 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)
  23098. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  23099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23100. * * 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
  23101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23102. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  23103. * @param name defines the name of the mesh
  23104. * @param options defines the options used to create the mesh
  23105. * @param scene defines the hosting scene
  23106. * @returns the box mesh
  23107. */
  23108. static CreateBox(name: string, options: {
  23109. size?: number;
  23110. width?: number;
  23111. height?: number;
  23112. depth?: number;
  23113. faceUV?: Vector4[];
  23114. faceColors?: Color4[];
  23115. sideOrientation?: number;
  23116. frontUVs?: Vector4;
  23117. backUVs?: Vector4;
  23118. updatable?: boolean;
  23119. }, scene?: Nullable<Scene>): Mesh;
  23120. /**
  23121. * Creates a sphere mesh
  23122. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  23123. * * 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`)
  23124. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  23125. * * 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
  23126. * * 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)
  23127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23128. * * 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
  23129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23130. * @param name defines the name of the mesh
  23131. * @param options defines the options used to create the mesh
  23132. * @param scene defines the hosting scene
  23133. * @returns the sphere mesh
  23134. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  23135. */
  23136. static CreateSphere(name: string, options: {
  23137. segments?: number;
  23138. diameter?: number;
  23139. diameterX?: number;
  23140. diameterY?: number;
  23141. diameterZ?: number;
  23142. arc?: number;
  23143. slice?: number;
  23144. sideOrientation?: number;
  23145. frontUVs?: Vector4;
  23146. backUVs?: Vector4;
  23147. updatable?: boolean;
  23148. }, scene: any): Mesh;
  23149. /**
  23150. * Creates a plane polygonal mesh. By default, this is a disc
  23151. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23152. * * 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
  23153. * * 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
  23154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23155. * * 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
  23156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23157. * @param name defines the name of the mesh
  23158. * @param options defines the options used to create the mesh
  23159. * @param scene defines the hosting scene
  23160. * @returns the plane polygonal mesh
  23161. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23162. */
  23163. static CreateDisc(name: string, options: {
  23164. radius?: number;
  23165. tessellation?: number;
  23166. arc?: number;
  23167. updatable?: boolean;
  23168. sideOrientation?: number;
  23169. frontUVs?: Vector4;
  23170. backUVs?: Vector4;
  23171. }, scene?: Nullable<Scene>): Mesh;
  23172. /**
  23173. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  23174. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  23175. * * 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`)
  23176. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  23177. * * 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
  23178. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23179. * * 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
  23180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23181. * @param name defines the name of the mesh
  23182. * @param options defines the options used to create the mesh
  23183. * @param scene defines the hosting scene
  23184. * @returns the icosahedron mesh
  23185. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  23186. */
  23187. static CreateIcoSphere(name: string, options: {
  23188. radius?: number;
  23189. radiusX?: number;
  23190. radiusY?: number;
  23191. radiusZ?: number;
  23192. flat?: boolean;
  23193. subdivisions?: number;
  23194. sideOrientation?: number;
  23195. frontUVs?: Vector4;
  23196. backUVs?: Vector4;
  23197. updatable?: boolean;
  23198. }, scene: Scene): Mesh;
  23199. /**
  23200. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23201. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  23202. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  23203. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  23204. * * 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
  23205. * * 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
  23206. * * 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
  23207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23208. * * 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
  23209. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23210. * * 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
  23211. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  23212. * * 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
  23213. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  23214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23215. * @param name defines the name of the mesh
  23216. * @param options defines the options used to create the mesh
  23217. * @param scene defines the hosting scene
  23218. * @returns the ribbon mesh
  23219. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  23220. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  23221. */
  23222. static CreateRibbon(name: string, options: {
  23223. pathArray: Vector3[][];
  23224. closeArray?: boolean;
  23225. closePath?: boolean;
  23226. offset?: number;
  23227. updatable?: boolean;
  23228. sideOrientation?: number;
  23229. frontUVs?: Vector4;
  23230. backUVs?: Vector4;
  23231. instance?: Mesh;
  23232. invertUV?: boolean;
  23233. uvs?: Vector2[];
  23234. colors?: Color4[];
  23235. }, scene?: Nullable<Scene>): Mesh;
  23236. /**
  23237. * Creates a cylinder or a cone mesh
  23238. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  23239. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  23240. * * 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.
  23241. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  23242. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  23243. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  23244. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  23245. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  23246. * * 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).
  23247. * * 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
  23248. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  23249. * * 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
  23250. * * 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.
  23251. * * If `enclose` is false, a ring surface is one element.
  23252. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  23253. * * 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
  23254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23255. * * 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
  23256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23257. * @param name defines the name of the mesh
  23258. * @param options defines the options used to create the mesh
  23259. * @param scene defines the hosting scene
  23260. * @returns the cylinder mesh
  23261. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  23262. */
  23263. static CreateCylinder(name: string, options: {
  23264. height?: number;
  23265. diameterTop?: number;
  23266. diameterBottom?: number;
  23267. diameter?: number;
  23268. tessellation?: number;
  23269. subdivisions?: number;
  23270. arc?: number;
  23271. faceColors?: Color4[];
  23272. faceUV?: Vector4[];
  23273. updatable?: boolean;
  23274. hasRings?: boolean;
  23275. enclose?: boolean;
  23276. sideOrientation?: number;
  23277. frontUVs?: Vector4;
  23278. backUVs?: Vector4;
  23279. }, scene: any): Mesh;
  23280. /**
  23281. * Creates a torus mesh
  23282. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  23283. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  23284. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  23285. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23286. * * 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
  23287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23288. * @param name defines the name of the mesh
  23289. * @param options defines the options used to create the mesh
  23290. * @param scene defines the hosting scene
  23291. * @returns the torus mesh
  23292. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  23293. */
  23294. static CreateTorus(name: string, options: {
  23295. diameter?: number;
  23296. thickness?: number;
  23297. tessellation?: number;
  23298. updatable?: boolean;
  23299. sideOrientation?: number;
  23300. frontUVs?: Vector4;
  23301. backUVs?: Vector4;
  23302. }, scene: any): Mesh;
  23303. /**
  23304. * Creates a torus knot mesh
  23305. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  23306. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  23307. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  23308. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  23309. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23310. * * 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
  23311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23312. * @param name defines the name of the mesh
  23313. * @param options defines the options used to create the mesh
  23314. * @param scene defines the hosting scene
  23315. * @returns the torus knot mesh
  23316. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  23317. */
  23318. static CreateTorusKnot(name: string, options: {
  23319. radius?: number;
  23320. tube?: number;
  23321. radialSegments?: number;
  23322. tubularSegments?: number;
  23323. p?: number;
  23324. q?: number;
  23325. updatable?: boolean;
  23326. sideOrientation?: number;
  23327. frontUVs?: Vector4;
  23328. backUVs?: Vector4;
  23329. }, scene: any): Mesh;
  23330. /**
  23331. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  23332. * * 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
  23333. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  23334. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  23335. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  23336. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  23337. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  23338. * * 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
  23339. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  23340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23341. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  23342. * @param name defines the name of the new line system
  23343. * @param options defines the options used to create the line system
  23344. * @param scene defines the hosting scene
  23345. * @returns a new line system mesh
  23346. */
  23347. static CreateLineSystem(name: string, options: {
  23348. lines: Vector3[][];
  23349. updatable?: boolean;
  23350. instance?: Nullable<LinesMesh>;
  23351. colors?: Nullable<Color4[][]>;
  23352. useVertexAlpha?: boolean;
  23353. }, scene: Nullable<Scene>): LinesMesh;
  23354. /**
  23355. * Creates a line mesh
  23356. * 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
  23357. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23358. * * The parameter `points` is an array successive Vector3
  23359. * * 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
  23360. * * The optional parameter `colors` is an array of successive Color4, one per line point
  23361. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  23362. * * When updating an instance, remember that only point positions can change, not the number of points
  23363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23364. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  23365. * @param name defines the name of the new line system
  23366. * @param options defines the options used to create the line system
  23367. * @param scene defines the hosting scene
  23368. * @returns a new line mesh
  23369. */
  23370. static CreateLines(name: string, options: {
  23371. points: Vector3[];
  23372. updatable?: boolean;
  23373. instance?: Nullable<LinesMesh>;
  23374. colors?: Color4[];
  23375. useVertexAlpha?: boolean;
  23376. }, scene?: Nullable<Scene>): LinesMesh;
  23377. /**
  23378. * Creates a dashed line mesh
  23379. * * 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
  23380. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  23381. * * The parameter `points` is an array successive Vector3
  23382. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  23383. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  23384. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  23385. * * 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
  23386. * * When updating an instance, remember that only point positions can change, not the number of points
  23387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23388. * @param name defines the name of the mesh
  23389. * @param options defines the options used to create the mesh
  23390. * @param scene defines the hosting scene
  23391. * @returns the dashed line mesh
  23392. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  23393. */
  23394. static CreateDashedLines(name: string, options: {
  23395. points: Vector3[];
  23396. dashSize?: number;
  23397. gapSize?: number;
  23398. dashNb?: number;
  23399. updatable?: boolean;
  23400. instance?: LinesMesh;
  23401. }, scene?: Nullable<Scene>): LinesMesh;
  23402. /**
  23403. * 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.
  23404. * * 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.
  23405. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23406. * * 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.
  23407. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  23408. * * 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
  23409. * * 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
  23410. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  23411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23412. * * 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
  23413. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  23414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23415. * @param name defines the name of the mesh
  23416. * @param options defines the options used to create the mesh
  23417. * @param scene defines the hosting scene
  23418. * @returns the extruded shape mesh
  23419. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  23420. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23421. */
  23422. static ExtrudeShape(name: string, options: {
  23423. shape: Vector3[];
  23424. path: Vector3[];
  23425. scale?: number;
  23426. rotation?: number;
  23427. cap?: number;
  23428. updatable?: boolean;
  23429. sideOrientation?: number;
  23430. frontUVs?: Vector4;
  23431. backUVs?: Vector4;
  23432. instance?: Mesh;
  23433. invertUV?: boolean;
  23434. }, scene?: Nullable<Scene>): Mesh;
  23435. /**
  23436. * Creates an custom extruded shape mesh.
  23437. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  23438. * * 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.
  23439. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  23440. * * 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
  23441. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  23442. * * 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
  23443. * * It must returns a float value that will be the scale value applied to the shape on each path point
  23444. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  23445. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  23446. * * 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
  23447. * * 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
  23448. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  23449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23450. * * 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
  23451. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23453. * @param name defines the name of the mesh
  23454. * @param options defines the options used to create the mesh
  23455. * @param scene defines the hosting scene
  23456. * @returns the custom extruded shape mesh
  23457. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  23458. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  23459. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23460. */
  23461. static ExtrudeShapeCustom(name: string, options: {
  23462. shape: Vector3[];
  23463. path: Vector3[];
  23464. scaleFunction?: any;
  23465. rotationFunction?: any;
  23466. ribbonCloseArray?: boolean;
  23467. ribbonClosePath?: boolean;
  23468. cap?: number;
  23469. updatable?: boolean;
  23470. sideOrientation?: number;
  23471. frontUVs?: Vector4;
  23472. backUVs?: Vector4;
  23473. instance?: Mesh;
  23474. invertUV?: boolean;
  23475. }, scene: Scene): Mesh;
  23476. /**
  23477. * Creates lathe mesh.
  23478. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  23479. * * 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
  23480. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  23481. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  23482. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  23483. * * 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
  23484. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  23485. * * 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
  23486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23487. * * 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
  23488. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23490. * @param name defines the name of the mesh
  23491. * @param options defines the options used to create the mesh
  23492. * @param scene defines the hosting scene
  23493. * @returns the lathe mesh
  23494. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  23495. */
  23496. static CreateLathe(name: string, options: {
  23497. shape: Vector3[];
  23498. radius?: number;
  23499. tessellation?: number;
  23500. clip?: number;
  23501. arc?: number;
  23502. closed?: boolean;
  23503. updatable?: boolean;
  23504. sideOrientation?: number;
  23505. frontUVs?: Vector4;
  23506. backUVs?: Vector4;
  23507. cap?: number;
  23508. invertUV?: boolean;
  23509. }, scene: Scene): Mesh;
  23510. /**
  23511. * Creates a plane mesh
  23512. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  23513. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  23514. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  23515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23516. * * 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
  23517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23518. * @param name defines the name of the mesh
  23519. * @param options defines the options used to create the mesh
  23520. * @param scene defines the hosting scene
  23521. * @returns the plane mesh
  23522. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  23523. */
  23524. static CreatePlane(name: string, options: {
  23525. size?: number;
  23526. width?: number;
  23527. height?: number;
  23528. sideOrientation?: number;
  23529. frontUVs?: Vector4;
  23530. backUVs?: Vector4;
  23531. updatable?: boolean;
  23532. sourcePlane?: Plane;
  23533. }, scene: Scene): Mesh;
  23534. /**
  23535. * Creates a ground mesh
  23536. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  23537. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  23538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23539. * @param name defines the name of the mesh
  23540. * @param options defines the options used to create the mesh
  23541. * @param scene defines the hosting scene
  23542. * @returns the ground mesh
  23543. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  23544. */
  23545. static CreateGround(name: string, options: {
  23546. width?: number;
  23547. height?: number;
  23548. subdivisions?: number;
  23549. subdivisionsX?: number;
  23550. subdivisionsY?: number;
  23551. updatable?: boolean;
  23552. }, scene: any): Mesh;
  23553. /**
  23554. * Creates a tiled ground mesh
  23555. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  23556. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  23557. * * 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
  23558. * * 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
  23559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23560. * @param name defines the name of the mesh
  23561. * @param options defines the options used to create the mesh
  23562. * @param scene defines the hosting scene
  23563. * @returns the tiled ground mesh
  23564. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  23565. */
  23566. static CreateTiledGround(name: string, options: {
  23567. xmin: number;
  23568. zmin: number;
  23569. xmax: number;
  23570. zmax: number;
  23571. subdivisions?: {
  23572. w: number;
  23573. h: number;
  23574. };
  23575. precision?: {
  23576. w: number;
  23577. h: number;
  23578. };
  23579. updatable?: boolean;
  23580. }, scene: Scene): Mesh;
  23581. /**
  23582. * Creates a ground mesh from a height map
  23583. * * The parameter `url` sets the URL of the height map image resource.
  23584. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  23585. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  23586. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  23587. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  23588. * * 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.
  23589. * * 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).
  23590. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  23591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23592. * @param name defines the name of the mesh
  23593. * @param url defines the url to the height map
  23594. * @param options defines the options used to create the mesh
  23595. * @param scene defines the hosting scene
  23596. * @returns the ground mesh
  23597. * @see https://doc.babylonjs.com/babylon101/height_map
  23598. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  23599. */
  23600. static CreateGroundFromHeightMap(name: string, url: string, options: {
  23601. width?: number;
  23602. height?: number;
  23603. subdivisions?: number;
  23604. minHeight?: number;
  23605. maxHeight?: number;
  23606. colorFilter?: Color3;
  23607. alphaFilter?: number;
  23608. updatable?: boolean;
  23609. onReady?: (mesh: GroundMesh) => void;
  23610. }, scene: Scene): GroundMesh;
  23611. /**
  23612. * Creates a polygon mesh
  23613. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  23614. * * 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
  23615. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23617. * * 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)
  23618. * * Remember you can only change the shape positions, not their number when updating a polygon
  23619. * @param name defines the name of the mesh
  23620. * @param options defines the options used to create the mesh
  23621. * @param scene defines the hosting scene
  23622. * @returns the polygon mesh
  23623. */
  23624. static CreatePolygon(name: string, options: {
  23625. shape: Vector3[];
  23626. holes?: Vector3[][];
  23627. depth?: number;
  23628. faceUV?: Vector4[];
  23629. faceColors?: Color4[];
  23630. updatable?: boolean;
  23631. sideOrientation?: number;
  23632. frontUVs?: Vector4;
  23633. backUVs?: Vector4;
  23634. }, scene: Scene): Mesh;
  23635. /**
  23636. * Creates an extruded polygon mesh, with depth in the Y direction.
  23637. * * 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)
  23638. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  23639. * @param name defines the name of the mesh
  23640. * @param options defines the options used to create the mesh
  23641. * @param scene defines the hosting scene
  23642. * @returns the polygon mesh
  23643. */
  23644. static ExtrudePolygon(name: string, options: {
  23645. shape: Vector3[];
  23646. holes?: Vector3[][];
  23647. depth?: number;
  23648. faceUV?: Vector4[];
  23649. faceColors?: Color4[];
  23650. updatable?: boolean;
  23651. sideOrientation?: number;
  23652. frontUVs?: Vector4;
  23653. backUVs?: Vector4;
  23654. }, scene: Scene): Mesh;
  23655. /**
  23656. * Creates a tube mesh.
  23657. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  23658. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  23659. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  23660. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  23661. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  23662. * * 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)
  23663. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  23664. * * 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
  23665. * * 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
  23666. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23667. * * 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
  23668. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  23669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23670. * @param name defines the name of the mesh
  23671. * @param options defines the options used to create the mesh
  23672. * @param scene defines the hosting scene
  23673. * @returns the tube mesh
  23674. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  23675. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  23676. */
  23677. static CreateTube(name: string, options: {
  23678. path: Vector3[];
  23679. radius?: number;
  23680. tessellation?: number;
  23681. radiusFunction?: {
  23682. (i: number, distance: number): number;
  23683. };
  23684. cap?: number;
  23685. arc?: number;
  23686. updatable?: boolean;
  23687. sideOrientation?: number;
  23688. frontUVs?: Vector4;
  23689. backUVs?: Vector4;
  23690. instance?: Mesh;
  23691. invertUV?: boolean;
  23692. }, scene: Scene): Mesh;
  23693. /**
  23694. * Creates a polyhedron mesh
  23695. * * 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
  23696. * * The parameter `size` (positive float, default 1) sets the polygon size
  23697. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  23698. * * 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`
  23699. * * 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
  23700. * * 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)`)
  23701. * * 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
  23702. * * 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
  23703. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23704. * * 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
  23705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23706. * @param name defines the name of the mesh
  23707. * @param options defines the options used to create the mesh
  23708. * @param scene defines the hosting scene
  23709. * @returns the polyhedron mesh
  23710. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  23711. */
  23712. static CreatePolyhedron(name: string, options: {
  23713. type?: number;
  23714. size?: number;
  23715. sizeX?: number;
  23716. sizeY?: number;
  23717. sizeZ?: number;
  23718. custom?: any;
  23719. faceUV?: Vector4[];
  23720. faceColors?: Color4[];
  23721. flat?: boolean;
  23722. updatable?: boolean;
  23723. sideOrientation?: number;
  23724. frontUVs?: Vector4;
  23725. backUVs?: Vector4;
  23726. }, scene: Scene): Mesh;
  23727. /**
  23728. * Creates a decal mesh.
  23729. * 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
  23730. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  23731. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  23732. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  23733. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  23734. * @param name defines the name of the mesh
  23735. * @param sourceMesh defines the mesh where the decal must be applied
  23736. * @param options defines the options used to create the mesh
  23737. * @param scene defines the hosting scene
  23738. * @returns the decal mesh
  23739. * @see https://doc.babylonjs.com/how_to/decals
  23740. */
  23741. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  23742. position?: Vector3;
  23743. normal?: Vector3;
  23744. size?: Vector3;
  23745. angle?: number;
  23746. }): Mesh;
  23747. private static _ExtrudeShapeGeneric;
  23748. }
  23749. }
  23750. declare module BABYLON {
  23751. /**
  23752. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23753. *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.
  23754. * The SPS is also a particle system. It provides some methods to manage the particles.
  23755. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23756. *
  23757. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23758. */
  23759. export class SolidParticleSystem implements IDisposable {
  23760. /**
  23761. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23762. * Example : var p = SPS.particles[i];
  23763. */
  23764. particles: SolidParticle[];
  23765. /**
  23766. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23767. */
  23768. nbParticles: number;
  23769. /**
  23770. * If the particles must ever face the camera (default false). Useful for planar particles.
  23771. */
  23772. billboard: boolean;
  23773. /**
  23774. * Recompute normals when adding a shape
  23775. */
  23776. recomputeNormals: boolean;
  23777. /**
  23778. * This a counter ofr your own usage. It's not set by any SPS functions.
  23779. */
  23780. counter: number;
  23781. /**
  23782. * The SPS name. This name is also given to the underlying mesh.
  23783. */
  23784. name: string;
  23785. /**
  23786. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23787. */
  23788. mesh: Mesh;
  23789. /**
  23790. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23791. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23792. */
  23793. vars: any;
  23794. /**
  23795. * This array is populated when the SPS is set as 'pickable'.
  23796. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23797. * Each element of this array is an object `{idx: int, faceId: int}`.
  23798. * `idx` is the picked particle index in the `SPS.particles` array
  23799. * `faceId` is the picked face index counted within this particle.
  23800. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23801. */
  23802. pickedParticles: {
  23803. idx: number;
  23804. faceId: number;
  23805. }[];
  23806. /**
  23807. * This array is populated when `enableDepthSort` is set to true.
  23808. * Each element of this array is an instance of the class DepthSortedParticle.
  23809. */
  23810. depthSortedParticles: DepthSortedParticle[];
  23811. /**
  23812. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23813. * @hidden
  23814. */
  23815. _bSphereOnly: boolean;
  23816. /**
  23817. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23818. * @hidden
  23819. */
  23820. _bSphereRadiusFactor: number;
  23821. private _scene;
  23822. private _positions;
  23823. private _indices;
  23824. private _normals;
  23825. private _colors;
  23826. private _uvs;
  23827. private _indices32;
  23828. private _positions32;
  23829. private _normals32;
  23830. private _fixedNormal32;
  23831. private _colors32;
  23832. private _uvs32;
  23833. private _index;
  23834. private _updatable;
  23835. private _pickable;
  23836. private _isVisibilityBoxLocked;
  23837. private _alwaysVisible;
  23838. private _depthSort;
  23839. private _shapeCounter;
  23840. private _copy;
  23841. private _color;
  23842. private _computeParticleColor;
  23843. private _computeParticleTexture;
  23844. private _computeParticleRotation;
  23845. private _computeParticleVertex;
  23846. private _computeBoundingBox;
  23847. private _depthSortParticles;
  23848. private _camera;
  23849. private _mustUnrotateFixedNormals;
  23850. private _particlesIntersect;
  23851. private _needs32Bits;
  23852. /**
  23853. * Creates a SPS (Solid Particle System) object.
  23854. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23855. * @param scene (Scene) is the scene in which the SPS is added.
  23856. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23857. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23858. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23859. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23860. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23861. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23862. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23863. */
  23864. constructor(name: string, scene: Scene, options?: {
  23865. updatable?: boolean;
  23866. isPickable?: boolean;
  23867. enableDepthSort?: boolean;
  23868. particleIntersection?: boolean;
  23869. boundingSphereOnly?: boolean;
  23870. bSphereRadiusFactor?: number;
  23871. });
  23872. /**
  23873. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23874. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23875. * @returns the created mesh
  23876. */
  23877. buildMesh(): Mesh;
  23878. /**
  23879. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23880. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23881. * Thus the particles generated from `digest()` have their property `position` set yet.
  23882. * @param mesh ( Mesh ) is the mesh to be digested
  23883. * @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
  23884. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23885. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23886. * @returns the current SPS
  23887. */
  23888. digest(mesh: Mesh, options?: {
  23889. facetNb?: number;
  23890. number?: number;
  23891. delta?: number;
  23892. }): SolidParticleSystem;
  23893. private _unrotateFixedNormals;
  23894. private _resetCopy;
  23895. private _meshBuilder;
  23896. private _posToShape;
  23897. private _uvsToShapeUV;
  23898. private _addParticle;
  23899. /**
  23900. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23901. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23902. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23903. * @param nb (positive integer) the number of particles to be created from this model
  23904. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23905. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23906. * @returns the number of shapes in the system
  23907. */
  23908. addShape(mesh: Mesh, nb: number, options?: {
  23909. positionFunction?: any;
  23910. vertexFunction?: any;
  23911. }): number;
  23912. private _rebuildParticle;
  23913. /**
  23914. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23915. * @returns the SPS.
  23916. */
  23917. rebuildMesh(): SolidParticleSystem;
  23918. /**
  23919. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23920. * This method calls `updateParticle()` for each particle of the SPS.
  23921. * For an animated SPS, it is usually called within the render loop.
  23922. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23923. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23924. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23925. * @returns the SPS.
  23926. */
  23927. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23928. /**
  23929. * Disposes the SPS.
  23930. */
  23931. dispose(): void;
  23932. /**
  23933. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23934. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23935. * @returns the SPS.
  23936. */
  23937. refreshVisibleSize(): SolidParticleSystem;
  23938. /**
  23939. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23940. * @param size the size (float) of the visibility box
  23941. * note : this doesn't lock the SPS mesh bounding box.
  23942. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23943. */
  23944. setVisibilityBox(size: number): void;
  23945. /**
  23946. * Gets whether the SPS as always visible or not
  23947. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23948. */
  23949. /**
  23950. * Sets the SPS as always visible or not
  23951. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23952. */
  23953. isAlwaysVisible: boolean;
  23954. /**
  23955. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23956. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23957. */
  23958. /**
  23959. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23960. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23961. */
  23962. isVisibilityBoxLocked: boolean;
  23963. /**
  23964. * Tells to `setParticles()` to compute the particle rotations or not.
  23965. * Default value : true. The SPS is faster when it's set to false.
  23966. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23967. */
  23968. /**
  23969. * Gets if `setParticles()` computes the particle rotations or not.
  23970. * Default value : true. The SPS is faster when it's set to false.
  23971. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23972. */
  23973. computeParticleRotation: boolean;
  23974. /**
  23975. * Tells to `setParticles()` to compute the particle colors or not.
  23976. * Default value : true. The SPS is faster when it's set to false.
  23977. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23978. */
  23979. /**
  23980. * Gets if `setParticles()` computes the particle colors or not.
  23981. * Default value : true. The SPS is faster when it's set to false.
  23982. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23983. */
  23984. computeParticleColor: boolean;
  23985. /**
  23986. * Gets if `setParticles()` computes the particle textures or not.
  23987. * Default value : true. The SPS is faster when it's set to false.
  23988. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23989. */
  23990. computeParticleTexture: boolean;
  23991. /**
  23992. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23993. * Default value : false. The SPS is faster when it's set to false.
  23994. * Note : the particle custom vertex positions aren't stored values.
  23995. */
  23996. /**
  23997. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23998. * Default value : false. The SPS is faster when it's set to false.
  23999. * Note : the particle custom vertex positions aren't stored values.
  24000. */
  24001. computeParticleVertex: boolean;
  24002. /**
  24003. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24004. */
  24005. /**
  24006. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24007. */
  24008. computeBoundingBox: boolean;
  24009. /**
  24010. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24011. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24012. * Default : `true`
  24013. */
  24014. /**
  24015. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24016. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24017. * Default : `true`
  24018. */
  24019. depthSortParticles: boolean;
  24020. /**
  24021. * This function does nothing. It may be overwritten to set all the particle first values.
  24022. * The SPS doesn't call this function, you may have to call it by your own.
  24023. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24024. */
  24025. initParticles(): void;
  24026. /**
  24027. * This function does nothing. It may be overwritten to recycle a particle.
  24028. * The SPS doesn't call this function, you may have to call it by your own.
  24029. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24030. * @param particle The particle to recycle
  24031. * @returns the recycled particle
  24032. */
  24033. recycleParticle(particle: SolidParticle): SolidParticle;
  24034. /**
  24035. * Updates a particle : this function should be overwritten by the user.
  24036. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24037. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24038. * @example : just set a particle position or velocity and recycle conditions
  24039. * @param particle The particle to update
  24040. * @returns the updated particle
  24041. */
  24042. updateParticle(particle: SolidParticle): SolidParticle;
  24043. /**
  24044. * Updates a vertex of a particle : it can be overwritten by the user.
  24045. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24046. * @param particle the current particle
  24047. * @param vertex the current index of the current particle
  24048. * @param pt the index of the current vertex in the particle shape
  24049. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24050. * @example : just set a vertex particle position
  24051. * @returns the updated vertex
  24052. */
  24053. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24054. /**
  24055. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24056. * This does nothing and may be overwritten by the user.
  24057. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24058. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24059. * @param update the boolean update value actually passed to setParticles()
  24060. */
  24061. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24062. /**
  24063. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24064. * This will be passed three parameters.
  24065. * This does nothing and may be overwritten by the user.
  24066. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24067. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24068. * @param update the boolean update value actually passed to setParticles()
  24069. */
  24070. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24071. }
  24072. }
  24073. declare module BABYLON {
  24074. /**
  24075. * Represents one particle of a solid particle system.
  24076. */
  24077. export class SolidParticle {
  24078. /**
  24079. * particle global index
  24080. */
  24081. idx: number;
  24082. /**
  24083. * The color of the particle
  24084. */
  24085. color: Nullable<Color4>;
  24086. /**
  24087. * The world space position of the particle.
  24088. */
  24089. position: Vector3;
  24090. /**
  24091. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24092. */
  24093. rotation: Vector3;
  24094. /**
  24095. * The world space rotation quaternion of the particle.
  24096. */
  24097. rotationQuaternion: Nullable<Quaternion>;
  24098. /**
  24099. * The scaling of the particle.
  24100. */
  24101. scaling: Vector3;
  24102. /**
  24103. * The uvs of the particle.
  24104. */
  24105. uvs: Vector4;
  24106. /**
  24107. * The current speed of the particle.
  24108. */
  24109. velocity: Vector3;
  24110. /**
  24111. * The pivot point in the particle local space.
  24112. */
  24113. pivot: Vector3;
  24114. /**
  24115. * Must the particle be translated from its pivot point in its local space ?
  24116. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24117. * Default : false
  24118. */
  24119. translateFromPivot: boolean;
  24120. /**
  24121. * Is the particle active or not ?
  24122. */
  24123. alive: boolean;
  24124. /**
  24125. * Is the particle visible or not ?
  24126. */
  24127. isVisible: boolean;
  24128. /**
  24129. * Index of this particle in the global "positions" array (Internal use)
  24130. * @hidden
  24131. */
  24132. _pos: number;
  24133. /**
  24134. * @hidden Index of this particle in the global "indices" array (Internal use)
  24135. */
  24136. _ind: number;
  24137. /**
  24138. * @hidden ModelShape of this particle (Internal use)
  24139. */
  24140. _model: ModelShape;
  24141. /**
  24142. * ModelShape id of this particle
  24143. */
  24144. shapeId: number;
  24145. /**
  24146. * Index of the particle in its shape id (Internal use)
  24147. */
  24148. idxInShape: number;
  24149. /**
  24150. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24151. */
  24152. _modelBoundingInfo: BoundingInfo;
  24153. /**
  24154. * @hidden Particle BoundingInfo object (Internal use)
  24155. */
  24156. _boundingInfo: BoundingInfo;
  24157. /**
  24158. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24159. */
  24160. _sps: SolidParticleSystem;
  24161. /**
  24162. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24163. */
  24164. _stillInvisible: boolean;
  24165. /**
  24166. * @hidden Last computed particle rotation matrix
  24167. */
  24168. _rotationMatrix: number[];
  24169. /**
  24170. * Parent particle Id, if any.
  24171. * Default null.
  24172. */
  24173. parentId: Nullable<number>;
  24174. /**
  24175. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24176. * The possible values are :
  24177. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24178. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24179. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24180. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24181. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24182. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24183. * */
  24184. cullingStrategy: number;
  24185. /**
  24186. * @hidden Internal global position in the SPS.
  24187. */
  24188. _globalPosition: Vector3;
  24189. /**
  24190. * Creates a Solid Particle object.
  24191. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24192. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24193. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24194. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24195. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24196. * @param shapeId (integer) is the model shape identifier in the SPS.
  24197. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24198. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24199. */
  24200. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24201. /**
  24202. * Legacy support, changed scale to scaling
  24203. */
  24204. /**
  24205. * Legacy support, changed scale to scaling
  24206. */
  24207. scale: Vector3;
  24208. /**
  24209. * Legacy support, changed quaternion to rotationQuaternion
  24210. */
  24211. /**
  24212. * Legacy support, changed quaternion to rotationQuaternion
  24213. */
  24214. quaternion: Nullable<Quaternion>;
  24215. /**
  24216. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24217. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24218. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24219. * @returns true if it intersects
  24220. */
  24221. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24222. /**
  24223. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24224. * A particle is in the frustum if its bounding box intersects the frustum
  24225. * @param frustumPlanes defines the frustum to test
  24226. * @returns true if the particle is in the frustum planes
  24227. */
  24228. isInFrustum(frustumPlanes: Plane[]): boolean;
  24229. /**
  24230. * get the rotation matrix of the particle
  24231. * @hidden
  24232. */
  24233. getRotationMatrix(m: Matrix): void;
  24234. }
  24235. /**
  24236. * Represents the shape of the model used by one particle of a solid particle system.
  24237. * SPS internal tool, don't use it manually.
  24238. */
  24239. export class ModelShape {
  24240. /**
  24241. * The shape id
  24242. * @hidden
  24243. */
  24244. shapeID: number;
  24245. /**
  24246. * flat array of model positions (internal use)
  24247. * @hidden
  24248. */
  24249. _shape: Vector3[];
  24250. /**
  24251. * flat array of model UVs (internal use)
  24252. * @hidden
  24253. */
  24254. _shapeUV: number[];
  24255. /**
  24256. * length of the shape in the model indices array (internal use)
  24257. * @hidden
  24258. */
  24259. _indicesLength: number;
  24260. /**
  24261. * Custom position function (internal use)
  24262. * @hidden
  24263. */
  24264. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24265. /**
  24266. * Custom vertex function (internal use)
  24267. * @hidden
  24268. */
  24269. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24270. /**
  24271. * 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.
  24272. * SPS internal tool, don't use it manually.
  24273. * @hidden
  24274. */
  24275. 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>);
  24276. }
  24277. /**
  24278. * Represents a Depth Sorted Particle in the solid particle system.
  24279. */
  24280. export class DepthSortedParticle {
  24281. /**
  24282. * Index of the particle in the "indices" array
  24283. */
  24284. ind: number;
  24285. /**
  24286. * Length of the particle shape in the "indices" array
  24287. */
  24288. indicesLength: number;
  24289. /**
  24290. * Squared distance from the particle to the camera
  24291. */
  24292. sqDistance: number;
  24293. }
  24294. }
  24295. declare module BABYLON {
  24296. /**
  24297. * Class used to store all common mesh properties
  24298. */
  24299. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24300. /** No occlusion */
  24301. static OCCLUSION_TYPE_NONE: number;
  24302. /** Occlusion set to optimisitic */
  24303. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24304. /** Occlusion set to strict */
  24305. static OCCLUSION_TYPE_STRICT: number;
  24306. /** Use an accurante occlusion algorithm */
  24307. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24308. /** Use a conservative occlusion algorithm */
  24309. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24310. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24311. * Test order :
  24312. * Is the bounding sphere outside the frustum ?
  24313. * If not, are the bounding box vertices outside the frustum ?
  24314. * It not, then the cullable object is in the frustum.
  24315. */
  24316. static readonly CULLINGSTRATEGY_STANDARD: number;
  24317. /** Culling strategy : Bounding Sphere Only.
  24318. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24319. * It's also less accurate than the standard because some not visible objects can still be selected.
  24320. * Test : is the bounding sphere outside the frustum ?
  24321. * If not, then the cullable object is in the frustum.
  24322. */
  24323. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24324. /** Culling strategy : Optimistic Inclusion.
  24325. * This in an inclusion test first, then the standard exclusion test.
  24326. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24327. * 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.
  24328. * Anyway, it's as accurate as the standard strategy.
  24329. * Test :
  24330. * Is the cullable object bounding sphere center in the frustum ?
  24331. * If not, apply the default culling strategy.
  24332. */
  24333. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24334. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24335. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24336. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24337. * 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.
  24338. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24339. * Test :
  24340. * Is the cullable object bounding sphere center in the frustum ?
  24341. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24342. */
  24343. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24344. /**
  24345. * No billboard
  24346. */
  24347. static readonly BILLBOARDMODE_NONE: number;
  24348. /** Billboard on X axis */
  24349. static readonly BILLBOARDMODE_X: number;
  24350. /** Billboard on Y axis */
  24351. static readonly BILLBOARDMODE_Y: number;
  24352. /** Billboard on Z axis */
  24353. static readonly BILLBOARDMODE_Z: number;
  24354. /** Billboard on all axes */
  24355. static readonly BILLBOARDMODE_ALL: number;
  24356. private _facetData;
  24357. /**
  24358. * The culling strategy to use to check whether the mesh must be rendered or not.
  24359. * This value can be changed at any time and will be used on the next render mesh selection.
  24360. * The possible values are :
  24361. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24362. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24363. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24364. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24365. * Please read each static variable documentation to get details about the culling process.
  24366. * */
  24367. cullingStrategy: number;
  24368. /**
  24369. * Gets the number of facets in the mesh
  24370. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24371. */
  24372. readonly facetNb: number;
  24373. /**
  24374. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24375. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24376. */
  24377. partitioningSubdivisions: number;
  24378. /**
  24379. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24380. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24381. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24382. */
  24383. partitioningBBoxRatio: number;
  24384. /**
  24385. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24386. * Works only for updatable meshes.
  24387. * Doesn't work with multi-materials
  24388. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24389. */
  24390. mustDepthSortFacets: boolean;
  24391. /**
  24392. * The location (Vector3) where the facet depth sort must be computed from.
  24393. * By default, the active camera position.
  24394. * Used only when facet depth sort is enabled
  24395. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24396. */
  24397. facetDepthSortFrom: Vector3;
  24398. /**
  24399. * gets a boolean indicating if facetData is enabled
  24400. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24401. */
  24402. readonly isFacetDataEnabled: boolean;
  24403. /** @hidden */
  24404. _updateNonUniformScalingState(value: boolean): boolean;
  24405. /**
  24406. * An event triggered when this mesh collides with another one
  24407. */
  24408. onCollideObservable: Observable<AbstractMesh>;
  24409. private _onCollideObserver;
  24410. /** Set a function to call when this mesh collides with another one */
  24411. onCollide: () => void;
  24412. /**
  24413. * An event triggered when the collision's position changes
  24414. */
  24415. onCollisionPositionChangeObservable: Observable<Vector3>;
  24416. private _onCollisionPositionChangeObserver;
  24417. /** Set a function to call when the collision's position changes */
  24418. onCollisionPositionChange: () => void;
  24419. /**
  24420. * An event triggered when material is changed
  24421. */
  24422. onMaterialChangedObservable: Observable<AbstractMesh>;
  24423. /**
  24424. * Gets or sets the orientation for POV movement & rotation
  24425. */
  24426. definedFacingForward: boolean;
  24427. /** @hidden */
  24428. _occlusionQuery: Nullable<WebGLQuery>;
  24429. private _visibility;
  24430. /**
  24431. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24432. */
  24433. /**
  24434. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24435. */
  24436. visibility: number;
  24437. /** Gets or sets the alpha index used to sort transparent meshes
  24438. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24439. */
  24440. alphaIndex: number;
  24441. /**
  24442. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24443. */
  24444. isVisible: boolean;
  24445. /**
  24446. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24447. */
  24448. isPickable: boolean;
  24449. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24450. showSubMeshesBoundingBox: boolean;
  24451. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24452. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24453. */
  24454. isBlocker: boolean;
  24455. /**
  24456. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24457. */
  24458. enablePointerMoveEvents: boolean;
  24459. /**
  24460. * Specifies the rendering group id for this mesh (0 by default)
  24461. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24462. */
  24463. renderingGroupId: number;
  24464. private _material;
  24465. /** Gets or sets current material */
  24466. material: Nullable<Material>;
  24467. private _receiveShadows;
  24468. /**
  24469. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24470. * @see http://doc.babylonjs.com/babylon101/shadows
  24471. */
  24472. receiveShadows: boolean;
  24473. /** Defines color to use when rendering outline */
  24474. outlineColor: Color3;
  24475. /** Define width to use when rendering outline */
  24476. outlineWidth: number;
  24477. /** Defines color to use when rendering overlay */
  24478. overlayColor: Color3;
  24479. /** Defines alpha to use when rendering overlay */
  24480. overlayAlpha: number;
  24481. private _hasVertexAlpha;
  24482. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24483. hasVertexAlpha: boolean;
  24484. private _useVertexColors;
  24485. /** 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) */
  24486. useVertexColors: boolean;
  24487. private _computeBonesUsingShaders;
  24488. /**
  24489. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24490. */
  24491. computeBonesUsingShaders: boolean;
  24492. private _numBoneInfluencers;
  24493. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24494. numBoneInfluencers: number;
  24495. private _applyFog;
  24496. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24497. applyFog: boolean;
  24498. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24499. useOctreeForRenderingSelection: boolean;
  24500. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24501. useOctreeForPicking: boolean;
  24502. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24503. useOctreeForCollisions: boolean;
  24504. private _layerMask;
  24505. /**
  24506. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24507. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24508. */
  24509. layerMask: number;
  24510. /**
  24511. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24512. */
  24513. alwaysSelectAsActiveMesh: boolean;
  24514. /**
  24515. * Gets or sets the current action manager
  24516. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24517. */
  24518. actionManager: Nullable<ActionManager>;
  24519. private _checkCollisions;
  24520. private _collisionMask;
  24521. private _collisionGroup;
  24522. /**
  24523. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24524. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24525. */
  24526. ellipsoid: Vector3;
  24527. /**
  24528. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24529. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24530. */
  24531. ellipsoidOffset: Vector3;
  24532. private _collider;
  24533. private _oldPositionForCollisions;
  24534. private _diffPositionForCollisions;
  24535. /**
  24536. * Gets or sets a collision mask used to mask collisions (default is -1).
  24537. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24538. */
  24539. collisionMask: number;
  24540. /**
  24541. * Gets or sets the current collision group mask (-1 by default).
  24542. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24543. */
  24544. collisionGroup: number;
  24545. /**
  24546. * Defines edge width used when edgesRenderer is enabled
  24547. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24548. */
  24549. edgesWidth: number;
  24550. /**
  24551. * Defines edge color used when edgesRenderer is enabled
  24552. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24553. */
  24554. edgesColor: Color4;
  24555. /** @hidden */
  24556. _edgesRenderer: Nullable<IEdgesRenderer>;
  24557. /** @hidden */
  24558. _masterMesh: Nullable<AbstractMesh>;
  24559. /** @hidden */
  24560. _boundingInfo: Nullable<BoundingInfo>;
  24561. /** @hidden */
  24562. _renderId: number;
  24563. /**
  24564. * Gets or sets the list of subMeshes
  24565. * @see http://doc.babylonjs.com/how_to/multi_materials
  24566. */
  24567. subMeshes: SubMesh[];
  24568. /** @hidden */
  24569. _intersectionsInProgress: AbstractMesh[];
  24570. /** @hidden */
  24571. _unIndexed: boolean;
  24572. /** @hidden */
  24573. _lightSources: Light[];
  24574. /** @hidden */
  24575. readonly _positions: Nullable<Vector3[]>;
  24576. /** @hidden */
  24577. _waitingActions: any;
  24578. /** @hidden */
  24579. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24580. private _skeleton;
  24581. /** @hidden */
  24582. _bonesTransformMatrices: Nullable<Float32Array>;
  24583. /**
  24584. * Gets or sets a skeleton to apply skining transformations
  24585. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24586. */
  24587. skeleton: Nullable<Skeleton>;
  24588. /**
  24589. * An event triggered when the mesh is rebuilt.
  24590. */
  24591. onRebuildObservable: Observable<AbstractMesh>;
  24592. /**
  24593. * Creates a new AbstractMesh
  24594. * @param name defines the name of the mesh
  24595. * @param scene defines the hosting scene
  24596. */
  24597. constructor(name: string, scene?: Nullable<Scene>);
  24598. /**
  24599. * Returns the string "AbstractMesh"
  24600. * @returns "AbstractMesh"
  24601. */
  24602. getClassName(): string;
  24603. /**
  24604. * Gets a string representation of the current mesh
  24605. * @param fullDetails defines a boolean indicating if full details must be included
  24606. * @returns a string representation of the current mesh
  24607. */
  24608. toString(fullDetails?: boolean): string;
  24609. /** @hidden */
  24610. _rebuild(): void;
  24611. /** @hidden */
  24612. _resyncLightSources(): void;
  24613. /** @hidden */
  24614. _resyncLighSource(light: Light): void;
  24615. /** @hidden */
  24616. _unBindEffect(): void;
  24617. /** @hidden */
  24618. _removeLightSource(light: Light): void;
  24619. private _markSubMeshesAsDirty;
  24620. /** @hidden */
  24621. _markSubMeshesAsLightDirty(): void;
  24622. /** @hidden */
  24623. _markSubMeshesAsAttributesDirty(): void;
  24624. /** @hidden */
  24625. _markSubMeshesAsMiscDirty(): void;
  24626. /**
  24627. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24628. */
  24629. scaling: Vector3;
  24630. /**
  24631. * Returns true if the mesh is blocked. Implemented by child classes
  24632. */
  24633. readonly isBlocked: boolean;
  24634. /**
  24635. * Returns the mesh itself by default. Implemented by child classes
  24636. * @param camera defines the camera to use to pick the right LOD level
  24637. * @returns the currentAbstractMesh
  24638. */
  24639. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24640. /**
  24641. * Returns 0 by default. Implemented by child classes
  24642. * @returns an integer
  24643. */
  24644. getTotalVertices(): number;
  24645. /**
  24646. * Returns a positive integer : the total number of indices in this mesh geometry.
  24647. * @returns the numner of indices or zero if the mesh has no geometry.
  24648. */
  24649. getTotalIndices(): number;
  24650. /**
  24651. * Returns null by default. Implemented by child classes
  24652. * @returns null
  24653. */
  24654. getIndices(): Nullable<IndicesArray>;
  24655. /**
  24656. * Returns the array of the requested vertex data kind. Implemented by child classes
  24657. * @param kind defines the vertex data kind to use
  24658. * @returns null
  24659. */
  24660. getVerticesData(kind: string): Nullable<FloatArray>;
  24661. /**
  24662. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24663. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24664. * Note that a new underlying VertexBuffer object is created each call.
  24665. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24666. * @param kind defines vertex data kind:
  24667. * * VertexBuffer.PositionKind
  24668. * * VertexBuffer.UVKind
  24669. * * VertexBuffer.UV2Kind
  24670. * * VertexBuffer.UV3Kind
  24671. * * VertexBuffer.UV4Kind
  24672. * * VertexBuffer.UV5Kind
  24673. * * VertexBuffer.UV6Kind
  24674. * * VertexBuffer.ColorKind
  24675. * * VertexBuffer.MatricesIndicesKind
  24676. * * VertexBuffer.MatricesIndicesExtraKind
  24677. * * VertexBuffer.MatricesWeightsKind
  24678. * * VertexBuffer.MatricesWeightsExtraKind
  24679. * @param data defines the data source
  24680. * @param updatable defines if the data must be flagged as updatable (or static)
  24681. * @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
  24682. * @returns the current mesh
  24683. */
  24684. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24685. /**
  24686. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24687. * If the mesh has no geometry, it is simply returned as it is.
  24688. * @param kind defines vertex data kind:
  24689. * * VertexBuffer.PositionKind
  24690. * * VertexBuffer.UVKind
  24691. * * VertexBuffer.UV2Kind
  24692. * * VertexBuffer.UV3Kind
  24693. * * VertexBuffer.UV4Kind
  24694. * * VertexBuffer.UV5Kind
  24695. * * VertexBuffer.UV6Kind
  24696. * * VertexBuffer.ColorKind
  24697. * * VertexBuffer.MatricesIndicesKind
  24698. * * VertexBuffer.MatricesIndicesExtraKind
  24699. * * VertexBuffer.MatricesWeightsKind
  24700. * * VertexBuffer.MatricesWeightsExtraKind
  24701. * @param data defines the data source
  24702. * @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
  24703. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24704. * @returns the current mesh
  24705. */
  24706. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24707. /**
  24708. * Sets the mesh indices,
  24709. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24710. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24711. * @param totalVertices Defines the total number of vertices
  24712. * @returns the current mesh
  24713. */
  24714. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24715. /**
  24716. * Gets a boolean indicating if specific vertex data is present
  24717. * @param kind defines the vertex data kind to use
  24718. * @returns true is data kind is present
  24719. */
  24720. isVerticesDataPresent(kind: string): boolean;
  24721. /**
  24722. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24723. * @returns a BoundingInfo
  24724. */
  24725. getBoundingInfo(): BoundingInfo;
  24726. /**
  24727. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24728. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24729. * @returns the current mesh
  24730. */
  24731. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24732. /**
  24733. * Overwrite the current bounding info
  24734. * @param boundingInfo defines the new bounding info
  24735. * @returns the current mesh
  24736. */
  24737. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24738. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24739. readonly useBones: boolean;
  24740. /** @hidden */
  24741. _preActivate(): void;
  24742. /** @hidden */
  24743. _preActivateForIntermediateRendering(renderId: number): void;
  24744. /** @hidden */
  24745. _activate(renderId: number): void;
  24746. /**
  24747. * Gets the current world matrix
  24748. * @returns a Matrix
  24749. */
  24750. getWorldMatrix(): Matrix;
  24751. /** @hidden */
  24752. _getWorldMatrixDeterminant(): number;
  24753. /**
  24754. * Perform relative position change from the point of view of behind the front of the mesh.
  24755. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24756. * Supports definition of mesh facing forward or backward
  24757. * @param amountRight defines the distance on the right axis
  24758. * @param amountUp defines the distance on the up axis
  24759. * @param amountForward defines the distance on the forward axis
  24760. * @returns the current mesh
  24761. */
  24762. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24763. /**
  24764. * Calculate relative position change from the point of view of behind the front of the mesh.
  24765. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24766. * Supports definition of mesh facing forward or backward
  24767. * @param amountRight defines the distance on the right axis
  24768. * @param amountUp defines the distance on the up axis
  24769. * @param amountForward defines the distance on the forward axis
  24770. * @returns the new displacement vector
  24771. */
  24772. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24773. /**
  24774. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24775. * Supports definition of mesh facing forward or backward
  24776. * @param flipBack defines the flip
  24777. * @param twirlClockwise defines the twirl
  24778. * @param tiltRight defines the tilt
  24779. * @returns the current mesh
  24780. */
  24781. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24782. /**
  24783. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24784. * Supports definition of mesh facing forward or backward.
  24785. * @param flipBack defines the flip
  24786. * @param twirlClockwise defines the twirl
  24787. * @param tiltRight defines the tilt
  24788. * @returns the new rotation vector
  24789. */
  24790. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24791. /**
  24792. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24793. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24794. * @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
  24795. * @returns the new bounding vectors
  24796. */
  24797. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24798. min: Vector3;
  24799. max: Vector3;
  24800. };
  24801. /**
  24802. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24803. * This means the mesh underlying bounding box and sphere are recomputed.
  24804. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24805. * @returns the current mesh
  24806. */
  24807. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24808. /** @hidden */
  24809. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24810. /** @hidden */
  24811. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24812. /** @hidden */
  24813. _updateBoundingInfo(): AbstractMesh;
  24814. /** @hidden */
  24815. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24816. /** @hidden */
  24817. protected _afterComputeWorldMatrix(): void;
  24818. /**
  24819. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24820. * A mesh is in the frustum if its bounding box intersects the frustum
  24821. * @param frustumPlanes defines the frustum to test
  24822. * @returns true if the mesh is in the frustum planes
  24823. */
  24824. isInFrustum(frustumPlanes: Plane[]): boolean;
  24825. /**
  24826. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24827. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24828. * @param frustumPlanes defines the frustum to test
  24829. * @returns true if the mesh is completely in the frustum planes
  24830. */
  24831. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24832. /**
  24833. * True if the mesh intersects another mesh or a SolidParticle object
  24834. * @param mesh defines a target mesh or SolidParticle to test
  24835. * @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)
  24836. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24837. * @returns true if there is an intersection
  24838. */
  24839. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24840. /**
  24841. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24842. * @param point defines the point to test
  24843. * @returns true if there is an intersection
  24844. */
  24845. intersectsPoint(point: Vector3): boolean;
  24846. /**
  24847. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24848. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24849. */
  24850. checkCollisions: boolean;
  24851. /**
  24852. * Gets Collider object used to compute collisions (not physics)
  24853. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24854. */
  24855. readonly collider: Collider;
  24856. /**
  24857. * Move the mesh using collision engine
  24858. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24859. * @param displacement defines the requested displacement vector
  24860. * @returns the current mesh
  24861. */
  24862. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24863. private _onCollisionPositionChange;
  24864. /** @hidden */
  24865. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24866. /** @hidden */
  24867. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24868. /** @hidden */
  24869. _checkCollision(collider: Collider): AbstractMesh;
  24870. /** @hidden */
  24871. _generatePointsArray(): boolean;
  24872. /**
  24873. * Checks if the passed Ray intersects with the mesh
  24874. * @param ray defines the ray to use
  24875. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24876. * @returns the picking info
  24877. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24878. */
  24879. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24880. /**
  24881. * Clones the current mesh
  24882. * @param name defines the mesh name
  24883. * @param newParent defines the new mesh parent
  24884. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24885. * @returns the new mesh
  24886. */
  24887. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24888. /**
  24889. * Disposes all the submeshes of the current meshnp
  24890. * @returns the current mesh
  24891. */
  24892. releaseSubMeshes(): AbstractMesh;
  24893. /**
  24894. * Releases resources associated with this abstract mesh.
  24895. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24896. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24897. */
  24898. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24899. /**
  24900. * Adds the passed mesh as a child to the current mesh
  24901. * @param mesh defines the child mesh
  24902. * @returns the current mesh
  24903. */
  24904. addChild(mesh: AbstractMesh): AbstractMesh;
  24905. /**
  24906. * Removes the passed mesh from the current mesh children list
  24907. * @param mesh defines the child mesh
  24908. * @returns the current mesh
  24909. */
  24910. removeChild(mesh: AbstractMesh): AbstractMesh;
  24911. /** @hidden */
  24912. private _initFacetData;
  24913. /**
  24914. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24915. * This method can be called within the render loop.
  24916. * 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
  24917. * @returns the current mesh
  24918. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24919. */
  24920. updateFacetData(): AbstractMesh;
  24921. /**
  24922. * Returns the facetLocalNormals array.
  24923. * The normals are expressed in the mesh local spac
  24924. * @returns an array of Vector3
  24925. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24926. */
  24927. getFacetLocalNormals(): Vector3[];
  24928. /**
  24929. * Returns the facetLocalPositions array.
  24930. * The facet positions are expressed in the mesh local space
  24931. * @returns an array of Vector3
  24932. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24933. */
  24934. getFacetLocalPositions(): Vector3[];
  24935. /**
  24936. * Returns the facetLocalPartioning array
  24937. * @returns an array of array of numbers
  24938. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24939. */
  24940. getFacetLocalPartitioning(): number[][];
  24941. /**
  24942. * Returns the i-th facet position in the world system.
  24943. * This method allocates a new Vector3 per call
  24944. * @param i defines the facet index
  24945. * @returns a new Vector3
  24946. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24947. */
  24948. getFacetPosition(i: number): Vector3;
  24949. /**
  24950. * Sets the reference Vector3 with the i-th facet position in the world system
  24951. * @param i defines the facet index
  24952. * @param ref defines the target vector
  24953. * @returns the current mesh
  24954. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24955. */
  24956. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24957. /**
  24958. * Returns the i-th facet normal in the world system.
  24959. * This method allocates a new Vector3 per call
  24960. * @param i defines the facet index
  24961. * @returns a new Vector3
  24962. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24963. */
  24964. getFacetNormal(i: number): Vector3;
  24965. /**
  24966. * Sets the reference Vector3 with the i-th facet normal in the world system
  24967. * @param i defines the facet index
  24968. * @param ref defines the target vector
  24969. * @returns the current mesh
  24970. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24971. */
  24972. getFacetNormalToRef(i: number, ref: Vector3): this;
  24973. /**
  24974. * 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)
  24975. * @param x defines x coordinate
  24976. * @param y defines y coordinate
  24977. * @param z defines z coordinate
  24978. * @returns the array of facet indexes
  24979. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24980. */
  24981. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24982. /**
  24983. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24984. * @param projected sets as the (x,y,z) world projection on the facet
  24985. * @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
  24986. * @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
  24987. * @param x defines x coordinate
  24988. * @param y defines y coordinate
  24989. * @param z defines z coordinate
  24990. * @returns the face index if found (or null instead)
  24991. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24992. */
  24993. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24994. /**
  24995. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24996. * @param projected sets as the (x,y,z) local projection on the facet
  24997. * @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
  24998. * @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
  24999. * @param x defines x coordinate
  25000. * @param y defines y coordinate
  25001. * @param z defines z coordinate
  25002. * @returns the face index if found (or null instead)
  25003. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25004. */
  25005. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25006. /**
  25007. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25008. * @returns the parameters
  25009. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25010. */
  25011. getFacetDataParameters(): any;
  25012. /**
  25013. * Disables the feature FacetData and frees the related memory
  25014. * @returns the current mesh
  25015. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25016. */
  25017. disableFacetData(): AbstractMesh;
  25018. /**
  25019. * Updates the AbstractMesh indices array
  25020. * @param indices defines the data source
  25021. * @returns the current mesh
  25022. */
  25023. updateIndices(indices: IndicesArray): AbstractMesh;
  25024. /**
  25025. * Creates new normals data for the mesh
  25026. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25027. * @returns the current mesh
  25028. */
  25029. createNormals(updatable: boolean): AbstractMesh;
  25030. /**
  25031. * Align the mesh with a normal
  25032. * @param normal defines the normal to use
  25033. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25034. * @returns the current mesh
  25035. */
  25036. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25037. /** @hidden */
  25038. _checkOcclusionQuery(): boolean;
  25039. }
  25040. }
  25041. declare module BABYLON {
  25042. /**
  25043. * Defines how a node can be built from a string name.
  25044. */
  25045. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25046. /**
  25047. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25048. */
  25049. export class Node implements IBehaviorAware<Node> {
  25050. /** @hidden */
  25051. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  25052. private static _NodeConstructors;
  25053. /**
  25054. * Add a new node constructor
  25055. * @param type defines the type name of the node to construct
  25056. * @param constructorFunc defines the constructor function
  25057. */
  25058. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25059. /**
  25060. * Returns a node constructor based on type name
  25061. * @param type defines the type name
  25062. * @param name defines the new node name
  25063. * @param scene defines the hosting scene
  25064. * @param options defines optional options to transmit to constructors
  25065. * @returns the new constructor or null
  25066. */
  25067. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25068. /**
  25069. * Gets or sets the name of the node
  25070. */
  25071. name: string;
  25072. /**
  25073. * Gets or sets the id of the node
  25074. */
  25075. id: string;
  25076. /**
  25077. * Gets or sets the unique id of the node
  25078. */
  25079. uniqueId: number;
  25080. /**
  25081. * Gets or sets a string used to store user defined state for the node
  25082. */
  25083. state: string;
  25084. /**
  25085. * Gets or sets an object used to store user defined information for the node
  25086. */
  25087. metadata: any;
  25088. /**
  25089. * For internal use only. Please do not use.
  25090. */
  25091. reservedDataStore: any;
  25092. /**
  25093. * Gets or sets a boolean used to define if the node must be serialized
  25094. */
  25095. doNotSerialize: boolean;
  25096. /** @hidden */
  25097. _isDisposed: boolean;
  25098. /**
  25099. * Gets a list of Animations associated with the node
  25100. */
  25101. animations: Animation[];
  25102. protected _ranges: {
  25103. [name: string]: Nullable<AnimationRange>;
  25104. };
  25105. /**
  25106. * Callback raised when the node is ready to be used
  25107. */
  25108. onReady: (node: Node) => void;
  25109. private _isEnabled;
  25110. private _isParentEnabled;
  25111. private _isReady;
  25112. /** @hidden */
  25113. _currentRenderId: number;
  25114. private _parentRenderId;
  25115. protected _childRenderId: number;
  25116. /** @hidden */
  25117. _waitingParentId: Nullable<string>;
  25118. /** @hidden */
  25119. _scene: Scene;
  25120. /** @hidden */
  25121. _cache: any;
  25122. private _parentNode;
  25123. private _children;
  25124. /** @hidden */
  25125. _worldMatrix: Matrix;
  25126. /** @hidden */
  25127. _worldMatrixDeterminant: number;
  25128. /** @hidden */
  25129. private _sceneRootNodesIndex;
  25130. /**
  25131. * Gets a boolean indicating if the node has been disposed
  25132. * @returns true if the node was disposed
  25133. */
  25134. isDisposed(): boolean;
  25135. /**
  25136. * Gets or sets the parent of the node
  25137. */
  25138. parent: Nullable<Node>;
  25139. private addToSceneRootNodes;
  25140. private removeFromSceneRootNodes;
  25141. private _animationPropertiesOverride;
  25142. /**
  25143. * Gets or sets the animation properties override
  25144. */
  25145. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25146. /**
  25147. * Gets a string idenfifying the name of the class
  25148. * @returns "Node" string
  25149. */
  25150. getClassName(): string;
  25151. /** @hidden */
  25152. readonly _isNode: boolean;
  25153. /**
  25154. * An event triggered when the mesh is disposed
  25155. */
  25156. onDisposeObservable: Observable<Node>;
  25157. private _onDisposeObserver;
  25158. /**
  25159. * Sets a callback that will be raised when the node will be disposed
  25160. */
  25161. onDispose: () => void;
  25162. /**
  25163. * Creates a new Node
  25164. * @param name the name and id to be given to this node
  25165. * @param scene the scene this node will be added to
  25166. * @param addToRootNodes the node will be added to scene.rootNodes
  25167. */
  25168. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25169. /**
  25170. * Gets the scene of the node
  25171. * @returns a scene
  25172. */
  25173. getScene(): Scene;
  25174. /**
  25175. * Gets the engine of the node
  25176. * @returns a Engine
  25177. */
  25178. getEngine(): Engine;
  25179. private _behaviors;
  25180. /**
  25181. * Attach a behavior to the node
  25182. * @see http://doc.babylonjs.com/features/behaviour
  25183. * @param behavior defines the behavior to attach
  25184. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25185. * @returns the current Node
  25186. */
  25187. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25188. /**
  25189. * Remove an attached behavior
  25190. * @see http://doc.babylonjs.com/features/behaviour
  25191. * @param behavior defines the behavior to attach
  25192. * @returns the current Node
  25193. */
  25194. removeBehavior(behavior: Behavior<Node>): Node;
  25195. /**
  25196. * Gets the list of attached behaviors
  25197. * @see http://doc.babylonjs.com/features/behaviour
  25198. */
  25199. readonly behaviors: Behavior<Node>[];
  25200. /**
  25201. * Gets an attached behavior by name
  25202. * @param name defines the name of the behavior to look for
  25203. * @see http://doc.babylonjs.com/features/behaviour
  25204. * @returns null if behavior was not found else the requested behavior
  25205. */
  25206. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25207. /**
  25208. * Returns the latest update of the World matrix
  25209. * @returns a Matrix
  25210. */
  25211. getWorldMatrix(): Matrix;
  25212. /** @hidden */
  25213. _getWorldMatrixDeterminant(): number;
  25214. /**
  25215. * Returns directly the latest state of the mesh World matrix.
  25216. * A Matrix is returned.
  25217. */
  25218. readonly worldMatrixFromCache: Matrix;
  25219. /** @hidden */
  25220. _initCache(): void;
  25221. /** @hidden */
  25222. updateCache(force?: boolean): void;
  25223. /** @hidden */
  25224. _updateCache(ignoreParentClass?: boolean): void;
  25225. /** @hidden */
  25226. _isSynchronized(): boolean;
  25227. /** @hidden */
  25228. _markSyncedWithParent(): void;
  25229. /** @hidden */
  25230. isSynchronizedWithParent(): boolean;
  25231. /** @hidden */
  25232. isSynchronized(): boolean;
  25233. /**
  25234. * Is this node ready to be used/rendered
  25235. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25236. * @return true if the node is ready
  25237. */
  25238. isReady(completeCheck?: boolean): boolean;
  25239. /**
  25240. * Is this node enabled?
  25241. * 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
  25242. * @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
  25243. * @return whether this node (and its parent) is enabled
  25244. */
  25245. isEnabled(checkAncestors?: boolean): boolean;
  25246. /** @hidden */
  25247. protected _syncParentEnabledState(): void;
  25248. /**
  25249. * Set the enabled state of this node
  25250. * @param value defines the new enabled state
  25251. */
  25252. setEnabled(value: boolean): void;
  25253. /**
  25254. * Is this node a descendant of the given node?
  25255. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25256. * @param ancestor defines the parent node to inspect
  25257. * @returns a boolean indicating if this node is a descendant of the given node
  25258. */
  25259. isDescendantOf(ancestor: Node): boolean;
  25260. /** @hidden */
  25261. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25262. /**
  25263. * Will return all nodes that have this node as ascendant
  25264. * @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
  25265. * @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
  25266. * @return all children nodes of all types
  25267. */
  25268. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25269. /**
  25270. * Get all child-meshes of this node
  25271. * @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
  25272. * @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
  25273. * @returns an array of AbstractMesh
  25274. */
  25275. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25276. /**
  25277. * Get all direct children of this node
  25278. * @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
  25279. * @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)
  25280. * @returns an array of Node
  25281. */
  25282. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25283. /** @hidden */
  25284. _setReady(state: boolean): void;
  25285. /**
  25286. * Get an animation by name
  25287. * @param name defines the name of the animation to look for
  25288. * @returns null if not found else the requested animation
  25289. */
  25290. getAnimationByName(name: string): Nullable<Animation>;
  25291. /**
  25292. * Creates an animation range for this node
  25293. * @param name defines the name of the range
  25294. * @param from defines the starting key
  25295. * @param to defines the end key
  25296. */
  25297. createAnimationRange(name: string, from: number, to: number): void;
  25298. /**
  25299. * Delete a specific animation range
  25300. * @param name defines the name of the range to delete
  25301. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25302. */
  25303. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25304. /**
  25305. * Get an animation range by name
  25306. * @param name defines the name of the animation range to look for
  25307. * @returns null if not found else the requested animation range
  25308. */
  25309. getAnimationRange(name: string): Nullable<AnimationRange>;
  25310. /**
  25311. * Will start the animation sequence
  25312. * @param name defines the range frames for animation sequence
  25313. * @param loop defines if the animation should loop (false by default)
  25314. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25315. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25316. * @returns the object created for this animation. If range does not exist, it will return null
  25317. */
  25318. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25319. /**
  25320. * Serialize animation ranges into a JSON compatible object
  25321. * @returns serialization object
  25322. */
  25323. serializeAnimationRanges(): any;
  25324. /**
  25325. * Computes the world matrix of the node
  25326. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25327. * @returns the world matrix
  25328. */
  25329. computeWorldMatrix(force?: boolean): Matrix;
  25330. /**
  25331. * Releases resources associated with this node.
  25332. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25333. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25334. */
  25335. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25336. /**
  25337. * Parse animation range data from a serialization object and store them into a given node
  25338. * @param node defines where to store the animation ranges
  25339. * @param parsedNode defines the serialization object to read data from
  25340. * @param scene defines the hosting scene
  25341. */
  25342. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25343. }
  25344. }
  25345. declare module BABYLON {
  25346. /**
  25347. * Represents the range of an animation
  25348. */
  25349. export class AnimationRange {
  25350. /**The name of the animation range**/
  25351. name: string;
  25352. /**The starting frame of the animation */
  25353. from: number;
  25354. /**The ending frame of the animation*/
  25355. to: number;
  25356. /**
  25357. * Initializes the range of an animation
  25358. * @param name The name of the animation range
  25359. * @param from The starting frame of the animation
  25360. * @param to The ending frame of the animation
  25361. */
  25362. constructor(
  25363. /**The name of the animation range**/
  25364. name: string,
  25365. /**The starting frame of the animation */
  25366. from: number,
  25367. /**The ending frame of the animation*/
  25368. to: number);
  25369. /**
  25370. * Makes a copy of the animation range
  25371. * @returns A copy of the animation range
  25372. */
  25373. clone(): AnimationRange;
  25374. }
  25375. /**
  25376. * Composed of a frame, and an action function
  25377. */
  25378. export class AnimationEvent {
  25379. /** The frame for which the event is triggered **/
  25380. frame: number;
  25381. /** The event to perform when triggered **/
  25382. action: (currentFrame: number) => void;
  25383. /** Specifies if the event should be triggered only once**/
  25384. onlyOnce?: boolean | undefined;
  25385. /**
  25386. * Specifies if the animation event is done
  25387. */
  25388. isDone: boolean;
  25389. /**
  25390. * Initializes the animation event
  25391. * @param frame The frame for which the event is triggered
  25392. * @param action The event to perform when triggered
  25393. * @param onlyOnce Specifies if the event should be triggered only once
  25394. */
  25395. constructor(
  25396. /** The frame for which the event is triggered **/
  25397. frame: number,
  25398. /** The event to perform when triggered **/
  25399. action: (currentFrame: number) => void,
  25400. /** Specifies if the event should be triggered only once**/
  25401. onlyOnce?: boolean | undefined);
  25402. /** @hidden */
  25403. _clone(): AnimationEvent;
  25404. }
  25405. /**
  25406. * A cursor which tracks a point on a path
  25407. */
  25408. export class PathCursor {
  25409. private path;
  25410. /**
  25411. * Stores path cursor callbacks for when an onchange event is triggered
  25412. */
  25413. private _onchange;
  25414. /**
  25415. * The value of the path cursor
  25416. */
  25417. value: number;
  25418. /**
  25419. * The animation array of the path cursor
  25420. */
  25421. animations: Animation[];
  25422. /**
  25423. * Initializes the path cursor
  25424. * @param path The path to track
  25425. */
  25426. constructor(path: Path2);
  25427. /**
  25428. * Gets the cursor point on the path
  25429. * @returns A point on the path cursor at the cursor location
  25430. */
  25431. getPoint(): Vector3;
  25432. /**
  25433. * Moves the cursor ahead by the step amount
  25434. * @param step The amount to move the cursor forward
  25435. * @returns This path cursor
  25436. */
  25437. moveAhead(step?: number): PathCursor;
  25438. /**
  25439. * Moves the cursor behind by the step amount
  25440. * @param step The amount to move the cursor back
  25441. * @returns This path cursor
  25442. */
  25443. moveBack(step?: number): PathCursor;
  25444. /**
  25445. * Moves the cursor by the step amount
  25446. * If the step amount is greater than one, an exception is thrown
  25447. * @param step The amount to move the cursor
  25448. * @returns This path cursor
  25449. */
  25450. move(step: number): PathCursor;
  25451. /**
  25452. * Ensures that the value is limited between zero and one
  25453. * @returns This path cursor
  25454. */
  25455. private ensureLimits;
  25456. /**
  25457. * Runs onchange callbacks on change (used by the animation engine)
  25458. * @returns This path cursor
  25459. */
  25460. private raiseOnChange;
  25461. /**
  25462. * Executes a function on change
  25463. * @param f A path cursor onchange callback
  25464. * @returns This path cursor
  25465. */
  25466. onchange(f: (cursor: PathCursor) => void): PathCursor;
  25467. }
  25468. /**
  25469. * Defines an interface which represents an animation key frame
  25470. */
  25471. export interface IAnimationKey {
  25472. /**
  25473. * Frame of the key frame
  25474. */
  25475. frame: number;
  25476. /**
  25477. * Value at the specifies key frame
  25478. */
  25479. value: any;
  25480. /**
  25481. * The input tangent for the cubic hermite spline
  25482. */
  25483. inTangent?: any;
  25484. /**
  25485. * The output tangent for the cubic hermite spline
  25486. */
  25487. outTangent?: any;
  25488. /**
  25489. * The animation interpolation type
  25490. */
  25491. interpolation?: AnimationKeyInterpolation;
  25492. }
  25493. /**
  25494. * Enum for the animation key frame interpolation type
  25495. */
  25496. export enum AnimationKeyInterpolation {
  25497. /**
  25498. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  25499. */
  25500. STEP = 1
  25501. }
  25502. /**
  25503. * Class used to store any kind of animation
  25504. */
  25505. export class Animation {
  25506. /**Name of the animation */
  25507. name: string;
  25508. /**Property to animate */
  25509. targetProperty: string;
  25510. /**The frames per second of the animation */
  25511. framePerSecond: number;
  25512. /**The data type of the animation */
  25513. dataType: number;
  25514. /**The loop mode of the animation */
  25515. loopMode?: number | undefined;
  25516. /**Specifies if blending should be enabled */
  25517. enableBlending?: boolean | undefined;
  25518. /**
  25519. * Use matrix interpolation instead of using direct key value when animating matrices
  25520. */
  25521. static AllowMatricesInterpolation: boolean;
  25522. /**
  25523. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25524. */
  25525. static AllowMatrixDecomposeForInterpolation: boolean;
  25526. /**
  25527. * Stores the key frames of the animation
  25528. */
  25529. private _keys;
  25530. /**
  25531. * Stores the easing function of the animation
  25532. */
  25533. private _easingFunction;
  25534. /**
  25535. * @hidden Internal use only
  25536. */
  25537. _runtimeAnimations: RuntimeAnimation[];
  25538. /**
  25539. * The set of event that will be linked to this animation
  25540. */
  25541. private _events;
  25542. /**
  25543. * Stores an array of target property paths
  25544. */
  25545. targetPropertyPath: string[];
  25546. /**
  25547. * Stores the blending speed of the animation
  25548. */
  25549. blendingSpeed: number;
  25550. /**
  25551. * Stores the animation ranges for the animation
  25552. */
  25553. private _ranges;
  25554. /**
  25555. * @hidden Internal use
  25556. */
  25557. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25558. /**
  25559. * Sets up an animation
  25560. * @param property The property to animate
  25561. * @param animationType The animation type to apply
  25562. * @param framePerSecond The frames per second of the animation
  25563. * @param easingFunction The easing function used in the animation
  25564. * @returns The created animation
  25565. */
  25566. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25567. /**
  25568. * Create and start an animation on a node
  25569. * @param name defines the name of the global animation that will be run on all nodes
  25570. * @param node defines the root node where the animation will take place
  25571. * @param targetProperty defines property to animate
  25572. * @param framePerSecond defines the number of frame per second yo use
  25573. * @param totalFrame defines the number of frames in total
  25574. * @param from defines the initial value
  25575. * @param to defines the final value
  25576. * @param loopMode defines which loop mode you want to use (off by default)
  25577. * @param easingFunction defines the easing function to use (linear by default)
  25578. * @param onAnimationEnd defines the callback to call when animation end
  25579. * @returns the animatable created for this animation
  25580. */
  25581. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25582. /**
  25583. * Create and start an animation on a node and its descendants
  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 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
  25587. * @param targetProperty defines property to animate
  25588. * @param framePerSecond defines the number of frame per second to use
  25589. * @param totalFrame defines the number of frames in total
  25590. * @param from defines the initial value
  25591. * @param to defines the final value
  25592. * @param loopMode defines which loop mode you want to use (off by default)
  25593. * @param easingFunction defines the easing function to use (linear by default)
  25594. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25595. * @returns the list of animatables created for all nodes
  25596. * @example https://www.babylonjs-playground.com/#MH0VLI
  25597. */
  25598. 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[]>;
  25599. /**
  25600. * Creates a new animation, merges it with the existing animations and starts it
  25601. * @param name Name of the animation
  25602. * @param node Node which contains the scene that begins the animations
  25603. * @param targetProperty Specifies which property to animate
  25604. * @param framePerSecond The frames per second of the animation
  25605. * @param totalFrame The total number of frames
  25606. * @param from The frame at the beginning of the animation
  25607. * @param to The frame at the end of the animation
  25608. * @param loopMode Specifies the loop mode of the animation
  25609. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25610. * @param onAnimationEnd Callback to run once the animation is complete
  25611. * @returns Nullable animation
  25612. */
  25613. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25614. /**
  25615. * Transition property of an host to the target Value
  25616. * @param property The property to transition
  25617. * @param targetValue The target Value of the property
  25618. * @param host The object where the property to animate belongs
  25619. * @param scene Scene used to run the animation
  25620. * @param frameRate Framerate (in frame/s) to use
  25621. * @param transition The transition type we want to use
  25622. * @param duration The duration of the animation, in milliseconds
  25623. * @param onAnimationEnd Callback trigger at the end of the animation
  25624. * @returns Nullable animation
  25625. */
  25626. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25627. /**
  25628. * Return the array of runtime animations currently using this animation
  25629. */
  25630. readonly runtimeAnimations: RuntimeAnimation[];
  25631. /**
  25632. * Specifies if any of the runtime animations are currently running
  25633. */
  25634. readonly hasRunningRuntimeAnimations: boolean;
  25635. /**
  25636. * Initializes the animation
  25637. * @param name Name of the animation
  25638. * @param targetProperty Property to animate
  25639. * @param framePerSecond The frames per second of the animation
  25640. * @param dataType The data type of the animation
  25641. * @param loopMode The loop mode of the animation
  25642. * @param enableBlendings Specifies if blending should be enabled
  25643. */
  25644. constructor(
  25645. /**Name of the animation */
  25646. name: string,
  25647. /**Property to animate */
  25648. targetProperty: string,
  25649. /**The frames per second of the animation */
  25650. framePerSecond: number,
  25651. /**The data type of the animation */
  25652. dataType: number,
  25653. /**The loop mode of the animation */
  25654. loopMode?: number | undefined,
  25655. /**Specifies if blending should be enabled */
  25656. enableBlending?: boolean | undefined);
  25657. /**
  25658. * Converts the animation to a string
  25659. * @param fullDetails support for multiple levels of logging within scene loading
  25660. * @returns String form of the animation
  25661. */
  25662. toString(fullDetails?: boolean): string;
  25663. /**
  25664. * Add an event to this animation
  25665. * @param event Event to add
  25666. */
  25667. addEvent(event: AnimationEvent): void;
  25668. /**
  25669. * Remove all events found at the given frame
  25670. * @param frame The frame to remove events from
  25671. */
  25672. removeEvents(frame: number): void;
  25673. /**
  25674. * Retrieves all the events from the animation
  25675. * @returns Events from the animation
  25676. */
  25677. getEvents(): AnimationEvent[];
  25678. /**
  25679. * Creates an animation range
  25680. * @param name Name of the animation range
  25681. * @param from Starting frame of the animation range
  25682. * @param to Ending frame of the animation
  25683. */
  25684. createRange(name: string, from: number, to: number): void;
  25685. /**
  25686. * Deletes an animation range by name
  25687. * @param name Name of the animation range to delete
  25688. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25689. */
  25690. deleteRange(name: string, deleteFrames?: boolean): void;
  25691. /**
  25692. * Gets the animation range by name, or null if not defined
  25693. * @param name Name of the animation range
  25694. * @returns Nullable animation range
  25695. */
  25696. getRange(name: string): Nullable<AnimationRange>;
  25697. /**
  25698. * Gets the key frames from the animation
  25699. * @returns The key frames of the animation
  25700. */
  25701. getKeys(): Array<IAnimationKey>;
  25702. /**
  25703. * Gets the highest frame rate of the animation
  25704. * @returns Highest frame rate of the animation
  25705. */
  25706. getHighestFrame(): number;
  25707. /**
  25708. * Gets the easing function of the animation
  25709. * @returns Easing function of the animation
  25710. */
  25711. getEasingFunction(): IEasingFunction;
  25712. /**
  25713. * Sets the easing function of the animation
  25714. * @param easingFunction A custom mathematical formula for animation
  25715. */
  25716. setEasingFunction(easingFunction: EasingFunction): void;
  25717. /**
  25718. * Interpolates a scalar linearly
  25719. * @param startValue Start value of the animation curve
  25720. * @param endValue End value of the animation curve
  25721. * @param gradient Scalar amount to interpolate
  25722. * @returns Interpolated scalar value
  25723. */
  25724. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25725. /**
  25726. * Interpolates a scalar cubically
  25727. * @param startValue Start value of the animation curve
  25728. * @param outTangent End tangent of the animation
  25729. * @param endValue End value of the animation curve
  25730. * @param inTangent Start tangent of the animation curve
  25731. * @param gradient Scalar amount to interpolate
  25732. * @returns Interpolated scalar value
  25733. */
  25734. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25735. /**
  25736. * Interpolates a quaternion using a spherical linear interpolation
  25737. * @param startValue Start value of the animation curve
  25738. * @param endValue End value of the animation curve
  25739. * @param gradient Scalar amount to interpolate
  25740. * @returns Interpolated quaternion value
  25741. */
  25742. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25743. /**
  25744. * Interpolates a quaternion cubically
  25745. * @param startValue Start value of the animation curve
  25746. * @param outTangent End tangent of the animation curve
  25747. * @param endValue End value of the animation curve
  25748. * @param inTangent Start tangent of the animation curve
  25749. * @param gradient Scalar amount to interpolate
  25750. * @returns Interpolated quaternion value
  25751. */
  25752. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25753. /**
  25754. * Interpolates a Vector3 linearl
  25755. * @param startValue Start value of the animation curve
  25756. * @param endValue End value of the animation curve
  25757. * @param gradient Scalar amount to interpolate
  25758. * @returns Interpolated scalar value
  25759. */
  25760. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25761. /**
  25762. * Interpolates a Vector3 cubically
  25763. * @param startValue Start value of the animation curve
  25764. * @param outTangent End tangent of the animation
  25765. * @param endValue End value of the animation curve
  25766. * @param inTangent Start tangent of the animation curve
  25767. * @param gradient Scalar amount to interpolate
  25768. * @returns InterpolatedVector3 value
  25769. */
  25770. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25771. /**
  25772. * Interpolates a Vector2 linearly
  25773. * @param startValue Start value of the animation curve
  25774. * @param endValue End value of the animation curve
  25775. * @param gradient Scalar amount to interpolate
  25776. * @returns Interpolated Vector2 value
  25777. */
  25778. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25779. /**
  25780. * Interpolates a Vector2 cubically
  25781. * @param startValue Start value of the animation curve
  25782. * @param outTangent End tangent of the animation
  25783. * @param endValue End value of the animation curve
  25784. * @param inTangent Start tangent of the animation curve
  25785. * @param gradient Scalar amount to interpolate
  25786. * @returns Interpolated Vector2 value
  25787. */
  25788. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25789. /**
  25790. * Interpolates a size linearly
  25791. * @param startValue Start value of the animation curve
  25792. * @param endValue End value of the animation curve
  25793. * @param gradient Scalar amount to interpolate
  25794. * @returns Interpolated Size value
  25795. */
  25796. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25797. /**
  25798. * Interpolates a Color3 linearly
  25799. * @param startValue Start value of the animation curve
  25800. * @param endValue End value of the animation curve
  25801. * @param gradient Scalar amount to interpolate
  25802. * @returns Interpolated Color3 value
  25803. */
  25804. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25805. /**
  25806. * @hidden Internal use only
  25807. */
  25808. _getKeyValue(value: any): any;
  25809. /**
  25810. * @hidden Internal use only
  25811. */
  25812. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25813. /**
  25814. * Defines the function to use to interpolate matrices
  25815. * @param startValue defines the start matrix
  25816. * @param endValue defines the end matrix
  25817. * @param gradient defines the gradient between both matrices
  25818. * @param result defines an optional target matrix where to store the interpolation
  25819. * @returns the interpolated matrix
  25820. */
  25821. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25822. /**
  25823. * Makes a copy of the animation
  25824. * @returns Cloned animation
  25825. */
  25826. clone(): Animation;
  25827. /**
  25828. * Sets the key frames of the animation
  25829. * @param values The animation key frames to set
  25830. */
  25831. setKeys(values: Array<IAnimationKey>): void;
  25832. /**
  25833. * Serializes the animation to an object
  25834. * @returns Serialized object
  25835. */
  25836. serialize(): any;
  25837. /**
  25838. * Float animation type
  25839. */
  25840. private static _ANIMATIONTYPE_FLOAT;
  25841. /**
  25842. * Vector3 animation type
  25843. */
  25844. private static _ANIMATIONTYPE_VECTOR3;
  25845. /**
  25846. * Quaternion animation type
  25847. */
  25848. private static _ANIMATIONTYPE_QUATERNION;
  25849. /**
  25850. * Matrix animation type
  25851. */
  25852. private static _ANIMATIONTYPE_MATRIX;
  25853. /**
  25854. * Color3 animation type
  25855. */
  25856. private static _ANIMATIONTYPE_COLOR3;
  25857. /**
  25858. * Vector2 animation type
  25859. */
  25860. private static _ANIMATIONTYPE_VECTOR2;
  25861. /**
  25862. * Size animation type
  25863. */
  25864. private static _ANIMATIONTYPE_SIZE;
  25865. /**
  25866. * Relative Loop Mode
  25867. */
  25868. private static _ANIMATIONLOOPMODE_RELATIVE;
  25869. /**
  25870. * Cycle Loop Mode
  25871. */
  25872. private static _ANIMATIONLOOPMODE_CYCLE;
  25873. /**
  25874. * Constant Loop Mode
  25875. */
  25876. private static _ANIMATIONLOOPMODE_CONSTANT;
  25877. /**
  25878. * Get the float animation type
  25879. */
  25880. static readonly ANIMATIONTYPE_FLOAT: number;
  25881. /**
  25882. * Get the Vector3 animation type
  25883. */
  25884. static readonly ANIMATIONTYPE_VECTOR3: number;
  25885. /**
  25886. * Get the Vector2 animation type
  25887. */
  25888. static readonly ANIMATIONTYPE_VECTOR2: number;
  25889. /**
  25890. * Get the Size animation type
  25891. */
  25892. static readonly ANIMATIONTYPE_SIZE: number;
  25893. /**
  25894. * Get the Quaternion animation type
  25895. */
  25896. static readonly ANIMATIONTYPE_QUATERNION: number;
  25897. /**
  25898. * Get the Matrix animation type
  25899. */
  25900. static readonly ANIMATIONTYPE_MATRIX: number;
  25901. /**
  25902. * Get the Color3 animation type
  25903. */
  25904. static readonly ANIMATIONTYPE_COLOR3: number;
  25905. /**
  25906. * Get the Relative Loop Mode
  25907. */
  25908. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25909. /**
  25910. * Get the Cycle Loop Mode
  25911. */
  25912. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25913. /**
  25914. * Get the Constant Loop Mode
  25915. */
  25916. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25917. /** @hidden */
  25918. static _UniversalLerp(left: any, right: any, amount: number): any;
  25919. /**
  25920. * Parses an animation object and creates an animation
  25921. * @param parsedAnimation Parsed animation object
  25922. * @returns Animation object
  25923. */
  25924. static Parse(parsedAnimation: any): Animation;
  25925. /**
  25926. * Appends the serialized animations from the source animations
  25927. * @param source Source containing the animations
  25928. * @param destination Target to store the animations
  25929. */
  25930. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25931. }
  25932. }
  25933. declare module BABYLON {
  25934. /**
  25935. * Base class of all the textures in babylon.
  25936. * It groups all the common properties the materials, post process, lights... might need
  25937. * in order to make a correct use of the texture.
  25938. */
  25939. export class BaseTexture implements IAnimatable {
  25940. /**
  25941. * Default anisotropic filtering level for the application.
  25942. * It is set to 4 as a good tradeoff between perf and quality.
  25943. */
  25944. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25945. /**
  25946. * Gets or sets the unique id of the texture
  25947. */
  25948. uniqueId: number;
  25949. /**
  25950. * Define the name of the texture.
  25951. */
  25952. name: string;
  25953. /**
  25954. * Gets or sets an object used to store user defined information.
  25955. */
  25956. metadata: any;
  25957. /**
  25958. * For internal use only. Please do not use.
  25959. */
  25960. reservedDataStore: any;
  25961. private _hasAlpha;
  25962. /**
  25963. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25964. */
  25965. hasAlpha: boolean;
  25966. /**
  25967. * Defines if the alpha value should be determined via the rgb values.
  25968. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25969. */
  25970. getAlphaFromRGB: boolean;
  25971. /**
  25972. * Intensity or strength of the texture.
  25973. * It is commonly used by materials to fine tune the intensity of the texture
  25974. */
  25975. level: number;
  25976. /**
  25977. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25978. * This is part of the texture as textures usually maps to one uv set.
  25979. */
  25980. coordinatesIndex: number;
  25981. private _coordinatesMode;
  25982. /**
  25983. * How a texture is mapped.
  25984. *
  25985. * | Value | Type | Description |
  25986. * | ----- | ----------------------------------- | ----------- |
  25987. * | 0 | EXPLICIT_MODE | |
  25988. * | 1 | SPHERICAL_MODE | |
  25989. * | 2 | PLANAR_MODE | |
  25990. * | 3 | CUBIC_MODE | |
  25991. * | 4 | PROJECTION_MODE | |
  25992. * | 5 | SKYBOX_MODE | |
  25993. * | 6 | INVCUBIC_MODE | |
  25994. * | 7 | EQUIRECTANGULAR_MODE | |
  25995. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25996. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25997. */
  25998. coordinatesMode: number;
  25999. /**
  26000. * | Value | Type | Description |
  26001. * | ----- | ------------------ | ----------- |
  26002. * | 0 | CLAMP_ADDRESSMODE | |
  26003. * | 1 | WRAP_ADDRESSMODE | |
  26004. * | 2 | MIRROR_ADDRESSMODE | |
  26005. */
  26006. wrapU: number;
  26007. /**
  26008. * | Value | Type | Description |
  26009. * | ----- | ------------------ | ----------- |
  26010. * | 0 | CLAMP_ADDRESSMODE | |
  26011. * | 1 | WRAP_ADDRESSMODE | |
  26012. * | 2 | MIRROR_ADDRESSMODE | |
  26013. */
  26014. wrapV: number;
  26015. /**
  26016. * | Value | Type | Description |
  26017. * | ----- | ------------------ | ----------- |
  26018. * | 0 | CLAMP_ADDRESSMODE | |
  26019. * | 1 | WRAP_ADDRESSMODE | |
  26020. * | 2 | MIRROR_ADDRESSMODE | |
  26021. */
  26022. wrapR: number;
  26023. /**
  26024. * With compliant hardware and browser (supporting anisotropic filtering)
  26025. * this defines the level of anisotropic filtering in the texture.
  26026. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26027. */
  26028. anisotropicFilteringLevel: number;
  26029. /**
  26030. * Define if the texture is a cube texture or if false a 2d texture.
  26031. */
  26032. isCube: boolean;
  26033. /**
  26034. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26035. */
  26036. is3D: boolean;
  26037. /**
  26038. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26039. * HDR texture are usually stored in linear space.
  26040. * This only impacts the PBR and Background materials
  26041. */
  26042. gammaSpace: boolean;
  26043. /**
  26044. * Gets whether or not the texture contains RGBD data.
  26045. */
  26046. readonly isRGBD: boolean;
  26047. /**
  26048. * Is Z inverted in the texture (useful in a cube texture).
  26049. */
  26050. invertZ: boolean;
  26051. /**
  26052. * Are mip maps generated for this texture or not.
  26053. */
  26054. readonly noMipmap: boolean;
  26055. /**
  26056. * @hidden
  26057. */
  26058. lodLevelInAlpha: boolean;
  26059. /**
  26060. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26061. */
  26062. lodGenerationOffset: number;
  26063. /**
  26064. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26065. */
  26066. lodGenerationScale: number;
  26067. /**
  26068. * Define if the texture is a render target.
  26069. */
  26070. isRenderTarget: boolean;
  26071. /**
  26072. * Define the unique id of the texture in the scene.
  26073. */
  26074. readonly uid: string;
  26075. /**
  26076. * Return a string representation of the texture.
  26077. * @returns the texture as a string
  26078. */
  26079. toString(): string;
  26080. /**
  26081. * Get the class name of the texture.
  26082. * @returns "BaseTexture"
  26083. */
  26084. getClassName(): string;
  26085. /**
  26086. * Define the list of animation attached to the texture.
  26087. */
  26088. animations: Animation[];
  26089. /**
  26090. * An event triggered when the texture is disposed.
  26091. */
  26092. onDisposeObservable: Observable<BaseTexture>;
  26093. private _onDisposeObserver;
  26094. /**
  26095. * Callback triggered when the texture has been disposed.
  26096. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26097. */
  26098. onDispose: () => void;
  26099. /**
  26100. * Define the current state of the loading sequence when in delayed load mode.
  26101. */
  26102. delayLoadState: number;
  26103. private _scene;
  26104. /** @hidden */
  26105. _texture: Nullable<InternalTexture>;
  26106. private _uid;
  26107. /**
  26108. * Define if the texture is preventinga material to render or not.
  26109. * If not and the texture is not ready, the engine will use a default black texture instead.
  26110. */
  26111. readonly isBlocking: boolean;
  26112. /**
  26113. * Instantiates a new BaseTexture.
  26114. * Base class of all the textures in babylon.
  26115. * It groups all the common properties the materials, post process, lights... might need
  26116. * in order to make a correct use of the texture.
  26117. * @param scene Define the scene the texture blongs to
  26118. */
  26119. constructor(scene: Nullable<Scene>);
  26120. /**
  26121. * Get the scene the texture belongs to.
  26122. * @returns the scene or null if undefined
  26123. */
  26124. getScene(): Nullable<Scene>;
  26125. /**
  26126. * Get the texture transform matrix used to offset tile the texture for istance.
  26127. * @returns the transformation matrix
  26128. */
  26129. getTextureMatrix(): Matrix;
  26130. /**
  26131. * Get the texture reflection matrix used to rotate/transform the reflection.
  26132. * @returns the reflection matrix
  26133. */
  26134. getReflectionTextureMatrix(): Matrix;
  26135. /**
  26136. * Get the underlying lower level texture from Babylon.
  26137. * @returns the insternal texture
  26138. */
  26139. getInternalTexture(): Nullable<InternalTexture>;
  26140. /**
  26141. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26142. * @returns true if ready or not blocking
  26143. */
  26144. isReadyOrNotBlocking(): boolean;
  26145. /**
  26146. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26147. * @returns true if fully ready
  26148. */
  26149. isReady(): boolean;
  26150. private _cachedSize;
  26151. /**
  26152. * Get the size of the texture.
  26153. * @returns the texture size.
  26154. */
  26155. getSize(): ISize;
  26156. /**
  26157. * Get the base size of the texture.
  26158. * It can be different from the size if the texture has been resized for POT for instance
  26159. * @returns the base size
  26160. */
  26161. getBaseSize(): ISize;
  26162. /**
  26163. * Update the sampling mode of the texture.
  26164. * Default is Trilinear mode.
  26165. *
  26166. * | Value | Type | Description |
  26167. * | ----- | ------------------ | ----------- |
  26168. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26169. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26170. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26171. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26172. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26173. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26174. * | 7 | NEAREST_LINEAR | |
  26175. * | 8 | NEAREST_NEAREST | |
  26176. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26177. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26178. * | 11 | LINEAR_LINEAR | |
  26179. * | 12 | LINEAR_NEAREST | |
  26180. *
  26181. * > _mag_: magnification filter (close to the viewer)
  26182. * > _min_: minification filter (far from the viewer)
  26183. * > _mip_: filter used between mip map levels
  26184. *@param samplingMode Define the new sampling mode of the texture
  26185. */
  26186. updateSamplingMode(samplingMode: number): void;
  26187. /**
  26188. * Scales the texture if is `canRescale()`
  26189. * @param ratio the resize factor we want to use to rescale
  26190. */
  26191. scale(ratio: number): void;
  26192. /**
  26193. * Get if the texture can rescale.
  26194. */
  26195. readonly canRescale: boolean;
  26196. /** @hidden */
  26197. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  26198. /** @hidden */
  26199. _rebuild(): void;
  26200. /**
  26201. * Triggers the load sequence in delayed load mode.
  26202. */
  26203. delayLoad(): void;
  26204. /**
  26205. * Clones the texture.
  26206. * @returns the cloned texture
  26207. */
  26208. clone(): Nullable<BaseTexture>;
  26209. /**
  26210. * Get the texture underlying type (INT, FLOAT...)
  26211. */
  26212. readonly textureType: number;
  26213. /**
  26214. * Get the texture underlying format (RGB, RGBA...)
  26215. */
  26216. readonly textureFormat: number;
  26217. /**
  26218. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26219. * This will returns an RGBA array buffer containing either in values (0-255) or
  26220. * float values (0-1) depending of the underlying buffer type.
  26221. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26222. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26223. * @param buffer defines a user defined buffer to fill with data (can be null)
  26224. * @returns The Array buffer containing the pixels data.
  26225. */
  26226. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26227. /**
  26228. * Release and destroy the underlying lower level texture aka internalTexture.
  26229. */
  26230. releaseInternalTexture(): void;
  26231. /**
  26232. * Get the polynomial representation of the texture data.
  26233. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26234. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26235. */
  26236. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26237. /** @hidden */
  26238. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26239. /** @hidden */
  26240. readonly _lodTextureMid: Nullable<BaseTexture>;
  26241. /** @hidden */
  26242. readonly _lodTextureLow: Nullable<BaseTexture>;
  26243. /**
  26244. * Dispose the texture and release its associated resources.
  26245. */
  26246. dispose(): void;
  26247. /**
  26248. * Serialize the texture into a JSON representation that can be parsed later on.
  26249. * @returns the JSON representation of the texture
  26250. */
  26251. serialize(): any;
  26252. /**
  26253. * Helper function to be called back once a list of texture contains only ready textures.
  26254. * @param textures Define the list of textures to wait for
  26255. * @param callback Define the callback triggered once the entire list will be ready
  26256. */
  26257. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26258. }
  26259. }
  26260. declare module BABYLON {
  26261. /**
  26262. * Uniform buffer objects.
  26263. *
  26264. * Handles blocks of uniform on the GPU.
  26265. *
  26266. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26267. *
  26268. * For more information, please refer to :
  26269. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26270. */
  26271. export class UniformBuffer {
  26272. private _engine;
  26273. private _buffer;
  26274. private _data;
  26275. private _bufferData;
  26276. private _dynamic?;
  26277. private _uniformLocations;
  26278. private _uniformSizes;
  26279. private _uniformLocationPointer;
  26280. private _needSync;
  26281. private _noUBO;
  26282. private _currentEffect;
  26283. private static _MAX_UNIFORM_SIZE;
  26284. private static _tempBuffer;
  26285. /**
  26286. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26287. * This is dynamic to allow compat with webgl 1 and 2.
  26288. * You will need to pass the name of the uniform as well as the value.
  26289. */
  26290. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26291. /**
  26292. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26293. * This is dynamic to allow compat with webgl 1 and 2.
  26294. * You will need to pass the name of the uniform as well as the value.
  26295. */
  26296. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26297. /**
  26298. * Lambda to Update a single float in a uniform buffer.
  26299. * This is dynamic to allow compat with webgl 1 and 2.
  26300. * You will need to pass the name of the uniform as well as the value.
  26301. */
  26302. updateFloat: (name: string, x: number) => void;
  26303. /**
  26304. * Lambda to Update a vec2 of float in a uniform buffer.
  26305. * This is dynamic to allow compat with webgl 1 and 2.
  26306. * You will need to pass the name of the uniform as well as the value.
  26307. */
  26308. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26309. /**
  26310. * Lambda to Update a vec3 of float in a uniform buffer.
  26311. * This is dynamic to allow compat with webgl 1 and 2.
  26312. * You will need to pass the name of the uniform as well as the value.
  26313. */
  26314. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26315. /**
  26316. * Lambda to Update a vec4 of float in a uniform buffer.
  26317. * This is dynamic to allow compat with webgl 1 and 2.
  26318. * You will need to pass the name of the uniform as well as the value.
  26319. */
  26320. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26321. /**
  26322. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26323. * This is dynamic to allow compat with webgl 1 and 2.
  26324. * You will need to pass the name of the uniform as well as the value.
  26325. */
  26326. updateMatrix: (name: string, mat: Matrix) => void;
  26327. /**
  26328. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26329. * This is dynamic to allow compat with webgl 1 and 2.
  26330. * You will need to pass the name of the uniform as well as the value.
  26331. */
  26332. updateVector3: (name: string, vector: Vector3) => void;
  26333. /**
  26334. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26335. * This is dynamic to allow compat with webgl 1 and 2.
  26336. * You will need to pass the name of the uniform as well as the value.
  26337. */
  26338. updateVector4: (name: string, vector: Vector4) => void;
  26339. /**
  26340. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26341. * This is dynamic to allow compat with webgl 1 and 2.
  26342. * You will need to pass the name of the uniform as well as the value.
  26343. */
  26344. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26345. /**
  26346. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26347. * This is dynamic to allow compat with webgl 1 and 2.
  26348. * You will need to pass the name of the uniform as well as the value.
  26349. */
  26350. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26351. /**
  26352. * Instantiates a new Uniform buffer objects.
  26353. *
  26354. * Handles blocks of uniform on the GPU.
  26355. *
  26356. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26357. *
  26358. * For more information, please refer to :
  26359. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26360. * @param engine Define the engine the buffer is associated with
  26361. * @param data Define the data contained in the buffer
  26362. * @param dynamic Define if the buffer is updatable
  26363. */
  26364. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26365. /**
  26366. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26367. * or just falling back on setUniformXXX calls.
  26368. */
  26369. readonly useUbo: boolean;
  26370. /**
  26371. * Indicates if the WebGL underlying uniform buffer is in sync
  26372. * with the javascript cache data.
  26373. */
  26374. readonly isSync: boolean;
  26375. /**
  26376. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26377. * Also, a dynamic UniformBuffer will disable cache verification and always
  26378. * update the underlying WebGL uniform buffer to the GPU.
  26379. * @returns if Dynamic, otherwise false
  26380. */
  26381. isDynamic(): boolean;
  26382. /**
  26383. * The data cache on JS side.
  26384. * @returns the underlying data as a float array
  26385. */
  26386. getData(): Float32Array;
  26387. /**
  26388. * The underlying WebGL Uniform buffer.
  26389. * @returns the webgl buffer
  26390. */
  26391. getBuffer(): Nullable<WebGLBuffer>;
  26392. /**
  26393. * std140 layout specifies how to align data within an UBO structure.
  26394. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26395. * for specs.
  26396. */
  26397. private _fillAlignment;
  26398. /**
  26399. * Adds an uniform in the buffer.
  26400. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26401. * for the layout to be correct !
  26402. * @param name Name of the uniform, as used in the uniform block in the shader.
  26403. * @param size Data size, or data directly.
  26404. */
  26405. addUniform(name: string, size: number | number[]): void;
  26406. /**
  26407. * Adds a Matrix 4x4 to the uniform buffer.
  26408. * @param name Name of the uniform, as used in the uniform block in the shader.
  26409. * @param mat A 4x4 matrix.
  26410. */
  26411. addMatrix(name: string, mat: Matrix): void;
  26412. /**
  26413. * Adds a vec2 to the uniform buffer.
  26414. * @param name Name of the uniform, as used in the uniform block in the shader.
  26415. * @param x Define the x component value of the vec2
  26416. * @param y Define the y component value of the vec2
  26417. */
  26418. addFloat2(name: string, x: number, y: number): void;
  26419. /**
  26420. * Adds a vec3 to the uniform buffer.
  26421. * @param name Name of the uniform, as used in the uniform block in the shader.
  26422. * @param x Define the x component value of the vec3
  26423. * @param y Define the y component value of the vec3
  26424. * @param z Define the z component value of the vec3
  26425. */
  26426. addFloat3(name: string, x: number, y: number, z: number): void;
  26427. /**
  26428. * Adds a vec3 to the uniform buffer.
  26429. * @param name Name of the uniform, as used in the uniform block in the shader.
  26430. * @param color Define the vec3 from a Color
  26431. */
  26432. addColor3(name: string, color: Color3): void;
  26433. /**
  26434. * Adds a vec4 to the uniform buffer.
  26435. * @param name Name of the uniform, as used in the uniform block in the shader.
  26436. * @param color Define the rgb components from a Color
  26437. * @param alpha Define the a component of the vec4
  26438. */
  26439. addColor4(name: string, color: Color3, alpha: number): void;
  26440. /**
  26441. * Adds a vec3 to the uniform buffer.
  26442. * @param name Name of the uniform, as used in the uniform block in the shader.
  26443. * @param vector Define the vec3 components from a Vector
  26444. */
  26445. addVector3(name: string, vector: Vector3): void;
  26446. /**
  26447. * Adds a Matrix 3x3 to the uniform buffer.
  26448. * @param name Name of the uniform, as used in the uniform block in the shader.
  26449. */
  26450. addMatrix3x3(name: string): void;
  26451. /**
  26452. * Adds a Matrix 2x2 to the uniform buffer.
  26453. * @param name Name of the uniform, as used in the uniform block in the shader.
  26454. */
  26455. addMatrix2x2(name: string): void;
  26456. /**
  26457. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26458. */
  26459. create(): void;
  26460. /** @hidden */
  26461. _rebuild(): void;
  26462. /**
  26463. * Updates the WebGL Uniform Buffer on the GPU.
  26464. * If the `dynamic` flag is set to true, no cache comparison is done.
  26465. * Otherwise, the buffer will be updated only if the cache differs.
  26466. */
  26467. update(): void;
  26468. /**
  26469. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26470. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26471. * @param data Define the flattened data
  26472. * @param size Define the size of the data.
  26473. */
  26474. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26475. private _updateMatrix3x3ForUniform;
  26476. private _updateMatrix3x3ForEffect;
  26477. private _updateMatrix2x2ForEffect;
  26478. private _updateMatrix2x2ForUniform;
  26479. private _updateFloatForEffect;
  26480. private _updateFloatForUniform;
  26481. private _updateFloat2ForEffect;
  26482. private _updateFloat2ForUniform;
  26483. private _updateFloat3ForEffect;
  26484. private _updateFloat3ForUniform;
  26485. private _updateFloat4ForEffect;
  26486. private _updateFloat4ForUniform;
  26487. private _updateMatrixForEffect;
  26488. private _updateMatrixForUniform;
  26489. private _updateVector3ForEffect;
  26490. private _updateVector3ForUniform;
  26491. private _updateVector4ForEffect;
  26492. private _updateVector4ForUniform;
  26493. private _updateColor3ForEffect;
  26494. private _updateColor3ForUniform;
  26495. private _updateColor4ForEffect;
  26496. private _updateColor4ForUniform;
  26497. /**
  26498. * Sets a sampler uniform on the effect.
  26499. * @param name Define the name of the sampler.
  26500. * @param texture Define the texture to set in the sampler
  26501. */
  26502. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26503. /**
  26504. * Directly updates the value of the uniform in the cache AND on the GPU.
  26505. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26506. * @param data Define the flattened data
  26507. */
  26508. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26509. /**
  26510. * Binds this uniform buffer to an effect.
  26511. * @param effect Define the effect to bind the buffer to
  26512. * @param name Name of the uniform block in the shader.
  26513. */
  26514. bindToEffect(effect: Effect, name: string): void;
  26515. /**
  26516. * Disposes the uniform buffer.
  26517. */
  26518. dispose(): void;
  26519. }
  26520. }
  26521. declare module BABYLON {
  26522. /**
  26523. * This represents the required contract to create a new type of texture loader.
  26524. */
  26525. export interface IInternalTextureLoader {
  26526. /**
  26527. * Defines wether the loader supports cascade loading the different faces.
  26528. */
  26529. supportCascades: boolean;
  26530. /**
  26531. * This returns if the loader support the current file information.
  26532. * @param extension defines the file extension of the file being loaded
  26533. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26534. * @param fallback defines the fallback internal texture if any
  26535. * @param isBase64 defines whether the texture is encoded as a base64
  26536. * @param isBuffer defines whether the texture data are stored as a buffer
  26537. * @returns true if the loader can load the specified file
  26538. */
  26539. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26540. /**
  26541. * Transform the url before loading if required.
  26542. * @param rootUrl the url of the texture
  26543. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26544. * @returns the transformed texture
  26545. */
  26546. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26547. /**
  26548. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26549. * @param rootUrl the url of the texture
  26550. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26551. * @returns the fallback texture
  26552. */
  26553. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26554. /**
  26555. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26556. * @param data contains the texture data
  26557. * @param texture defines the BabylonJS internal texture
  26558. * @param createPolynomials will be true if polynomials have been requested
  26559. * @param onLoad defines the callback to trigger once the texture is ready
  26560. * @param onError defines the callback to trigger in case of error
  26561. */
  26562. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26563. /**
  26564. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26565. * @param data contains the texture data
  26566. * @param texture defines the BabylonJS internal texture
  26567. * @param callback defines the method to call once ready to upload
  26568. */
  26569. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26570. }
  26571. }
  26572. declare module BABYLON {
  26573. /**
  26574. * Creation options of the multi render target texture.
  26575. */
  26576. export interface IMultiRenderTargetOptions {
  26577. /**
  26578. * Define if the texture needs to create mip maps after render.
  26579. */
  26580. generateMipMaps?: boolean;
  26581. /**
  26582. * Define the types of all the draw buffers we want to create
  26583. */
  26584. types?: number[];
  26585. /**
  26586. * Define the sampling modes of all the draw buffers we want to create
  26587. */
  26588. samplingModes?: number[];
  26589. /**
  26590. * Define if a depth buffer is required
  26591. */
  26592. generateDepthBuffer?: boolean;
  26593. /**
  26594. * Define if a stencil buffer is required
  26595. */
  26596. generateStencilBuffer?: boolean;
  26597. /**
  26598. * Define if a depth texture is required instead of a depth buffer
  26599. */
  26600. generateDepthTexture?: boolean;
  26601. /**
  26602. * Define the number of desired draw buffers
  26603. */
  26604. textureCount?: number;
  26605. /**
  26606. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26607. */
  26608. doNotChangeAspectRatio?: boolean;
  26609. /**
  26610. * Define the default type of the buffers we are creating
  26611. */
  26612. defaultType?: number;
  26613. }
  26614. /**
  26615. * A multi render target, like a render target provides the ability to render to a texture.
  26616. * Unlike the render target, it can render to several draw buffers in one draw.
  26617. * This is specially interesting in deferred rendering or for any effects requiring more than
  26618. * just one color from a single pass.
  26619. */
  26620. export class MultiRenderTarget extends RenderTargetTexture {
  26621. private _internalTextures;
  26622. private _textures;
  26623. private _multiRenderTargetOptions;
  26624. /**
  26625. * Get if draw buffers are currently supported by the used hardware and browser.
  26626. */
  26627. readonly isSupported: boolean;
  26628. /**
  26629. * Get the list of textures generated by the multi render target.
  26630. */
  26631. readonly textures: Texture[];
  26632. /**
  26633. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26634. */
  26635. readonly depthTexture: Texture;
  26636. /**
  26637. * Set the wrapping mode on U of all the textures we are rendering to.
  26638. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26639. */
  26640. wrapU: number;
  26641. /**
  26642. * Set the wrapping mode on V of all the textures we are rendering to.
  26643. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26644. */
  26645. wrapV: number;
  26646. /**
  26647. * Instantiate a new multi render target texture.
  26648. * A multi render target, like a render target provides the ability to render to a texture.
  26649. * Unlike the render target, it can render to several draw buffers in one draw.
  26650. * This is specially interesting in deferred rendering or for any effects requiring more than
  26651. * just one color from a single pass.
  26652. * @param name Define the name of the texture
  26653. * @param size Define the size of the buffers to render to
  26654. * @param count Define the number of target we are rendering into
  26655. * @param scene Define the scene the texture belongs to
  26656. * @param options Define the options used to create the multi render target
  26657. */
  26658. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26659. /** @hidden */
  26660. _rebuild(): void;
  26661. private _createInternalTextures;
  26662. private _createTextures;
  26663. /**
  26664. * Define the number of samples used if MSAA is enabled.
  26665. */
  26666. samples: number;
  26667. /**
  26668. * Resize all the textures in the multi render target.
  26669. * Be carrefull as it will recreate all the data in the new texture.
  26670. * @param size Define the new size
  26671. */
  26672. resize(size: any): void;
  26673. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26674. /**
  26675. * Dispose the render targets and their associated resources
  26676. */
  26677. dispose(): void;
  26678. /**
  26679. * Release all the underlying texture used as draw buffers.
  26680. */
  26681. releaseInternalTextures(): void;
  26682. }
  26683. }
  26684. declare module BABYLON {
  26685. /**
  26686. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26687. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26688. */
  26689. export class Analyser {
  26690. /**
  26691. * Gets or sets the smoothing
  26692. * @ignorenaming
  26693. */
  26694. SMOOTHING: number;
  26695. /**
  26696. * Gets or sets the FFT table size
  26697. * @ignorenaming
  26698. */
  26699. FFT_SIZE: number;
  26700. /**
  26701. * Gets or sets the bar graph amplitude
  26702. * @ignorenaming
  26703. */
  26704. BARGRAPHAMPLITUDE: number;
  26705. /**
  26706. * Gets or sets the position of the debug canvas
  26707. * @ignorenaming
  26708. */
  26709. DEBUGCANVASPOS: {
  26710. x: number;
  26711. y: number;
  26712. };
  26713. /**
  26714. * Gets or sets the debug canvas size
  26715. * @ignorenaming
  26716. */
  26717. DEBUGCANVASSIZE: {
  26718. width: number;
  26719. height: number;
  26720. };
  26721. private _byteFreqs;
  26722. private _byteTime;
  26723. private _floatFreqs;
  26724. private _webAudioAnalyser;
  26725. private _debugCanvas;
  26726. private _debugCanvasContext;
  26727. private _scene;
  26728. private _registerFunc;
  26729. private _audioEngine;
  26730. /**
  26731. * Creates a new analyser
  26732. * @param scene defines hosting scene
  26733. */
  26734. constructor(scene: Scene);
  26735. /**
  26736. * Get the number of data values you will have to play with for the visualization
  26737. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26738. * @returns a number
  26739. */
  26740. getFrequencyBinCount(): number;
  26741. /**
  26742. * Gets the current frequency data as a byte array
  26743. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26744. * @returns a Uint8Array
  26745. */
  26746. getByteFrequencyData(): Uint8Array;
  26747. /**
  26748. * Gets the current waveform as a byte array
  26749. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26750. * @returns a Uint8Array
  26751. */
  26752. getByteTimeDomainData(): Uint8Array;
  26753. /**
  26754. * Gets the current frequency data as a float array
  26755. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26756. * @returns a Float32Array
  26757. */
  26758. getFloatFrequencyData(): Float32Array;
  26759. /**
  26760. * Renders the debug canvas
  26761. */
  26762. drawDebugCanvas(): void;
  26763. /**
  26764. * Stops rendering the debug canvas and removes it
  26765. */
  26766. stopDebugCanvas(): void;
  26767. /**
  26768. * Connects two audio nodes
  26769. * @param inputAudioNode defines first node to connect
  26770. * @param outputAudioNode defines second node to connect
  26771. */
  26772. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26773. /**
  26774. * Releases all associated resources
  26775. */
  26776. dispose(): void;
  26777. }
  26778. }
  26779. declare module BABYLON {
  26780. /**
  26781. * This represents an audio engine and it is responsible
  26782. * to play, synchronize and analyse sounds throughout the application.
  26783. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26784. */
  26785. export interface IAudioEngine extends IDisposable {
  26786. /**
  26787. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26788. */
  26789. readonly canUseWebAudio: boolean;
  26790. /**
  26791. * Gets the current AudioContext if available.
  26792. */
  26793. readonly audioContext: Nullable<AudioContext>;
  26794. /**
  26795. * The master gain node defines the global audio volume of your audio engine.
  26796. */
  26797. readonly masterGain: GainNode;
  26798. /**
  26799. * Gets whether or not mp3 are supported by your browser.
  26800. */
  26801. readonly isMP3supported: boolean;
  26802. /**
  26803. * Gets whether or not ogg are supported by your browser.
  26804. */
  26805. readonly isOGGsupported: boolean;
  26806. /**
  26807. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26808. * @ignoreNaming
  26809. */
  26810. WarnedWebAudioUnsupported: boolean;
  26811. /**
  26812. * Defines if the audio engine relies on a custom unlocked button.
  26813. * In this case, the embedded button will not be displayed.
  26814. */
  26815. useCustomUnlockedButton: boolean;
  26816. /**
  26817. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26818. */
  26819. readonly unlocked: boolean;
  26820. /**
  26821. * Event raised when audio has been unlocked on the browser.
  26822. */
  26823. onAudioUnlockedObservable: Observable<AudioEngine>;
  26824. /**
  26825. * Event raised when audio has been locked on the browser.
  26826. */
  26827. onAudioLockedObservable: Observable<AudioEngine>;
  26828. /**
  26829. * Flags the audio engine in Locked state.
  26830. * This happens due to new browser policies preventing audio to autoplay.
  26831. */
  26832. lock(): void;
  26833. /**
  26834. * Unlocks the audio engine once a user action has been done on the dom.
  26835. * This is helpful to resume play once browser policies have been satisfied.
  26836. */
  26837. unlock(): void;
  26838. }
  26839. /**
  26840. * This represents the default audio engine used in babylon.
  26841. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26843. */
  26844. export class AudioEngine implements IAudioEngine {
  26845. private _audioContext;
  26846. private _audioContextInitialized;
  26847. private _muteButton;
  26848. private _hostElement;
  26849. /**
  26850. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26851. */
  26852. canUseWebAudio: boolean;
  26853. /**
  26854. * The master gain node defines the global audio volume of your audio engine.
  26855. */
  26856. masterGain: GainNode;
  26857. /**
  26858. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26859. * @ignoreNaming
  26860. */
  26861. WarnedWebAudioUnsupported: boolean;
  26862. /**
  26863. * Gets whether or not mp3 are supported by your browser.
  26864. */
  26865. isMP3supported: boolean;
  26866. /**
  26867. * Gets whether or not ogg are supported by your browser.
  26868. */
  26869. isOGGsupported: boolean;
  26870. /**
  26871. * Gets whether audio has been unlocked on the device.
  26872. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26873. * a user interaction has happened.
  26874. */
  26875. unlocked: boolean;
  26876. /**
  26877. * Defines if the audio engine relies on a custom unlocked button.
  26878. * In this case, the embedded button will not be displayed.
  26879. */
  26880. useCustomUnlockedButton: boolean;
  26881. /**
  26882. * Event raised when audio has been unlocked on the browser.
  26883. */
  26884. onAudioUnlockedObservable: Observable<AudioEngine>;
  26885. /**
  26886. * Event raised when audio has been locked on the browser.
  26887. */
  26888. onAudioLockedObservable: Observable<AudioEngine>;
  26889. /**
  26890. * Gets the current AudioContext if available.
  26891. */
  26892. readonly audioContext: Nullable<AudioContext>;
  26893. private _connectedAnalyser;
  26894. /**
  26895. * Instantiates a new audio engine.
  26896. *
  26897. * There should be only one per page as some browsers restrict the number
  26898. * of audio contexts you can create.
  26899. * @param hostElement defines the host element where to display the mute icon if necessary
  26900. */
  26901. constructor(hostElement?: Nullable<HTMLElement>);
  26902. /**
  26903. * Flags the audio engine in Locked state.
  26904. * This happens due to new browser policies preventing audio to autoplay.
  26905. */
  26906. lock(): void;
  26907. /**
  26908. * Unlocks the audio engine once a user action has been done on the dom.
  26909. * This is helpful to resume play once browser policies have been satisfied.
  26910. */
  26911. unlock(): void;
  26912. private _resumeAudioContext;
  26913. private _initializeAudioContext;
  26914. private _tryToRun;
  26915. private _triggerRunningState;
  26916. private _triggerSuspendedState;
  26917. private _displayMuteButton;
  26918. private _moveButtonToTopLeft;
  26919. private _onResize;
  26920. private _hideMuteButton;
  26921. /**
  26922. * Destroy and release the resources associated with the audio ccontext.
  26923. */
  26924. dispose(): void;
  26925. /**
  26926. * Gets the global volume sets on the master gain.
  26927. * @returns the global volume if set or -1 otherwise
  26928. */
  26929. getGlobalVolume(): number;
  26930. /**
  26931. * Sets the global volume of your experience (sets on the master gain).
  26932. * @param newVolume Defines the new global volume of the application
  26933. */
  26934. setGlobalVolume(newVolume: number): void;
  26935. /**
  26936. * Connect the audio engine to an audio analyser allowing some amazing
  26937. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26938. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26939. * @param analyser The analyser to connect to the engine
  26940. */
  26941. connectToAnalyser(analyser: Analyser): void;
  26942. }
  26943. }
  26944. declare module BABYLON {
  26945. /**
  26946. * Interface used to present a loading screen while loading a scene
  26947. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26948. */
  26949. export interface ILoadingScreen {
  26950. /**
  26951. * Function called to display the loading screen
  26952. */
  26953. displayLoadingUI: () => void;
  26954. /**
  26955. * Function called to hide the loading screen
  26956. */
  26957. hideLoadingUI: () => void;
  26958. /**
  26959. * Gets or sets the color to use for the background
  26960. */
  26961. loadingUIBackgroundColor: string;
  26962. /**
  26963. * Gets or sets the text to display while loading
  26964. */
  26965. loadingUIText: string;
  26966. }
  26967. /**
  26968. * Class used for the default loading screen
  26969. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26970. */
  26971. export class DefaultLoadingScreen implements ILoadingScreen {
  26972. private _renderingCanvas;
  26973. private _loadingText;
  26974. private _loadingDivBackgroundColor;
  26975. private _loadingDiv;
  26976. private _loadingTextDiv;
  26977. /**
  26978. * Creates a new default loading screen
  26979. * @param _renderingCanvas defines the canvas used to render the scene
  26980. * @param _loadingText defines the default text to display
  26981. * @param _loadingDivBackgroundColor defines the default background color
  26982. */
  26983. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26984. /**
  26985. * Function called to display the loading screen
  26986. */
  26987. displayLoadingUI(): void;
  26988. /**
  26989. * Function called to hide the loading screen
  26990. */
  26991. hideLoadingUI(): void;
  26992. /**
  26993. * Gets or sets the text to display while loading
  26994. */
  26995. loadingUIText: string;
  26996. /**
  26997. * Gets or sets the color to use for the background
  26998. */
  26999. loadingUIBackgroundColor: string;
  27000. private _resizeLoadingUI;
  27001. }
  27002. }
  27003. declare module BABYLON {
  27004. /**
  27005. * Settings for finer control over video usage
  27006. */
  27007. export interface VideoTextureSettings {
  27008. /**
  27009. * Applies `autoplay` to video, if specified
  27010. */
  27011. autoPlay?: boolean;
  27012. /**
  27013. * Applies `loop` to video, if specified
  27014. */
  27015. loop?: boolean;
  27016. /**
  27017. * Automatically updates internal texture from video at every frame in the render loop
  27018. */
  27019. autoUpdateTexture: boolean;
  27020. /**
  27021. * Image src displayed during the video loading or until the user interacts with the video.
  27022. */
  27023. poster?: string;
  27024. }
  27025. /**
  27026. * If you want to display a video in your scene, this is the special texture for that.
  27027. * This special texture works similar to other textures, with the exception of a few parameters.
  27028. * @see https://doc.babylonjs.com/how_to/video_texture
  27029. */
  27030. export class VideoTexture extends Texture {
  27031. /**
  27032. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27033. */
  27034. readonly autoUpdateTexture: boolean;
  27035. /**
  27036. * The video instance used by the texture internally
  27037. */
  27038. readonly video: HTMLVideoElement;
  27039. private _onUserActionRequestedObservable;
  27040. /**
  27041. * Event triggerd when a dom action is required by the user to play the video.
  27042. * This happens due to recent changes in browser policies preventing video to auto start.
  27043. */
  27044. readonly onUserActionRequestedObservable: Observable<Texture>;
  27045. private _generateMipMaps;
  27046. private _engine;
  27047. private _stillImageCaptured;
  27048. private _displayingPosterTexture;
  27049. private _settings;
  27050. private _createInternalTextureOnEvent;
  27051. /**
  27052. * Creates a video texture.
  27053. * If you want to display a video in your scene, this is the special texture for that.
  27054. * This special texture works similar to other textures, with the exception of a few parameters.
  27055. * @see https://doc.babylonjs.com/how_to/video_texture
  27056. * @param name optional name, will detect from video source, if not defined
  27057. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27058. * @param scene is obviously the current scene.
  27059. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27060. * @param invertY is false by default but can be used to invert video on Y axis
  27061. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27062. * @param settings allows finer control over video usage
  27063. */
  27064. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27065. private _getName;
  27066. private _getVideo;
  27067. private _createInternalTexture;
  27068. private reset;
  27069. /**
  27070. * @hidden Internal method to initiate `update`.
  27071. */
  27072. _rebuild(): void;
  27073. /**
  27074. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27075. */
  27076. update(): void;
  27077. /**
  27078. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27079. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27080. */
  27081. updateTexture(isVisible: boolean): void;
  27082. protected _updateInternalTexture: () => void;
  27083. /**
  27084. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27085. * @param url New url.
  27086. */
  27087. updateURL(url: string): void;
  27088. /**
  27089. * Dispose the texture and release its associated resources.
  27090. */
  27091. dispose(): void;
  27092. /**
  27093. * Creates a video texture straight from your WebCam video feed.
  27094. * @param scene Define the scene the texture should be created in
  27095. * @param onReady Define a callback to triggered once the texture will be ready
  27096. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27097. */
  27098. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27099. minWidth: number;
  27100. maxWidth: number;
  27101. minHeight: number;
  27102. maxHeight: number;
  27103. deviceId: string;
  27104. }): void;
  27105. }
  27106. }
  27107. declare module BABYLON {
  27108. /**
  27109. * Interface for attribute information associated with buffer instanciation
  27110. */
  27111. export class InstancingAttributeInfo {
  27112. /**
  27113. * Index/offset of the attribute in the vertex shader
  27114. */
  27115. index: number;
  27116. /**
  27117. * size of the attribute, 1, 2, 3 or 4
  27118. */
  27119. attributeSize: number;
  27120. /**
  27121. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27122. * default is FLOAT
  27123. */
  27124. attribyteType: number;
  27125. /**
  27126. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27127. */
  27128. normalized: boolean;
  27129. /**
  27130. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27131. */
  27132. offset: number;
  27133. /**
  27134. * Name of the GLSL attribute, for debugging purpose only
  27135. */
  27136. attributeName: string;
  27137. }
  27138. /**
  27139. * Define options used to create a depth texture
  27140. */
  27141. export class DepthTextureCreationOptions {
  27142. /** Specifies whether or not a stencil should be allocated in the texture */
  27143. generateStencil?: boolean;
  27144. /** Specifies whether or not bilinear filtering is enable on the texture */
  27145. bilinearFiltering?: boolean;
  27146. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27147. comparisonFunction?: number;
  27148. /** Specifies if the created texture is a cube texture */
  27149. isCube?: boolean;
  27150. }
  27151. /**
  27152. * Class used to describe the capabilities of the engine relatively to the current browser
  27153. */
  27154. export class EngineCapabilities {
  27155. /** Maximum textures units per fragment shader */
  27156. maxTexturesImageUnits: number;
  27157. /** Maximum texture units per vertex shader */
  27158. maxVertexTextureImageUnits: number;
  27159. /** Maximum textures units in the entire pipeline */
  27160. maxCombinedTexturesImageUnits: number;
  27161. /** Maximum texture size */
  27162. maxTextureSize: number;
  27163. /** Maximum cube texture size */
  27164. maxCubemapTextureSize: number;
  27165. /** Maximum render texture size */
  27166. maxRenderTextureSize: number;
  27167. /** Maximum number of vertex attributes */
  27168. maxVertexAttribs: number;
  27169. /** Maximum number of varyings */
  27170. maxVaryingVectors: number;
  27171. /** Maximum number of uniforms per vertex shader */
  27172. maxVertexUniformVectors: number;
  27173. /** Maximum number of uniforms per fragment shader */
  27174. maxFragmentUniformVectors: number;
  27175. /** Defines if standard derivates (dx/dy) are supported */
  27176. standardDerivatives: boolean;
  27177. /** Defines if s3tc texture compression is supported */
  27178. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27179. /** Defines if pvrtc texture compression is supported */
  27180. pvrtc: any;
  27181. /** Defines if etc1 texture compression is supported */
  27182. etc1: any;
  27183. /** Defines if etc2 texture compression is supported */
  27184. etc2: any;
  27185. /** Defines if astc texture compression is supported */
  27186. astc: any;
  27187. /** Defines if float textures are supported */
  27188. textureFloat: boolean;
  27189. /** Defines if vertex array objects are supported */
  27190. vertexArrayObject: boolean;
  27191. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27192. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27193. /** Gets the maximum level of anisotropy supported */
  27194. maxAnisotropy: number;
  27195. /** Defines if instancing is supported */
  27196. instancedArrays: boolean;
  27197. /** Defines if 32 bits indices are supported */
  27198. uintIndices: boolean;
  27199. /** Defines if high precision shaders are supported */
  27200. highPrecisionShaderSupported: boolean;
  27201. /** Defines if depth reading in the fragment shader is supported */
  27202. fragmentDepthSupported: boolean;
  27203. /** Defines if float texture linear filtering is supported*/
  27204. textureFloatLinearFiltering: boolean;
  27205. /** Defines if rendering to float textures is supported */
  27206. textureFloatRender: boolean;
  27207. /** Defines if half float textures are supported*/
  27208. textureHalfFloat: boolean;
  27209. /** Defines if half float texture linear filtering is supported*/
  27210. textureHalfFloatLinearFiltering: boolean;
  27211. /** Defines if rendering to half float textures is supported */
  27212. textureHalfFloatRender: boolean;
  27213. /** Defines if textureLOD shader command is supported */
  27214. textureLOD: boolean;
  27215. /** Defines if draw buffers extension is supported */
  27216. drawBuffersExtension: boolean;
  27217. /** Defines if depth textures are supported */
  27218. depthTextureExtension: boolean;
  27219. /** Defines if float color buffer are supported */
  27220. colorBufferFloat: boolean;
  27221. /** Gets disjoint timer query extension (null if not supported) */
  27222. timerQuery: EXT_disjoint_timer_query;
  27223. /** Defines if timestamp can be used with timer query */
  27224. canUseTimestampForTimerQuery: boolean;
  27225. /** Function used to let the system compiles shaders in background */
  27226. parallelShaderCompile: {
  27227. MAX_SHADER_COMPILER_THREADS_KHR: number;
  27228. maxShaderCompilerThreadsKHR: (thread: number) => void;
  27229. COMPLETION_STATUS_KHR: number;
  27230. };
  27231. }
  27232. /** Interface defining initialization parameters for Engine class */
  27233. export interface EngineOptions extends WebGLContextAttributes {
  27234. /**
  27235. * Defines if the engine should no exceed a specified device ratio
  27236. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27237. */
  27238. limitDeviceRatio?: number;
  27239. /**
  27240. * Defines if webvr should be enabled automatically
  27241. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27242. */
  27243. autoEnableWebVR?: boolean;
  27244. /**
  27245. * Defines if webgl2 should be turned off even if supported
  27246. * @see http://doc.babylonjs.com/features/webgl2
  27247. */
  27248. disableWebGL2Support?: boolean;
  27249. /**
  27250. * Defines if webaudio should be initialized as well
  27251. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27252. */
  27253. audioEngine?: boolean;
  27254. /**
  27255. * Defines if animations should run using a deterministic lock step
  27256. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27257. */
  27258. deterministicLockstep?: boolean;
  27259. /** Defines the maximum steps to use with deterministic lock step mode */
  27260. lockstepMaxSteps?: number;
  27261. /**
  27262. * Defines that engine should ignore context lost events
  27263. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27264. */
  27265. doNotHandleContextLost?: boolean;
  27266. /**
  27267. * Defines that engine should ignore modifying touch action attribute and style
  27268. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27269. */
  27270. doNotHandleTouchAction?: boolean;
  27271. }
  27272. /**
  27273. * Defines the interface used by display changed events
  27274. */
  27275. export interface IDisplayChangedEventArgs {
  27276. /** Gets the vrDisplay object (if any) */
  27277. vrDisplay: Nullable<any>;
  27278. /** Gets a boolean indicating if webVR is supported */
  27279. vrSupported: boolean;
  27280. }
  27281. /**
  27282. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27283. */
  27284. export class Engine {
  27285. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27286. static ExceptionList: ({
  27287. key: string;
  27288. capture: string;
  27289. captureConstraint: number;
  27290. targets: string[];
  27291. } | {
  27292. key: string;
  27293. capture: null;
  27294. captureConstraint: null;
  27295. targets: string[];
  27296. })[];
  27297. /** Gets the list of created engines */
  27298. static readonly Instances: Engine[];
  27299. /**
  27300. * Gets the latest created engine
  27301. */
  27302. static readonly LastCreatedEngine: Nullable<Engine>;
  27303. /**
  27304. * Gets the latest created scene
  27305. */
  27306. static readonly LastCreatedScene: Nullable<Scene>;
  27307. /**
  27308. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27309. * @param flag defines which part of the materials must be marked as dirty
  27310. * @param predicate defines a predicate used to filter which materials should be affected
  27311. */
  27312. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27313. /**
  27314. * Hidden
  27315. */
  27316. static _TextureLoaders: IInternalTextureLoader[];
  27317. /** Defines that alpha blending is disabled */
  27318. static readonly ALPHA_DISABLE: number;
  27319. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27320. static readonly ALPHA_ADD: number;
  27321. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27322. static readonly ALPHA_COMBINE: number;
  27323. /** Defines that alpha blending to DEST - SRC * DEST */
  27324. static readonly ALPHA_SUBTRACT: number;
  27325. /** Defines that alpha blending to SRC * DEST */
  27326. static readonly ALPHA_MULTIPLY: number;
  27327. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27328. static readonly ALPHA_MAXIMIZED: number;
  27329. /** Defines that alpha blending to SRC + DEST */
  27330. static readonly ALPHA_ONEONE: number;
  27331. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27332. static readonly ALPHA_PREMULTIPLIED: number;
  27333. /**
  27334. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27335. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27336. */
  27337. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27338. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27339. static readonly ALPHA_INTERPOLATE: number;
  27340. /**
  27341. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27342. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27343. */
  27344. static readonly ALPHA_SCREENMODE: number;
  27345. /** Defines that the ressource is not delayed*/
  27346. static readonly DELAYLOADSTATE_NONE: number;
  27347. /** Defines that the ressource was successfully delay loaded */
  27348. static readonly DELAYLOADSTATE_LOADED: number;
  27349. /** Defines that the ressource is currently delay loading */
  27350. static readonly DELAYLOADSTATE_LOADING: number;
  27351. /** Defines that the ressource is delayed and has not started loading */
  27352. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27353. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27354. static readonly NEVER: number;
  27355. /** 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 */
  27356. static readonly ALWAYS: number;
  27357. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27358. static readonly LESS: number;
  27359. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27360. static readonly EQUAL: number;
  27361. /** 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 */
  27362. static readonly LEQUAL: number;
  27363. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27364. static readonly GREATER: number;
  27365. /** 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 */
  27366. static readonly GEQUAL: number;
  27367. /** 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 */
  27368. static readonly NOTEQUAL: number;
  27369. /** Passed to stencilOperation to specify that stencil value must be kept */
  27370. static readonly KEEP: number;
  27371. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27372. static readonly REPLACE: number;
  27373. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27374. static readonly INCR: number;
  27375. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27376. static readonly DECR: number;
  27377. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27378. static readonly INVERT: number;
  27379. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27380. static readonly INCR_WRAP: number;
  27381. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27382. static readonly DECR_WRAP: number;
  27383. /** Texture is not repeating outside of 0..1 UVs */
  27384. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27385. /** Texture is repeating outside of 0..1 UVs */
  27386. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27387. /** Texture is repeating and mirrored */
  27388. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27389. /** ALPHA */
  27390. static readonly TEXTUREFORMAT_ALPHA: number;
  27391. /** LUMINANCE */
  27392. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27393. /** LUMINANCE_ALPHA */
  27394. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27395. /** RGB */
  27396. static readonly TEXTUREFORMAT_RGB: number;
  27397. /** RGBA */
  27398. static readonly TEXTUREFORMAT_RGBA: number;
  27399. /** RED */
  27400. static readonly TEXTUREFORMAT_RED: number;
  27401. /** RED (2nd reference) */
  27402. static readonly TEXTUREFORMAT_R: number;
  27403. /** RG */
  27404. static readonly TEXTUREFORMAT_RG: number;
  27405. /** RED_INTEGER */
  27406. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27407. /** RED_INTEGER (2nd reference) */
  27408. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27409. /** RG_INTEGER */
  27410. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27411. /** RGB_INTEGER */
  27412. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27413. /** RGBA_INTEGER */
  27414. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27415. /** UNSIGNED_BYTE */
  27416. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27417. /** UNSIGNED_BYTE (2nd reference) */
  27418. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27419. /** FLOAT */
  27420. static readonly TEXTURETYPE_FLOAT: number;
  27421. /** HALF_FLOAT */
  27422. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27423. /** BYTE */
  27424. static readonly TEXTURETYPE_BYTE: number;
  27425. /** SHORT */
  27426. static readonly TEXTURETYPE_SHORT: number;
  27427. /** UNSIGNED_SHORT */
  27428. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27429. /** INT */
  27430. static readonly TEXTURETYPE_INT: number;
  27431. /** UNSIGNED_INT */
  27432. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27433. /** UNSIGNED_SHORT_4_4_4_4 */
  27434. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27435. /** UNSIGNED_SHORT_5_5_5_1 */
  27436. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27437. /** UNSIGNED_SHORT_5_6_5 */
  27438. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27439. /** UNSIGNED_INT_2_10_10_10_REV */
  27440. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27441. /** UNSIGNED_INT_24_8 */
  27442. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27443. /** UNSIGNED_INT_10F_11F_11F_REV */
  27444. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27445. /** UNSIGNED_INT_5_9_9_9_REV */
  27446. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27447. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27448. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27449. /** nearest is mag = nearest and min = nearest and mip = linear */
  27450. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27451. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27452. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27453. /** Trilinear is mag = linear and min = linear and mip = linear */
  27454. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27455. /** nearest is mag = nearest and min = nearest and mip = linear */
  27456. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27457. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27458. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27459. /** Trilinear is mag = linear and min = linear and mip = linear */
  27460. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27461. /** mag = nearest and min = nearest and mip = nearest */
  27462. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27463. /** mag = nearest and min = linear and mip = nearest */
  27464. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27465. /** mag = nearest and min = linear and mip = linear */
  27466. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27467. /** mag = nearest and min = linear and mip = none */
  27468. static readonly TEXTURE_NEAREST_LINEAR: number;
  27469. /** mag = nearest and min = nearest and mip = none */
  27470. static readonly TEXTURE_NEAREST_NEAREST: number;
  27471. /** mag = linear and min = nearest and mip = nearest */
  27472. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27473. /** mag = linear and min = nearest and mip = linear */
  27474. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27475. /** mag = linear and min = linear and mip = none */
  27476. static readonly TEXTURE_LINEAR_LINEAR: number;
  27477. /** mag = linear and min = nearest and mip = none */
  27478. static readonly TEXTURE_LINEAR_NEAREST: number;
  27479. /** Explicit coordinates mode */
  27480. static readonly TEXTURE_EXPLICIT_MODE: number;
  27481. /** Spherical coordinates mode */
  27482. static readonly TEXTURE_SPHERICAL_MODE: number;
  27483. /** Planar coordinates mode */
  27484. static readonly TEXTURE_PLANAR_MODE: number;
  27485. /** Cubic coordinates mode */
  27486. static readonly TEXTURE_CUBIC_MODE: number;
  27487. /** Projection coordinates mode */
  27488. static readonly TEXTURE_PROJECTION_MODE: number;
  27489. /** Skybox coordinates mode */
  27490. static readonly TEXTURE_SKYBOX_MODE: number;
  27491. /** Inverse Cubic coordinates mode */
  27492. static readonly TEXTURE_INVCUBIC_MODE: number;
  27493. /** Equirectangular coordinates mode */
  27494. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27495. /** Equirectangular Fixed coordinates mode */
  27496. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27497. /** Equirectangular Fixed Mirrored coordinates mode */
  27498. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27499. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27500. static readonly SCALEMODE_FLOOR: number;
  27501. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27502. static readonly SCALEMODE_NEAREST: number;
  27503. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27504. static readonly SCALEMODE_CEILING: number;
  27505. /**
  27506. * Returns the current version of the framework
  27507. */
  27508. static readonly Version: string;
  27509. /**
  27510. * Returns a string describing the current engine
  27511. */
  27512. readonly description: string;
  27513. /**
  27514. * Gets or sets the epsilon value used by collision engine
  27515. */
  27516. static CollisionsEpsilon: number;
  27517. /**
  27518. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27519. */
  27520. static ShadersRepository: string;
  27521. /**
  27522. * Method called to create the default loading screen.
  27523. * This can be overriden in your own app.
  27524. * @param canvas The rendering canvas element
  27525. * @returns The loading screen
  27526. */
  27527. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27528. /**
  27529. * Method called to create the default rescale post process on each engine.
  27530. */
  27531. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27532. /**
  27533. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27534. */
  27535. forcePOTTextures: boolean;
  27536. /**
  27537. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27538. */
  27539. isFullscreen: boolean;
  27540. /**
  27541. * Gets a boolean indicating if the pointer is currently locked
  27542. */
  27543. isPointerLock: boolean;
  27544. /**
  27545. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27546. */
  27547. cullBackFaces: boolean;
  27548. /**
  27549. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27550. */
  27551. renderEvenInBackground: boolean;
  27552. /**
  27553. * Gets or sets a boolean indicating that cache can be kept between frames
  27554. */
  27555. preventCacheWipeBetweenFrames: boolean;
  27556. /**
  27557. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27558. **/
  27559. enableOfflineSupport: boolean;
  27560. /**
  27561. * 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)
  27562. **/
  27563. disableManifestCheck: boolean;
  27564. /**
  27565. * Gets the list of created scenes
  27566. */
  27567. scenes: Scene[];
  27568. /**
  27569. * Event raised when a new scene is created
  27570. */
  27571. onNewSceneAddedObservable: Observable<Scene>;
  27572. /**
  27573. * Gets the list of created postprocesses
  27574. */
  27575. postProcesses: PostProcess[];
  27576. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27577. validateShaderPrograms: boolean;
  27578. /**
  27579. * Observable event triggered each time the rendering canvas is resized
  27580. */
  27581. onResizeObservable: Observable<Engine>;
  27582. /**
  27583. * Observable event triggered each time the canvas loses focus
  27584. */
  27585. onCanvasBlurObservable: Observable<Engine>;
  27586. /**
  27587. * Observable event triggered each time the canvas gains focus
  27588. */
  27589. onCanvasFocusObservable: Observable<Engine>;
  27590. /**
  27591. * Observable event triggered each time the canvas receives pointerout event
  27592. */
  27593. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27594. /**
  27595. * Observable event triggered before each texture is initialized
  27596. */
  27597. onBeforeTextureInitObservable: Observable<Texture>;
  27598. private _vrDisplay;
  27599. private _vrSupported;
  27600. private _oldSize;
  27601. private _oldHardwareScaleFactor;
  27602. private _vrExclusivePointerMode;
  27603. private _webVRInitPromise;
  27604. /**
  27605. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27606. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27607. */
  27608. readonly isInVRExclusivePointerMode: boolean;
  27609. /**
  27610. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27611. */
  27612. disableUniformBuffers: boolean;
  27613. /** @hidden */
  27614. _uniformBuffers: UniformBuffer[];
  27615. /**
  27616. * Gets a boolean indicating that the engine supports uniform buffers
  27617. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27618. */
  27619. readonly supportsUniformBuffers: boolean;
  27620. /**
  27621. * Observable raised when the engine begins a new frame
  27622. */
  27623. onBeginFrameObservable: Observable<Engine>;
  27624. /**
  27625. * If set, will be used to request the next animation frame for the render loop
  27626. */
  27627. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27628. /**
  27629. * Observable raised when the engine ends the current frame
  27630. */
  27631. onEndFrameObservable: Observable<Engine>;
  27632. /**
  27633. * Observable raised when the engine is about to compile a shader
  27634. */
  27635. onBeforeShaderCompilationObservable: Observable<Engine>;
  27636. /**
  27637. * Observable raised when the engine has jsut compiled a shader
  27638. */
  27639. onAfterShaderCompilationObservable: Observable<Engine>;
  27640. /** @hidden */
  27641. _gl: WebGLRenderingContext;
  27642. private _renderingCanvas;
  27643. private _windowIsBackground;
  27644. private _webGLVersion;
  27645. /**
  27646. * Gets a boolean indicating that only power of 2 textures are supported
  27647. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27648. */
  27649. readonly needPOTTextures: boolean;
  27650. /** @hidden */
  27651. _badOS: boolean;
  27652. /** @hidden */
  27653. _badDesktopOS: boolean;
  27654. /**
  27655. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27656. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27657. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27658. */
  27659. disableTextureBindingOptimization: boolean;
  27660. /**
  27661. * Gets the audio engine
  27662. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27663. * @ignorenaming
  27664. */
  27665. static audioEngine: IAudioEngine;
  27666. /**
  27667. * Default AudioEngine factory responsible of creating the Audio Engine.
  27668. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27669. */
  27670. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27671. /**
  27672. * Default offline support factory responsible of creating a tool used to store data locally.
  27673. * By default, this will create a Database object if the workload has been embedded.
  27674. */
  27675. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27676. private _onFocus;
  27677. private _onBlur;
  27678. private _onCanvasPointerOut;
  27679. private _onCanvasBlur;
  27680. private _onCanvasFocus;
  27681. private _onFullscreenChange;
  27682. private _onPointerLockChange;
  27683. private _onVRDisplayPointerRestricted;
  27684. private _onVRDisplayPointerUnrestricted;
  27685. private _onVrDisplayConnect;
  27686. private _onVrDisplayDisconnect;
  27687. private _onVrDisplayPresentChange;
  27688. /**
  27689. * Observable signaled when VR display mode changes
  27690. */
  27691. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27692. /**
  27693. * Observable signaled when VR request present is complete
  27694. */
  27695. onVRRequestPresentComplete: Observable<boolean>;
  27696. /**
  27697. * Observable signaled when VR request present starts
  27698. */
  27699. onVRRequestPresentStart: Observable<Engine>;
  27700. private _hardwareScalingLevel;
  27701. /** @hidden */
  27702. protected _caps: EngineCapabilities;
  27703. private _pointerLockRequested;
  27704. private _isStencilEnable;
  27705. private _colorWrite;
  27706. private _loadingScreen;
  27707. /** @hidden */
  27708. _drawCalls: PerfCounter;
  27709. /** @hidden */
  27710. _textureCollisions: PerfCounter;
  27711. private _glVersion;
  27712. private _glRenderer;
  27713. private _glVendor;
  27714. private _videoTextureSupported;
  27715. private _renderingQueueLaunched;
  27716. private _activeRenderLoops;
  27717. private _deterministicLockstep;
  27718. private _lockstepMaxSteps;
  27719. /**
  27720. * Observable signaled when a context lost event is raised
  27721. */
  27722. onContextLostObservable: Observable<Engine>;
  27723. /**
  27724. * Observable signaled when a context restored event is raised
  27725. */
  27726. onContextRestoredObservable: Observable<Engine>;
  27727. private _onContextLost;
  27728. private _onContextRestored;
  27729. private _contextWasLost;
  27730. private _doNotHandleContextLost;
  27731. /**
  27732. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27733. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27734. */
  27735. doNotHandleContextLost: boolean;
  27736. private _performanceMonitor;
  27737. private _fps;
  27738. private _deltaTime;
  27739. /**
  27740. * Turn this value on if you want to pause FPS computation when in background
  27741. */
  27742. disablePerformanceMonitorInBackground: boolean;
  27743. /**
  27744. * Gets the performance monitor attached to this engine
  27745. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27746. */
  27747. readonly performanceMonitor: PerformanceMonitor;
  27748. /** @hidden */
  27749. protected _depthCullingState: _DepthCullingState;
  27750. /** @hidden */
  27751. protected _stencilState: _StencilState;
  27752. /** @hidden */
  27753. protected _alphaState: _AlphaState;
  27754. /** @hidden */
  27755. protected _alphaMode: number;
  27756. protected _internalTexturesCache: InternalTexture[];
  27757. /** @hidden */
  27758. protected _activeChannel: number;
  27759. private _currentTextureChannel;
  27760. /** @hidden */
  27761. protected _boundTexturesCache: {
  27762. [key: string]: Nullable<InternalTexture>;
  27763. };
  27764. /** @hidden */
  27765. protected _currentEffect: Nullable<Effect>;
  27766. /** @hidden */
  27767. protected _currentProgram: Nullable<WebGLProgram>;
  27768. private _compiledEffects;
  27769. private _vertexAttribArraysEnabled;
  27770. /** @hidden */
  27771. protected _cachedViewport: Nullable<Viewport>;
  27772. private _cachedVertexArrayObject;
  27773. /** @hidden */
  27774. protected _cachedVertexBuffers: any;
  27775. /** @hidden */
  27776. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27777. /** @hidden */
  27778. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27779. /** @hidden */
  27780. protected _currentRenderTarget: Nullable<InternalTexture>;
  27781. private _uintIndicesCurrentlySet;
  27782. private _currentBoundBuffer;
  27783. /** @hidden */
  27784. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27785. private _currentBufferPointers;
  27786. private _currentInstanceLocations;
  27787. private _currentInstanceBuffers;
  27788. private _textureUnits;
  27789. private _firstBoundInternalTextureTracker;
  27790. private _lastBoundInternalTextureTracker;
  27791. private _workingCanvas;
  27792. private _workingContext;
  27793. private _rescalePostProcess;
  27794. private _dummyFramebuffer;
  27795. private _externalData;
  27796. private _bindedRenderFunction;
  27797. private _vaoRecordInProgress;
  27798. private _mustWipeVertexAttributes;
  27799. private _emptyTexture;
  27800. private _emptyCubeTexture;
  27801. private _emptyTexture3D;
  27802. /** @hidden */
  27803. _frameHandler: number;
  27804. private _nextFreeTextureSlots;
  27805. private _maxSimultaneousTextures;
  27806. private _activeRequests;
  27807. private _texturesSupported;
  27808. private _textureFormatInUse;
  27809. /**
  27810. * Gets the list of texture formats supported
  27811. */
  27812. readonly texturesSupported: Array<string>;
  27813. /**
  27814. * Gets the list of texture formats in use
  27815. */
  27816. readonly textureFormatInUse: Nullable<string>;
  27817. /**
  27818. * Gets the current viewport
  27819. */
  27820. readonly currentViewport: Nullable<Viewport>;
  27821. /**
  27822. * Gets the default empty texture
  27823. */
  27824. readonly emptyTexture: InternalTexture;
  27825. /**
  27826. * Gets the default empty 3D texture
  27827. */
  27828. readonly emptyTexture3D: InternalTexture;
  27829. /**
  27830. * Gets the default empty cube texture
  27831. */
  27832. readonly emptyCubeTexture: InternalTexture;
  27833. /**
  27834. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27835. */
  27836. readonly premultipliedAlpha: boolean;
  27837. /**
  27838. * Creates a new engine
  27839. * @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
  27840. * @param antialias defines enable antialiasing (default: false)
  27841. * @param options defines further options to be sent to the getContext() function
  27842. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27843. */
  27844. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27845. private _disableTouchAction;
  27846. private _rebuildInternalTextures;
  27847. private _rebuildEffects;
  27848. /**
  27849. * Gets a boolean indicating if all created effects are ready
  27850. * @returns true if all effects are ready
  27851. */
  27852. areAllEffectsReady(): boolean;
  27853. private _rebuildBuffers;
  27854. private _initGLContext;
  27855. /**
  27856. * Gets version of the current webGL context
  27857. */
  27858. readonly webGLVersion: number;
  27859. /**
  27860. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27861. */
  27862. readonly isStencilEnable: boolean;
  27863. private _prepareWorkingCanvas;
  27864. /**
  27865. * Reset the texture cache to empty state
  27866. */
  27867. resetTextureCache(): void;
  27868. /**
  27869. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27870. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27871. * @returns true if engine is in deterministic lock step mode
  27872. */
  27873. isDeterministicLockStep(): boolean;
  27874. /**
  27875. * Gets the max steps when engine is running in deterministic lock step
  27876. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27877. * @returns the max steps
  27878. */
  27879. getLockstepMaxSteps(): number;
  27880. /**
  27881. * Gets an object containing information about the current webGL context
  27882. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27883. */
  27884. getGlInfo(): {
  27885. vendor: string;
  27886. renderer: string;
  27887. version: string;
  27888. };
  27889. /**
  27890. * Gets current aspect ratio
  27891. * @param camera defines the camera to use to get the aspect ratio
  27892. * @param useScreen defines if screen size must be used (or the current render target if any)
  27893. * @returns a number defining the aspect ratio
  27894. */
  27895. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27896. /**
  27897. * Gets current screen aspect ratio
  27898. * @returns a number defining the aspect ratio
  27899. */
  27900. getScreenAspectRatio(): number;
  27901. /**
  27902. * Gets the current render width
  27903. * @param useScreen defines if screen size must be used (or the current render target if any)
  27904. * @returns a number defining the current render width
  27905. */
  27906. getRenderWidth(useScreen?: boolean): number;
  27907. /**
  27908. * Gets the current render height
  27909. * @param useScreen defines if screen size must be used (or the current render target if any)
  27910. * @returns a number defining the current render height
  27911. */
  27912. getRenderHeight(useScreen?: boolean): number;
  27913. /**
  27914. * Gets the HTML canvas attached with the current webGL context
  27915. * @returns a HTML canvas
  27916. */
  27917. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27918. /**
  27919. * Gets the client rect of the HTML canvas attached with the current webGL context
  27920. * @returns a client rectanglee
  27921. */
  27922. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27923. /**
  27924. * Defines the hardware scaling level.
  27925. * By default the hardware scaling level is computed from the window device ratio.
  27926. * 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.
  27927. * @param level defines the level to use
  27928. */
  27929. setHardwareScalingLevel(level: number): void;
  27930. /**
  27931. * Gets the current hardware scaling level.
  27932. * By default the hardware scaling level is computed from the window device ratio.
  27933. * 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.
  27934. * @returns a number indicating the current hardware scaling level
  27935. */
  27936. getHardwareScalingLevel(): number;
  27937. /**
  27938. * Gets the list of loaded textures
  27939. * @returns an array containing all loaded textures
  27940. */
  27941. getLoadedTexturesCache(): InternalTexture[];
  27942. /**
  27943. * Gets the object containing all engine capabilities
  27944. * @returns the EngineCapabilities object
  27945. */
  27946. getCaps(): EngineCapabilities;
  27947. /**
  27948. * Gets the current depth function
  27949. * @returns a number defining the depth function
  27950. */
  27951. getDepthFunction(): Nullable<number>;
  27952. /**
  27953. * Sets the current depth function
  27954. * @param depthFunc defines the function to use
  27955. */
  27956. setDepthFunction(depthFunc: number): void;
  27957. /**
  27958. * Sets the current depth function to GREATER
  27959. */
  27960. setDepthFunctionToGreater(): void;
  27961. /**
  27962. * Sets the current depth function to GEQUAL
  27963. */
  27964. setDepthFunctionToGreaterOrEqual(): void;
  27965. /**
  27966. * Sets the current depth function to LESS
  27967. */
  27968. setDepthFunctionToLess(): void;
  27969. /**
  27970. * Sets the current depth function to LEQUAL
  27971. */
  27972. setDepthFunctionToLessOrEqual(): void;
  27973. /**
  27974. * Gets a boolean indicating if stencil buffer is enabled
  27975. * @returns the current stencil buffer state
  27976. */
  27977. getStencilBuffer(): boolean;
  27978. /**
  27979. * Enable or disable the stencil buffer
  27980. * @param enable defines if the stencil buffer must be enabled or disabled
  27981. */
  27982. setStencilBuffer(enable: boolean): void;
  27983. /**
  27984. * Gets the current stencil mask
  27985. * @returns a number defining the new stencil mask to use
  27986. */
  27987. getStencilMask(): number;
  27988. /**
  27989. * Sets the current stencil mask
  27990. * @param mask defines the new stencil mask to use
  27991. */
  27992. setStencilMask(mask: number): void;
  27993. /**
  27994. * Gets the current stencil function
  27995. * @returns a number defining the stencil function to use
  27996. */
  27997. getStencilFunction(): number;
  27998. /**
  27999. * Gets the current stencil reference value
  28000. * @returns a number defining the stencil reference value to use
  28001. */
  28002. getStencilFunctionReference(): number;
  28003. /**
  28004. * Gets the current stencil mask
  28005. * @returns a number defining the stencil mask to use
  28006. */
  28007. getStencilFunctionMask(): number;
  28008. /**
  28009. * Sets the current stencil function
  28010. * @param stencilFunc defines the new stencil function to use
  28011. */
  28012. setStencilFunction(stencilFunc: number): void;
  28013. /**
  28014. * Sets the current stencil reference
  28015. * @param reference defines the new stencil reference to use
  28016. */
  28017. setStencilFunctionReference(reference: number): void;
  28018. /**
  28019. * Sets the current stencil mask
  28020. * @param mask defines the new stencil mask to use
  28021. */
  28022. setStencilFunctionMask(mask: number): void;
  28023. /**
  28024. * Gets the current stencil operation when stencil fails
  28025. * @returns a number defining stencil operation to use when stencil fails
  28026. */
  28027. getStencilOperationFail(): number;
  28028. /**
  28029. * Gets the current stencil operation when depth fails
  28030. * @returns a number defining stencil operation to use when depth fails
  28031. */
  28032. getStencilOperationDepthFail(): number;
  28033. /**
  28034. * Gets the current stencil operation when stencil passes
  28035. * @returns a number defining stencil operation to use when stencil passes
  28036. */
  28037. getStencilOperationPass(): number;
  28038. /**
  28039. * Sets the stencil operation to use when stencil fails
  28040. * @param operation defines the stencil operation to use when stencil fails
  28041. */
  28042. setStencilOperationFail(operation: number): void;
  28043. /**
  28044. * Sets the stencil operation to use when depth fails
  28045. * @param operation defines the stencil operation to use when depth fails
  28046. */
  28047. setStencilOperationDepthFail(operation: number): void;
  28048. /**
  28049. * Sets the stencil operation to use when stencil passes
  28050. * @param operation defines the stencil operation to use when stencil passes
  28051. */
  28052. setStencilOperationPass(operation: number): void;
  28053. /**
  28054. * Sets a boolean indicating if the dithering state is enabled or disabled
  28055. * @param value defines the dithering state
  28056. */
  28057. setDitheringState(value: boolean): void;
  28058. /**
  28059. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28060. * @param value defines the rasterizer state
  28061. */
  28062. setRasterizerState(value: boolean): void;
  28063. /**
  28064. * stop executing a render loop function and remove it from the execution array
  28065. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28066. */
  28067. stopRenderLoop(renderFunction?: () => void): void;
  28068. /** @hidden */
  28069. _renderLoop(): void;
  28070. /**
  28071. * Register and execute a render loop. The engine can have more than one render function
  28072. * @param renderFunction defines the function to continuously execute
  28073. */
  28074. runRenderLoop(renderFunction: () => void): void;
  28075. /**
  28076. * Toggle full screen mode
  28077. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28078. */
  28079. switchFullscreen(requestPointerLock: boolean): void;
  28080. /**
  28081. * Clear the current render buffer or the current render target (if any is set up)
  28082. * @param color defines the color to use
  28083. * @param backBuffer defines if the back buffer must be cleared
  28084. * @param depth defines if the depth buffer must be cleared
  28085. * @param stencil defines if the stencil buffer must be cleared
  28086. */
  28087. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28088. /**
  28089. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28090. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28091. * @param y defines the y-coordinate of the corner of the clear rectangle
  28092. * @param width defines the width of the clear rectangle
  28093. * @param height defines the height of the clear rectangle
  28094. * @param clearColor defines the clear color
  28095. */
  28096. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28097. /**
  28098. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28099. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28100. * @param y defines the y-coordinate of the corner of the clear rectangle
  28101. * @param width defines the width of the clear rectangle
  28102. * @param height defines the height of the clear rectangle
  28103. */
  28104. enableScissor(x: number, y: number, width: number, height: number): void;
  28105. /**
  28106. * Disable previously set scissor test rectangle
  28107. */
  28108. disableScissor(): void;
  28109. private _viewportCached;
  28110. /** @hidden */
  28111. _viewport(x: number, y: number, width: number, height: number): void;
  28112. /**
  28113. * Set the WebGL's viewport
  28114. * @param viewport defines the viewport element to be used
  28115. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28116. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28117. */
  28118. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28119. /**
  28120. * Directly set the WebGL Viewport
  28121. * @param x defines the x coordinate of the viewport (in screen space)
  28122. * @param y defines the y coordinate of the viewport (in screen space)
  28123. * @param width defines the width of the viewport (in screen space)
  28124. * @param height defines the height of the viewport (in screen space)
  28125. * @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
  28126. */
  28127. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28128. /**
  28129. * Begin a new frame
  28130. */
  28131. beginFrame(): void;
  28132. /**
  28133. * Enf the current frame
  28134. */
  28135. endFrame(): void;
  28136. /**
  28137. * Resize the view according to the canvas' size
  28138. */
  28139. resize(): void;
  28140. /**
  28141. * Force a specific size of the canvas
  28142. * @param width defines the new canvas' width
  28143. * @param height defines the new canvas' height
  28144. */
  28145. setSize(width: number, height: number): void;
  28146. /**
  28147. * Gets a boolean indicating if a webVR device was detected
  28148. * @returns true if a webVR device was detected
  28149. */
  28150. isVRDevicePresent(): boolean;
  28151. /**
  28152. * Gets the current webVR device
  28153. * @returns the current webVR device (or null)
  28154. */
  28155. getVRDevice(): any;
  28156. /**
  28157. * Initializes a webVR display and starts listening to display change events
  28158. * The onVRDisplayChangedObservable will be notified upon these changes
  28159. * @returns The onVRDisplayChangedObservable
  28160. */
  28161. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28162. /**
  28163. * Initializes a webVR display and starts listening to display change events
  28164. * The onVRDisplayChangedObservable will be notified upon these changes
  28165. * @returns A promise containing a VRDisplay and if vr is supported
  28166. */
  28167. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28168. /**
  28169. * Call this function to switch to webVR mode
  28170. * Will do nothing if webVR is not supported or if there is no webVR device
  28171. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28172. */
  28173. enableVR(): void;
  28174. /**
  28175. * Call this function to leave webVR mode
  28176. * Will do nothing if webVR is not supported or if there is no webVR device
  28177. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28178. */
  28179. disableVR(): void;
  28180. private _onVRFullScreenTriggered;
  28181. private _getVRDisplaysAsync;
  28182. /**
  28183. * Binds the frame buffer to the specified texture.
  28184. * @param texture The texture to render to or null for the default canvas
  28185. * @param faceIndex The face of the texture to render to in case of cube texture
  28186. * @param requiredWidth The width of the target to render to
  28187. * @param requiredHeight The height of the target to render to
  28188. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28189. * @param depthStencilTexture The depth stencil texture to use to render
  28190. * @param lodLevel defines le lod level to bind to the frame buffer
  28191. */
  28192. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28193. private bindUnboundFramebuffer;
  28194. /**
  28195. * Unbind the current render target texture from the webGL context
  28196. * @param texture defines the render target texture to unbind
  28197. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28198. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28199. */
  28200. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28201. /**
  28202. * Unbind a list of render target textures from the webGL context
  28203. * This is used only when drawBuffer extension or webGL2 are active
  28204. * @param textures defines the render target textures to unbind
  28205. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28206. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28207. */
  28208. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28209. /**
  28210. * Force the mipmap generation for the given render target texture
  28211. * @param texture defines the render target texture to use
  28212. */
  28213. generateMipMapsForCubemap(texture: InternalTexture): void;
  28214. /**
  28215. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28216. */
  28217. flushFramebuffer(): void;
  28218. /**
  28219. * Unbind the current render target and bind the default framebuffer
  28220. */
  28221. restoreDefaultFramebuffer(): void;
  28222. /**
  28223. * Create an uniform buffer
  28224. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28225. * @param elements defines the content of the uniform buffer
  28226. * @returns the webGL uniform buffer
  28227. */
  28228. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28229. /**
  28230. * Create a dynamic uniform buffer
  28231. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28232. * @param elements defines the content of the uniform buffer
  28233. * @returns the webGL uniform buffer
  28234. */
  28235. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28236. /**
  28237. * Update an existing uniform buffer
  28238. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28239. * @param uniformBuffer defines the target uniform buffer
  28240. * @param elements defines the content to update
  28241. * @param offset defines the offset in the uniform buffer where update should start
  28242. * @param count defines the size of the data to update
  28243. */
  28244. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28245. private _resetVertexBufferBinding;
  28246. /**
  28247. * Creates a vertex buffer
  28248. * @param data the data for the vertex buffer
  28249. * @returns the new WebGL static buffer
  28250. */
  28251. createVertexBuffer(data: DataArray): WebGLBuffer;
  28252. /**
  28253. * Creates a dynamic vertex buffer
  28254. * @param data the data for the dynamic vertex buffer
  28255. * @returns the new WebGL dynamic buffer
  28256. */
  28257. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28258. /**
  28259. * Update a dynamic index buffer
  28260. * @param indexBuffer defines the target index buffer
  28261. * @param indices defines the data to update
  28262. * @param offset defines the offset in the target index buffer where update should start
  28263. */
  28264. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28265. /**
  28266. * Updates a dynamic vertex buffer.
  28267. * @param vertexBuffer the vertex buffer to update
  28268. * @param data the data used to update the vertex buffer
  28269. * @param byteOffset the byte offset of the data
  28270. * @param byteLength the byte length of the data
  28271. */
  28272. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28273. private _resetIndexBufferBinding;
  28274. /**
  28275. * Creates a new index buffer
  28276. * @param indices defines the content of the index buffer
  28277. * @param updatable defines if the index buffer must be updatable
  28278. * @returns a new webGL buffer
  28279. */
  28280. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28281. /**
  28282. * Bind a webGL buffer to the webGL context
  28283. * @param buffer defines the buffer to bind
  28284. */
  28285. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28286. /**
  28287. * Bind an uniform buffer to the current webGL context
  28288. * @param buffer defines the buffer to bind
  28289. */
  28290. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28291. /**
  28292. * Bind a buffer to the current webGL context at a given location
  28293. * @param buffer defines the buffer to bind
  28294. * @param location defines the index where to bind the buffer
  28295. */
  28296. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28297. /**
  28298. * Bind a specific block at a given index in a specific shader program
  28299. * @param shaderProgram defines the shader program
  28300. * @param blockName defines the block name
  28301. * @param index defines the index where to bind the block
  28302. */
  28303. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28304. private bindIndexBuffer;
  28305. private bindBuffer;
  28306. /**
  28307. * update the bound buffer with the given data
  28308. * @param data defines the data to update
  28309. */
  28310. updateArrayBuffer(data: Float32Array): void;
  28311. private _vertexAttribPointer;
  28312. private _bindIndexBufferWithCache;
  28313. private _bindVertexBuffersAttributes;
  28314. /**
  28315. * Records a vertex array object
  28316. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28317. * @param vertexBuffers defines the list of vertex buffers to store
  28318. * @param indexBuffer defines the index buffer to store
  28319. * @param effect defines the effect to store
  28320. * @returns the new vertex array object
  28321. */
  28322. recordVertexArrayObject(vertexBuffers: {
  28323. [key: string]: VertexBuffer;
  28324. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28325. /**
  28326. * Bind a specific vertex array object
  28327. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28328. * @param vertexArrayObject defines the vertex array object to bind
  28329. * @param indexBuffer defines the index buffer to bind
  28330. */
  28331. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28332. /**
  28333. * Bind webGl buffers directly to the webGL context
  28334. * @param vertexBuffer defines the vertex buffer to bind
  28335. * @param indexBuffer defines the index buffer to bind
  28336. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28337. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28338. * @param effect defines the effect associated with the vertex buffer
  28339. */
  28340. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28341. private _unbindVertexArrayObject;
  28342. /**
  28343. * Bind a list of vertex buffers to the webGL context
  28344. * @param vertexBuffers defines the list of vertex buffers to bind
  28345. * @param indexBuffer defines the index buffer to bind
  28346. * @param effect defines the effect associated with the vertex buffers
  28347. */
  28348. bindBuffers(vertexBuffers: {
  28349. [key: string]: Nullable<VertexBuffer>;
  28350. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28351. /**
  28352. * Unbind all instance attributes
  28353. */
  28354. unbindInstanceAttributes(): void;
  28355. /**
  28356. * Release and free the memory of a vertex array object
  28357. * @param vao defines the vertex array object to delete
  28358. */
  28359. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28360. /** @hidden */
  28361. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28362. /**
  28363. * Creates a webGL buffer to use with instanciation
  28364. * @param capacity defines the size of the buffer
  28365. * @returns the webGL buffer
  28366. */
  28367. createInstancesBuffer(capacity: number): WebGLBuffer;
  28368. /**
  28369. * Delete a webGL buffer used with instanciation
  28370. * @param buffer defines the webGL buffer to delete
  28371. */
  28372. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28373. /**
  28374. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28375. * @param instancesBuffer defines the webGL buffer to update and bind
  28376. * @param data defines the data to store in the buffer
  28377. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28378. */
  28379. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28380. /**
  28381. * Apply all cached states (depth, culling, stencil and alpha)
  28382. */
  28383. applyStates(): void;
  28384. /**
  28385. * Send a draw order
  28386. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28387. * @param indexStart defines the starting index
  28388. * @param indexCount defines the number of index to draw
  28389. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28390. */
  28391. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28392. /**
  28393. * Draw a list of points
  28394. * @param verticesStart defines the index of first vertex to draw
  28395. * @param verticesCount defines the count of vertices to draw
  28396. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28397. */
  28398. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28399. /**
  28400. * Draw a list of unindexed primitives
  28401. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28402. * @param verticesStart defines the index of first vertex to draw
  28403. * @param verticesCount defines the count of vertices to draw
  28404. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28405. */
  28406. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28407. /**
  28408. * Draw a list of indexed primitives
  28409. * @param fillMode defines the primitive to use
  28410. * @param indexStart defines the starting index
  28411. * @param indexCount defines the number of index to draw
  28412. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28413. */
  28414. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28415. /**
  28416. * Draw a list of unindexed primitives
  28417. * @param fillMode defines the primitive to use
  28418. * @param verticesStart defines the index of first vertex to draw
  28419. * @param verticesCount defines the count of vertices to draw
  28420. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28421. */
  28422. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28423. private _drawMode;
  28424. /** @hidden */
  28425. _releaseEffect(effect: Effect): void;
  28426. /** @hidden */
  28427. _deleteProgram(program: WebGLProgram): void;
  28428. /**
  28429. * Create a new effect (used to store vertex/fragment shaders)
  28430. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28431. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28432. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28433. * @param samplers defines an array of string used to represent textures
  28434. * @param defines defines the string containing the defines to use to compile the shaders
  28435. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28436. * @param onCompiled defines a function to call when the effect creation is successful
  28437. * @param onError defines a function to call when the effect creation has failed
  28438. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28439. * @returns the new Effect
  28440. */
  28441. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  28442. private _compileShader;
  28443. private _compileRawShader;
  28444. /**
  28445. * Directly creates a webGL program
  28446. * @param vertexCode defines the vertex shader code to use
  28447. * @param fragmentCode defines the fragment shader code to use
  28448. * @param context defines the webGL context to use (if not set, the current one will be used)
  28449. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28450. * @returns the new webGL program
  28451. */
  28452. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28453. /**
  28454. * Creates a webGL program
  28455. * @param vertexCode defines the vertex shader code to use
  28456. * @param fragmentCode defines the fragment shader code to use
  28457. * @param defines defines the string containing the defines to use to compile the shaders
  28458. * @param context defines the webGL context to use (if not set, the current one will be used)
  28459. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28460. * @returns the new webGL program
  28461. */
  28462. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28463. private _createShaderProgram;
  28464. private _finalizeProgram;
  28465. /** @hidden */
  28466. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28467. /** @hidden */
  28468. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28469. /**
  28470. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28471. * @param shaderProgram defines the webGL program to use
  28472. * @param uniformsNames defines the list of uniform names
  28473. * @returns an array of webGL uniform locations
  28474. */
  28475. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28476. /**
  28477. * Gets the lsit of active attributes for a given webGL program
  28478. * @param shaderProgram defines the webGL program to use
  28479. * @param attributesNames defines the list of attribute names to get
  28480. * @returns an array of indices indicating the offset of each attribute
  28481. */
  28482. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28483. /**
  28484. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28485. * @param effect defines the effect to activate
  28486. */
  28487. enableEffect(effect: Nullable<Effect>): void;
  28488. /**
  28489. * Set the value of an uniform to an array of int32
  28490. * @param uniform defines the webGL uniform location where to store the value
  28491. * @param array defines the array of int32 to store
  28492. */
  28493. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28494. /**
  28495. * Set the value of an uniform to an array of int32 (stored as vec2)
  28496. * @param uniform defines the webGL uniform location where to store the value
  28497. * @param array defines the array of int32 to store
  28498. */
  28499. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28500. /**
  28501. * Set the value of an uniform to an array of int32 (stored as vec3)
  28502. * @param uniform defines the webGL uniform location where to store the value
  28503. * @param array defines the array of int32 to store
  28504. */
  28505. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28506. /**
  28507. * Set the value of an uniform to an array of int32 (stored as vec4)
  28508. * @param uniform defines the webGL uniform location where to store the value
  28509. * @param array defines the array of int32 to store
  28510. */
  28511. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28512. /**
  28513. * Set the value of an uniform to an array of float32
  28514. * @param uniform defines the webGL uniform location where to store the value
  28515. * @param array defines the array of float32 to store
  28516. */
  28517. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28518. /**
  28519. * Set the value of an uniform to an array of float32 (stored as vec2)
  28520. * @param uniform defines the webGL uniform location where to store the value
  28521. * @param array defines the array of float32 to store
  28522. */
  28523. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28524. /**
  28525. * Set the value of an uniform to an array of float32 (stored as vec3)
  28526. * @param uniform defines the webGL uniform location where to store the value
  28527. * @param array defines the array of float32 to store
  28528. */
  28529. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28530. /**
  28531. * Set the value of an uniform to an array of float32 (stored as vec4)
  28532. * @param uniform defines the webGL uniform location where to store the value
  28533. * @param array defines the array of float32 to store
  28534. */
  28535. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28536. /**
  28537. * Set the value of an uniform to an array of number
  28538. * @param uniform defines the webGL uniform location where to store the value
  28539. * @param array defines the array of number to store
  28540. */
  28541. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28542. /**
  28543. * Set the value of an uniform to an array of number (stored as vec2)
  28544. * @param uniform defines the webGL uniform location where to store the value
  28545. * @param array defines the array of number to store
  28546. */
  28547. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28548. /**
  28549. * Set the value of an uniform to an array of number (stored as vec3)
  28550. * @param uniform defines the webGL uniform location where to store the value
  28551. * @param array defines the array of number to store
  28552. */
  28553. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28554. /**
  28555. * Set the value of an uniform to an array of number (stored as vec4)
  28556. * @param uniform defines the webGL uniform location where to store the value
  28557. * @param array defines the array of number to store
  28558. */
  28559. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28560. /**
  28561. * Set the value of an uniform to an array of float32 (stored as matrices)
  28562. * @param uniform defines the webGL uniform location where to store the value
  28563. * @param matrices defines the array of float32 to store
  28564. */
  28565. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28566. /**
  28567. * Set the value of an uniform to a matrix
  28568. * @param uniform defines the webGL uniform location where to store the value
  28569. * @param matrix defines the matrix to store
  28570. */
  28571. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28572. /**
  28573. * Set the value of an uniform to a matrix (3x3)
  28574. * @param uniform defines the webGL uniform location where to store the value
  28575. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28576. */
  28577. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28578. /**
  28579. * Set the value of an uniform to a matrix (2x2)
  28580. * @param uniform defines the webGL uniform location where to store the value
  28581. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28582. */
  28583. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28584. /**
  28585. * Set the value of an uniform to a number (int)
  28586. * @param uniform defines the webGL uniform location where to store the value
  28587. * @param value defines the int number to store
  28588. */
  28589. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28590. /**
  28591. * Set the value of an uniform to a number (float)
  28592. * @param uniform defines the webGL uniform location where to store the value
  28593. * @param value defines the float number to store
  28594. */
  28595. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28596. /**
  28597. * Set the value of an uniform to a vec2
  28598. * @param uniform defines the webGL uniform location where to store the value
  28599. * @param x defines the 1st component of the value
  28600. * @param y defines the 2nd component of the value
  28601. */
  28602. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28603. /**
  28604. * Set the value of an uniform to a vec3
  28605. * @param uniform defines the webGL uniform location where to store the value
  28606. * @param x defines the 1st component of the value
  28607. * @param y defines the 2nd component of the value
  28608. * @param z defines the 3rd component of the value
  28609. */
  28610. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28611. /**
  28612. * Set the value of an uniform to a boolean
  28613. * @param uniform defines the webGL uniform location where to store the value
  28614. * @param bool defines the boolean to store
  28615. */
  28616. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28617. /**
  28618. * Set the value of an uniform to a vec4
  28619. * @param uniform defines the webGL uniform location where to store the value
  28620. * @param x defines the 1st component of the value
  28621. * @param y defines the 2nd component of the value
  28622. * @param z defines the 3rd component of the value
  28623. * @param w defines the 4th component of the value
  28624. */
  28625. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28626. /**
  28627. * Set the value of an uniform to a Color3
  28628. * @param uniform defines the webGL uniform location where to store the value
  28629. * @param color3 defines the color to store
  28630. */
  28631. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28632. /**
  28633. * Set the value of an uniform to a Color3 and an alpha value
  28634. * @param uniform defines the webGL uniform location where to store the value
  28635. * @param color3 defines the color to store
  28636. * @param alpha defines the alpha component to store
  28637. */
  28638. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28639. /**
  28640. * Sets a Color4 on a uniform variable
  28641. * @param uniform defines the uniform location
  28642. * @param color4 defines the value to be set
  28643. */
  28644. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28645. /**
  28646. * Set various states to the webGL context
  28647. * @param culling defines backface culling state
  28648. * @param zOffset defines the value to apply to zOffset (0 by default)
  28649. * @param force defines if states must be applied even if cache is up to date
  28650. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28651. */
  28652. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28653. /**
  28654. * Set the z offset to apply to current rendering
  28655. * @param value defines the offset to apply
  28656. */
  28657. setZOffset(value: number): void;
  28658. /**
  28659. * Gets the current value of the zOffset
  28660. * @returns the current zOffset state
  28661. */
  28662. getZOffset(): number;
  28663. /**
  28664. * Enable or disable depth buffering
  28665. * @param enable defines the state to set
  28666. */
  28667. setDepthBuffer(enable: boolean): void;
  28668. /**
  28669. * Gets a boolean indicating if depth writing is enabled
  28670. * @returns the current depth writing state
  28671. */
  28672. getDepthWrite(): boolean;
  28673. /**
  28674. * Enable or disable depth writing
  28675. * @param enable defines the state to set
  28676. */
  28677. setDepthWrite(enable: boolean): void;
  28678. /**
  28679. * Enable or disable color writing
  28680. * @param enable defines the state to set
  28681. */
  28682. setColorWrite(enable: boolean): void;
  28683. /**
  28684. * Gets a boolean indicating if color writing is enabled
  28685. * @returns the current color writing state
  28686. */
  28687. getColorWrite(): boolean;
  28688. /**
  28689. * Sets alpha constants used by some alpha blending modes
  28690. * @param r defines the red component
  28691. * @param g defines the green component
  28692. * @param b defines the blue component
  28693. * @param a defines the alpha component
  28694. */
  28695. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28696. /**
  28697. * Sets the current alpha mode
  28698. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28699. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28700. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28701. */
  28702. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28703. /**
  28704. * Gets the current alpha mode
  28705. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28706. * @returns the current alpha mode
  28707. */
  28708. getAlphaMode(): number;
  28709. /**
  28710. * Clears the list of texture accessible through engine.
  28711. * This can help preventing texture load conflict due to name collision.
  28712. */
  28713. clearInternalTexturesCache(): void;
  28714. /**
  28715. * Force the entire cache to be cleared
  28716. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28717. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28718. */
  28719. wipeCaches(bruteForce?: boolean): void;
  28720. /**
  28721. * Set the compressed texture format to use, based on the formats you have, and the formats
  28722. * supported by the hardware / browser.
  28723. *
  28724. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28725. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28726. * to API arguments needed to compressed textures. This puts the burden on the container
  28727. * generator to house the arcane code for determining these for current & future formats.
  28728. *
  28729. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28730. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28731. *
  28732. * Note: The result of this call is not taken into account when a texture is base64.
  28733. *
  28734. * @param formatsAvailable defines the list of those format families you have created
  28735. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28736. *
  28737. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28738. * @returns The extension selected.
  28739. */
  28740. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28741. private _getSamplingParameters;
  28742. private _partialLoadImg;
  28743. private _cascadeLoadImgs;
  28744. /** @hidden */
  28745. _createTexture(): WebGLTexture;
  28746. /**
  28747. * Usually called from Texture.ts.
  28748. * Passed information to create a WebGLTexture
  28749. * @param urlArg defines a value which contains one of the following:
  28750. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28751. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28752. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28753. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28754. * @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)
  28755. * @param scene needed for loading to the correct scene
  28756. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28757. * @param onLoad optional callback to be called upon successful completion
  28758. * @param onError optional callback to be called upon failure
  28759. * @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
  28760. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28761. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28762. * @param forcedExtension defines the extension to use to pick the right loader
  28763. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28764. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28765. */
  28766. 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;
  28767. private _rescaleTexture;
  28768. /**
  28769. * Update a raw texture
  28770. * @param texture defines the texture to update
  28771. * @param data defines the data to store in the texture
  28772. * @param format defines the format of the data
  28773. * @param invertY defines if data must be stored with Y axis inverted
  28774. * @param compression defines the compression used (null by default)
  28775. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28776. */
  28777. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28778. /**
  28779. * Creates a raw texture
  28780. * @param data defines the data to store in the texture
  28781. * @param width defines the width of the texture
  28782. * @param height defines the height of the texture
  28783. * @param format defines the format of the data
  28784. * @param generateMipMaps defines if the engine should generate the mip levels
  28785. * @param invertY defines if data must be stored with Y axis inverted
  28786. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28787. * @param compression defines the compression used (null by default)
  28788. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28789. * @returns the raw texture inside an InternalTexture
  28790. */
  28791. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28792. private _unpackFlipYCached;
  28793. /**
  28794. * In case you are sharing the context with other applications, it might
  28795. * be interested to not cache the unpack flip y state to ensure a consistent
  28796. * value would be set.
  28797. */
  28798. enableUnpackFlipYCached: boolean;
  28799. /** @hidden */
  28800. _unpackFlipY(value: boolean): void;
  28801. /** @hidden */
  28802. _getUnpackAlignement(): number;
  28803. /**
  28804. * Creates a dynamic texture
  28805. * @param width defines the width of the texture
  28806. * @param height defines the height of the texture
  28807. * @param generateMipMaps defines if the engine should generate the mip levels
  28808. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28809. * @returns the dynamic texture inside an InternalTexture
  28810. */
  28811. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28812. /**
  28813. * Update the sampling mode of a given texture
  28814. * @param samplingMode defines the required sampling mode
  28815. * @param texture defines the texture to update
  28816. */
  28817. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28818. /**
  28819. * Update the content of a dynamic texture
  28820. * @param texture defines the texture to update
  28821. * @param canvas defines the canvas containing the source
  28822. * @param invertY defines if data must be stored with Y axis inverted
  28823. * @param premulAlpha defines if alpha is stored as premultiplied
  28824. * @param format defines the format of the data
  28825. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28826. */
  28827. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28828. /**
  28829. * Update a video texture
  28830. * @param texture defines the texture to update
  28831. * @param video defines the video element to use
  28832. * @param invertY defines if data must be stored with Y axis inverted
  28833. */
  28834. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28835. /**
  28836. * Updates a depth texture Comparison Mode and Function.
  28837. * If the comparison Function is equal to 0, the mode will be set to none.
  28838. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28839. * @param texture The texture to set the comparison function for
  28840. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28841. */
  28842. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28843. private _setupDepthStencilTexture;
  28844. /**
  28845. * Creates a depth stencil texture.
  28846. * This is only available in WebGL 2 or with the depth texture extension available.
  28847. * @param size The size of face edge in the texture.
  28848. * @param options The options defining the texture.
  28849. * @returns The texture
  28850. */
  28851. createDepthStencilTexture(size: number | {
  28852. width: number;
  28853. height: number;
  28854. }, options: DepthTextureCreationOptions): InternalTexture;
  28855. /**
  28856. * Creates a depth stencil texture.
  28857. * This is only available in WebGL 2 or with the depth texture extension available.
  28858. * @param size The size of face edge in the texture.
  28859. * @param options The options defining the texture.
  28860. * @returns The texture
  28861. */
  28862. private _createDepthStencilTexture;
  28863. /**
  28864. * Creates a depth stencil cube texture.
  28865. * This is only available in WebGL 2.
  28866. * @param size The size of face edge in the cube texture.
  28867. * @param options The options defining the cube texture.
  28868. * @returns The cube texture
  28869. */
  28870. private _createDepthStencilCubeTexture;
  28871. /**
  28872. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28873. * @param renderTarget The render target to set the frame buffer for
  28874. */
  28875. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28876. /**
  28877. * Creates a new render target texture
  28878. * @param size defines the size of the texture
  28879. * @param options defines the options used to create the texture
  28880. * @returns a new render target texture stored in an InternalTexture
  28881. */
  28882. createRenderTargetTexture(size: number | {
  28883. width: number;
  28884. height: number;
  28885. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28886. /**
  28887. * Create a multi render target texture
  28888. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28889. * @param size defines the size of the texture
  28890. * @param options defines the creation options
  28891. * @returns the cube texture as an InternalTexture
  28892. */
  28893. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28894. private _setupFramebufferDepthAttachments;
  28895. /**
  28896. * Updates the sample count of a render target texture
  28897. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28898. * @param texture defines the texture to update
  28899. * @param samples defines the sample count to set
  28900. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28901. */
  28902. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28903. /**
  28904. * Update the sample count for a given multiple render target texture
  28905. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28906. * @param textures defines the textures to update
  28907. * @param samples defines the sample count to set
  28908. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28909. */
  28910. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28911. /** @hidden */
  28912. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28913. /** @hidden */
  28914. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28915. /** @hidden */
  28916. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28917. /** @hidden */
  28918. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28919. /**
  28920. * Creates a new render target cube texture
  28921. * @param size defines the size of the texture
  28922. * @param options defines the options used to create the texture
  28923. * @returns a new render target cube texture stored in an InternalTexture
  28924. */
  28925. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28926. /**
  28927. * Creates a cube texture
  28928. * @param rootUrl defines the url where the files to load is located
  28929. * @param scene defines the current scene
  28930. * @param files defines the list of files to load (1 per face)
  28931. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28932. * @param onLoad defines an optional callback raised when the texture is loaded
  28933. * @param onError defines an optional callback raised if there is an issue to load the texture
  28934. * @param format defines the format of the data
  28935. * @param forcedExtension defines the extension to use to pick the right loader
  28936. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28937. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28938. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28939. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28940. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28941. * @returns the cube texture as an InternalTexture
  28942. */
  28943. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  28944. /**
  28945. * @hidden
  28946. */
  28947. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28948. /**
  28949. * Update a raw cube texture
  28950. * @param texture defines the texture to udpdate
  28951. * @param data defines the data to store
  28952. * @param format defines the data format
  28953. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28954. * @param invertY defines if data must be stored with Y axis inverted
  28955. * @param compression defines the compression used (null by default)
  28956. * @param level defines which level of the texture to update
  28957. */
  28958. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28959. /**
  28960. * Creates a new raw cube texture
  28961. * @param data defines the array of data to use to create each face
  28962. * @param size defines the size of the textures
  28963. * @param format defines the format of the data
  28964. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28965. * @param generateMipMaps defines if the engine should generate the mip levels
  28966. * @param invertY defines if data must be stored with Y axis inverted
  28967. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28968. * @param compression defines the compression used (null by default)
  28969. * @returns the cube texture as an InternalTexture
  28970. */
  28971. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28972. /**
  28973. * Creates a new raw cube texture from a specified url
  28974. * @param url defines the url where the data is located
  28975. * @param scene defines the current scene
  28976. * @param size defines the size of the textures
  28977. * @param format defines the format of the data
  28978. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28979. * @param noMipmap defines if the engine should avoid generating the mip levels
  28980. * @param callback defines a callback used to extract texture data from loaded data
  28981. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28982. * @param onLoad defines a callback called when texture is loaded
  28983. * @param onError defines a callback called if there is an error
  28984. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28985. * @param invertY defines if data must be stored with Y axis inverted
  28986. * @returns the cube texture as an InternalTexture
  28987. */
  28988. 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;
  28989. /**
  28990. * Update a raw 3D texture
  28991. * @param texture defines the texture to update
  28992. * @param data defines the data to store
  28993. * @param format defines the data format
  28994. * @param invertY defines if data must be stored with Y axis inverted
  28995. * @param compression defines the used compression (can be null)
  28996. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28997. */
  28998. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28999. /**
  29000. * Creates a new raw 3D texture
  29001. * @param data defines the data used to create the texture
  29002. * @param width defines the width of the texture
  29003. * @param height defines the height of the texture
  29004. * @param depth defines the depth of the texture
  29005. * @param format defines the format of the texture
  29006. * @param generateMipMaps defines if the engine must generate mip levels
  29007. * @param invertY defines if data must be stored with Y axis inverted
  29008. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29009. * @param compression defines the compressed used (can be null)
  29010. * @param textureType defines the compressed used (can be null)
  29011. * @returns a new raw 3D texture (stored in an InternalTexture)
  29012. */
  29013. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29014. private _prepareWebGLTextureContinuation;
  29015. private _prepareWebGLTexture;
  29016. private _convertRGBtoRGBATextureData;
  29017. /** @hidden */
  29018. _releaseFramebufferObjects(texture: InternalTexture): void;
  29019. /** @hidden */
  29020. _releaseTexture(texture: InternalTexture): void;
  29021. private setProgram;
  29022. private _boundUniforms;
  29023. /**
  29024. * Binds an effect to the webGL context
  29025. * @param effect defines the effect to bind
  29026. */
  29027. bindSamplers(effect: Effect): void;
  29028. private _moveBoundTextureOnTop;
  29029. private _getCorrectTextureChannel;
  29030. private _linkTrackers;
  29031. private _removeDesignatedSlot;
  29032. private _activateCurrentTexture;
  29033. /** @hidden */
  29034. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29035. /** @hidden */
  29036. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29037. /**
  29038. * Sets a texture to the webGL context from a postprocess
  29039. * @param channel defines the channel to use
  29040. * @param postProcess defines the source postprocess
  29041. */
  29042. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29043. /**
  29044. * Binds the output of the passed in post process to the texture channel specified
  29045. * @param channel The channel the texture should be bound to
  29046. * @param postProcess The post process which's output should be bound
  29047. */
  29048. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29049. /**
  29050. * Unbind all textures from the webGL context
  29051. */
  29052. unbindAllTextures(): void;
  29053. /**
  29054. * Sets a texture to the according uniform.
  29055. * @param channel The texture channel
  29056. * @param uniform The uniform to set
  29057. * @param texture The texture to apply
  29058. */
  29059. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29060. /**
  29061. * Sets a depth stencil texture from a render target to the according uniform.
  29062. * @param channel The texture channel
  29063. * @param uniform The uniform to set
  29064. * @param texture The render target texture containing the depth stencil texture to apply
  29065. */
  29066. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29067. private _bindSamplerUniformToChannel;
  29068. private _getTextureWrapMode;
  29069. private _setTexture;
  29070. /**
  29071. * Sets an array of texture to the webGL context
  29072. * @param channel defines the channel where the texture array must be set
  29073. * @param uniform defines the associated uniform location
  29074. * @param textures defines the array of textures to bind
  29075. */
  29076. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29077. /** @hidden */
  29078. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29079. private _setTextureParameterFloat;
  29080. private _setTextureParameterInteger;
  29081. /**
  29082. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29083. * @param x defines the x coordinate of the rectangle where pixels must be read
  29084. * @param y defines the y coordinate of the rectangle where pixels must be read
  29085. * @param width defines the width of the rectangle where pixels must be read
  29086. * @param height defines the height of the rectangle where pixels must be read
  29087. * @returns a Uint8Array containing RGBA colors
  29088. */
  29089. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29090. /**
  29091. * Add an externaly attached data from its key.
  29092. * This method call will fail and return false, if such key already exists.
  29093. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29094. * @param key the unique key that identifies the data
  29095. * @param data the data object to associate to the key for this Engine instance
  29096. * @return true if no such key were already present and the data was added successfully, false otherwise
  29097. */
  29098. addExternalData<T>(key: string, data: T): boolean;
  29099. /**
  29100. * Get an externaly attached data from its key
  29101. * @param key the unique key that identifies the data
  29102. * @return the associated data, if present (can be null), or undefined if not present
  29103. */
  29104. getExternalData<T>(key: string): T;
  29105. /**
  29106. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29107. * @param key the unique key that identifies the data
  29108. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29109. * @return the associated data, can be null if the factory returned null.
  29110. */
  29111. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29112. /**
  29113. * Remove an externaly attached data from the Engine instance
  29114. * @param key the unique key that identifies the data
  29115. * @return true if the data was successfully removed, false if it doesn't exist
  29116. */
  29117. removeExternalData(key: string): boolean;
  29118. /**
  29119. * Unbind all vertex attributes from the webGL context
  29120. */
  29121. unbindAllAttributes(): void;
  29122. /**
  29123. * 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
  29124. */
  29125. releaseEffects(): void;
  29126. /**
  29127. * Dispose and release all associated resources
  29128. */
  29129. dispose(): void;
  29130. /**
  29131. * Display the loading screen
  29132. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29133. */
  29134. displayLoadingUI(): void;
  29135. /**
  29136. * Hide the loading screen
  29137. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29138. */
  29139. hideLoadingUI(): void;
  29140. /**
  29141. * Gets the current loading screen object
  29142. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29143. */
  29144. /**
  29145. * Sets the current loading screen object
  29146. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29147. */
  29148. loadingScreen: ILoadingScreen;
  29149. /**
  29150. * Sets the current loading screen text
  29151. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29152. */
  29153. loadingUIText: string;
  29154. /**
  29155. * Sets the current loading screen background color
  29156. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29157. */
  29158. loadingUIBackgroundColor: string;
  29159. /**
  29160. * Attach a new callback raised when context lost event is fired
  29161. * @param callback defines the callback to call
  29162. */
  29163. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29164. /**
  29165. * Attach a new callback raised when context restored event is fired
  29166. * @param callback defines the callback to call
  29167. */
  29168. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29169. /**
  29170. * Gets the source code of the vertex shader associated with a specific webGL program
  29171. * @param program defines the program to use
  29172. * @returns a string containing the source code of the vertex shader associated with the program
  29173. */
  29174. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29175. /**
  29176. * Gets the source code of the fragment shader associated with a specific webGL program
  29177. * @param program defines the program to use
  29178. * @returns a string containing the source code of the fragment shader associated with the program
  29179. */
  29180. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29181. /**
  29182. * Get the current error code of the webGL context
  29183. * @returns the error code
  29184. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29185. */
  29186. getError(): number;
  29187. /**
  29188. * Gets the current framerate
  29189. * @returns a number representing the framerate
  29190. */
  29191. getFps(): number;
  29192. /**
  29193. * Gets the time spent between current and previous frame
  29194. * @returns a number representing the delta time in ms
  29195. */
  29196. getDeltaTime(): number;
  29197. private _measureFps;
  29198. /** @hidden */
  29199. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29200. private _canRenderToFloatFramebuffer;
  29201. private _canRenderToHalfFloatFramebuffer;
  29202. private _canRenderToFramebuffer;
  29203. /** @hidden */
  29204. _getWebGLTextureType(type: number): number;
  29205. private _getInternalFormat;
  29206. /** @hidden */
  29207. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29208. /** @hidden */
  29209. _getRGBAMultiSampleBufferFormat(type: number): number;
  29210. /** @hidden */
  29211. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  29212. /** @hidden */
  29213. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29214. private _partialLoadFile;
  29215. private _cascadeLoadFiles;
  29216. /**
  29217. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29218. * @returns true if the engine can be created
  29219. * @ignorenaming
  29220. */
  29221. static isSupported(): boolean;
  29222. }
  29223. }
  29224. declare module BABYLON {
  29225. /**
  29226. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29227. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29228. */
  29229. export class EffectFallbacks {
  29230. private _defines;
  29231. private _currentRank;
  29232. private _maxRank;
  29233. private _mesh;
  29234. /**
  29235. * Removes the fallback from the bound mesh.
  29236. */
  29237. unBindMesh(): void;
  29238. /**
  29239. * Adds a fallback on the specified property.
  29240. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29241. * @param define The name of the define in the shader
  29242. */
  29243. addFallback(rank: number, define: string): void;
  29244. /**
  29245. * Sets the mesh to use CPU skinning when needing to fallback.
  29246. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29247. * @param mesh The mesh to use the fallbacks.
  29248. */
  29249. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29250. /**
  29251. * Checks to see if more fallbacks are still availible.
  29252. */
  29253. readonly isMoreFallbacks: boolean;
  29254. /**
  29255. * Removes the defines that shoould be removed when falling back.
  29256. * @param currentDefines defines the current define statements for the shader.
  29257. * @param effect defines the current effect we try to compile
  29258. * @returns The resulting defines with defines of the current rank removed.
  29259. */
  29260. reduce(currentDefines: string, effect: Effect): string;
  29261. }
  29262. /**
  29263. * Options to be used when creating an effect.
  29264. */
  29265. export class EffectCreationOptions {
  29266. /**
  29267. * Atrributes that will be used in the shader.
  29268. */
  29269. attributes: string[];
  29270. /**
  29271. * Uniform varible names that will be set in the shader.
  29272. */
  29273. uniformsNames: string[];
  29274. /**
  29275. * Uniform buffer varible names that will be set in the shader.
  29276. */
  29277. uniformBuffersNames: string[];
  29278. /**
  29279. * Sampler texture variable names that will be set in the shader.
  29280. */
  29281. samplers: string[];
  29282. /**
  29283. * Define statements that will be set in the shader.
  29284. */
  29285. defines: any;
  29286. /**
  29287. * Possible fallbacks for this effect to improve performance when needed.
  29288. */
  29289. fallbacks: Nullable<EffectFallbacks>;
  29290. /**
  29291. * Callback that will be called when the shader is compiled.
  29292. */
  29293. onCompiled: Nullable<(effect: Effect) => void>;
  29294. /**
  29295. * Callback that will be called if an error occurs during shader compilation.
  29296. */
  29297. onError: Nullable<(effect: Effect, errors: string) => void>;
  29298. /**
  29299. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29300. */
  29301. indexParameters: any;
  29302. /**
  29303. * Max number of lights that can be used in the shader.
  29304. */
  29305. maxSimultaneousLights: number;
  29306. /**
  29307. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29308. */
  29309. transformFeedbackVaryings: Nullable<string[]>;
  29310. }
  29311. /**
  29312. * Effect containing vertex and fragment shader that can be executed on an object.
  29313. */
  29314. export class Effect {
  29315. /**
  29316. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29317. */
  29318. static ShadersRepository: string;
  29319. /**
  29320. * Name of the effect.
  29321. */
  29322. name: any;
  29323. /**
  29324. * String container all the define statements that should be set on the shader.
  29325. */
  29326. defines: string;
  29327. /**
  29328. * Callback that will be called when the shader is compiled.
  29329. */
  29330. onCompiled: Nullable<(effect: Effect) => void>;
  29331. /**
  29332. * Callback that will be called if an error occurs during shader compilation.
  29333. */
  29334. onError: Nullable<(effect: Effect, errors: string) => void>;
  29335. /**
  29336. * Callback that will be called when effect is bound.
  29337. */
  29338. onBind: Nullable<(effect: Effect) => void>;
  29339. /**
  29340. * Unique ID of the effect.
  29341. */
  29342. uniqueId: number;
  29343. /**
  29344. * Observable that will be called when the shader is compiled.
  29345. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29346. */
  29347. onCompileObservable: Observable<Effect>;
  29348. /**
  29349. * Observable that will be called if an error occurs during shader compilation.
  29350. */
  29351. onErrorObservable: Observable<Effect>;
  29352. /** @hidden */
  29353. _onBindObservable: Nullable<Observable<Effect>>;
  29354. /**
  29355. * Observable that will be called when effect is bound.
  29356. */
  29357. readonly onBindObservable: Observable<Effect>;
  29358. /** @hidden */
  29359. _bonesComputationForcedToCPU: boolean;
  29360. private static _uniqueIdSeed;
  29361. private _engine;
  29362. private _uniformBuffersNames;
  29363. private _uniformsNames;
  29364. private _samplers;
  29365. private _isReady;
  29366. private _compilationError;
  29367. private _attributesNames;
  29368. private _attributes;
  29369. private _uniforms;
  29370. /**
  29371. * Key for the effect.
  29372. * @hidden
  29373. */
  29374. _key: string;
  29375. private _indexParameters;
  29376. private _fallbacks;
  29377. private _vertexSourceCode;
  29378. private _fragmentSourceCode;
  29379. private _vertexSourceCodeOverride;
  29380. private _fragmentSourceCodeOverride;
  29381. private _transformFeedbackVaryings;
  29382. /**
  29383. * Compiled shader to webGL program.
  29384. * @hidden
  29385. */
  29386. _program: WebGLProgram;
  29387. private _valueCache;
  29388. private static _baseCache;
  29389. /**
  29390. * Instantiates an effect.
  29391. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29392. * @param baseName Name of the effect.
  29393. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29394. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29395. * @param samplers List of sampler variables that will be passed to the shader.
  29396. * @param engine Engine to be used to render the effect
  29397. * @param defines Define statements to be added to the shader.
  29398. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29399. * @param onCompiled Callback that will be called when the shader is compiled.
  29400. * @param onError Callback that will be called if an error occurs during shader compilation.
  29401. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29402. */
  29403. 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);
  29404. /**
  29405. * Unique key for this effect
  29406. */
  29407. readonly key: string;
  29408. /**
  29409. * If the effect has been compiled and prepared.
  29410. * @returns if the effect is compiled and prepared.
  29411. */
  29412. isReady(): boolean;
  29413. /**
  29414. * The engine the effect was initialized with.
  29415. * @returns the engine.
  29416. */
  29417. getEngine(): Engine;
  29418. /**
  29419. * The compiled webGL program for the effect
  29420. * @returns the webGL program.
  29421. */
  29422. getProgram(): WebGLProgram;
  29423. /**
  29424. * The set of names of attribute variables for the shader.
  29425. * @returns An array of attribute names.
  29426. */
  29427. getAttributesNames(): string[];
  29428. /**
  29429. * Returns the attribute at the given index.
  29430. * @param index The index of the attribute.
  29431. * @returns The location of the attribute.
  29432. */
  29433. getAttributeLocation(index: number): number;
  29434. /**
  29435. * Returns the attribute based on the name of the variable.
  29436. * @param name of the attribute to look up.
  29437. * @returns the attribute location.
  29438. */
  29439. getAttributeLocationByName(name: string): number;
  29440. /**
  29441. * The number of attributes.
  29442. * @returns the numnber of attributes.
  29443. */
  29444. getAttributesCount(): number;
  29445. /**
  29446. * Gets the index of a uniform variable.
  29447. * @param uniformName of the uniform to look up.
  29448. * @returns the index.
  29449. */
  29450. getUniformIndex(uniformName: string): number;
  29451. /**
  29452. * Returns the attribute based on the name of the variable.
  29453. * @param uniformName of the uniform to look up.
  29454. * @returns the location of the uniform.
  29455. */
  29456. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29457. /**
  29458. * Returns an array of sampler variable names
  29459. * @returns The array of sampler variable neames.
  29460. */
  29461. getSamplers(): string[];
  29462. /**
  29463. * The error from the last compilation.
  29464. * @returns the error string.
  29465. */
  29466. getCompilationError(): string;
  29467. /**
  29468. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29469. * @param func The callback to be used.
  29470. */
  29471. executeWhenCompiled(func: (effect: Effect) => void): void;
  29472. private _checkIsReady;
  29473. /** @hidden */
  29474. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29475. /** @hidden */
  29476. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29477. /** @hidden */
  29478. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29479. private _processShaderConversion;
  29480. private _processIncludes;
  29481. private _processPrecision;
  29482. /**
  29483. * Recompiles the webGL program
  29484. * @param vertexSourceCode The source code for the vertex shader.
  29485. * @param fragmentSourceCode The source code for the fragment shader.
  29486. * @param onCompiled Callback called when completed.
  29487. * @param onError Callback called on error.
  29488. * @hidden
  29489. */
  29490. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29491. /**
  29492. * Gets the uniform locations of the the specified variable names
  29493. * @param names THe names of the variables to lookup.
  29494. * @returns Array of locations in the same order as variable names.
  29495. */
  29496. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29497. /**
  29498. * Prepares the effect
  29499. * @hidden
  29500. */
  29501. _prepareEffect(): void;
  29502. /**
  29503. * Checks if the effect is supported. (Must be called after compilation)
  29504. */
  29505. readonly isSupported: boolean;
  29506. /**
  29507. * Binds a texture to the engine to be used as output of the shader.
  29508. * @param channel Name of the output variable.
  29509. * @param texture Texture to bind.
  29510. * @hidden
  29511. */
  29512. _bindTexture(channel: string, texture: InternalTexture): void;
  29513. /**
  29514. * Sets a texture on the engine to be used in the shader.
  29515. * @param channel Name of the sampler variable.
  29516. * @param texture Texture to set.
  29517. */
  29518. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29519. /**
  29520. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29521. * @param channel Name of the sampler variable.
  29522. * @param texture Texture to set.
  29523. */
  29524. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29525. /**
  29526. * Sets an array of textures on the engine to be used in the shader.
  29527. * @param channel Name of the variable.
  29528. * @param textures Textures to set.
  29529. */
  29530. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29531. /**
  29532. * 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)
  29533. * @param channel Name of the sampler variable.
  29534. * @param postProcess Post process to get the input texture from.
  29535. */
  29536. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29537. /**
  29538. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29539. * 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)
  29540. * @param channel Name of the sampler variable.
  29541. * @param postProcess Post process to get the output texture from.
  29542. */
  29543. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29544. /** @hidden */
  29545. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29546. /** @hidden */
  29547. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29548. /** @hidden */
  29549. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29550. /** @hidden */
  29551. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29552. /**
  29553. * Binds a buffer to a uniform.
  29554. * @param buffer Buffer to bind.
  29555. * @param name Name of the uniform variable to bind to.
  29556. */
  29557. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29558. /**
  29559. * Binds block to a uniform.
  29560. * @param blockName Name of the block to bind.
  29561. * @param index Index to bind.
  29562. */
  29563. bindUniformBlock(blockName: string, index: number): void;
  29564. /**
  29565. * Sets an interger value on a uniform variable.
  29566. * @param uniformName Name of the variable.
  29567. * @param value Value to be set.
  29568. * @returns this effect.
  29569. */
  29570. setInt(uniformName: string, value: number): Effect;
  29571. /**
  29572. * Sets an int array on a uniform variable.
  29573. * @param uniformName Name of the variable.
  29574. * @param array array to be set.
  29575. * @returns this effect.
  29576. */
  29577. setIntArray(uniformName: string, array: Int32Array): Effect;
  29578. /**
  29579. * 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)
  29580. * @param uniformName Name of the variable.
  29581. * @param array array to be set.
  29582. * @returns this effect.
  29583. */
  29584. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29585. /**
  29586. * 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)
  29587. * @param uniformName Name of the variable.
  29588. * @param array array to be set.
  29589. * @returns this effect.
  29590. */
  29591. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29592. /**
  29593. * 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)
  29594. * @param uniformName Name of the variable.
  29595. * @param array array to be set.
  29596. * @returns this effect.
  29597. */
  29598. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29599. /**
  29600. * Sets an float array on a uniform variable.
  29601. * @param uniformName Name of the variable.
  29602. * @param array array to be set.
  29603. * @returns this effect.
  29604. */
  29605. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29606. /**
  29607. * 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)
  29608. * @param uniformName Name of the variable.
  29609. * @param array array to be set.
  29610. * @returns this effect.
  29611. */
  29612. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29613. /**
  29614. * 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)
  29615. * @param uniformName Name of the variable.
  29616. * @param array array to be set.
  29617. * @returns this effect.
  29618. */
  29619. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29620. /**
  29621. * 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)
  29622. * @param uniformName Name of the variable.
  29623. * @param array array to be set.
  29624. * @returns this effect.
  29625. */
  29626. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29627. /**
  29628. * Sets an array on a uniform variable.
  29629. * @param uniformName Name of the variable.
  29630. * @param array array to be set.
  29631. * @returns this effect.
  29632. */
  29633. setArray(uniformName: string, array: number[]): Effect;
  29634. /**
  29635. * 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)
  29636. * @param uniformName Name of the variable.
  29637. * @param array array to be set.
  29638. * @returns this effect.
  29639. */
  29640. setArray2(uniformName: string, array: number[]): Effect;
  29641. /**
  29642. * 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)
  29643. * @param uniformName Name of the variable.
  29644. * @param array array to be set.
  29645. * @returns this effect.
  29646. */
  29647. setArray3(uniformName: string, array: number[]): Effect;
  29648. /**
  29649. * 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)
  29650. * @param uniformName Name of the variable.
  29651. * @param array array to be set.
  29652. * @returns this effect.
  29653. */
  29654. setArray4(uniformName: string, array: number[]): Effect;
  29655. /**
  29656. * Sets matrices on a uniform variable.
  29657. * @param uniformName Name of the variable.
  29658. * @param matrices matrices to be set.
  29659. * @returns this effect.
  29660. */
  29661. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29662. /**
  29663. * Sets matrix on a uniform variable.
  29664. * @param uniformName Name of the variable.
  29665. * @param matrix matrix to be set.
  29666. * @returns this effect.
  29667. */
  29668. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29669. /**
  29670. * 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)
  29671. * @param uniformName Name of the variable.
  29672. * @param matrix matrix to be set.
  29673. * @returns this effect.
  29674. */
  29675. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29676. /**
  29677. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29678. * @param uniformName Name of the variable.
  29679. * @param matrix matrix to be set.
  29680. * @returns this effect.
  29681. */
  29682. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29683. /**
  29684. * Sets a float on a uniform variable.
  29685. * @param uniformName Name of the variable.
  29686. * @param value value to be set.
  29687. * @returns this effect.
  29688. */
  29689. setFloat(uniformName: string, value: number): Effect;
  29690. /**
  29691. * Sets a boolean on a uniform variable.
  29692. * @param uniformName Name of the variable.
  29693. * @param bool value to be set.
  29694. * @returns this effect.
  29695. */
  29696. setBool(uniformName: string, bool: boolean): Effect;
  29697. /**
  29698. * Sets a Vector2 on a uniform variable.
  29699. * @param uniformName Name of the variable.
  29700. * @param vector2 vector2 to be set.
  29701. * @returns this effect.
  29702. */
  29703. setVector2(uniformName: string, vector2: Vector2): Effect;
  29704. /**
  29705. * Sets a float2 on a uniform variable.
  29706. * @param uniformName Name of the variable.
  29707. * @param x First float in float2.
  29708. * @param y Second float in float2.
  29709. * @returns this effect.
  29710. */
  29711. setFloat2(uniformName: string, x: number, y: number): Effect;
  29712. /**
  29713. * Sets a Vector3 on a uniform variable.
  29714. * @param uniformName Name of the variable.
  29715. * @param vector3 Value to be set.
  29716. * @returns this effect.
  29717. */
  29718. setVector3(uniformName: string, vector3: Vector3): Effect;
  29719. /**
  29720. * Sets a float3 on a uniform variable.
  29721. * @param uniformName Name of the variable.
  29722. * @param x First float in float3.
  29723. * @param y Second float in float3.
  29724. * @param z Third float in float3.
  29725. * @returns this effect.
  29726. */
  29727. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29728. /**
  29729. * Sets a Vector4 on a uniform variable.
  29730. * @param uniformName Name of the variable.
  29731. * @param vector4 Value to be set.
  29732. * @returns this effect.
  29733. */
  29734. setVector4(uniformName: string, vector4: Vector4): Effect;
  29735. /**
  29736. * Sets a float4 on a uniform variable.
  29737. * @param uniformName Name of the variable.
  29738. * @param x First float in float4.
  29739. * @param y Second float in float4.
  29740. * @param z Third float in float4.
  29741. * @param w Fourth float in float4.
  29742. * @returns this effect.
  29743. */
  29744. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29745. /**
  29746. * Sets a Color3 on a uniform variable.
  29747. * @param uniformName Name of the variable.
  29748. * @param color3 Value to be set.
  29749. * @returns this effect.
  29750. */
  29751. setColor3(uniformName: string, color3: Color3): Effect;
  29752. /**
  29753. * Sets a Color4 on a uniform variable.
  29754. * @param uniformName Name of the variable.
  29755. * @param color3 Value to be set.
  29756. * @param alpha Alpha value to be set.
  29757. * @returns this effect.
  29758. */
  29759. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29760. /**
  29761. * Sets a Color4 on a uniform variable
  29762. * @param uniformName defines the name of the variable
  29763. * @param color4 defines the value to be set
  29764. * @returns this effect.
  29765. */
  29766. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29767. /**
  29768. * This function will add a new shader to the shader store
  29769. * @param name the name of the shader
  29770. * @param pixelShader optional pixel shader content
  29771. * @param vertexShader optional vertex shader content
  29772. */
  29773. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29774. /**
  29775. * Store of each shader (The can be looked up using effect.key)
  29776. */
  29777. static ShadersStore: {
  29778. [key: string]: string;
  29779. };
  29780. /**
  29781. * Store of each included file for a shader (The can be looked up using effect.key)
  29782. */
  29783. static IncludesShadersStore: {
  29784. [key: string]: string;
  29785. };
  29786. /**
  29787. * Resets the cache of effects.
  29788. */
  29789. static ResetCache(): void;
  29790. }
  29791. }
  29792. declare module BABYLON {
  29793. /**
  29794. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29795. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29796. * 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;
  29797. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29798. */
  29799. export class ColorCurves {
  29800. private _dirty;
  29801. private _tempColor;
  29802. private _globalCurve;
  29803. private _highlightsCurve;
  29804. private _midtonesCurve;
  29805. private _shadowsCurve;
  29806. private _positiveCurve;
  29807. private _negativeCurve;
  29808. private _globalHue;
  29809. private _globalDensity;
  29810. private _globalSaturation;
  29811. private _globalExposure;
  29812. /**
  29813. * Gets the global Hue value.
  29814. * 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).
  29815. */
  29816. /**
  29817. * Sets the global Hue value.
  29818. * 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).
  29819. */
  29820. globalHue: number;
  29821. /**
  29822. * Gets the global Density value.
  29823. * 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.
  29824. * Values less than zero provide a filter of opposite hue.
  29825. */
  29826. /**
  29827. * Sets the global Density value.
  29828. * 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.
  29829. * Values less than zero provide a filter of opposite hue.
  29830. */
  29831. globalDensity: number;
  29832. /**
  29833. * Gets the global Saturation value.
  29834. * 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.
  29835. */
  29836. /**
  29837. * Sets the global Saturation value.
  29838. * 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.
  29839. */
  29840. globalSaturation: number;
  29841. /**
  29842. * Gets the global Exposure value.
  29843. * 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.
  29844. */
  29845. /**
  29846. * Sets the global Exposure value.
  29847. * 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.
  29848. */
  29849. globalExposure: number;
  29850. private _highlightsHue;
  29851. private _highlightsDensity;
  29852. private _highlightsSaturation;
  29853. private _highlightsExposure;
  29854. /**
  29855. * Gets the highlights Hue value.
  29856. * 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).
  29857. */
  29858. /**
  29859. * Sets the highlights Hue value.
  29860. * 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).
  29861. */
  29862. highlightsHue: number;
  29863. /**
  29864. * Gets the highlights Density value.
  29865. * 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.
  29866. * Values less than zero provide a filter of opposite hue.
  29867. */
  29868. /**
  29869. * Sets the highlights Density value.
  29870. * 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.
  29871. * Values less than zero provide a filter of opposite hue.
  29872. */
  29873. highlightsDensity: number;
  29874. /**
  29875. * Gets the highlights Saturation value.
  29876. * 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.
  29877. */
  29878. /**
  29879. * Sets the highlights Saturation value.
  29880. * 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.
  29881. */
  29882. highlightsSaturation: number;
  29883. /**
  29884. * Gets the highlights Exposure value.
  29885. * 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.
  29886. */
  29887. /**
  29888. * Sets the highlights Exposure value.
  29889. * 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.
  29890. */
  29891. highlightsExposure: number;
  29892. private _midtonesHue;
  29893. private _midtonesDensity;
  29894. private _midtonesSaturation;
  29895. private _midtonesExposure;
  29896. /**
  29897. * Gets the midtones Hue value.
  29898. * 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).
  29899. */
  29900. /**
  29901. * Sets the midtones Hue value.
  29902. * 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).
  29903. */
  29904. midtonesHue: number;
  29905. /**
  29906. * Gets the midtones Density value.
  29907. * 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.
  29908. * Values less than zero provide a filter of opposite hue.
  29909. */
  29910. /**
  29911. * Sets the midtones Density value.
  29912. * 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.
  29913. * Values less than zero provide a filter of opposite hue.
  29914. */
  29915. midtonesDensity: number;
  29916. /**
  29917. * Gets the midtones Saturation value.
  29918. * 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.
  29919. */
  29920. /**
  29921. * Sets the midtones Saturation value.
  29922. * 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.
  29923. */
  29924. midtonesSaturation: number;
  29925. /**
  29926. * Gets the midtones Exposure value.
  29927. * 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.
  29928. */
  29929. /**
  29930. * Sets the midtones Exposure value.
  29931. * 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.
  29932. */
  29933. midtonesExposure: number;
  29934. private _shadowsHue;
  29935. private _shadowsDensity;
  29936. private _shadowsSaturation;
  29937. private _shadowsExposure;
  29938. /**
  29939. * Gets the shadows Hue value.
  29940. * 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).
  29941. */
  29942. /**
  29943. * Sets the shadows Hue value.
  29944. * 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).
  29945. */
  29946. shadowsHue: number;
  29947. /**
  29948. * Gets the shadows Density value.
  29949. * 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.
  29950. * Values less than zero provide a filter of opposite hue.
  29951. */
  29952. /**
  29953. * Sets the shadows Density value.
  29954. * 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.
  29955. * Values less than zero provide a filter of opposite hue.
  29956. */
  29957. shadowsDensity: number;
  29958. /**
  29959. * Gets the shadows Saturation value.
  29960. * 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.
  29961. */
  29962. /**
  29963. * Sets the shadows Saturation value.
  29964. * 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.
  29965. */
  29966. shadowsSaturation: number;
  29967. /**
  29968. * Gets the shadows Exposure value.
  29969. * 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.
  29970. */
  29971. /**
  29972. * Sets the shadows Exposure value.
  29973. * 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.
  29974. */
  29975. shadowsExposure: number;
  29976. /**
  29977. * Returns the class name
  29978. * @returns The class name
  29979. */
  29980. getClassName(): string;
  29981. /**
  29982. * Binds the color curves to the shader.
  29983. * @param colorCurves The color curve to bind
  29984. * @param effect The effect to bind to
  29985. * @param positiveUniform The positive uniform shader parameter
  29986. * @param neutralUniform The neutral uniform shader parameter
  29987. * @param negativeUniform The negative uniform shader parameter
  29988. */
  29989. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29990. /**
  29991. * Prepare the list of uniforms associated with the ColorCurves effects.
  29992. * @param uniformsList The list of uniforms used in the effect
  29993. */
  29994. static PrepareUniforms(uniformsList: string[]): void;
  29995. /**
  29996. * Returns color grading data based on a hue, density, saturation and exposure value.
  29997. * @param filterHue The hue of the color filter.
  29998. * @param filterDensity The density of the color filter.
  29999. * @param saturation The saturation.
  30000. * @param exposure The exposure.
  30001. * @param result The result data container.
  30002. */
  30003. private getColorGradingDataToRef;
  30004. /**
  30005. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30006. * @param value The input slider value in range [-100,100].
  30007. * @returns Adjusted value.
  30008. */
  30009. private static applyColorGradingSliderNonlinear;
  30010. /**
  30011. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30012. * @param hue The hue (H) input.
  30013. * @param saturation The saturation (S) input.
  30014. * @param brightness The brightness (B) input.
  30015. * @result An RGBA color represented as Vector4.
  30016. */
  30017. private static fromHSBToRef;
  30018. /**
  30019. * Returns a value clamped between min and max
  30020. * @param value The value to clamp
  30021. * @param min The minimum of value
  30022. * @param max The maximum of value
  30023. * @returns The clamped value.
  30024. */
  30025. private static clamp;
  30026. /**
  30027. * Clones the current color curve instance.
  30028. * @return The cloned curves
  30029. */
  30030. clone(): ColorCurves;
  30031. /**
  30032. * Serializes the current color curve instance to a json representation.
  30033. * @return a JSON representation
  30034. */
  30035. serialize(): any;
  30036. /**
  30037. * Parses the color curve from a json representation.
  30038. * @param source the JSON source to parse
  30039. * @return The parsed curves
  30040. */
  30041. static Parse(source: any): ColorCurves;
  30042. }
  30043. }
  30044. declare module BABYLON {
  30045. /**
  30046. * Interface to follow in your material defines to integrate easily the
  30047. * Image proccessing functions.
  30048. * @hidden
  30049. */
  30050. export interface IImageProcessingConfigurationDefines {
  30051. IMAGEPROCESSING: boolean;
  30052. VIGNETTE: boolean;
  30053. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30054. VIGNETTEBLENDMODEOPAQUE: boolean;
  30055. TONEMAPPING: boolean;
  30056. TONEMAPPING_ACES: boolean;
  30057. CONTRAST: boolean;
  30058. EXPOSURE: boolean;
  30059. COLORCURVES: boolean;
  30060. COLORGRADING: boolean;
  30061. COLORGRADING3D: boolean;
  30062. SAMPLER3DGREENDEPTH: boolean;
  30063. SAMPLER3DBGRMAP: boolean;
  30064. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30065. }
  30066. /**
  30067. * @hidden
  30068. */
  30069. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30070. IMAGEPROCESSING: boolean;
  30071. VIGNETTE: boolean;
  30072. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30073. VIGNETTEBLENDMODEOPAQUE: boolean;
  30074. TONEMAPPING: boolean;
  30075. TONEMAPPING_ACES: boolean;
  30076. CONTRAST: boolean;
  30077. COLORCURVES: boolean;
  30078. COLORGRADING: boolean;
  30079. COLORGRADING3D: boolean;
  30080. SAMPLER3DGREENDEPTH: boolean;
  30081. SAMPLER3DBGRMAP: boolean;
  30082. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30083. EXPOSURE: boolean;
  30084. constructor();
  30085. }
  30086. /**
  30087. * This groups together the common properties used for image processing either in direct forward pass
  30088. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30089. * or not.
  30090. */
  30091. export class ImageProcessingConfiguration {
  30092. /**
  30093. * Default tone mapping applied in BabylonJS.
  30094. */
  30095. static readonly TONEMAPPING_STANDARD: number;
  30096. /**
  30097. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30098. * to other engines rendering to increase portability.
  30099. */
  30100. static readonly TONEMAPPING_ACES: number;
  30101. /**
  30102. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30103. */
  30104. colorCurves: Nullable<ColorCurves>;
  30105. private _colorCurvesEnabled;
  30106. /**
  30107. * Gets wether the color curves effect is enabled.
  30108. */
  30109. /**
  30110. * Sets wether the color curves effect is enabled.
  30111. */
  30112. colorCurvesEnabled: boolean;
  30113. private _colorGradingTexture;
  30114. /**
  30115. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30116. */
  30117. /**
  30118. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30119. */
  30120. colorGradingTexture: Nullable<BaseTexture>;
  30121. private _colorGradingEnabled;
  30122. /**
  30123. * Gets wether the color grading effect is enabled.
  30124. */
  30125. /**
  30126. * Sets wether the color grading effect is enabled.
  30127. */
  30128. colorGradingEnabled: boolean;
  30129. private _colorGradingWithGreenDepth;
  30130. /**
  30131. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30132. */
  30133. /**
  30134. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30135. */
  30136. colorGradingWithGreenDepth: boolean;
  30137. private _colorGradingBGR;
  30138. /**
  30139. * Gets wether the color grading texture contains BGR values.
  30140. */
  30141. /**
  30142. * Sets wether the color grading texture contains BGR values.
  30143. */
  30144. colorGradingBGR: boolean;
  30145. /** @hidden */
  30146. _exposure: number;
  30147. /**
  30148. * Gets the Exposure used in the effect.
  30149. */
  30150. /**
  30151. * Sets the Exposure used in the effect.
  30152. */
  30153. exposure: number;
  30154. private _toneMappingEnabled;
  30155. /**
  30156. * Gets wether the tone mapping effect is enabled.
  30157. */
  30158. /**
  30159. * Sets wether the tone mapping effect is enabled.
  30160. */
  30161. toneMappingEnabled: boolean;
  30162. private _toneMappingType;
  30163. /**
  30164. * Gets the type of tone mapping effect.
  30165. */
  30166. /**
  30167. * Sets the type of tone mapping effect used in BabylonJS.
  30168. */
  30169. toneMappingType: number;
  30170. protected _contrast: number;
  30171. /**
  30172. * Gets the contrast used in the effect.
  30173. */
  30174. /**
  30175. * Sets the contrast used in the effect.
  30176. */
  30177. contrast: number;
  30178. /**
  30179. * Vignette stretch size.
  30180. */
  30181. vignetteStretch: number;
  30182. /**
  30183. * Vignette centre X Offset.
  30184. */
  30185. vignetteCentreX: number;
  30186. /**
  30187. * Vignette centre Y Offset.
  30188. */
  30189. vignetteCentreY: number;
  30190. /**
  30191. * Vignette weight or intensity of the vignette effect.
  30192. */
  30193. vignetteWeight: number;
  30194. /**
  30195. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30196. * if vignetteEnabled is set to true.
  30197. */
  30198. vignetteColor: Color4;
  30199. /**
  30200. * Camera field of view used by the Vignette effect.
  30201. */
  30202. vignetteCameraFov: number;
  30203. private _vignetteBlendMode;
  30204. /**
  30205. * Gets the vignette blend mode allowing different kind of effect.
  30206. */
  30207. /**
  30208. * Sets the vignette blend mode allowing different kind of effect.
  30209. */
  30210. vignetteBlendMode: number;
  30211. private _vignetteEnabled;
  30212. /**
  30213. * Gets wether the vignette effect is enabled.
  30214. */
  30215. /**
  30216. * Sets wether the vignette effect is enabled.
  30217. */
  30218. vignetteEnabled: boolean;
  30219. private _applyByPostProcess;
  30220. /**
  30221. * Gets wether the image processing is applied through a post process or not.
  30222. */
  30223. /**
  30224. * Sets wether the image processing is applied through a post process or not.
  30225. */
  30226. applyByPostProcess: boolean;
  30227. private _isEnabled;
  30228. /**
  30229. * Gets wether the image processing is enabled or not.
  30230. */
  30231. /**
  30232. * Sets wether the image processing is enabled or not.
  30233. */
  30234. isEnabled: boolean;
  30235. /**
  30236. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30237. */
  30238. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30239. /**
  30240. * Method called each time the image processing information changes requires to recompile the effect.
  30241. */
  30242. protected _updateParameters(): void;
  30243. /**
  30244. * Gets the current class name.
  30245. * @return "ImageProcessingConfiguration"
  30246. */
  30247. getClassName(): string;
  30248. /**
  30249. * Prepare the list of uniforms associated with the Image Processing effects.
  30250. * @param uniforms The list of uniforms used in the effect
  30251. * @param defines the list of defines currently in use
  30252. */
  30253. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30254. /**
  30255. * Prepare the list of samplers associated with the Image Processing effects.
  30256. * @param samplersList The list of uniforms used in the effect
  30257. * @param defines the list of defines currently in use
  30258. */
  30259. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30260. /**
  30261. * Prepare the list of defines associated to the shader.
  30262. * @param defines the list of defines to complete
  30263. * @param forPostProcess Define if we are currently in post process mode or not
  30264. */
  30265. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30266. /**
  30267. * Returns true if all the image processing information are ready.
  30268. * @returns True if ready, otherwise, false
  30269. */
  30270. isReady(): boolean;
  30271. /**
  30272. * Binds the image processing to the shader.
  30273. * @param effect The effect to bind to
  30274. * @param aspectRatio Define the current aspect ratio of the effect
  30275. */
  30276. bind(effect: Effect, aspectRatio?: number): void;
  30277. /**
  30278. * Clones the current image processing instance.
  30279. * @return The cloned image processing
  30280. */
  30281. clone(): ImageProcessingConfiguration;
  30282. /**
  30283. * Serializes the current image processing instance to a json representation.
  30284. * @return a JSON representation
  30285. */
  30286. serialize(): any;
  30287. /**
  30288. * Parses the image processing from a json representation.
  30289. * @param source the JSON source to parse
  30290. * @return The parsed image processing
  30291. */
  30292. static Parse(source: any): ImageProcessingConfiguration;
  30293. private static _VIGNETTEMODE_MULTIPLY;
  30294. private static _VIGNETTEMODE_OPAQUE;
  30295. /**
  30296. * Used to apply the vignette as a mix with the pixel color.
  30297. */
  30298. static readonly VIGNETTEMODE_MULTIPLY: number;
  30299. /**
  30300. * Used to apply the vignette as a replacement of the pixel color.
  30301. */
  30302. static readonly VIGNETTEMODE_OPAQUE: number;
  30303. }
  30304. }
  30305. declare module BABYLON {
  30306. /**
  30307. * This represents all the required information to add a fresnel effect on a material:
  30308. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30309. */
  30310. export class FresnelParameters {
  30311. private _isEnabled;
  30312. /**
  30313. * Define if the fresnel effect is enable or not.
  30314. */
  30315. isEnabled: boolean;
  30316. /**
  30317. * Define the color used on edges (grazing angle)
  30318. */
  30319. leftColor: Color3;
  30320. /**
  30321. * Define the color used on center
  30322. */
  30323. rightColor: Color3;
  30324. /**
  30325. * Define bias applied to computed fresnel term
  30326. */
  30327. bias: number;
  30328. /**
  30329. * Defined the power exponent applied to fresnel term
  30330. */
  30331. power: number;
  30332. /**
  30333. * Clones the current fresnel and its valuues
  30334. * @returns a clone fresnel configuration
  30335. */
  30336. clone(): FresnelParameters;
  30337. /**
  30338. * Serializes the current fresnel parameters to a JSON representation.
  30339. * @return the JSON serialization
  30340. */
  30341. serialize(): any;
  30342. /**
  30343. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30344. * @param parsedFresnelParameters Define the JSON representation
  30345. * @returns the parsed parameters
  30346. */
  30347. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30348. }
  30349. }
  30350. declare module BABYLON {
  30351. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30352. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30353. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30354. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30355. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30356. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30357. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30358. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30359. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30360. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30361. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30362. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30363. /**
  30364. * Decorator used to define property that can be serialized as reference to a camera
  30365. * @param sourceName defines the name of the property to decorate
  30366. */
  30367. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30368. /**
  30369. * Class used to help serialization objects
  30370. */
  30371. export class SerializationHelper {
  30372. /** hidden */
  30373. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30374. /** hidden */
  30375. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30376. /** hidden */
  30377. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30378. /** hidden */
  30379. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30380. /**
  30381. * Appends the serialized animations from the source animations
  30382. * @param source Source containing the animations
  30383. * @param destination Target to store the animations
  30384. */
  30385. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30386. /**
  30387. * Static function used to serialized a specific entity
  30388. * @param entity defines the entity to serialize
  30389. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30390. * @returns a JSON compatible object representing the serialization of the entity
  30391. */
  30392. static Serialize<T>(entity: T, serializationObject?: any): any;
  30393. /**
  30394. * Creates a new entity from a serialization data object
  30395. * @param creationFunction defines a function used to instanciated the new entity
  30396. * @param source defines the source serialization data
  30397. * @param scene defines the hosting scene
  30398. * @param rootUrl defines the root url for resources
  30399. * @returns a new entity
  30400. */
  30401. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30402. /**
  30403. * Clones an object
  30404. * @param creationFunction defines the function used to instanciate the new object
  30405. * @param source defines the source object
  30406. * @returns the cloned object
  30407. */
  30408. static Clone<T>(creationFunction: () => T, source: T): T;
  30409. /**
  30410. * Instanciates a new object based on a source one (some data will be shared between both object)
  30411. * @param creationFunction defines the function used to instanciate the new object
  30412. * @param source defines the source object
  30413. * @returns the new object
  30414. */
  30415. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30416. }
  30417. }
  30418. declare module BABYLON {
  30419. /**
  30420. * This is the base class of all the camera used in the application.
  30421. * @see http://doc.babylonjs.com/features/cameras
  30422. */
  30423. export class Camera extends Node {
  30424. /** @hidden */
  30425. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30426. /**
  30427. * This is the default projection mode used by the cameras.
  30428. * It helps recreating a feeling of perspective and better appreciate depth.
  30429. * This is the best way to simulate real life cameras.
  30430. */
  30431. static readonly PERSPECTIVE_CAMERA: number;
  30432. /**
  30433. * This helps creating camera with an orthographic mode.
  30434. * 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.
  30435. */
  30436. static readonly ORTHOGRAPHIC_CAMERA: number;
  30437. /**
  30438. * This is the default FOV mode for perspective cameras.
  30439. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30440. */
  30441. static readonly FOVMODE_VERTICAL_FIXED: number;
  30442. /**
  30443. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30444. */
  30445. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30446. /**
  30447. * This specifies ther is no need for a camera rig.
  30448. * Basically only one eye is rendered corresponding to the camera.
  30449. */
  30450. static readonly RIG_MODE_NONE: number;
  30451. /**
  30452. * Simulates a camera Rig with one blue eye and one red eye.
  30453. * This can be use with 3d blue and red glasses.
  30454. */
  30455. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30456. /**
  30457. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30458. */
  30459. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30460. /**
  30461. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30462. */
  30463. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30464. /**
  30465. * Defines that both eyes of the camera will be rendered over under each other.
  30466. */
  30467. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30468. /**
  30469. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30470. */
  30471. static readonly RIG_MODE_VR: number;
  30472. /**
  30473. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30474. */
  30475. static readonly RIG_MODE_WEBVR: number;
  30476. /**
  30477. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30478. */
  30479. static readonly RIG_MODE_CUSTOM: number;
  30480. /**
  30481. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30482. */
  30483. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30484. /**
  30485. * @hidden
  30486. * Might be removed once multiview will be a thing
  30487. */
  30488. static UseAlternateWebVRRendering: boolean;
  30489. /**
  30490. * Define the input manager associated with the camera.
  30491. */
  30492. inputs: CameraInputsManager<Camera>;
  30493. /**
  30494. * Define the current local position of the camera in the scene
  30495. */
  30496. position: Vector3;
  30497. /**
  30498. * The vector the camera should consider as up.
  30499. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30500. */
  30501. upVector: Vector3;
  30502. /**
  30503. * Define the current limit on the left side for an orthographic camera
  30504. * In scene unit
  30505. */
  30506. orthoLeft: Nullable<number>;
  30507. /**
  30508. * Define the current limit on the right side for an orthographic camera
  30509. * In scene unit
  30510. */
  30511. orthoRight: Nullable<number>;
  30512. /**
  30513. * Define the current limit on the bottom side for an orthographic camera
  30514. * In scene unit
  30515. */
  30516. orthoBottom: Nullable<number>;
  30517. /**
  30518. * Define the current limit on the top side for an orthographic camera
  30519. * In scene unit
  30520. */
  30521. orthoTop: Nullable<number>;
  30522. /**
  30523. * Field Of View is set in Radians. (default is 0.8)
  30524. */
  30525. fov: number;
  30526. /**
  30527. * Define the minimum distance the camera can see from.
  30528. * This is important to note that the depth buffer are not infinite and the closer it starts
  30529. * the more your scene might encounter depth fighting issue.
  30530. */
  30531. minZ: number;
  30532. /**
  30533. * Define the maximum distance the camera can see to.
  30534. * This is important to note that the depth buffer are not infinite and the further it end
  30535. * the more your scene might encounter depth fighting issue.
  30536. */
  30537. maxZ: number;
  30538. /**
  30539. * Define the default inertia of the camera.
  30540. * This helps giving a smooth feeling to the camera movement.
  30541. */
  30542. inertia: number;
  30543. /**
  30544. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30545. */
  30546. mode: number;
  30547. /**
  30548. * Define wether the camera is intermediate.
  30549. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30550. */
  30551. isIntermediate: boolean;
  30552. /**
  30553. * Define the viewport of the camera.
  30554. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30555. */
  30556. viewport: Viewport;
  30557. /**
  30558. * Restricts the camera to viewing objects with the same layerMask.
  30559. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30560. */
  30561. layerMask: number;
  30562. /**
  30563. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30564. */
  30565. fovMode: number;
  30566. /**
  30567. * Rig mode of the camera.
  30568. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30569. * This is normally controlled byt the camera themselves as internal use.
  30570. */
  30571. cameraRigMode: number;
  30572. /**
  30573. * Defines the distance between both "eyes" in case of a RIG
  30574. */
  30575. interaxialDistance: number;
  30576. /**
  30577. * Defines if stereoscopic rendering is done side by side or over under.
  30578. */
  30579. isStereoscopicSideBySide: boolean;
  30580. /**
  30581. * 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
  30582. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30583. * else in the scene.
  30584. */
  30585. customRenderTargets: RenderTargetTexture[];
  30586. /**
  30587. * When set, the camera will render to this render target instead of the default canvas
  30588. */
  30589. outputRenderTarget: Nullable<RenderTargetTexture>;
  30590. /**
  30591. * Observable triggered when the camera view matrix has changed.
  30592. */
  30593. onViewMatrixChangedObservable: Observable<Camera>;
  30594. /**
  30595. * Observable triggered when the camera Projection matrix has changed.
  30596. */
  30597. onProjectionMatrixChangedObservable: Observable<Camera>;
  30598. /**
  30599. * Observable triggered when the inputs have been processed.
  30600. */
  30601. onAfterCheckInputsObservable: Observable<Camera>;
  30602. /**
  30603. * Observable triggered when reset has been called and applied to the camera.
  30604. */
  30605. onRestoreStateObservable: Observable<Camera>;
  30606. /** @hidden */
  30607. _cameraRigParams: any;
  30608. /** @hidden */
  30609. _rigCameras: Camera[];
  30610. /** @hidden */
  30611. _rigPostProcess: Nullable<PostProcess>;
  30612. protected _webvrViewMatrix: Matrix;
  30613. /** @hidden */
  30614. _skipRendering: boolean;
  30615. /** @hidden */
  30616. _alternateCamera: Camera;
  30617. /** @hidden */
  30618. _projectionMatrix: Matrix;
  30619. /** @hidden */
  30620. _postProcesses: Nullable<PostProcess>[];
  30621. /** @hidden */
  30622. _activeMeshes: SmartArray<AbstractMesh>;
  30623. protected _globalPosition: Vector3;
  30624. /** hidden */
  30625. _computedViewMatrix: Matrix;
  30626. private _doNotComputeProjectionMatrix;
  30627. private _transformMatrix;
  30628. private _frustumPlanes;
  30629. private _refreshFrustumPlanes;
  30630. private _storedFov;
  30631. private _stateStored;
  30632. /**
  30633. * Instantiates a new camera object.
  30634. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30635. * @see http://doc.babylonjs.com/features/cameras
  30636. * @param name Defines the name of the camera in the scene
  30637. * @param position Defines the position of the camera
  30638. * @param scene Defines the scene the camera belongs too
  30639. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30640. */
  30641. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30642. /**
  30643. * Store current camera state (fov, position, etc..)
  30644. * @returns the camera
  30645. */
  30646. storeState(): Camera;
  30647. /**
  30648. * Restores the camera state values if it has been stored. You must call storeState() first
  30649. */
  30650. protected _restoreStateValues(): boolean;
  30651. /**
  30652. * Restored camera state. You must call storeState() first.
  30653. * @returns true if restored and false otherwise
  30654. */
  30655. restoreState(): boolean;
  30656. /**
  30657. * Gets the class name of the camera.
  30658. * @returns the class name
  30659. */
  30660. getClassName(): string;
  30661. /** @hidden */
  30662. readonly _isCamera: boolean;
  30663. /**
  30664. * Gets a string representation of the camera useful for debug purpose.
  30665. * @param fullDetails Defines that a more verboe level of logging is required
  30666. * @returns the string representation
  30667. */
  30668. toString(fullDetails?: boolean): string;
  30669. /**
  30670. * Gets the current world space position of the camera.
  30671. */
  30672. readonly globalPosition: Vector3;
  30673. /**
  30674. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30675. * @returns the active meshe list
  30676. */
  30677. getActiveMeshes(): SmartArray<AbstractMesh>;
  30678. /**
  30679. * Check wether a mesh is part of the current active mesh list of the camera
  30680. * @param mesh Defines the mesh to check
  30681. * @returns true if active, false otherwise
  30682. */
  30683. isActiveMesh(mesh: Mesh): boolean;
  30684. /**
  30685. * Is this camera ready to be used/rendered
  30686. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30687. * @return true if the camera is ready
  30688. */
  30689. isReady(completeCheck?: boolean): boolean;
  30690. /** @hidden */
  30691. _initCache(): void;
  30692. /** @hidden */
  30693. _updateCache(ignoreParentClass?: boolean): void;
  30694. /** @hidden */
  30695. _isSynchronized(): boolean;
  30696. /** @hidden */
  30697. _isSynchronizedViewMatrix(): boolean;
  30698. /** @hidden */
  30699. _isSynchronizedProjectionMatrix(): boolean;
  30700. /**
  30701. * Attach the input controls to a specific dom element to get the input from.
  30702. * @param element Defines the element the controls should be listened from
  30703. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30704. */
  30705. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30706. /**
  30707. * Detach the current controls from the specified dom element.
  30708. * @param element Defines the element to stop listening the inputs from
  30709. */
  30710. detachControl(element: HTMLElement): void;
  30711. /**
  30712. * Update the camera state according to the different inputs gathered during the frame.
  30713. */
  30714. update(): void;
  30715. /** @hidden */
  30716. _checkInputs(): void;
  30717. /** @hidden */
  30718. readonly rigCameras: Camera[];
  30719. /**
  30720. * Gets the post process used by the rig cameras
  30721. */
  30722. readonly rigPostProcess: Nullable<PostProcess>;
  30723. /**
  30724. * Internal, gets the first post proces.
  30725. * @returns the first post process to be run on this camera.
  30726. */
  30727. _getFirstPostProcess(): Nullable<PostProcess>;
  30728. private _cascadePostProcessesToRigCams;
  30729. /**
  30730. * Attach a post process to the camera.
  30731. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30732. * @param postProcess The post process to attach to the camera
  30733. * @param insertAt The position of the post process in case several of them are in use in the scene
  30734. * @returns the position the post process has been inserted at
  30735. */
  30736. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30737. /**
  30738. * Detach a post process to the camera.
  30739. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30740. * @param postProcess The post process to detach from the camera
  30741. */
  30742. detachPostProcess(postProcess: PostProcess): void;
  30743. /**
  30744. * Gets the current world matrix of the camera
  30745. */
  30746. getWorldMatrix(): Matrix;
  30747. /** @hidden */
  30748. _getViewMatrix(): Matrix;
  30749. /**
  30750. * Gets the current view matrix of the camera.
  30751. * @param force forces the camera to recompute the matrix without looking at the cached state
  30752. * @returns the view matrix
  30753. */
  30754. getViewMatrix(force?: boolean): Matrix;
  30755. /**
  30756. * Freeze the projection matrix.
  30757. * It will prevent the cache check of the camera projection compute and can speed up perf
  30758. * if no parameter of the camera are meant to change
  30759. * @param projection Defines manually a projection if necessary
  30760. */
  30761. freezeProjectionMatrix(projection?: Matrix): void;
  30762. /**
  30763. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30764. */
  30765. unfreezeProjectionMatrix(): void;
  30766. /**
  30767. * Gets the current projection matrix of the camera.
  30768. * @param force forces the camera to recompute the matrix without looking at the cached state
  30769. * @returns the projection matrix
  30770. */
  30771. getProjectionMatrix(force?: boolean): Matrix;
  30772. /**
  30773. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30774. * @returns a Matrix
  30775. */
  30776. getTransformationMatrix(): Matrix;
  30777. private _updateFrustumPlanes;
  30778. /**
  30779. * Checks if a cullable object (mesh...) is in the camera frustum
  30780. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30781. * @param target The object to check
  30782. * @returns true if the object is in frustum otherwise false
  30783. */
  30784. isInFrustum(target: ICullable): boolean;
  30785. /**
  30786. * Checks if a cullable object (mesh...) is in the camera frustum
  30787. * Unlike isInFrustum this cheks the full bounding box
  30788. * @param target The object to check
  30789. * @returns true if the object is in frustum otherwise false
  30790. */
  30791. isCompletelyInFrustum(target: ICullable): boolean;
  30792. /**
  30793. * Gets a ray in the forward direction from the camera.
  30794. * @param length Defines the length of the ray to create
  30795. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30796. * @param origin Defines the start point of the ray which defaults to the camera position
  30797. * @returns the forward ray
  30798. */
  30799. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30800. /**
  30801. * Releases resources associated with this node.
  30802. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30803. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30804. */
  30805. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30806. /**
  30807. * Gets the left camera of a rig setup in case of Rigged Camera
  30808. */
  30809. readonly leftCamera: Nullable<FreeCamera>;
  30810. /**
  30811. * Gets the right camera of a rig setup in case of Rigged Camera
  30812. */
  30813. readonly rightCamera: Nullable<FreeCamera>;
  30814. /**
  30815. * Gets the left camera target of a rig setup in case of Rigged Camera
  30816. * @returns the target position
  30817. */
  30818. getLeftTarget(): Nullable<Vector3>;
  30819. /**
  30820. * Gets the right camera target of a rig setup in case of Rigged Camera
  30821. * @returns the target position
  30822. */
  30823. getRightTarget(): Nullable<Vector3>;
  30824. /**
  30825. * @hidden
  30826. */
  30827. setCameraRigMode(mode: number, rigParams: any): void;
  30828. /** @hidden */
  30829. static _setStereoscopicRigMode(camera: Camera): void;
  30830. /** @hidden */
  30831. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30832. /** @hidden */
  30833. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30834. /** @hidden */
  30835. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30836. /** @hidden */
  30837. _getVRProjectionMatrix(): Matrix;
  30838. protected _updateCameraRotationMatrix(): void;
  30839. protected _updateWebVRCameraRotationMatrix(): void;
  30840. /**
  30841. * This function MUST be overwritten by the different WebVR cameras available.
  30842. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30843. * @hidden
  30844. */
  30845. _getWebVRProjectionMatrix(): Matrix;
  30846. /**
  30847. * This function MUST be overwritten by the different WebVR cameras available.
  30848. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30849. * @hidden
  30850. */
  30851. _getWebVRViewMatrix(): Matrix;
  30852. /** @hidden */
  30853. setCameraRigParameter(name: string, value: any): void;
  30854. /**
  30855. * needs to be overridden by children so sub has required properties to be copied
  30856. * @hidden
  30857. */
  30858. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30859. /**
  30860. * May need to be overridden by children
  30861. * @hidden
  30862. */
  30863. _updateRigCameras(): void;
  30864. /** @hidden */
  30865. _setupInputs(): void;
  30866. /**
  30867. * Serialiaze the camera setup to a json represention
  30868. * @returns the JSON representation
  30869. */
  30870. serialize(): any;
  30871. /**
  30872. * Clones the current camera.
  30873. * @param name The cloned camera name
  30874. * @returns the cloned camera
  30875. */
  30876. clone(name: string): Camera;
  30877. /**
  30878. * Gets the direction of the camera relative to a given local axis.
  30879. * @param localAxis Defines the reference axis to provide a relative direction.
  30880. * @return the direction
  30881. */
  30882. getDirection(localAxis: Vector3): Vector3;
  30883. /**
  30884. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30885. * @param localAxis Defines the reference axis to provide a relative direction.
  30886. * @param result Defines the vector to store the result in
  30887. */
  30888. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30889. /**
  30890. * Gets a camera constructor for a given camera type
  30891. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30892. * @param name The name of the camera the result will be able to instantiate
  30893. * @param scene The scene the result will construct the camera in
  30894. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30895. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30896. * @returns a factory method to construc the camera
  30897. */
  30898. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30899. /**
  30900. * Compute the world matrix of the camera.
  30901. * @returns the camera workd matrix
  30902. */
  30903. computeWorldMatrix(): Matrix;
  30904. /**
  30905. * Parse a JSON and creates the camera from the parsed information
  30906. * @param parsedCamera The JSON to parse
  30907. * @param scene The scene to instantiate the camera in
  30908. * @returns the newly constructed camera
  30909. */
  30910. static Parse(parsedCamera: any, scene: Scene): Camera;
  30911. }
  30912. }
  30913. declare module BABYLON {
  30914. /**
  30915. * Interface for any object that can request an animation frame
  30916. */
  30917. export interface ICustomAnimationFrameRequester {
  30918. /**
  30919. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30920. */
  30921. renderFunction?: Function;
  30922. /**
  30923. * Called to request the next frame to render to
  30924. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30925. */
  30926. requestAnimationFrame: Function;
  30927. /**
  30928. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30929. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30930. */
  30931. requestID?: number;
  30932. }
  30933. /**
  30934. * Interface containing an array of animations
  30935. */
  30936. export interface IAnimatable {
  30937. /**
  30938. * Array of animations
  30939. */
  30940. animations: Array<Animation>;
  30941. }
  30942. /** Interface used by value gradients (color, factor, ...) */
  30943. export interface IValueGradient {
  30944. /**
  30945. * Gets or sets the gradient value (between 0 and 1)
  30946. */
  30947. gradient: number;
  30948. }
  30949. /** Class used to store color4 gradient */
  30950. export class ColorGradient implements IValueGradient {
  30951. /**
  30952. * Gets or sets the gradient value (between 0 and 1)
  30953. */
  30954. gradient: number;
  30955. /**
  30956. * Gets or sets first associated color
  30957. */
  30958. color1: Color4;
  30959. /**
  30960. * Gets or sets second associated color
  30961. */
  30962. color2?: Color4;
  30963. /**
  30964. * Will get a color picked randomly between color1 and color2.
  30965. * If color2 is undefined then color1 will be used
  30966. * @param result defines the target Color4 to store the result in
  30967. */
  30968. getColorToRef(result: Color4): void;
  30969. }
  30970. /** Class used to store color 3 gradient */
  30971. export class Color3Gradient implements IValueGradient {
  30972. /**
  30973. * Gets or sets the gradient value (between 0 and 1)
  30974. */
  30975. gradient: number;
  30976. /**
  30977. * Gets or sets the associated color
  30978. */
  30979. color: Color3;
  30980. }
  30981. /** Class used to store factor gradient */
  30982. export class FactorGradient implements IValueGradient {
  30983. /**
  30984. * Gets or sets the gradient value (between 0 and 1)
  30985. */
  30986. gradient: number;
  30987. /**
  30988. * Gets or sets first associated factor
  30989. */
  30990. factor1: number;
  30991. /**
  30992. * Gets or sets second associated factor
  30993. */
  30994. factor2?: number;
  30995. /**
  30996. * Will get a number picked randomly between factor1 and factor2.
  30997. * If factor2 is undefined then factor1 will be used
  30998. * @returns the picked number
  30999. */
  31000. getFactor(): number;
  31001. }
  31002. /**
  31003. * @ignore
  31004. * Application error to support additional information when loading a file
  31005. */
  31006. export class LoadFileError extends Error {
  31007. /** defines the optional XHR request */
  31008. request?: XMLHttpRequest | undefined;
  31009. private static _setPrototypeOf;
  31010. /**
  31011. * Creates a new LoadFileError
  31012. * @param message defines the message of the error
  31013. * @param request defines the optional XHR request
  31014. */
  31015. constructor(message: string,
  31016. /** defines the optional XHR request */
  31017. request?: XMLHttpRequest | undefined);
  31018. }
  31019. /**
  31020. * Class used to define a retry strategy when error happens while loading assets
  31021. */
  31022. export class RetryStrategy {
  31023. /**
  31024. * Function used to defines an exponential back off strategy
  31025. * @param maxRetries defines the maximum number of retries (3 by default)
  31026. * @param baseInterval defines the interval between retries
  31027. * @returns the strategy function to use
  31028. */
  31029. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  31030. }
  31031. /**
  31032. * File request interface
  31033. */
  31034. export interface IFileRequest {
  31035. /**
  31036. * Raised when the request is complete (success or error).
  31037. */
  31038. onCompleteObservable: Observable<IFileRequest>;
  31039. /**
  31040. * Aborts the request for a file.
  31041. */
  31042. abort: () => void;
  31043. }
  31044. /**
  31045. * Class containing a set of static utilities functions
  31046. */
  31047. export class Tools {
  31048. /**
  31049. * Gets or sets the base URL to use to load assets
  31050. */
  31051. static BaseUrl: string;
  31052. /**
  31053. * Enable/Disable Custom HTTP Request Headers globally.
  31054. * default = false
  31055. * @see CustomRequestHeaders
  31056. */
  31057. static UseCustomRequestHeaders: boolean;
  31058. /**
  31059. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31060. * i.e. when loading files, where the server/service expects an Authorization header.
  31061. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  31062. */
  31063. static CustomRequestHeaders: {
  31064. [key: string]: string;
  31065. };
  31066. /**
  31067. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31068. */
  31069. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  31070. /**
  31071. * Default behaviour for cors in the application.
  31072. * It can be a string if the expected behavior is identical in the entire app.
  31073. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31074. */
  31075. static CorsBehavior: string | ((url: string | string[]) => string);
  31076. /**
  31077. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31078. * @ignorenaming
  31079. */
  31080. static UseFallbackTexture: boolean;
  31081. /**
  31082. * Use this object to register external classes like custom textures or material
  31083. * to allow the laoders to instantiate them
  31084. */
  31085. static RegisteredExternalClasses: {
  31086. [key: string]: Object;
  31087. };
  31088. /**
  31089. * Texture content used if a texture cannot loaded
  31090. * @ignorenaming
  31091. */
  31092. static fallbackTexture: string;
  31093. /**
  31094. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31095. * @param u defines the coordinate on X axis
  31096. * @param v defines the coordinate on Y axis
  31097. * @param width defines the width of the source data
  31098. * @param height defines the height of the source data
  31099. * @param pixels defines the source byte array
  31100. * @param color defines the output color
  31101. */
  31102. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31103. /**
  31104. * Interpolates between a and b via alpha
  31105. * @param a The lower value (returned when alpha = 0)
  31106. * @param b The upper value (returned when alpha = 1)
  31107. * @param alpha The interpolation-factor
  31108. * @return The mixed value
  31109. */
  31110. static Mix(a: number, b: number, alpha: number): number;
  31111. /**
  31112. * Tries to instantiate a new object from a given class name
  31113. * @param className defines the class name to instantiate
  31114. * @returns the new object or null if the system was not able to do the instantiation
  31115. */
  31116. static Instantiate(className: string): any;
  31117. /**
  31118. * Provides a slice function that will work even on IE
  31119. * @param data defines the array to slice
  31120. * @param start defines the start of the data (optional)
  31121. * @param end defines the end of the data (optional)
  31122. * @returns the new sliced array
  31123. */
  31124. static Slice<T>(data: T, start?: number, end?: number): T;
  31125. /**
  31126. * Polyfill for setImmediate
  31127. * @param action defines the action to execute after the current execution block
  31128. */
  31129. static SetImmediate(action: () => void): void;
  31130. /**
  31131. * Function indicating if a number is an exponent of 2
  31132. * @param value defines the value to test
  31133. * @returns true if the value is an exponent of 2
  31134. */
  31135. static IsExponentOfTwo(value: number): boolean;
  31136. private static _tmpFloatArray;
  31137. /**
  31138. * Returns the nearest 32-bit single precision float representation of a Number
  31139. * @param value A Number. If the parameter is of a different type, it will get converted
  31140. * to a number or to NaN if it cannot be converted
  31141. * @returns number
  31142. */
  31143. static FloatRound(value: number): number;
  31144. /**
  31145. * Find the next highest power of two.
  31146. * @param x Number to start search from.
  31147. * @return Next highest power of two.
  31148. */
  31149. static CeilingPOT(x: number): number;
  31150. /**
  31151. * Find the next lowest power of two.
  31152. * @param x Number to start search from.
  31153. * @return Next lowest power of two.
  31154. */
  31155. static FloorPOT(x: number): number;
  31156. /**
  31157. * Find the nearest power of two.
  31158. * @param x Number to start search from.
  31159. * @return Next nearest power of two.
  31160. */
  31161. static NearestPOT(x: number): number;
  31162. /**
  31163. * Get the closest exponent of two
  31164. * @param value defines the value to approximate
  31165. * @param max defines the maximum value to return
  31166. * @param mode defines how to define the closest value
  31167. * @returns closest exponent of two of the given value
  31168. */
  31169. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31170. /**
  31171. * Extracts the filename from a path
  31172. * @param path defines the path to use
  31173. * @returns the filename
  31174. */
  31175. static GetFilename(path: string): string;
  31176. /**
  31177. * Extracts the "folder" part of a path (everything before the filename).
  31178. * @param uri The URI to extract the info from
  31179. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31180. * @returns The "folder" part of the path
  31181. */
  31182. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31183. /**
  31184. * Extracts text content from a DOM element hierarchy
  31185. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31186. */
  31187. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31188. /**
  31189. * Convert an angle in radians to degrees
  31190. * @param angle defines the angle to convert
  31191. * @returns the angle in degrees
  31192. */
  31193. static ToDegrees(angle: number): number;
  31194. /**
  31195. * Convert an angle in degrees to radians
  31196. * @param angle defines the angle to convert
  31197. * @returns the angle in radians
  31198. */
  31199. static ToRadians(angle: number): number;
  31200. /**
  31201. * Encode a buffer to a base64 string
  31202. * @param buffer defines the buffer to encode
  31203. * @returns the encoded string
  31204. */
  31205. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31206. /**
  31207. * Extracts minimum and maximum values from a list of indexed positions
  31208. * @param positions defines the positions to use
  31209. * @param indices defines the indices to the positions
  31210. * @param indexStart defines the start index
  31211. * @param indexCount defines the end index
  31212. * @param bias defines bias value to add to the result
  31213. * @return minimum and maximum values
  31214. */
  31215. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31216. minimum: Vector3;
  31217. maximum: Vector3;
  31218. };
  31219. /**
  31220. * Extracts minimum and maximum values from a list of positions
  31221. * @param positions defines the positions to use
  31222. * @param start defines the start index in the positions array
  31223. * @param count defines the number of positions to handle
  31224. * @param bias defines bias value to add to the result
  31225. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31226. * @return minimum and maximum values
  31227. */
  31228. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31229. minimum: Vector3;
  31230. maximum: Vector3;
  31231. };
  31232. /**
  31233. * Returns an array if obj is not an array
  31234. * @param obj defines the object to evaluate as an array
  31235. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31236. * @returns either obj directly if obj is an array or a new array containing obj
  31237. */
  31238. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31239. /**
  31240. * Gets the pointer prefix to use
  31241. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31242. */
  31243. static GetPointerPrefix(): string;
  31244. /**
  31245. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31246. * @param func - the function to be called
  31247. * @param requester - the object that will request the next frame. Falls back to window.
  31248. * @returns frame number
  31249. */
  31250. static QueueNewFrame(func: () => void, requester?: any): number;
  31251. /**
  31252. * Ask the browser to promote the current element to fullscreen rendering mode
  31253. * @param element defines the DOM element to promote
  31254. */
  31255. static RequestFullscreen(element: HTMLElement): void;
  31256. /**
  31257. * Asks the browser to exit fullscreen mode
  31258. */
  31259. static ExitFullscreen(): void;
  31260. /**
  31261. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31262. * @param url define the url we are trying
  31263. * @param element define the dom element where to configure the cors policy
  31264. */
  31265. static SetCorsBehavior(url: string | string[], element: {
  31266. crossOrigin: string | null;
  31267. }): void;
  31268. /**
  31269. * Removes unwanted characters from an url
  31270. * @param url defines the url to clean
  31271. * @returns the cleaned url
  31272. */
  31273. static CleanUrl(url: string): string;
  31274. /**
  31275. * Gets or sets a function used to pre-process url before using them to load assets
  31276. */
  31277. static PreprocessUrl: (url: string) => string;
  31278. /**
  31279. * Loads an image as an HTMLImageElement.
  31280. * @param input url string, ArrayBuffer, or Blob to load
  31281. * @param onLoad callback called when the image successfully loads
  31282. * @param onError callback called when the image fails to load
  31283. * @param offlineProvider offline provider for caching
  31284. * @returns the HTMLImageElement of the loaded image
  31285. */
  31286. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31287. /**
  31288. * Loads a file
  31289. * @param url url string, ArrayBuffer, or Blob to load
  31290. * @param onSuccess callback called when the file successfully loads
  31291. * @param onProgress callback called while file is loading (if the server supports this mode)
  31292. * @param offlineProvider defines the offline provider for caching
  31293. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31294. * @param onError callback called when the file fails to load
  31295. * @returns a file request object
  31296. */
  31297. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  31298. /**
  31299. * Load a script (identified by an url). When the url returns, the
  31300. * content of this file is added into a new script element, attached to the DOM (body element)
  31301. * @param scriptUrl defines the url of the script to laod
  31302. * @param onSuccess defines the callback called when the script is loaded
  31303. * @param onError defines the callback to call if an error occurs
  31304. */
  31305. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31306. /**
  31307. * Loads a file from a blob
  31308. * @param fileToLoad defines the blob to use
  31309. * @param callback defines the callback to call when data is loaded
  31310. * @param progressCallback defines the callback to call during loading process
  31311. * @returns a file request object
  31312. */
  31313. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31314. /**
  31315. * Loads a file
  31316. * @param fileToLoad defines the file to load
  31317. * @param callback defines the callback to call when data is loaded
  31318. * @param progressCallBack defines the callback to call during loading process
  31319. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31320. * @returns a file request object
  31321. */
  31322. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31323. /**
  31324. * Creates a data url from a given string content
  31325. * @param content defines the content to convert
  31326. * @returns the new data url link
  31327. */
  31328. static FileAsURL(content: string): string;
  31329. /**
  31330. * Format the given number to a specific decimal format
  31331. * @param value defines the number to format
  31332. * @param decimals defines the number of decimals to use
  31333. * @returns the formatted string
  31334. */
  31335. static Format(value: number, decimals?: number): string;
  31336. /**
  31337. * Checks if a given vector is inside a specific range
  31338. * @param v defines the vector to test
  31339. * @param min defines the minimum range
  31340. * @param max defines the maximum range
  31341. */
  31342. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31343. /**
  31344. * Tries to copy an object by duplicating every property
  31345. * @param source defines the source object
  31346. * @param destination defines the target object
  31347. * @param doNotCopyList defines a list of properties to avoid
  31348. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31349. */
  31350. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31351. /**
  31352. * Gets a boolean indicating if the given object has no own property
  31353. * @param obj defines the object to test
  31354. * @returns true if object has no own property
  31355. */
  31356. static IsEmpty(obj: any): boolean;
  31357. /**
  31358. * Function used to register events at window level
  31359. * @param events defines the events to register
  31360. */
  31361. static RegisterTopRootEvents(events: {
  31362. name: string;
  31363. handler: Nullable<(e: FocusEvent) => any>;
  31364. }[]): void;
  31365. /**
  31366. * Function used to unregister events from window level
  31367. * @param events defines the events to unregister
  31368. */
  31369. static UnregisterTopRootEvents(events: {
  31370. name: string;
  31371. handler: Nullable<(e: FocusEvent) => any>;
  31372. }[]): void;
  31373. /**
  31374. * Dumps the current bound framebuffer
  31375. * @param width defines the rendering width
  31376. * @param height defines the rendering height
  31377. * @param engine defines the hosting engine
  31378. * @param successCallback defines the callback triggered once the data are available
  31379. * @param mimeType defines the mime type of the result
  31380. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31381. */
  31382. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31383. /**
  31384. * Converts the canvas data to blob.
  31385. * This acts as a polyfill for browsers not supporting the to blob function.
  31386. * @param canvas Defines the canvas to extract the data from
  31387. * @param successCallback Defines the callback triggered once the data are available
  31388. * @param mimeType Defines the mime type of the result
  31389. */
  31390. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31391. /**
  31392. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31393. * @param successCallback defines the callback triggered once the data are available
  31394. * @param mimeType defines the mime type of the result
  31395. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31396. */
  31397. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31398. /**
  31399. * Downloads a blob in the browser
  31400. * @param blob defines the blob to download
  31401. * @param fileName defines the name of the downloaded file
  31402. */
  31403. static Download(blob: Blob, fileName: string): void;
  31404. /**
  31405. * Captures a screenshot of the current rendering
  31406. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31407. * @param engine defines the rendering engine
  31408. * @param camera defines the source camera
  31409. * @param size This parameter can be set to a single number or to an object with the
  31410. * following (optional) properties: precision, width, height. If a single number is passed,
  31411. * it will be used for both width and height. If an object is passed, the screenshot size
  31412. * will be derived from the parameters. The precision property is a multiplier allowing
  31413. * rendering at a higher or lower resolution
  31414. * @param successCallback defines the callback receives a single parameter which contains the
  31415. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31416. * src parameter of an <img> to display it
  31417. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31418. * Check your browser for supported MIME types
  31419. */
  31420. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31421. /**
  31422. * Generates an image screenshot from the specified camera.
  31423. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31424. * @param engine The engine to use for rendering
  31425. * @param camera The camera to use for rendering
  31426. * @param size This parameter can be set to a single number or to an object with the
  31427. * following (optional) properties: precision, width, height. If a single number is passed,
  31428. * it will be used for both width and height. If an object is passed, the screenshot size
  31429. * will be derived from the parameters. The precision property is a multiplier allowing
  31430. * rendering at a higher or lower resolution
  31431. * @param successCallback The callback receives a single parameter which contains the
  31432. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31433. * src parameter of an <img> to display it
  31434. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31435. * Check your browser for supported MIME types
  31436. * @param samples Texture samples (default: 1)
  31437. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31438. * @param fileName A name for for the downloaded file.
  31439. */
  31440. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31441. /**
  31442. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31443. * Be aware Math.random() could cause collisions, but:
  31444. * "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"
  31445. * @returns a pseudo random id
  31446. */
  31447. static RandomId(): string;
  31448. /**
  31449. * Test if the given uri is a base64 string
  31450. * @param uri The uri to test
  31451. * @return True if the uri is a base64 string or false otherwise
  31452. */
  31453. static IsBase64(uri: string): boolean;
  31454. /**
  31455. * Decode the given base64 uri.
  31456. * @param uri The uri to decode
  31457. * @return The decoded base64 data.
  31458. */
  31459. static DecodeBase64(uri: string): ArrayBuffer;
  31460. /**
  31461. * No log
  31462. */
  31463. static readonly NoneLogLevel: number;
  31464. /**
  31465. * Only message logs
  31466. */
  31467. static readonly MessageLogLevel: number;
  31468. /**
  31469. * Only warning logs
  31470. */
  31471. static readonly WarningLogLevel: number;
  31472. /**
  31473. * Only error logs
  31474. */
  31475. static readonly ErrorLogLevel: number;
  31476. /**
  31477. * All logs
  31478. */
  31479. static readonly AllLogLevel: number;
  31480. /**
  31481. * Gets a value indicating the number of loading errors
  31482. * @ignorenaming
  31483. */
  31484. static readonly errorsCount: number;
  31485. /**
  31486. * Callback called when a new log is added
  31487. */
  31488. static OnNewCacheEntry: (entry: string) => void;
  31489. /**
  31490. * Log a message to the console
  31491. * @param message defines the message to log
  31492. */
  31493. static Log(message: string): void;
  31494. /**
  31495. * Write a warning message to the console
  31496. * @param message defines the message to log
  31497. */
  31498. static Warn(message: string): void;
  31499. /**
  31500. * Write an error message to the console
  31501. * @param message defines the message to log
  31502. */
  31503. static Error(message: string): void;
  31504. /**
  31505. * Gets current log cache (list of logs)
  31506. */
  31507. static readonly LogCache: string;
  31508. /**
  31509. * Clears the log cache
  31510. */
  31511. static ClearLogCache(): void;
  31512. /**
  31513. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31514. */
  31515. static LogLevels: number;
  31516. /**
  31517. * Checks if the loaded document was accessed via `file:`-Protocol.
  31518. * @returns boolean
  31519. */
  31520. static IsFileURL(): boolean;
  31521. /**
  31522. * Checks if the window object exists
  31523. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31524. */
  31525. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31526. /**
  31527. * No performance log
  31528. */
  31529. static readonly PerformanceNoneLogLevel: number;
  31530. /**
  31531. * Use user marks to log performance
  31532. */
  31533. static readonly PerformanceUserMarkLogLevel: number;
  31534. /**
  31535. * Log performance to the console
  31536. */
  31537. static readonly PerformanceConsoleLogLevel: number;
  31538. private static _performance;
  31539. /**
  31540. * Sets the current performance log level
  31541. */
  31542. static PerformanceLogLevel: number;
  31543. private static _StartPerformanceCounterDisabled;
  31544. private static _EndPerformanceCounterDisabled;
  31545. private static _StartUserMark;
  31546. private static _EndUserMark;
  31547. private static _StartPerformanceConsole;
  31548. private static _EndPerformanceConsole;
  31549. /**
  31550. * Injects the @see CustomRequestHeaders into the given request
  31551. * @param request the request that should be used for injection
  31552. */
  31553. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  31554. /**
  31555. * Starts a performance counter
  31556. */
  31557. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31558. /**
  31559. * Ends a specific performance coutner
  31560. */
  31561. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31562. /**
  31563. * Gets either window.performance.now() if supported or Date.now() else
  31564. */
  31565. static readonly Now: number;
  31566. /**
  31567. * This method will return the name of the class used to create the instance of the given object.
  31568. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31569. * @param object the object to get the class name from
  31570. * @param isType defines if the object is actually a type
  31571. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31572. */
  31573. static GetClassName(object: any, isType?: boolean): string;
  31574. /**
  31575. * Gets the first element of an array satisfying a given predicate
  31576. * @param array defines the array to browse
  31577. * @param predicate defines the predicate to use
  31578. * @returns null if not found or the element
  31579. */
  31580. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31581. /**
  31582. * This method will return the name of the full name of the class, including its owning module (if any).
  31583. * 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).
  31584. * @param object the object to get the class name from
  31585. * @param isType defines if the object is actually a type
  31586. * @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.
  31587. * @ignorenaming
  31588. */
  31589. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31590. /**
  31591. * Returns a promise that resolves after the given amount of time.
  31592. * @param delay Number of milliseconds to delay
  31593. * @returns Promise that resolves after the given amount of time
  31594. */
  31595. static DelayAsync(delay: number): Promise<void>;
  31596. /**
  31597. * Gets the current gradient from an array of IValueGradient
  31598. * @param ratio defines the current ratio to get
  31599. * @param gradients defines the array of IValueGradient
  31600. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31601. */
  31602. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31603. }
  31604. /**
  31605. * This class is used to track a performance counter which is number based.
  31606. * The user has access to many properties which give statistics of different nature.
  31607. *
  31608. * The implementer can track two kinds of Performance Counter: time and count.
  31609. * 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.
  31610. * 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.
  31611. */
  31612. export class PerfCounter {
  31613. /**
  31614. * Gets or sets a global boolean to turn on and off all the counters
  31615. */
  31616. static Enabled: boolean;
  31617. /**
  31618. * Returns the smallest value ever
  31619. */
  31620. readonly min: number;
  31621. /**
  31622. * Returns the biggest value ever
  31623. */
  31624. readonly max: number;
  31625. /**
  31626. * Returns the average value since the performance counter is running
  31627. */
  31628. readonly average: number;
  31629. /**
  31630. * Returns the average value of the last second the counter was monitored
  31631. */
  31632. readonly lastSecAverage: number;
  31633. /**
  31634. * Returns the current value
  31635. */
  31636. readonly current: number;
  31637. /**
  31638. * Gets the accumulated total
  31639. */
  31640. readonly total: number;
  31641. /**
  31642. * Gets the total value count
  31643. */
  31644. readonly count: number;
  31645. /**
  31646. * Creates a new counter
  31647. */
  31648. constructor();
  31649. /**
  31650. * Call this method to start monitoring a new frame.
  31651. * 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.
  31652. */
  31653. fetchNewFrame(): void;
  31654. /**
  31655. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31656. * @param newCount the count value to add to the monitored count
  31657. * @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.
  31658. */
  31659. addCount(newCount: number, fetchResult: boolean): void;
  31660. /**
  31661. * Start monitoring this performance counter
  31662. */
  31663. beginMonitoring(): void;
  31664. /**
  31665. * Compute the time lapsed since the previous beginMonitoring() call.
  31666. * @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
  31667. */
  31668. endMonitoring(newFrame?: boolean): void;
  31669. private _fetchResult;
  31670. private _startMonitoringTime;
  31671. private _min;
  31672. private _max;
  31673. private _average;
  31674. private _current;
  31675. private _totalValueCount;
  31676. private _totalAccumulated;
  31677. private _lastSecAverage;
  31678. private _lastSecAccumulated;
  31679. private _lastSecTime;
  31680. private _lastSecValueCount;
  31681. }
  31682. /**
  31683. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31684. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31685. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31686. * @param name The name of the class, case should be preserved
  31687. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31688. */
  31689. export function className(name: string, module?: string): (target: Object) => void;
  31690. /**
  31691. * An implementation of a loop for asynchronous functions.
  31692. */
  31693. export class AsyncLoop {
  31694. /**
  31695. * Defines the number of iterations for the loop
  31696. */
  31697. iterations: number;
  31698. /**
  31699. * Defines the current index of the loop.
  31700. */
  31701. index: number;
  31702. private _done;
  31703. private _fn;
  31704. private _successCallback;
  31705. /**
  31706. * Constructor.
  31707. * @param iterations the number of iterations.
  31708. * @param func the function to run each iteration
  31709. * @param successCallback the callback that will be called upon succesful execution
  31710. * @param offset starting offset.
  31711. */
  31712. constructor(
  31713. /**
  31714. * Defines the number of iterations for the loop
  31715. */
  31716. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31717. /**
  31718. * Execute the next iteration. Must be called after the last iteration was finished.
  31719. */
  31720. executeNext(): void;
  31721. /**
  31722. * Break the loop and run the success callback.
  31723. */
  31724. breakLoop(): void;
  31725. /**
  31726. * Create and run an async loop.
  31727. * @param iterations the number of iterations.
  31728. * @param fn the function to run each iteration
  31729. * @param successCallback the callback that will be called upon succesful execution
  31730. * @param offset starting offset.
  31731. * @returns the created async loop object
  31732. */
  31733. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31734. /**
  31735. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31736. * @param iterations total number of iterations
  31737. * @param syncedIterations number of synchronous iterations in each async iteration.
  31738. * @param fn the function to call each iteration.
  31739. * @param callback a success call back that will be called when iterating stops.
  31740. * @param breakFunction a break condition (optional)
  31741. * @param timeout timeout settings for the setTimeout function. default - 0.
  31742. * @returns the created async loop object
  31743. */
  31744. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31745. }
  31746. }
  31747. declare module BABYLON {
  31748. /**
  31749. * This class defines the direct association between an animation and a target
  31750. */
  31751. export class TargetedAnimation {
  31752. /**
  31753. * Animation to perform
  31754. */
  31755. animation: Animation;
  31756. /**
  31757. * Target to animate
  31758. */
  31759. target: any;
  31760. }
  31761. /**
  31762. * Use this class to create coordinated animations on multiple targets
  31763. */
  31764. export class AnimationGroup implements IDisposable {
  31765. /** The name of the animation group */
  31766. name: string;
  31767. private _scene;
  31768. private _targetedAnimations;
  31769. private _animatables;
  31770. private _from;
  31771. private _to;
  31772. private _isStarted;
  31773. private _isPaused;
  31774. private _speedRatio;
  31775. /**
  31776. * Gets or sets the unique id of the node
  31777. */
  31778. uniqueId: number;
  31779. /**
  31780. * This observable will notify when one animation have ended
  31781. */
  31782. onAnimationEndObservable: Observable<TargetedAnimation>;
  31783. /**
  31784. * Observer raised when one animation loops
  31785. */
  31786. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31787. /**
  31788. * This observable will notify when all animations have ended.
  31789. */
  31790. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31791. /**
  31792. * This observable will notify when all animations have paused.
  31793. */
  31794. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31795. /**
  31796. * This observable will notify when all animations are playing.
  31797. */
  31798. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31799. /**
  31800. * Gets the first frame
  31801. */
  31802. readonly from: number;
  31803. /**
  31804. * Gets the last frame
  31805. */
  31806. readonly to: number;
  31807. /**
  31808. * Define if the animations are started
  31809. */
  31810. readonly isStarted: boolean;
  31811. /**
  31812. * Gets a value indicating that the current group is playing
  31813. */
  31814. readonly isPlaying: boolean;
  31815. /**
  31816. * Gets or sets the speed ratio to use for all animations
  31817. */
  31818. /**
  31819. * Gets or sets the speed ratio to use for all animations
  31820. */
  31821. speedRatio: number;
  31822. /**
  31823. * Gets the targeted animations for this animation group
  31824. */
  31825. readonly targetedAnimations: Array<TargetedAnimation>;
  31826. /**
  31827. * returning the list of animatables controlled by this animation group.
  31828. */
  31829. readonly animatables: Array<Animatable>;
  31830. /**
  31831. * Instantiates a new Animation Group.
  31832. * This helps managing several animations at once.
  31833. * @see http://doc.babylonjs.com/how_to/group
  31834. * @param name Defines the name of the group
  31835. * @param scene Defines the scene the group belongs to
  31836. */
  31837. constructor(
  31838. /** The name of the animation group */
  31839. name: string, scene?: Nullable<Scene>);
  31840. /**
  31841. * Add an animation (with its target) in the group
  31842. * @param animation defines the animation we want to add
  31843. * @param target defines the target of the animation
  31844. * @returns the TargetedAnimation object
  31845. */
  31846. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31847. /**
  31848. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31849. * It can add constant keys at begin or end
  31850. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31851. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31852. * @returns the animation group
  31853. */
  31854. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31855. /**
  31856. * Start all animations on given targets
  31857. * @param loop defines if animations must loop
  31858. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31859. * @param from defines the from key (optional)
  31860. * @param to defines the to key (optional)
  31861. * @returns the current animation group
  31862. */
  31863. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31864. /**
  31865. * Pause all animations
  31866. * @returns the animation group
  31867. */
  31868. pause(): AnimationGroup;
  31869. /**
  31870. * Play all animations to initial state
  31871. * This function will start() the animations if they were not started or will restart() them if they were paused
  31872. * @param loop defines if animations must loop
  31873. * @returns the animation group
  31874. */
  31875. play(loop?: boolean): AnimationGroup;
  31876. /**
  31877. * Reset all animations to initial state
  31878. * @returns the animation group
  31879. */
  31880. reset(): AnimationGroup;
  31881. /**
  31882. * Restart animations from key 0
  31883. * @returns the animation group
  31884. */
  31885. restart(): AnimationGroup;
  31886. /**
  31887. * Stop all animations
  31888. * @returns the animation group
  31889. */
  31890. stop(): AnimationGroup;
  31891. /**
  31892. * Set animation weight for all animatables
  31893. * @param weight defines the weight to use
  31894. * @return the animationGroup
  31895. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31896. */
  31897. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31898. /**
  31899. * Synchronize and normalize all animatables with a source animatable
  31900. * @param root defines the root animatable to synchronize with
  31901. * @return the animationGroup
  31902. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31903. */
  31904. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31905. /**
  31906. * Goes to a specific frame in this animation group
  31907. * @param frame the frame number to go to
  31908. * @return the animationGroup
  31909. */
  31910. goToFrame(frame: number): AnimationGroup;
  31911. /**
  31912. * Dispose all associated resources
  31913. */
  31914. dispose(): void;
  31915. private _checkAnimationGroupEnded;
  31916. /**
  31917. * Returns a new AnimationGroup object parsed from the source provided.
  31918. * @param parsedAnimationGroup defines the source
  31919. * @param scene defines the scene that will receive the animationGroup
  31920. * @returns a new AnimationGroup
  31921. */
  31922. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31923. /**
  31924. * Returns the string "AnimationGroup"
  31925. * @returns "AnimationGroup"
  31926. */
  31927. getClassName(): string;
  31928. /**
  31929. * Creates a detailled string about the object
  31930. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31931. * @returns a string representing the object
  31932. */
  31933. toString(fullDetails?: boolean): string;
  31934. }
  31935. }
  31936. declare module BABYLON {
  31937. /** @hidden */
  31938. export interface ICollisionCoordinator {
  31939. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31940. init(scene: Scene): void;
  31941. destroy(): void;
  31942. onMeshAdded(mesh: AbstractMesh): void;
  31943. onMeshUpdated(mesh: AbstractMesh): void;
  31944. onMeshRemoved(mesh: AbstractMesh): void;
  31945. onGeometryAdded(geometry: Geometry): void;
  31946. onGeometryUpdated(geometry: Geometry): void;
  31947. onGeometryDeleted(geometry: Geometry): void;
  31948. }
  31949. /** @hidden */
  31950. export class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  31951. private _scene;
  31952. private _scaledPosition;
  31953. private _scaledVelocity;
  31954. private _finalPosition;
  31955. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31956. init(scene: Scene): void;
  31957. destroy(): void;
  31958. onMeshAdded(mesh: AbstractMesh): void;
  31959. onMeshUpdated(mesh: AbstractMesh): void;
  31960. onMeshRemoved(mesh: AbstractMesh): void;
  31961. onGeometryAdded(geometry: Geometry): void;
  31962. onGeometryUpdated(geometry: Geometry): void;
  31963. onGeometryDeleted(geometry: Geometry): void;
  31964. private _collideWithWorld;
  31965. }
  31966. }
  31967. declare module BABYLON {
  31968. /**
  31969. * Define an interface for all classes that will hold resources
  31970. */
  31971. export interface IDisposable {
  31972. /**
  31973. * Releases all held resources
  31974. */
  31975. dispose(): void;
  31976. }
  31977. /** Interface defining initialization parameters for Scene class */
  31978. export interface SceneOptions {
  31979. /**
  31980. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31981. * It will improve performance when the number of geometries becomes important.
  31982. */
  31983. useGeometryUniqueIdsMap?: boolean;
  31984. /**
  31985. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31986. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31987. */
  31988. useMaterialMeshMap?: boolean;
  31989. /**
  31990. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31991. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31992. */
  31993. useClonedMeshhMap?: boolean;
  31994. }
  31995. /**
  31996. * Represents a scene to be rendered by the engine.
  31997. * @see http://doc.babylonjs.com/features/scene
  31998. */
  31999. export class Scene extends AbstractScene implements IAnimatable {
  32000. private static _uniqueIdCounter;
  32001. /** The fog is deactivated */
  32002. static readonly FOGMODE_NONE: number;
  32003. /** The fog density is following an exponential function */
  32004. static readonly FOGMODE_EXP: number;
  32005. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32006. static readonly FOGMODE_EXP2: number;
  32007. /** The fog density is following a linear function. */
  32008. static readonly FOGMODE_LINEAR: number;
  32009. /**
  32010. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32011. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32012. */
  32013. static MinDeltaTime: number;
  32014. /**
  32015. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32016. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32017. */
  32018. static MaxDeltaTime: number;
  32019. /**
  32020. * Factory used to create the default material.
  32021. * @param name The name of the material to create
  32022. * @param scene The scene to create the material for
  32023. * @returns The default material
  32024. */
  32025. static DefaultMaterialFactory(scene: Scene): Material;
  32026. /** @hidden */
  32027. readonly _isScene: boolean;
  32028. /**
  32029. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32030. */
  32031. autoClear: boolean;
  32032. /**
  32033. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32034. */
  32035. autoClearDepthAndStencil: boolean;
  32036. /**
  32037. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32038. */
  32039. clearColor: Color4;
  32040. /**
  32041. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32042. */
  32043. ambientColor: Color3;
  32044. /** @hidden */
  32045. _environmentBRDFTexture: BaseTexture;
  32046. /** @hidden */
  32047. protected _environmentTexture: Nullable<BaseTexture>;
  32048. /**
  32049. * Texture used in all pbr material as the reflection texture.
  32050. * As in the majority of the scene they are the same (exception for multi room and so on),
  32051. * this is easier to reference from here than from all the materials.
  32052. */
  32053. /**
  32054. * Texture used in all pbr material as the reflection texture.
  32055. * As in the majority of the scene they are the same (exception for multi room and so on),
  32056. * this is easier to set here than in all the materials.
  32057. */
  32058. environmentTexture: Nullable<BaseTexture>;
  32059. /** @hidden */
  32060. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32061. /**
  32062. * Default image processing configuration used either in the rendering
  32063. * Forward main pass or through the imageProcessingPostProcess if present.
  32064. * As in the majority of the scene they are the same (exception for multi camera),
  32065. * this is easier to reference from here than from all the materials and post process.
  32066. *
  32067. * No setter as we it is a shared configuration, you can set the values instead.
  32068. */
  32069. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32070. private _forceWireframe;
  32071. /**
  32072. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32073. */
  32074. forceWireframe: boolean;
  32075. private _forcePointsCloud;
  32076. /**
  32077. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32078. */
  32079. forcePointsCloud: boolean;
  32080. /**
  32081. * Gets or sets the active clipplane 1
  32082. */
  32083. clipPlane: Nullable<Plane>;
  32084. /**
  32085. * Gets or sets the active clipplane 2
  32086. */
  32087. clipPlane2: Nullable<Plane>;
  32088. /**
  32089. * Gets or sets the active clipplane 3
  32090. */
  32091. clipPlane3: Nullable<Plane>;
  32092. /**
  32093. * Gets or sets the active clipplane 4
  32094. */
  32095. clipPlane4: Nullable<Plane>;
  32096. /**
  32097. * Gets or sets a boolean indicating if animations are enabled
  32098. */
  32099. animationsEnabled: boolean;
  32100. private _animationPropertiesOverride;
  32101. /**
  32102. * Gets or sets the animation properties override
  32103. */
  32104. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32105. /**
  32106. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32107. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32108. */
  32109. useConstantAnimationDeltaTime: boolean;
  32110. /**
  32111. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32112. * Please note that it requires to run a ray cast through the scene on every frame
  32113. */
  32114. constantlyUpdateMeshUnderPointer: boolean;
  32115. /**
  32116. * Defines the HTML cursor to use when hovering over interactive elements
  32117. */
  32118. hoverCursor: string;
  32119. /**
  32120. * Defines the HTML default cursor to use (empty by default)
  32121. */
  32122. defaultCursor: string;
  32123. /**
  32124. * This is used to call preventDefault() on pointer down
  32125. * in order to block unwanted artifacts like system double clicks
  32126. */
  32127. preventDefaultOnPointerDown: boolean;
  32128. /**
  32129. * This is used to call preventDefault() on pointer up
  32130. * in order to block unwanted artifacts like system double clicks
  32131. */
  32132. preventDefaultOnPointerUp: boolean;
  32133. /**
  32134. * Gets or sets user defined metadata
  32135. */
  32136. metadata: any;
  32137. /**
  32138. * For internal use only. Please do not use.
  32139. */
  32140. reservedDataStore: any;
  32141. /**
  32142. * Gets the name of the plugin used to load this scene (null by default)
  32143. */
  32144. loadingPluginName: string;
  32145. /**
  32146. * Use this array to add regular expressions used to disable offline support for specific urls
  32147. */
  32148. disableOfflineSupportExceptionRules: RegExp[];
  32149. /**
  32150. * An event triggered when the scene is disposed.
  32151. */
  32152. onDisposeObservable: Observable<Scene>;
  32153. private _onDisposeObserver;
  32154. /** Sets a function to be executed when this scene is disposed. */
  32155. onDispose: () => void;
  32156. /**
  32157. * An event triggered before rendering the scene (right after animations and physics)
  32158. */
  32159. onBeforeRenderObservable: Observable<Scene>;
  32160. private _onBeforeRenderObserver;
  32161. /** Sets a function to be executed before rendering this scene */
  32162. beforeRender: Nullable<() => void>;
  32163. /**
  32164. * An event triggered after rendering the scene
  32165. */
  32166. onAfterRenderObservable: Observable<Scene>;
  32167. private _onAfterRenderObserver;
  32168. /** Sets a function to be executed after rendering this scene */
  32169. afterRender: Nullable<() => void>;
  32170. /**
  32171. * An event triggered before animating the scene
  32172. */
  32173. onBeforeAnimationsObservable: Observable<Scene>;
  32174. /**
  32175. * An event triggered after animations processing
  32176. */
  32177. onAfterAnimationsObservable: Observable<Scene>;
  32178. /**
  32179. * An event triggered before draw calls are ready to be sent
  32180. */
  32181. onBeforeDrawPhaseObservable: Observable<Scene>;
  32182. /**
  32183. * An event triggered after draw calls have been sent
  32184. */
  32185. onAfterDrawPhaseObservable: Observable<Scene>;
  32186. /**
  32187. * An event triggered when the scene is ready
  32188. */
  32189. onReadyObservable: Observable<Scene>;
  32190. /**
  32191. * An event triggered before rendering a camera
  32192. */
  32193. onBeforeCameraRenderObservable: Observable<Camera>;
  32194. private _onBeforeCameraRenderObserver;
  32195. /** Sets a function to be executed before rendering a camera*/
  32196. beforeCameraRender: () => void;
  32197. /**
  32198. * An event triggered after rendering a camera
  32199. */
  32200. onAfterCameraRenderObservable: Observable<Camera>;
  32201. private _onAfterCameraRenderObserver;
  32202. /** Sets a function to be executed after rendering a camera*/
  32203. afterCameraRender: () => void;
  32204. /**
  32205. * An event triggered when active meshes evaluation is about to start
  32206. */
  32207. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32208. /**
  32209. * An event triggered when active meshes evaluation is done
  32210. */
  32211. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32212. /**
  32213. * An event triggered when particles rendering is about to start
  32214. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32215. */
  32216. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32217. /**
  32218. * An event triggered when particles rendering is done
  32219. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32220. */
  32221. onAfterParticlesRenderingObservable: Observable<Scene>;
  32222. /**
  32223. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32224. */
  32225. onDataLoadedObservable: Observable<Scene>;
  32226. /**
  32227. * An event triggered when a camera is created
  32228. */
  32229. onNewCameraAddedObservable: Observable<Camera>;
  32230. /**
  32231. * An event triggered when a camera is removed
  32232. */
  32233. onCameraRemovedObservable: Observable<Camera>;
  32234. /**
  32235. * An event triggered when a light is created
  32236. */
  32237. onNewLightAddedObservable: Observable<Light>;
  32238. /**
  32239. * An event triggered when a light is removed
  32240. */
  32241. onLightRemovedObservable: Observable<Light>;
  32242. /**
  32243. * An event triggered when a geometry is created
  32244. */
  32245. onNewGeometryAddedObservable: Observable<Geometry>;
  32246. /**
  32247. * An event triggered when a geometry is removed
  32248. */
  32249. onGeometryRemovedObservable: Observable<Geometry>;
  32250. /**
  32251. * An event triggered when a transform node is created
  32252. */
  32253. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32254. /**
  32255. * An event triggered when a transform node is removed
  32256. */
  32257. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32258. /**
  32259. * An event triggered when a mesh is created
  32260. */
  32261. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32262. /**
  32263. * An event triggered when a mesh is removed
  32264. */
  32265. onMeshRemovedObservable: Observable<AbstractMesh>;
  32266. /**
  32267. * An event triggered when a material is created
  32268. */
  32269. onNewMaterialAddedObservable: Observable<Material>;
  32270. /**
  32271. * An event triggered when a material is removed
  32272. */
  32273. onMaterialRemovedObservable: Observable<Material>;
  32274. /**
  32275. * An event triggered when a texture is created
  32276. */
  32277. onNewTextureAddedObservable: Observable<BaseTexture>;
  32278. /**
  32279. * An event triggered when a texture is removed
  32280. */
  32281. onTextureRemovedObservable: Observable<BaseTexture>;
  32282. /**
  32283. * An event triggered when render targets are about to be rendered
  32284. * Can happen multiple times per frame.
  32285. */
  32286. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32287. /**
  32288. * An event triggered when render targets were rendered.
  32289. * Can happen multiple times per frame.
  32290. */
  32291. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32292. /**
  32293. * An event triggered before calculating deterministic simulation step
  32294. */
  32295. onBeforeStepObservable: Observable<Scene>;
  32296. /**
  32297. * An event triggered after calculating deterministic simulation step
  32298. */
  32299. onAfterStepObservable: Observable<Scene>;
  32300. /**
  32301. * An event triggered when the activeCamera property is updated
  32302. */
  32303. onActiveCameraChanged: Observable<Scene>;
  32304. /**
  32305. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32306. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32307. * 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)
  32308. */
  32309. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32310. /**
  32311. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32312. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32313. * 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)
  32314. */
  32315. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32316. /**
  32317. * This Observable will when a mesh has been imported into the scene.
  32318. */
  32319. onMeshImportedObservable: Observable<AbstractMesh>;
  32320. private _registeredForLateAnimationBindings;
  32321. /**
  32322. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32323. */
  32324. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32325. /**
  32326. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32327. */
  32328. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32329. /**
  32330. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32331. */
  32332. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32333. private _onPointerMove;
  32334. private _onPointerDown;
  32335. private _onPointerUp;
  32336. /** Callback called when a pointer move is detected */
  32337. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32338. /** Callback called when a pointer down is detected */
  32339. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32340. /** Callback called when a pointer up is detected */
  32341. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32342. /** Callback called when a pointer pick is detected */
  32343. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32344. /**
  32345. * 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).
  32346. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32347. */
  32348. onPrePointerObservable: Observable<PointerInfoPre>;
  32349. /**
  32350. * Observable event triggered each time an input event is received from the rendering canvas
  32351. */
  32352. onPointerObservable: Observable<PointerInfo>;
  32353. /**
  32354. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32355. */
  32356. readonly unTranslatedPointer: Vector2;
  32357. /** The distance in pixel that you have to move to prevent some events */
  32358. static DragMovementThreshold: number;
  32359. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32360. static LongPressDelay: number;
  32361. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32362. static DoubleClickDelay: number;
  32363. /** If you need to check double click without raising a single click at first click, enable this flag */
  32364. static ExclusiveDoubleClickMode: boolean;
  32365. private _initClickEvent;
  32366. private _initActionManager;
  32367. private _delayedSimpleClick;
  32368. private _delayedSimpleClickTimeout;
  32369. private _previousDelayedSimpleClickTimeout;
  32370. private _meshPickProceed;
  32371. private _previousButtonPressed;
  32372. private _currentPickResult;
  32373. private _previousPickResult;
  32374. private _totalPointersPressed;
  32375. private _doubleClickOccured;
  32376. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32377. cameraToUseForPointers: Nullable<Camera>;
  32378. private _pointerX;
  32379. private _pointerY;
  32380. private _unTranslatedPointerX;
  32381. private _unTranslatedPointerY;
  32382. private _startingPointerPosition;
  32383. private _previousStartingPointerPosition;
  32384. private _startingPointerTime;
  32385. private _previousStartingPointerTime;
  32386. private _pointerCaptures;
  32387. private _timeAccumulator;
  32388. private _currentStepId;
  32389. private _currentInternalStep;
  32390. /** @hidden */
  32391. _mirroredCameraPosition: Nullable<Vector3>;
  32392. /**
  32393. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32394. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32395. */
  32396. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32397. /**
  32398. * Observable event triggered each time an keyboard event is received from the hosting window
  32399. */
  32400. onKeyboardObservable: Observable<KeyboardInfo>;
  32401. private _onKeyDown;
  32402. private _onKeyUp;
  32403. private _onCanvasFocusObserver;
  32404. private _onCanvasBlurObserver;
  32405. private _useRightHandedSystem;
  32406. /**
  32407. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32408. */
  32409. useRightHandedSystem: boolean;
  32410. /**
  32411. * Sets the step Id used by deterministic lock step
  32412. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32413. * @param newStepId defines the step Id
  32414. */
  32415. setStepId(newStepId: number): void;
  32416. /**
  32417. * Gets the step Id used by deterministic lock step
  32418. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32419. * @returns the step Id
  32420. */
  32421. getStepId(): number;
  32422. /**
  32423. * Gets the internal step used by deterministic lock step
  32424. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32425. * @returns the internal step
  32426. */
  32427. getInternalStep(): number;
  32428. private _fogEnabled;
  32429. /**
  32430. * Gets or sets a boolean indicating if fog is enabled on this scene
  32431. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32432. * (Default is true)
  32433. */
  32434. fogEnabled: boolean;
  32435. private _fogMode;
  32436. /**
  32437. * Gets or sets the fog mode to use
  32438. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32439. * | mode | value |
  32440. * | --- | --- |
  32441. * | FOGMODE_NONE | 0 |
  32442. * | FOGMODE_EXP | 1 |
  32443. * | FOGMODE_EXP2 | 2 |
  32444. * | FOGMODE_LINEAR | 3 |
  32445. */
  32446. fogMode: number;
  32447. /**
  32448. * Gets or sets the fog color to use
  32449. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32450. * (Default is Color3(0.2, 0.2, 0.3))
  32451. */
  32452. fogColor: Color3;
  32453. /**
  32454. * Gets or sets the fog density to use
  32455. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32456. * (Default is 0.1)
  32457. */
  32458. fogDensity: number;
  32459. /**
  32460. * Gets or sets the fog start distance to use
  32461. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32462. * (Default is 0)
  32463. */
  32464. fogStart: number;
  32465. /**
  32466. * Gets or sets the fog end distance to use
  32467. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32468. * (Default is 1000)
  32469. */
  32470. fogEnd: number;
  32471. private _shadowsEnabled;
  32472. /**
  32473. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32474. */
  32475. shadowsEnabled: boolean;
  32476. private _lightsEnabled;
  32477. /**
  32478. * Gets or sets a boolean indicating if lights are enabled on this scene
  32479. */
  32480. lightsEnabled: boolean;
  32481. /** All of the active cameras added to this scene. */
  32482. activeCameras: Camera[];
  32483. private _activeCamera;
  32484. /** Gets or sets the current active camera */
  32485. activeCamera: Nullable<Camera>;
  32486. private _defaultMaterial;
  32487. /** The default material used on meshes when no material is affected */
  32488. /** The default material used on meshes when no material is affected */
  32489. defaultMaterial: Material;
  32490. private _texturesEnabled;
  32491. /**
  32492. * Gets or sets a boolean indicating if textures are enabled on this scene
  32493. */
  32494. texturesEnabled: boolean;
  32495. /**
  32496. * Gets or sets a boolean indicating if particles are enabled on this scene
  32497. */
  32498. particlesEnabled: boolean;
  32499. /**
  32500. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32501. */
  32502. spritesEnabled: boolean;
  32503. private _skeletonsEnabled;
  32504. /**
  32505. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32506. */
  32507. skeletonsEnabled: boolean;
  32508. /**
  32509. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32510. */
  32511. lensFlaresEnabled: boolean;
  32512. /**
  32513. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32514. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32515. */
  32516. collisionsEnabled: boolean;
  32517. /** @hidden */
  32518. collisionCoordinator: ICollisionCoordinator;
  32519. /**
  32520. * Defines the gravity applied to this scene (used only for collisions)
  32521. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32522. */
  32523. gravity: Vector3;
  32524. /**
  32525. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32526. */
  32527. postProcessesEnabled: boolean;
  32528. /**
  32529. * The list of postprocesses added to the scene
  32530. */
  32531. postProcesses: PostProcess[];
  32532. /**
  32533. * Gets the current postprocess manager
  32534. */
  32535. postProcessManager: PostProcessManager;
  32536. /**
  32537. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32538. */
  32539. renderTargetsEnabled: boolean;
  32540. /**
  32541. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32542. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32543. */
  32544. dumpNextRenderTargets: boolean;
  32545. /**
  32546. * The list of user defined render targets added to the scene
  32547. */
  32548. customRenderTargets: RenderTargetTexture[];
  32549. /**
  32550. * Defines if texture loading must be delayed
  32551. * If true, textures will only be loaded when they need to be rendered
  32552. */
  32553. useDelayedTextureLoading: boolean;
  32554. /**
  32555. * Gets the list of meshes imported to the scene through SceneLoader
  32556. */
  32557. importedMeshesFiles: String[];
  32558. /**
  32559. * Gets or sets a boolean indicating if probes are enabled on this scene
  32560. */
  32561. probesEnabled: boolean;
  32562. /**
  32563. * Gets or sets the current offline provider to use to store scene data
  32564. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32565. */
  32566. offlineProvider: IOfflineProvider;
  32567. /**
  32568. * Gets or sets the action manager associated with the scene
  32569. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32570. */
  32571. actionManager: ActionManager;
  32572. private _meshesForIntersections;
  32573. /**
  32574. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32575. */
  32576. proceduralTexturesEnabled: boolean;
  32577. private _engine;
  32578. private _totalVertices;
  32579. /** @hidden */
  32580. _activeIndices: PerfCounter;
  32581. /** @hidden */
  32582. _activeParticles: PerfCounter;
  32583. /** @hidden */
  32584. _activeBones: PerfCounter;
  32585. private _animationRatio;
  32586. private _animationTimeLast;
  32587. private _animationTime;
  32588. /**
  32589. * Gets or sets a general scale for animation speed
  32590. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32591. */
  32592. animationTimeScale: number;
  32593. /** @hidden */
  32594. _cachedMaterial: Nullable<Material>;
  32595. /** @hidden */
  32596. _cachedEffect: Nullable<Effect>;
  32597. /** @hidden */
  32598. _cachedVisibility: Nullable<number>;
  32599. private _renderId;
  32600. private _frameId;
  32601. private _executeWhenReadyTimeoutId;
  32602. private _intermediateRendering;
  32603. private _viewUpdateFlag;
  32604. private _projectionUpdateFlag;
  32605. private _alternateViewUpdateFlag;
  32606. private _alternateProjectionUpdateFlag;
  32607. /** @hidden */
  32608. _toBeDisposed: Nullable<IDisposable>[];
  32609. private _activeRequests;
  32610. private _pendingData;
  32611. private _isDisposed;
  32612. /**
  32613. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32614. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32615. */
  32616. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32617. private _activeMeshes;
  32618. private _processedMaterials;
  32619. private _renderTargets;
  32620. /** @hidden */
  32621. _activeParticleSystems: SmartArray<IParticleSystem>;
  32622. private _activeSkeletons;
  32623. private _softwareSkinnedMeshes;
  32624. private _renderingManager;
  32625. /** @hidden */
  32626. _activeAnimatables: Animatable[];
  32627. private _transformMatrix;
  32628. private _sceneUbo;
  32629. private _alternateSceneUbo;
  32630. private _pickWithRayInverseMatrix;
  32631. private _viewMatrix;
  32632. private _projectionMatrix;
  32633. private _alternateViewMatrix;
  32634. private _alternateProjectionMatrix;
  32635. private _alternateTransformMatrix;
  32636. private _useAlternateCameraConfiguration;
  32637. private _alternateRendering;
  32638. private _wheelEventName;
  32639. /** @hidden */
  32640. _forcedViewPosition: Nullable<Vector3>;
  32641. /** @hidden */
  32642. readonly _isAlternateRenderingEnabled: boolean;
  32643. private _frustumPlanes;
  32644. /**
  32645. * Gets the list of frustum planes (built from the active camera)
  32646. */
  32647. readonly frustumPlanes: Plane[];
  32648. /**
  32649. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32650. * This is useful if there are more lights that the maximum simulteanous authorized
  32651. */
  32652. requireLightSorting: boolean;
  32653. /** @hidden */
  32654. readonly useMaterialMeshMap: boolean;
  32655. /** @hidden */
  32656. readonly useClonedMeshhMap: boolean;
  32657. private _pointerOverMesh;
  32658. private _pickedDownMesh;
  32659. private _pickedUpMesh;
  32660. private _externalData;
  32661. private _uid;
  32662. /**
  32663. * @hidden
  32664. * Backing store of defined scene components.
  32665. */
  32666. _components: ISceneComponent[];
  32667. /**
  32668. * @hidden
  32669. * Backing store of defined scene components.
  32670. */
  32671. _serializableComponents: ISceneSerializableComponent[];
  32672. /**
  32673. * List of components to register on the next registration step.
  32674. */
  32675. private _transientComponents;
  32676. /**
  32677. * Registers the transient components if needed.
  32678. */
  32679. private _registerTransientComponents;
  32680. /**
  32681. * @hidden
  32682. * Add a component to the scene.
  32683. * Note that the ccomponent could be registered on th next frame if this is called after
  32684. * the register component stage.
  32685. * @param component Defines the component to add to the scene
  32686. */
  32687. _addComponent(component: ISceneComponent): void;
  32688. /**
  32689. * @hidden
  32690. * Gets a component from the scene.
  32691. * @param name defines the name of the component to retrieve
  32692. * @returns the component or null if not present
  32693. */
  32694. _getComponent(name: string): Nullable<ISceneComponent>;
  32695. /**
  32696. * @hidden
  32697. * Defines the actions happening before camera updates.
  32698. */
  32699. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32700. /**
  32701. * @hidden
  32702. * Defines the actions happening before clear the canvas.
  32703. */
  32704. _beforeClearStage: Stage<SimpleStageAction>;
  32705. /**
  32706. * @hidden
  32707. * Defines the actions when collecting render targets for the frame.
  32708. */
  32709. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32710. /**
  32711. * @hidden
  32712. * Defines the actions happening for one camera in the frame.
  32713. */
  32714. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32715. /**
  32716. * @hidden
  32717. * Defines the actions happening during the per mesh ready checks.
  32718. */
  32719. _isReadyForMeshStage: Stage<MeshStageAction>;
  32720. /**
  32721. * @hidden
  32722. * Defines the actions happening before evaluate active mesh checks.
  32723. */
  32724. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32725. /**
  32726. * @hidden
  32727. * Defines the actions happening during the evaluate sub mesh checks.
  32728. */
  32729. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32730. /**
  32731. * @hidden
  32732. * Defines the actions happening during the active mesh stage.
  32733. */
  32734. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32735. /**
  32736. * @hidden
  32737. * Defines the actions happening during the per camera render target step.
  32738. */
  32739. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32740. /**
  32741. * @hidden
  32742. * Defines the actions happening just before the active camera is drawing.
  32743. */
  32744. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32745. /**
  32746. * @hidden
  32747. * Defines the actions happening just before a render target is drawing.
  32748. */
  32749. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32750. /**
  32751. * @hidden
  32752. * Defines the actions happening just before a rendering group is drawing.
  32753. */
  32754. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32755. /**
  32756. * @hidden
  32757. * Defines the actions happening just before a mesh is drawing.
  32758. */
  32759. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32760. /**
  32761. * @hidden
  32762. * Defines the actions happening just after a mesh has been drawn.
  32763. */
  32764. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32765. /**
  32766. * @hidden
  32767. * Defines the actions happening just after a rendering group has been drawn.
  32768. */
  32769. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32770. /**
  32771. * @hidden
  32772. * Defines the actions happening just after the active camera has been drawn.
  32773. */
  32774. _afterCameraDrawStage: Stage<CameraStageAction>;
  32775. /**
  32776. * @hidden
  32777. * Defines the actions happening just after a render target has been drawn.
  32778. */
  32779. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32780. /**
  32781. * @hidden
  32782. * Defines the actions happening just after rendering all cameras and computing intersections.
  32783. */
  32784. _afterRenderStage: Stage<SimpleStageAction>;
  32785. /**
  32786. * @hidden
  32787. * Defines the actions happening when a pointer move event happens.
  32788. */
  32789. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32790. /**
  32791. * @hidden
  32792. * Defines the actions happening when a pointer down event happens.
  32793. */
  32794. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32795. /**
  32796. * @hidden
  32797. * Defines the actions happening when a pointer up event happens.
  32798. */
  32799. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32800. /**
  32801. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32802. */
  32803. private geometriesByUniqueId;
  32804. /**
  32805. * Creates a new Scene
  32806. * @param engine defines the engine to use to render this scene
  32807. */
  32808. constructor(engine: Engine, options?: SceneOptions);
  32809. private _defaultMeshCandidates;
  32810. /**
  32811. * @hidden
  32812. */
  32813. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32814. private _defaultSubMeshCandidates;
  32815. /**
  32816. * @hidden
  32817. */
  32818. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32819. /**
  32820. * Sets the default candidate providers for the scene.
  32821. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32822. * and getCollidingSubMeshCandidates to their default function
  32823. */
  32824. setDefaultCandidateProviders(): void;
  32825. /**
  32826. * Gets a boolean indicating if collisions are processed on a web worker
  32827. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  32828. */
  32829. workerCollisions: boolean;
  32830. /**
  32831. * Gets the mesh that is currently under the pointer
  32832. */
  32833. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32834. /**
  32835. * Gets or sets the current on-screen X position of the pointer
  32836. */
  32837. pointerX: number;
  32838. /**
  32839. * Gets or sets the current on-screen Y position of the pointer
  32840. */
  32841. pointerY: number;
  32842. /**
  32843. * Gets the cached material (ie. the latest rendered one)
  32844. * @returns the cached material
  32845. */
  32846. getCachedMaterial(): Nullable<Material>;
  32847. /**
  32848. * Gets the cached effect (ie. the latest rendered one)
  32849. * @returns the cached effect
  32850. */
  32851. getCachedEffect(): Nullable<Effect>;
  32852. /**
  32853. * Gets the cached visibility state (ie. the latest rendered one)
  32854. * @returns the cached visibility state
  32855. */
  32856. getCachedVisibility(): Nullable<number>;
  32857. /**
  32858. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32859. * @param material defines the current material
  32860. * @param effect defines the current effect
  32861. * @param visibility defines the current visibility state
  32862. * @returns true if one parameter is not cached
  32863. */
  32864. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32865. /**
  32866. * Gets the engine associated with the scene
  32867. * @returns an Engine
  32868. */
  32869. getEngine(): Engine;
  32870. /**
  32871. * Gets the total number of vertices rendered per frame
  32872. * @returns the total number of vertices rendered per frame
  32873. */
  32874. getTotalVertices(): number;
  32875. /**
  32876. * Gets the performance counter for total vertices
  32877. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32878. */
  32879. readonly totalVerticesPerfCounter: PerfCounter;
  32880. /**
  32881. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32882. * @returns the total number of active indices rendered per frame
  32883. */
  32884. getActiveIndices(): number;
  32885. /**
  32886. * Gets the performance counter for active indices
  32887. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32888. */
  32889. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32890. /**
  32891. * Gets the total number of active particles rendered per frame
  32892. * @returns the total number of active particles rendered per frame
  32893. */
  32894. getActiveParticles(): number;
  32895. /**
  32896. * Gets the performance counter for active particles
  32897. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32898. */
  32899. readonly activeParticlesPerfCounter: PerfCounter;
  32900. /**
  32901. * Gets the total number of active bones rendered per frame
  32902. * @returns the total number of active bones rendered per frame
  32903. */
  32904. getActiveBones(): number;
  32905. /**
  32906. * Gets the performance counter for active bones
  32907. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32908. */
  32909. readonly activeBonesPerfCounter: PerfCounter;
  32910. /**
  32911. * Gets the array of active meshes
  32912. * @returns an array of AbstractMesh
  32913. */
  32914. getActiveMeshes(): SmartArray<AbstractMesh>;
  32915. /**
  32916. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32917. * @returns a number
  32918. */
  32919. getAnimationRatio(): number;
  32920. /**
  32921. * Gets an unique Id for the current render phase
  32922. * @returns a number
  32923. */
  32924. getRenderId(): number;
  32925. /**
  32926. * Gets an unique Id for the current frame
  32927. * @returns a number
  32928. */
  32929. getFrameId(): number;
  32930. /** Call this function if you want to manually increment the render Id*/
  32931. incrementRenderId(): void;
  32932. private _updatePointerPosition;
  32933. private _createUbo;
  32934. private _createAlternateUbo;
  32935. private _setRayOnPointerInfo;
  32936. /**
  32937. * Use this method to simulate a pointer move on a mesh
  32938. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32939. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32940. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32941. * @returns the current scene
  32942. */
  32943. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32944. private _processPointerMove;
  32945. private _checkPrePointerObservable;
  32946. /**
  32947. * Use this method to simulate a pointer down on a mesh
  32948. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32949. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32950. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32951. * @returns the current scene
  32952. */
  32953. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32954. private _processPointerDown;
  32955. /**
  32956. * Use this method to simulate a pointer up on a mesh
  32957. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32958. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32959. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32960. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32961. * @returns the current scene
  32962. */
  32963. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32964. private _processPointerUp;
  32965. /**
  32966. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32967. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32968. * @returns true if the pointer was captured
  32969. */
  32970. isPointerCaptured(pointerId?: number): boolean;
  32971. /** @hidden */
  32972. _isPointerSwiping(): boolean;
  32973. /**
  32974. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32975. * @param attachUp defines if you want to attach events to pointerup
  32976. * @param attachDown defines if you want to attach events to pointerdown
  32977. * @param attachMove defines if you want to attach events to pointermove
  32978. */
  32979. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32980. /** Detaches all event handlers*/
  32981. detachControl(): void;
  32982. /**
  32983. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32984. * Delay loaded resources are not taking in account
  32985. * @return true if all required resources are ready
  32986. */
  32987. isReady(): boolean;
  32988. /** Resets all cached information relative to material (including effect and visibility) */
  32989. resetCachedMaterial(): void;
  32990. /**
  32991. * Registers a function to be called before every frame render
  32992. * @param func defines the function to register
  32993. */
  32994. registerBeforeRender(func: () => void): void;
  32995. /**
  32996. * Unregisters a function called before every frame render
  32997. * @param func defines the function to unregister
  32998. */
  32999. unregisterBeforeRender(func: () => void): void;
  33000. /**
  33001. * Registers a function to be called after every frame render
  33002. * @param func defines the function to register
  33003. */
  33004. registerAfterRender(func: () => void): void;
  33005. /**
  33006. * Unregisters a function called after every frame render
  33007. * @param func defines the function to unregister
  33008. */
  33009. unregisterAfterRender(func: () => void): void;
  33010. private _executeOnceBeforeRender;
  33011. /**
  33012. * The provided function will run before render once and will be disposed afterwards.
  33013. * A timeout delay can be provided so that the function will be executed in N ms.
  33014. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33015. * @param func The function to be executed.
  33016. * @param timeout optional delay in ms
  33017. */
  33018. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33019. /** @hidden */
  33020. _addPendingData(data: any): void;
  33021. /** @hidden */
  33022. _removePendingData(data: any): void;
  33023. /**
  33024. * Returns the number of items waiting to be loaded
  33025. * @returns the number of items waiting to be loaded
  33026. */
  33027. getWaitingItemsCount(): number;
  33028. /**
  33029. * Returns a boolean indicating if the scene is still loading data
  33030. */
  33031. readonly isLoading: boolean;
  33032. /**
  33033. * Registers a function to be executed when the scene is ready
  33034. * @param {Function} func - the function to be executed
  33035. */
  33036. executeWhenReady(func: () => void): void;
  33037. /**
  33038. * Returns a promise that resolves when the scene is ready
  33039. * @returns A promise that resolves when the scene is ready
  33040. */
  33041. whenReadyAsync(): Promise<void>;
  33042. /** @hidden */
  33043. _checkIsReady(): void;
  33044. /**
  33045. * Will start the animation sequence of a given target
  33046. * @param target defines the target
  33047. * @param from defines from which frame should animation start
  33048. * @param to defines until which frame should animation run.
  33049. * @param weight defines the weight to apply to the animation (1.0 by default)
  33050. * @param loop defines if the animation loops
  33051. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  33052. * @param onAnimationEnd defines the function to be executed when the animation ends
  33053. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  33054. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  33055. * @param onAnimationLoop defines the callback to call when an animation loops
  33056. * @returns the animatable object created for this animation
  33057. */
  33058. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  33059. /**
  33060. * Will start the animation sequence of a given target
  33061. * @param target defines the target
  33062. * @param from defines from which frame should animation start
  33063. * @param to defines until which frame should animation run.
  33064. * @param loop defines if the animation loops
  33065. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  33066. * @param onAnimationEnd defines the function to be executed when the animation ends
  33067. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  33068. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  33069. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  33070. * @param onAnimationLoop defines the callback to call when an animation loops
  33071. * @returns the animatable object created for this animation
  33072. */
  33073. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  33074. /**
  33075. * Will start the animation sequence of a given target and its hierarchy
  33076. * @param target defines the target
  33077. * @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.
  33078. * @param from defines from which frame should animation start
  33079. * @param to defines until which frame should animation run.
  33080. * @param loop defines if the animation loops
  33081. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  33082. * @param onAnimationEnd defines the function to be executed when the animation ends
  33083. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  33084. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  33085. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  33086. * @param onAnimationLoop defines the callback to call when an animation loops
  33087. * @returns the list of created animatables
  33088. */
  33089. 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[];
  33090. /**
  33091. * Begin a new animation on a given node
  33092. * @param target defines the target where the animation will take place
  33093. * @param animations defines the list of animations to start
  33094. * @param from defines the initial value
  33095. * @param to defines the final value
  33096. * @param loop defines if you want animation to loop (off by default)
  33097. * @param speedRatio defines the speed ratio to apply to all animations
  33098. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33099. * @param onAnimationLoop defines the callback to call when an animation loops
  33100. * @returns the list of created animatables
  33101. */
  33102. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  33103. /**
  33104. * Begin a new animation on a given node and its hierarchy
  33105. * @param target defines the root node where the animation will take place
  33106. * @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.
  33107. * @param animations defines the list of animations to start
  33108. * @param from defines the initial value
  33109. * @param to defines the final value
  33110. * @param loop defines if you want animation to loop (off by default)
  33111. * @param speedRatio defines the speed ratio to apply to all animations
  33112. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33113. * @param onAnimationLoop defines the callback to call when an animation loops
  33114. * @returns the list of animatables created for all nodes
  33115. */
  33116. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  33117. /**
  33118. * Gets the animatable associated with a specific target
  33119. * @param target defines the target of the animatable
  33120. * @returns the required animatable if found
  33121. */
  33122. getAnimatableByTarget(target: any): Nullable<Animatable>;
  33123. /**
  33124. * Gets all animatables associated with a given target
  33125. * @param target defines the target to look animatables for
  33126. * @returns an array of Animatables
  33127. */
  33128. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  33129. /**
  33130. * Gets all animatable attached to the scene
  33131. */
  33132. readonly animatables: Animatable[];
  33133. /**
  33134. * Will stop the animation of the given target
  33135. * @param target - the target
  33136. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33137. * @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)
  33138. */
  33139. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33140. /**
  33141. * Stops and removes all animations that have been applied to the scene
  33142. */
  33143. stopAllAnimations(): void;
  33144. /**
  33145. * Resets the last animation time frame.
  33146. * Useful to override when animations start running when loading a scene for the first time.
  33147. */
  33148. resetLastAnimationTimeFrame(): void;
  33149. private _animate;
  33150. /** @hidden */
  33151. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  33152. private _processLateAnimationBindingsForMatrices;
  33153. private _processLateAnimationBindingsForQuaternions;
  33154. private _processLateAnimationBindings;
  33155. /** @hidden */
  33156. _switchToAlternateCameraConfiguration(active: boolean): void;
  33157. /**
  33158. * Gets the current view matrix
  33159. * @returns a Matrix
  33160. */
  33161. getViewMatrix(): Matrix;
  33162. /**
  33163. * Gets the current projection matrix
  33164. * @returns a Matrix
  33165. */
  33166. getProjectionMatrix(): Matrix;
  33167. /**
  33168. * Gets the current transform matrix
  33169. * @returns a Matrix made of View * Projection
  33170. */
  33171. getTransformMatrix(): Matrix;
  33172. /**
  33173. * Sets the current transform matrix
  33174. * @param view defines the View matrix to use
  33175. * @param projection defines the Projection matrix to use
  33176. */
  33177. setTransformMatrix(view: Matrix, projection: Matrix): void;
  33178. /** @hidden */
  33179. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  33180. /**
  33181. * Gets the uniform buffer used to store scene data
  33182. * @returns a UniformBuffer
  33183. */
  33184. getSceneUniformBuffer(): UniformBuffer;
  33185. /**
  33186. * Gets an unique (relatively to the current scene) Id
  33187. * @returns an unique number for the scene
  33188. */
  33189. getUniqueId(): number;
  33190. /**
  33191. * Add a mesh to the list of scene's meshes
  33192. * @param newMesh defines the mesh to add
  33193. * @param recursive if all child meshes should also be added to the scene
  33194. */
  33195. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33196. /**
  33197. * Remove a mesh for the list of scene's meshes
  33198. * @param toRemove defines the mesh to remove
  33199. * @param recursive if all child meshes should also be removed from the scene
  33200. * @returns the index where the mesh was in the mesh list
  33201. */
  33202. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33203. /**
  33204. * Add a transform node to the list of scene's transform nodes
  33205. * @param newTransformNode defines the transform node to add
  33206. */
  33207. addTransformNode(newTransformNode: TransformNode): void;
  33208. /**
  33209. * Remove a transform node for the list of scene's transform nodes
  33210. * @param toRemove defines the transform node to remove
  33211. * @returns the index where the transform node was in the transform node list
  33212. */
  33213. removeTransformNode(toRemove: TransformNode): number;
  33214. /**
  33215. * Remove a skeleton for the list of scene's skeletons
  33216. * @param toRemove defines the skeleton to remove
  33217. * @returns the index where the skeleton was in the skeleton list
  33218. */
  33219. removeSkeleton(toRemove: Skeleton): number;
  33220. /**
  33221. * Remove a morph target for the list of scene's morph targets
  33222. * @param toRemove defines the morph target to remove
  33223. * @returns the index where the morph target was in the morph target list
  33224. */
  33225. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33226. /**
  33227. * Remove a light for the list of scene's lights
  33228. * @param toRemove defines the light to remove
  33229. * @returns the index where the light was in the light list
  33230. */
  33231. removeLight(toRemove: Light): number;
  33232. /**
  33233. * Remove a camera for the list of scene's cameras
  33234. * @param toRemove defines the camera to remove
  33235. * @returns the index where the camera was in the camera list
  33236. */
  33237. removeCamera(toRemove: Camera): number;
  33238. /**
  33239. * Remove a particle system for the list of scene's particle systems
  33240. * @param toRemove defines the particle system to remove
  33241. * @returns the index where the particle system was in the particle system list
  33242. */
  33243. removeParticleSystem(toRemove: IParticleSystem): number;
  33244. /**
  33245. * Remove a animation for the list of scene's animations
  33246. * @param toRemove defines the animation to remove
  33247. * @returns the index where the animation was in the animation list
  33248. */
  33249. removeAnimation(toRemove: Animation): number;
  33250. /**
  33251. * Removes the given animation group from this scene.
  33252. * @param toRemove The animation group to remove
  33253. * @returns The index of the removed animation group
  33254. */
  33255. removeAnimationGroup(toRemove: AnimationGroup): number;
  33256. /**
  33257. * Removes the given multi-material from this scene.
  33258. * @param toRemove The multi-material to remove
  33259. * @returns The index of the removed multi-material
  33260. */
  33261. removeMultiMaterial(toRemove: MultiMaterial): number;
  33262. /**
  33263. * Removes the given material from this scene.
  33264. * @param toRemove The material to remove
  33265. * @returns The index of the removed material
  33266. */
  33267. removeMaterial(toRemove: Material): number;
  33268. /**
  33269. * Removes the given action manager from this scene.
  33270. * @param toRemove The action manager to remove
  33271. * @returns The index of the removed action manager
  33272. */
  33273. removeActionManager(toRemove: ActionManager): number;
  33274. /**
  33275. * Removes the given texture from this scene.
  33276. * @param toRemove The texture to remove
  33277. * @returns The index of the removed texture
  33278. */
  33279. removeTexture(toRemove: BaseTexture): number;
  33280. /**
  33281. * Adds the given light to this scene
  33282. * @param newLight The light to add
  33283. */
  33284. addLight(newLight: Light): void;
  33285. /**
  33286. * Sorts the list list based on light priorities
  33287. */
  33288. sortLightsByPriority(): void;
  33289. /**
  33290. * Adds the given camera to this scene
  33291. * @param newCamera The camera to add
  33292. */
  33293. addCamera(newCamera: Camera): void;
  33294. /**
  33295. * Adds the given skeleton to this scene
  33296. * @param newSkeleton The skeleton to add
  33297. */
  33298. addSkeleton(newSkeleton: Skeleton): void;
  33299. /**
  33300. * Adds the given particle system to this scene
  33301. * @param newParticleSystem The particle system to add
  33302. */
  33303. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33304. /**
  33305. * Adds the given animation to this scene
  33306. * @param newAnimation The animation to add
  33307. */
  33308. addAnimation(newAnimation: Animation): void;
  33309. /**
  33310. * Adds the given animation group to this scene.
  33311. * @param newAnimationGroup The animation group to add
  33312. */
  33313. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33314. /**
  33315. * Adds the given multi-material to this scene
  33316. * @param newMultiMaterial The multi-material to add
  33317. */
  33318. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33319. /**
  33320. * Adds the given material to this scene
  33321. * @param newMaterial The material to add
  33322. */
  33323. addMaterial(newMaterial: Material): void;
  33324. /**
  33325. * Adds the given morph target to this scene
  33326. * @param newMorphTargetManager The morph target to add
  33327. */
  33328. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33329. /**
  33330. * Adds the given geometry to this scene
  33331. * @param newGeometry The geometry to add
  33332. */
  33333. addGeometry(newGeometry: Geometry): void;
  33334. /**
  33335. * Adds the given action manager to this scene
  33336. * @param newActionManager The action manager to add
  33337. */
  33338. addActionManager(newActionManager: ActionManager): void;
  33339. /**
  33340. * Adds the given texture to this scene.
  33341. * @param newTexture The texture to add
  33342. */
  33343. addTexture(newTexture: BaseTexture): void;
  33344. /**
  33345. * Switch active camera
  33346. * @param newCamera defines the new active camera
  33347. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33348. */
  33349. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33350. /**
  33351. * sets the active camera of the scene using its ID
  33352. * @param id defines the camera's ID
  33353. * @return the new active camera or null if none found.
  33354. */
  33355. setActiveCameraByID(id: string): Nullable<Camera>;
  33356. /**
  33357. * sets the active camera of the scene using its name
  33358. * @param name defines the camera's name
  33359. * @returns the new active camera or null if none found.
  33360. */
  33361. setActiveCameraByName(name: string): Nullable<Camera>;
  33362. /**
  33363. * get an animation group using its name
  33364. * @param name defines the material's name
  33365. * @return the animation group or null if none found.
  33366. */
  33367. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33368. /**
  33369. * get a material using its id
  33370. * @param id defines the material's ID
  33371. * @return the material or null if none found.
  33372. */
  33373. getMaterialByID(id: string): Nullable<Material>;
  33374. /**
  33375. * Gets a material using its name
  33376. * @param name defines the material's name
  33377. * @return the material or null if none found.
  33378. */
  33379. getMaterialByName(name: string): Nullable<Material>;
  33380. /**
  33381. * Gets a camera using its id
  33382. * @param id defines the id to look for
  33383. * @returns the camera or null if not found
  33384. */
  33385. getCameraByID(id: string): Nullable<Camera>;
  33386. /**
  33387. * Gets a camera using its unique id
  33388. * @param uniqueId defines the unique id to look for
  33389. * @returns the camera or null if not found
  33390. */
  33391. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33392. /**
  33393. * Gets a camera using its name
  33394. * @param name defines the camera's name
  33395. * @return the camera or null if none found.
  33396. */
  33397. getCameraByName(name: string): Nullable<Camera>;
  33398. /**
  33399. * Gets a bone using its id
  33400. * @param id defines the bone's id
  33401. * @return the bone or null if not found
  33402. */
  33403. getBoneByID(id: string): Nullable<Bone>;
  33404. /**
  33405. * Gets a bone using its id
  33406. * @param name defines the bone's name
  33407. * @return the bone or null if not found
  33408. */
  33409. getBoneByName(name: string): Nullable<Bone>;
  33410. /**
  33411. * Gets a light node using its name
  33412. * @param name defines the the light's name
  33413. * @return the light or null if none found.
  33414. */
  33415. getLightByName(name: string): Nullable<Light>;
  33416. /**
  33417. * Gets a light node using its id
  33418. * @param id defines the light's id
  33419. * @return the light or null if none found.
  33420. */
  33421. getLightByID(id: string): Nullable<Light>;
  33422. /**
  33423. * Gets a light node using its scene-generated unique ID
  33424. * @param uniqueId defines the light's unique id
  33425. * @return the light or null if none found.
  33426. */
  33427. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33428. /**
  33429. * Gets a particle system by id
  33430. * @param id defines the particle system id
  33431. * @return the corresponding system or null if none found
  33432. */
  33433. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33434. /**
  33435. * Gets a geometry using its ID
  33436. * @param id defines the geometry's id
  33437. * @return the geometry or null if none found.
  33438. */
  33439. getGeometryByID(id: string): Nullable<Geometry>;
  33440. private _getGeometryByUniqueID;
  33441. /**
  33442. * Add a new geometry to this scene
  33443. * @param geometry defines the geometry to be added to the scene.
  33444. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33445. * @return a boolean defining if the geometry was added or not
  33446. */
  33447. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33448. /**
  33449. * Removes an existing geometry
  33450. * @param geometry defines the geometry to be removed from the scene
  33451. * @return a boolean defining if the geometry was removed or not
  33452. */
  33453. removeGeometry(geometry: Geometry): boolean;
  33454. /**
  33455. * Gets the list of geometries attached to the scene
  33456. * @returns an array of Geometry
  33457. */
  33458. getGeometries(): Geometry[];
  33459. /**
  33460. * Gets the first added mesh found of a given ID
  33461. * @param id defines the id to search for
  33462. * @return the mesh found or null if not found at all
  33463. */
  33464. getMeshByID(id: string): Nullable<AbstractMesh>;
  33465. /**
  33466. * Gets a list of meshes using their id
  33467. * @param id defines the id to search for
  33468. * @returns a list of meshes
  33469. */
  33470. getMeshesByID(id: string): Array<AbstractMesh>;
  33471. /**
  33472. * Gets the first added transform node found of a given ID
  33473. * @param id defines the id to search for
  33474. * @return the found transform node or null if not found at all.
  33475. */
  33476. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33477. /**
  33478. * Gets a list of transform nodes using their id
  33479. * @param id defines the id to search for
  33480. * @returns a list of transform nodes
  33481. */
  33482. getTransformNodesByID(id: string): Array<TransformNode>;
  33483. /**
  33484. * Gets a mesh with its auto-generated unique id
  33485. * @param uniqueId defines the unique id to search for
  33486. * @return the found mesh or null if not found at all.
  33487. */
  33488. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33489. /**
  33490. * Gets a the last added mesh using a given id
  33491. * @param id defines the id to search for
  33492. * @return the found mesh or null if not found at all.
  33493. */
  33494. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33495. /**
  33496. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33497. * @param id defines the id to search for
  33498. * @return the found node or null if not found at all
  33499. */
  33500. getLastEntryByID(id: string): Nullable<Node>;
  33501. /**
  33502. * Gets a node (Mesh, Camera, Light) using a given id
  33503. * @param id defines the id to search for
  33504. * @return the found node or null if not found at all
  33505. */
  33506. getNodeByID(id: string): Nullable<Node>;
  33507. /**
  33508. * Gets a node (Mesh, Camera, Light) using a given name
  33509. * @param name defines the name to search for
  33510. * @return the found node or null if not found at all.
  33511. */
  33512. getNodeByName(name: string): Nullable<Node>;
  33513. /**
  33514. * Gets a mesh using a given name
  33515. * @param name defines the name to search for
  33516. * @return the found mesh or null if not found at all.
  33517. */
  33518. getMeshByName(name: string): Nullable<AbstractMesh>;
  33519. /**
  33520. * Gets a transform node using a given name
  33521. * @param name defines the name to search for
  33522. * @return the found transform node or null if not found at all.
  33523. */
  33524. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33525. /**
  33526. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33527. * @param id defines the id to search for
  33528. * @return the found skeleton or null if not found at all.
  33529. */
  33530. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33531. /**
  33532. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33533. * @param id defines the id to search for
  33534. * @return the found skeleton or null if not found at all.
  33535. */
  33536. getSkeletonById(id: string): Nullable<Skeleton>;
  33537. /**
  33538. * Gets a skeleton using a given name
  33539. * @param name defines the name to search for
  33540. * @return the found skeleton or null if not found at all.
  33541. */
  33542. getSkeletonByName(name: string): Nullable<Skeleton>;
  33543. /**
  33544. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33545. * @param id defines the id to search for
  33546. * @return the found morph target manager or null if not found at all.
  33547. */
  33548. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33549. /**
  33550. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33551. * @param id defines the id to search for
  33552. * @return the found morph target or null if not found at all.
  33553. */
  33554. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33555. /**
  33556. * Gets a boolean indicating if the given mesh is active
  33557. * @param mesh defines the mesh to look for
  33558. * @returns true if the mesh is in the active list
  33559. */
  33560. isActiveMesh(mesh: AbstractMesh): boolean;
  33561. /**
  33562. * Return a unique id as a string which can serve as an identifier for the scene
  33563. */
  33564. readonly uid: string;
  33565. /**
  33566. * Add an externaly attached data from its key.
  33567. * This method call will fail and return false, if such key already exists.
  33568. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33569. * @param key the unique key that identifies the data
  33570. * @param data the data object to associate to the key for this Engine instance
  33571. * @return true if no such key were already present and the data was added successfully, false otherwise
  33572. */
  33573. addExternalData<T>(key: string, data: T): boolean;
  33574. /**
  33575. * Get an externaly attached data from its key
  33576. * @param key the unique key that identifies the data
  33577. * @return the associated data, if present (can be null), or undefined if not present
  33578. */
  33579. getExternalData<T>(key: string): Nullable<T>;
  33580. /**
  33581. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33582. * @param key the unique key that identifies the data
  33583. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33584. * @return the associated data, can be null if the factory returned null.
  33585. */
  33586. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33587. /**
  33588. * Remove an externaly attached data from the Engine instance
  33589. * @param key the unique key that identifies the data
  33590. * @return true if the data was successfully removed, false if it doesn't exist
  33591. */
  33592. removeExternalData(key: string): boolean;
  33593. private _evaluateSubMesh;
  33594. /**
  33595. * Clear the processed materials smart array preventing retention point in material dispose.
  33596. */
  33597. freeProcessedMaterials(): void;
  33598. private _preventFreeActiveMeshesAndRenderingGroups;
  33599. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33600. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33601. * when disposing several meshes in a row or a hierarchy of meshes.
  33602. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33603. */
  33604. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33605. /**
  33606. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33607. */
  33608. freeActiveMeshes(): void;
  33609. /**
  33610. * Clear the info related to rendering groups preventing retention points during dispose.
  33611. */
  33612. freeRenderingGroups(): void;
  33613. /** @hidden */
  33614. _isInIntermediateRendering(): boolean;
  33615. /**
  33616. * Lambda returning the list of potentially active meshes.
  33617. */
  33618. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33619. /**
  33620. * Lambda returning the list of potentially active sub meshes.
  33621. */
  33622. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33623. /**
  33624. * Lambda returning the list of potentially intersecting sub meshes.
  33625. */
  33626. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33627. /**
  33628. * Lambda returning the list of potentially colliding sub meshes.
  33629. */
  33630. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33631. private _activeMeshesFrozen;
  33632. /**
  33633. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33634. * @returns the current scene
  33635. */
  33636. freezeActiveMeshes(): Scene;
  33637. /**
  33638. * Use this function to restart evaluating active meshes on every frame
  33639. * @returns the current scene
  33640. */
  33641. unfreezeActiveMeshes(): Scene;
  33642. private _evaluateActiveMeshes;
  33643. private _activeMesh;
  33644. /**
  33645. * Update the transform matrix to update from the current active camera
  33646. * @param force defines a boolean used to force the update even if cache is up to date
  33647. */
  33648. updateTransformMatrix(force?: boolean): void;
  33649. /**
  33650. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  33651. * @param alternateCamera defines the camera to use
  33652. */
  33653. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33654. /** @hidden */
  33655. _allowPostProcessClearColor: boolean;
  33656. private _renderForCamera;
  33657. private _processSubCameras;
  33658. private _checkIntersections;
  33659. /** @hidden */
  33660. _advancePhysicsEngineStep(step: number): void;
  33661. /**
  33662. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33663. */
  33664. getDeterministicFrameTime: () => number;
  33665. /**
  33666. * Render the scene
  33667. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33668. */
  33669. render(updateCameras?: boolean): void;
  33670. /**
  33671. * Freeze all materials
  33672. * A frozen material will not be updatable but should be faster to render
  33673. */
  33674. freezeMaterials(): void;
  33675. /**
  33676. * Unfreeze all materials
  33677. * A frozen material will not be updatable but should be faster to render
  33678. */
  33679. unfreezeMaterials(): void;
  33680. /**
  33681. * Releases all held ressources
  33682. */
  33683. dispose(): void;
  33684. /**
  33685. * Gets if the scene is already disposed
  33686. */
  33687. readonly isDisposed: boolean;
  33688. /**
  33689. * Call this function to reduce memory footprint of the scene.
  33690. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33691. */
  33692. clearCachedVertexData(): void;
  33693. /**
  33694. * This function will remove the local cached buffer data from texture.
  33695. * It will save memory but will prevent the texture from being rebuilt
  33696. */
  33697. cleanCachedTextureBuffer(): void;
  33698. /**
  33699. * Get the world extend vectors with an optional filter
  33700. *
  33701. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33702. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33703. */
  33704. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33705. min: Vector3;
  33706. max: Vector3;
  33707. };
  33708. /**
  33709. * Creates a ray that can be used to pick in the scene
  33710. * @param x defines the x coordinate of the origin (on-screen)
  33711. * @param y defines the y coordinate of the origin (on-screen)
  33712. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33713. * @param camera defines the camera to use for the picking
  33714. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33715. * @returns a Ray
  33716. */
  33717. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33718. /**
  33719. * Creates a ray that can be used to pick in the scene
  33720. * @param x defines the x coordinate of the origin (on-screen)
  33721. * @param y defines the y coordinate of the origin (on-screen)
  33722. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33723. * @param result defines the ray where to store the picking ray
  33724. * @param camera defines the camera to use for the picking
  33725. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33726. * @returns the current scene
  33727. */
  33728. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33729. /**
  33730. * Creates a ray that can be used to pick in the scene
  33731. * @param x defines the x coordinate of the origin (on-screen)
  33732. * @param y defines the y coordinate of the origin (on-screen)
  33733. * @param camera defines the camera to use for the picking
  33734. * @returns a Ray
  33735. */
  33736. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33737. /**
  33738. * Creates a ray that can be used to pick in the scene
  33739. * @param x defines the x coordinate of the origin (on-screen)
  33740. * @param y defines the y coordinate of the origin (on-screen)
  33741. * @param result defines the ray where to store the picking ray
  33742. * @param camera defines the camera to use for the picking
  33743. * @returns the current scene
  33744. */
  33745. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33746. private _internalPick;
  33747. private _internalMultiPick;
  33748. private _tempPickingRay;
  33749. /** Launch a ray to try to pick a mesh in the scene
  33750. * @param x position on screen
  33751. * @param y position on screen
  33752. * @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
  33753. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33754. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33755. * @returns a PickingInfo
  33756. */
  33757. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  33758. private _cachedRayForTransform;
  33759. /** Use the given ray to pick a mesh in the scene
  33760. * @param ray The ray to use to pick meshes
  33761. * @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
  33762. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33763. * @returns a PickingInfo
  33764. */
  33765. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  33766. /**
  33767. * Launch a ray to try to pick a mesh in the scene
  33768. * @param x X position on screen
  33769. * @param y Y position on screen
  33770. * @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
  33771. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33772. * @returns an array of PickingInfo
  33773. */
  33774. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  33775. /**
  33776. * Launch a ray to try to pick a mesh in the scene
  33777. * @param ray Ray to use
  33778. * @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
  33779. * @returns an array of PickingInfo
  33780. */
  33781. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  33782. /**
  33783. * Force the value of meshUnderPointer
  33784. * @param mesh defines the mesh to use
  33785. */
  33786. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33787. /**
  33788. * Gets the mesh under the pointer
  33789. * @returns a Mesh or null if no mesh is under the pointer
  33790. */
  33791. getPointerOverMesh(): Nullable<AbstractMesh>;
  33792. /** @hidden */
  33793. _rebuildGeometries(): void;
  33794. /** @hidden */
  33795. _rebuildTextures(): void;
  33796. private _getByTags;
  33797. /**
  33798. * Get a list of meshes by tags
  33799. * @param tagsQuery defines the tags query to use
  33800. * @param forEach defines a predicate used to filter results
  33801. * @returns an array of Mesh
  33802. */
  33803. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33804. /**
  33805. * Get a list of cameras by tags
  33806. * @param tagsQuery defines the tags query to use
  33807. * @param forEach defines a predicate used to filter results
  33808. * @returns an array of Camera
  33809. */
  33810. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33811. /**
  33812. * Get a list of lights by tags
  33813. * @param tagsQuery defines the tags query to use
  33814. * @param forEach defines a predicate used to filter results
  33815. * @returns an array of Light
  33816. */
  33817. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33818. /**
  33819. * Get a list of materials by tags
  33820. * @param tagsQuery defines the tags query to use
  33821. * @param forEach defines a predicate used to filter results
  33822. * @returns an array of Material
  33823. */
  33824. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33825. /**
  33826. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33827. * This allowed control for front to back rendering or reversly depending of the special needs.
  33828. *
  33829. * @param renderingGroupId The rendering group id corresponding to its index
  33830. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33831. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33832. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33833. */
  33834. 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;
  33835. /**
  33836. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33837. *
  33838. * @param renderingGroupId The rendering group id corresponding to its index
  33839. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33840. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33841. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33842. */
  33843. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33844. /**
  33845. * Gets the current auto clear configuration for one rendering group of the rendering
  33846. * manager.
  33847. * @param index the rendering group index to get the information for
  33848. * @returns The auto clear setup for the requested rendering group
  33849. */
  33850. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33851. private _blockMaterialDirtyMechanism;
  33852. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33853. blockMaterialDirtyMechanism: boolean;
  33854. /**
  33855. * Will flag all materials as dirty to trigger new shader compilation
  33856. * @param flag defines the flag used to specify which material part must be marked as dirty
  33857. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33858. */
  33859. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33860. /** @hidden */
  33861. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  33862. /** @hidden */
  33863. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33864. }
  33865. }
  33866. declare module BABYLON {
  33867. /**
  33868. * Set of assets to keep when moving a scene into an asset container.
  33869. */
  33870. export class KeepAssets extends AbstractScene {
  33871. }
  33872. /**
  33873. * Container with a set of assets that can be added or removed from a scene.
  33874. */
  33875. export class AssetContainer extends AbstractScene {
  33876. /**
  33877. * The scene the AssetContainer belongs to.
  33878. */
  33879. scene: Scene;
  33880. /**
  33881. * Instantiates an AssetContainer.
  33882. * @param scene The scene the AssetContainer belongs to.
  33883. */
  33884. constructor(scene: Scene);
  33885. /**
  33886. * Adds all the assets from the container to the scene.
  33887. */
  33888. addAllToScene(): void;
  33889. /**
  33890. * Removes all the assets in the container from the scene
  33891. */
  33892. removeAllFromScene(): void;
  33893. /**
  33894. * Disposes all the assets in the container
  33895. */
  33896. dispose(): void;
  33897. private _moveAssets;
  33898. /**
  33899. * Removes all the assets contained in the scene and adds them to the container.
  33900. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33901. */
  33902. moveAllFromScene(keepAssets?: KeepAssets): void;
  33903. /**
  33904. * 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.
  33905. * @returns the root mesh
  33906. */
  33907. createRootMesh(): Mesh;
  33908. }
  33909. }
  33910. declare module BABYLON {
  33911. /**
  33912. * Defines how the parser contract is defined.
  33913. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33914. */
  33915. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33916. /**
  33917. * Defines how the individual parser contract is defined.
  33918. * These parser can parse an individual asset
  33919. */
  33920. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33921. /**
  33922. * Base class of the scene acting as a container for the different elements composing a scene.
  33923. * This class is dynamically extended by the different components of the scene increasing
  33924. * flexibility and reducing coupling
  33925. */
  33926. export abstract class AbstractScene {
  33927. /**
  33928. * Stores the list of available parsers in the application.
  33929. */
  33930. private static _BabylonFileParsers;
  33931. /**
  33932. * Stores the list of available individual parsers in the application.
  33933. */
  33934. private static _IndividualBabylonFileParsers;
  33935. /**
  33936. * Adds a parser in the list of available ones
  33937. * @param name Defines the name of the parser
  33938. * @param parser Defines the parser to add
  33939. */
  33940. static AddParser(name: string, parser: BabylonFileParser): void;
  33941. /**
  33942. * Gets a general parser from the list of avaialble ones
  33943. * @param name Defines the name of the parser
  33944. * @returns the requested parser or null
  33945. */
  33946. static GetParser(name: string): Nullable<BabylonFileParser>;
  33947. /**
  33948. * Adds n individual parser in the list of available ones
  33949. * @param name Defines the name of the parser
  33950. * @param parser Defines the parser to add
  33951. */
  33952. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33953. /**
  33954. * Gets an individual parser from the list of avaialble ones
  33955. * @param name Defines the name of the parser
  33956. * @returns the requested parser or null
  33957. */
  33958. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33959. /**
  33960. * Parser json data and populate both a scene and its associated container object
  33961. * @param jsonData Defines the data to parse
  33962. * @param scene Defines the scene to parse the data for
  33963. * @param container Defines the container attached to the parsing sequence
  33964. * @param rootUrl Defines the root url of the data
  33965. */
  33966. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33967. /**
  33968. * Gets the list of root nodes (ie. nodes with no parent)
  33969. */
  33970. rootNodes: Node[];
  33971. /** All of the cameras added to this scene
  33972. * @see http://doc.babylonjs.com/babylon101/cameras
  33973. */
  33974. cameras: Camera[];
  33975. /**
  33976. * All of the lights added to this scene
  33977. * @see http://doc.babylonjs.com/babylon101/lights
  33978. */
  33979. lights: Light[];
  33980. /**
  33981. * All of the (abstract) meshes added to this scene
  33982. */
  33983. meshes: AbstractMesh[];
  33984. /**
  33985. * The list of skeletons added to the scene
  33986. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33987. */
  33988. skeletons: Skeleton[];
  33989. /**
  33990. * All of the particle systems added to this scene
  33991. * @see http://doc.babylonjs.com/babylon101/particles
  33992. */
  33993. particleSystems: IParticleSystem[];
  33994. /**
  33995. * Gets a list of Animations associated with the scene
  33996. */
  33997. animations: Animation[];
  33998. /**
  33999. * All of the animation groups added to this scene
  34000. * @see http://doc.babylonjs.com/how_to/group
  34001. */
  34002. animationGroups: AnimationGroup[];
  34003. /**
  34004. * All of the multi-materials added to this scene
  34005. * @see http://doc.babylonjs.com/how_to/multi_materials
  34006. */
  34007. multiMaterials: MultiMaterial[];
  34008. /**
  34009. * All of the materials added to this scene
  34010. * In the context of a Scene, it is not supposed to be modified manually.
  34011. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34012. * Note also that the order of the Material wihin the array is not significant and might change.
  34013. * @see http://doc.babylonjs.com/babylon101/materials
  34014. */
  34015. materials: Material[];
  34016. /**
  34017. * The list of morph target managers added to the scene
  34018. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34019. */
  34020. morphTargetManagers: MorphTargetManager[];
  34021. /**
  34022. * The list of geometries used in the scene.
  34023. */
  34024. geometries: Geometry[];
  34025. /**
  34026. * All of the tranform nodes added to this scene
  34027. * In the context of a Scene, it is not supposed to be modified manually.
  34028. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34029. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34030. * @see http://doc.babylonjs.com/how_to/transformnode
  34031. */
  34032. transformNodes: TransformNode[];
  34033. /**
  34034. * ActionManagers available on the scene.
  34035. */
  34036. actionManagers: ActionManager[];
  34037. /**
  34038. * Textures to keep.
  34039. */
  34040. textures: BaseTexture[];
  34041. }
  34042. }
  34043. declare module BABYLON {
  34044. /**
  34045. * Defines a sound that can be played in the application.
  34046. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34048. */
  34049. export class Sound {
  34050. /**
  34051. * The name of the sound in the scene.
  34052. */
  34053. name: string;
  34054. /**
  34055. * Does the sound autoplay once loaded.
  34056. */
  34057. autoplay: boolean;
  34058. /**
  34059. * Does the sound loop after it finishes playing once.
  34060. */
  34061. loop: boolean;
  34062. /**
  34063. * Does the sound use a custom attenuation curve to simulate the falloff
  34064. * happening when the source gets further away from the camera.
  34065. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34066. */
  34067. useCustomAttenuation: boolean;
  34068. /**
  34069. * The sound track id this sound belongs to.
  34070. */
  34071. soundTrackId: number;
  34072. /**
  34073. * Is this sound currently played.
  34074. */
  34075. isPlaying: boolean;
  34076. /**
  34077. * Is this sound currently paused.
  34078. */
  34079. isPaused: boolean;
  34080. /**
  34081. * Does this sound enables spatial sound.
  34082. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34083. */
  34084. spatialSound: boolean;
  34085. /**
  34086. * Define the reference distance the sound should be heard perfectly.
  34087. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34088. */
  34089. refDistance: number;
  34090. /**
  34091. * Define the roll off factor of spatial sounds.
  34092. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34093. */
  34094. rolloffFactor: number;
  34095. /**
  34096. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34097. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34098. */
  34099. maxDistance: number;
  34100. /**
  34101. * Define the distance attenuation model the sound will follow.
  34102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34103. */
  34104. distanceModel: string;
  34105. /**
  34106. * @hidden
  34107. * Back Compat
  34108. **/
  34109. onended: () => any;
  34110. /**
  34111. * Observable event when the current playing sound finishes.
  34112. */
  34113. onEndedObservable: Observable<Sound>;
  34114. private _panningModel;
  34115. private _playbackRate;
  34116. private _streaming;
  34117. private _startTime;
  34118. private _startOffset;
  34119. private _position;
  34120. /** @hidden */
  34121. _positionInEmitterSpace: boolean;
  34122. private _localDirection;
  34123. private _volume;
  34124. private _isReadyToPlay;
  34125. private _isDirectional;
  34126. private _readyToPlayCallback;
  34127. private _audioBuffer;
  34128. private _soundSource;
  34129. private _streamingSource;
  34130. private _soundPanner;
  34131. private _soundGain;
  34132. private _inputAudioNode;
  34133. private _outputAudioNode;
  34134. private _coneInnerAngle;
  34135. private _coneOuterAngle;
  34136. private _coneOuterGain;
  34137. private _scene;
  34138. private _connectedTransformNode;
  34139. private _customAttenuationFunction;
  34140. private _registerFunc;
  34141. private _isOutputConnected;
  34142. private _htmlAudioElement;
  34143. private _urlType;
  34144. /** @hidden */
  34145. static _SceneComponentInitialization: (scene: Scene) => void;
  34146. /**
  34147. * Create a sound and attach it to a scene
  34148. * @param name Name of your sound
  34149. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34150. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34151. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34152. */
  34153. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34154. /**
  34155. * Release the sound and its associated resources
  34156. */
  34157. dispose(): void;
  34158. /**
  34159. * Gets if the sounds is ready to be played or not.
  34160. * @returns true if ready, otherwise false
  34161. */
  34162. isReady(): boolean;
  34163. private _soundLoaded;
  34164. /**
  34165. * Sets the data of the sound from an audiobuffer
  34166. * @param audioBuffer The audioBuffer containing the data
  34167. */
  34168. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34169. /**
  34170. * Updates the current sounds options such as maxdistance, loop...
  34171. * @param options A JSON object containing values named as the object properties
  34172. */
  34173. updateOptions(options: any): void;
  34174. private _createSpatialParameters;
  34175. private _updateSpatialParameters;
  34176. /**
  34177. * Switch the panning model to HRTF:
  34178. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34179. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34180. */
  34181. switchPanningModelToHRTF(): void;
  34182. /**
  34183. * Switch the panning model to Equal Power:
  34184. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34185. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34186. */
  34187. switchPanningModelToEqualPower(): void;
  34188. private _switchPanningModel;
  34189. /**
  34190. * Connect this sound to a sound track audio node like gain...
  34191. * @param soundTrackAudioNode the sound track audio node to connect to
  34192. */
  34193. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34194. /**
  34195. * Transform this sound into a directional source
  34196. * @param coneInnerAngle Size of the inner cone in degree
  34197. * @param coneOuterAngle Size of the outer cone in degree
  34198. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34199. */
  34200. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34201. /**
  34202. * Gets or sets the inner angle for the directional cone.
  34203. */
  34204. /**
  34205. * Gets or sets the inner angle for the directional cone.
  34206. */
  34207. directionalConeInnerAngle: number;
  34208. /**
  34209. * Gets or sets the outer angle for the directional cone.
  34210. */
  34211. /**
  34212. * Gets or sets the outer angle for the directional cone.
  34213. */
  34214. directionalConeOuterAngle: number;
  34215. /**
  34216. * Sets the position of the emitter if spatial sound is enabled
  34217. * @param newPosition Defines the new posisiton
  34218. */
  34219. setPosition(newPosition: Vector3): void;
  34220. /**
  34221. * Sets the local direction of the emitter if spatial sound is enabled
  34222. * @param newLocalDirection Defines the new local direction
  34223. */
  34224. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34225. private _updateDirection;
  34226. /** @hidden */
  34227. updateDistanceFromListener(): void;
  34228. /**
  34229. * Sets a new custom attenuation function for the sound.
  34230. * @param callback Defines the function used for the attenuation
  34231. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34232. */
  34233. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34234. /**
  34235. * Play the sound
  34236. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34237. * @param offset (optional) Start the sound setting it at a specific time
  34238. */
  34239. play(time?: number, offset?: number): void;
  34240. private _onended;
  34241. /**
  34242. * Stop the sound
  34243. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34244. */
  34245. stop(time?: number): void;
  34246. /**
  34247. * Put the sound in pause
  34248. */
  34249. pause(): void;
  34250. /**
  34251. * Sets a dedicated volume for this sounds
  34252. * @param newVolume Define the new volume of the sound
  34253. * @param time Define in how long the sound should be at this value
  34254. */
  34255. setVolume(newVolume: number, time?: number): void;
  34256. /**
  34257. * Set the sound play back rate
  34258. * @param newPlaybackRate Define the playback rate the sound should be played at
  34259. */
  34260. setPlaybackRate(newPlaybackRate: number): void;
  34261. /**
  34262. * Gets the volume of the sound.
  34263. * @returns the volume of the sound
  34264. */
  34265. getVolume(): number;
  34266. /**
  34267. * Attach the sound to a dedicated mesh
  34268. * @param transformNode The transform node to connect the sound with
  34269. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34270. */
  34271. attachToMesh(transformNode: TransformNode): void;
  34272. /**
  34273. * Detach the sound from the previously attached mesh
  34274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34275. */
  34276. detachFromMesh(): void;
  34277. private _onRegisterAfterWorldMatrixUpdate;
  34278. /**
  34279. * Clone the current sound in the scene.
  34280. * @returns the new sound clone
  34281. */
  34282. clone(): Nullable<Sound>;
  34283. /**
  34284. * Gets the current underlying audio buffer containing the data
  34285. * @returns the audio buffer
  34286. */
  34287. getAudioBuffer(): Nullable<AudioBuffer>;
  34288. /**
  34289. * Serializes the Sound in a JSON representation
  34290. * @returns the JSON representation of the sound
  34291. */
  34292. serialize(): any;
  34293. /**
  34294. * Parse a JSON representation of a sound to innstantiate in a given scene
  34295. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34296. * @param scene Define the scene the new parsed sound should be created in
  34297. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34298. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34299. * @returns the newly parsed sound
  34300. */
  34301. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34302. }
  34303. }
  34304. declare module BABYLON {
  34305. /**
  34306. * This defines an action helpful to play a defined sound on a triggered action.
  34307. */
  34308. export class PlaySoundAction extends Action {
  34309. private _sound;
  34310. /**
  34311. * Instantiate the action
  34312. * @param triggerOptions defines the trigger options
  34313. * @param sound defines the sound to play
  34314. * @param condition defines the trigger related conditions
  34315. */
  34316. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34317. /** @hidden */
  34318. _prepare(): void;
  34319. /**
  34320. * Execute the action and play the sound.
  34321. */
  34322. execute(): void;
  34323. /**
  34324. * Serializes the actions and its related information.
  34325. * @param parent defines the object to serialize in
  34326. * @returns the serialized object
  34327. */
  34328. serialize(parent: any): any;
  34329. }
  34330. /**
  34331. * This defines an action helpful to stop a defined sound on a triggered action.
  34332. */
  34333. export class StopSoundAction extends Action {
  34334. private _sound;
  34335. /**
  34336. * Instantiate the action
  34337. * @param triggerOptions defines the trigger options
  34338. * @param sound defines the sound to stop
  34339. * @param condition defines the trigger related conditions
  34340. */
  34341. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34342. /** @hidden */
  34343. _prepare(): void;
  34344. /**
  34345. * Execute the action and stop the sound.
  34346. */
  34347. execute(): void;
  34348. /**
  34349. * Serializes the actions and its related information.
  34350. * @param parent defines the object to serialize in
  34351. * @returns the serialized object
  34352. */
  34353. serialize(parent: any): any;
  34354. }
  34355. }
  34356. declare module BABYLON {
  34357. /**
  34358. * This defines an action responsible to change the value of a property
  34359. * by interpolating between its current value and the newly set one once triggered.
  34360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34361. */
  34362. export class InterpolateValueAction extends Action {
  34363. /**
  34364. * Defines the path of the property where the value should be interpolated
  34365. */
  34366. propertyPath: string;
  34367. /**
  34368. * Defines the target value at the end of the interpolation.
  34369. */
  34370. value: any;
  34371. /**
  34372. * Defines the time it will take for the property to interpolate to the value.
  34373. */
  34374. duration: number;
  34375. /**
  34376. * Defines if the other scene animations should be stopped when the action has been triggered
  34377. */
  34378. stopOtherAnimations?: boolean;
  34379. /**
  34380. * Defines a callback raised once the interpolation animation has been done.
  34381. */
  34382. onInterpolationDone?: () => void;
  34383. /**
  34384. * Observable triggered once the interpolation animation has been done.
  34385. */
  34386. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34387. private _target;
  34388. private _effectiveTarget;
  34389. private _property;
  34390. /**
  34391. * Instantiate the action
  34392. * @param triggerOptions defines the trigger options
  34393. * @param target defines the object containing the value to interpolate
  34394. * @param propertyPath defines the path to the property in the target object
  34395. * @param value defines the target value at the end of the interpolation
  34396. * @param duration deines the time it will take for the property to interpolate to the value.
  34397. * @param condition defines the trigger related conditions
  34398. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34399. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34400. */
  34401. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34402. /** @hidden */
  34403. _prepare(): void;
  34404. /**
  34405. * Execute the action starts the value interpolation.
  34406. */
  34407. execute(): void;
  34408. /**
  34409. * Serializes the actions and its related information.
  34410. * @param parent defines the object to serialize in
  34411. * @returns the serialized object
  34412. */
  34413. serialize(parent: any): any;
  34414. }
  34415. }
  34416. declare module BABYLON {
  34417. /**
  34418. * Options allowed during the creation of a sound track.
  34419. */
  34420. export interface ISoundTrackOptions {
  34421. /**
  34422. * The volume the sound track should take during creation
  34423. */
  34424. volume?: number;
  34425. /**
  34426. * Define if the sound track is the main sound track of the scene
  34427. */
  34428. mainTrack?: boolean;
  34429. }
  34430. /**
  34431. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34432. * It will be also used in a future release to apply effects on a specific track.
  34433. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34434. */
  34435. export class SoundTrack {
  34436. /**
  34437. * The unique identifier of the sound track in the scene.
  34438. */
  34439. id: number;
  34440. /**
  34441. * The list of sounds included in the sound track.
  34442. */
  34443. soundCollection: Array<Sound>;
  34444. private _outputAudioNode;
  34445. private _scene;
  34446. private _isMainTrack;
  34447. private _connectedAnalyser;
  34448. private _options;
  34449. private _isInitialized;
  34450. /**
  34451. * Creates a new sound track.
  34452. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34453. * @param scene Define the scene the sound track belongs to
  34454. * @param options
  34455. */
  34456. constructor(scene: Scene, options?: ISoundTrackOptions);
  34457. private _initializeSoundTrackAudioGraph;
  34458. /**
  34459. * Release the sound track and its associated resources
  34460. */
  34461. dispose(): void;
  34462. /**
  34463. * Adds a sound to this sound track
  34464. * @param sound define the cound to add
  34465. * @ignoreNaming
  34466. */
  34467. AddSound(sound: Sound): void;
  34468. /**
  34469. * Removes a sound to this sound track
  34470. * @param sound define the cound to remove
  34471. * @ignoreNaming
  34472. */
  34473. RemoveSound(sound: Sound): void;
  34474. /**
  34475. * Set a global volume for the full sound track.
  34476. * @param newVolume Define the new volume of the sound track
  34477. */
  34478. setVolume(newVolume: number): void;
  34479. /**
  34480. * Switch the panning model to HRTF:
  34481. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34482. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34483. */
  34484. switchPanningModelToHRTF(): void;
  34485. /**
  34486. * Switch the panning model to Equal Power:
  34487. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34488. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34489. */
  34490. switchPanningModelToEqualPower(): void;
  34491. /**
  34492. * Connect the sound track to an audio analyser allowing some amazing
  34493. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34494. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34495. * @param analyser The analyser to connect to the engine
  34496. */
  34497. connectToAnalyser(analyser: Analyser): void;
  34498. }
  34499. }
  34500. declare module BABYLON {
  34501. interface AbstractScene {
  34502. /**
  34503. * The list of sounds used in the scene.
  34504. */
  34505. sounds: Nullable<Array<Sound>>;
  34506. }
  34507. interface Scene {
  34508. /**
  34509. * @hidden
  34510. * Backing field
  34511. */
  34512. _mainSoundTrack: SoundTrack;
  34513. /**
  34514. * The main sound track played by the scene.
  34515. * It cotains your primary collection of sounds.
  34516. */
  34517. mainSoundTrack: SoundTrack;
  34518. /**
  34519. * The list of sound tracks added to the scene
  34520. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34521. */
  34522. soundTracks: Nullable<Array<SoundTrack>>;
  34523. /**
  34524. * Gets a sound using a given name
  34525. * @param name defines the name to search for
  34526. * @return the found sound or null if not found at all.
  34527. */
  34528. getSoundByName(name: string): Nullable<Sound>;
  34529. /**
  34530. * Gets or sets if audio support is enabled
  34531. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34532. */
  34533. audioEnabled: boolean;
  34534. /**
  34535. * Gets or sets if audio will be output to headphones
  34536. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34537. */
  34538. headphone: boolean;
  34539. }
  34540. /**
  34541. * Defines the sound scene component responsible to manage any sounds
  34542. * in a given scene.
  34543. */
  34544. export class AudioSceneComponent implements ISceneSerializableComponent {
  34545. /**
  34546. * The component name helpfull to identify the component in the list of scene components.
  34547. */
  34548. readonly name: string;
  34549. /**
  34550. * The scene the component belongs to.
  34551. */
  34552. scene: Scene;
  34553. private _audioEnabled;
  34554. /**
  34555. * Gets whether audio is enabled or not.
  34556. * Please use related enable/disable method to switch state.
  34557. */
  34558. readonly audioEnabled: boolean;
  34559. private _headphone;
  34560. /**
  34561. * Gets whether audio is outputing to headphone or not.
  34562. * Please use the according Switch methods to change output.
  34563. */
  34564. readonly headphone: boolean;
  34565. /**
  34566. * Creates a new instance of the component for the given scene
  34567. * @param scene Defines the scene to register the component in
  34568. */
  34569. constructor(scene: Scene);
  34570. /**
  34571. * Registers the component in a given scene
  34572. */
  34573. register(): void;
  34574. /**
  34575. * Rebuilds the elements related to this component in case of
  34576. * context lost for instance.
  34577. */
  34578. rebuild(): void;
  34579. /**
  34580. * Serializes the component data to the specified json object
  34581. * @param serializationObject The object to serialize to
  34582. */
  34583. serialize(serializationObject: any): void;
  34584. /**
  34585. * Adds all the element from the container to the scene
  34586. * @param container the container holding the elements
  34587. */
  34588. addFromContainer(container: AbstractScene): void;
  34589. /**
  34590. * Removes all the elements in the container from the scene
  34591. * @param container contains the elements to remove
  34592. */
  34593. removeFromContainer(container: AbstractScene): void;
  34594. /**
  34595. * Disposes the component and the associated ressources.
  34596. */
  34597. dispose(): void;
  34598. /**
  34599. * Disables audio in the associated scene.
  34600. */
  34601. disableAudio(): void;
  34602. /**
  34603. * Enables audio in the associated scene.
  34604. */
  34605. enableAudio(): void;
  34606. /**
  34607. * Switch audio to headphone output.
  34608. */
  34609. switchAudioModeForHeadphones(): void;
  34610. /**
  34611. * Switch audio to normal speakers.
  34612. */
  34613. switchAudioModeForNormalSpeakers(): void;
  34614. private _afterRender;
  34615. }
  34616. }
  34617. declare module BABYLON {
  34618. /**
  34619. * Wraps one or more Sound objects and selects one with random weight for playback.
  34620. */
  34621. export class WeightedSound {
  34622. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34623. loop: boolean;
  34624. private _coneInnerAngle;
  34625. private _coneOuterAngle;
  34626. private _volume;
  34627. /** A Sound is currently playing. */
  34628. isPlaying: boolean;
  34629. /** A Sound is currently paused. */
  34630. isPaused: boolean;
  34631. private _sounds;
  34632. private _weights;
  34633. private _currentIndex?;
  34634. /**
  34635. * Creates a new WeightedSound from the list of sounds given.
  34636. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34637. * @param sounds Array of Sounds that will be selected from.
  34638. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34639. */
  34640. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34641. /**
  34642. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34643. */
  34644. /**
  34645. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34646. */
  34647. directionalConeInnerAngle: number;
  34648. /**
  34649. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34650. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34651. */
  34652. /**
  34653. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34654. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34655. */
  34656. directionalConeOuterAngle: number;
  34657. /**
  34658. * Playback volume.
  34659. */
  34660. /**
  34661. * Playback volume.
  34662. */
  34663. volume: number;
  34664. private _onended;
  34665. /**
  34666. * Suspend playback
  34667. */
  34668. pause(): void;
  34669. /**
  34670. * Stop playback
  34671. */
  34672. stop(): void;
  34673. /**
  34674. * Start playback.
  34675. * @param startOffset Position the clip head at a specific time in seconds.
  34676. */
  34677. play(startOffset?: number): void;
  34678. }
  34679. }
  34680. declare module BABYLON {
  34681. /**
  34682. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34683. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34684. */
  34685. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34686. /**
  34687. * Gets the name of the behavior.
  34688. */
  34689. readonly name: string;
  34690. /**
  34691. * The easing function used by animations
  34692. */
  34693. static EasingFunction: BackEase;
  34694. /**
  34695. * The easing mode used by animations
  34696. */
  34697. static EasingMode: number;
  34698. /**
  34699. * The duration of the animation, in milliseconds
  34700. */
  34701. transitionDuration: number;
  34702. /**
  34703. * Length of the distance animated by the transition when lower radius is reached
  34704. */
  34705. lowerRadiusTransitionRange: number;
  34706. /**
  34707. * Length of the distance animated by the transition when upper radius is reached
  34708. */
  34709. upperRadiusTransitionRange: number;
  34710. private _autoTransitionRange;
  34711. /**
  34712. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34713. */
  34714. /**
  34715. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34716. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34717. */
  34718. autoTransitionRange: boolean;
  34719. private _attachedCamera;
  34720. private _onAfterCheckInputsObserver;
  34721. private _onMeshTargetChangedObserver;
  34722. /**
  34723. * Initializes the behavior.
  34724. */
  34725. init(): void;
  34726. /**
  34727. * Attaches the behavior to its arc rotate camera.
  34728. * @param camera Defines the camera to attach the behavior to
  34729. */
  34730. attach(camera: ArcRotateCamera): void;
  34731. /**
  34732. * Detaches the behavior from its current arc rotate camera.
  34733. */
  34734. detach(): void;
  34735. private _radiusIsAnimating;
  34736. private _radiusBounceTransition;
  34737. private _animatables;
  34738. private _cachedWheelPrecision;
  34739. /**
  34740. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34741. * @param radiusLimit The limit to check against.
  34742. * @return Bool to indicate if at limit.
  34743. */
  34744. private _isRadiusAtLimit;
  34745. /**
  34746. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34747. * @param radiusDelta The delta by which to animate to. Can be negative.
  34748. */
  34749. private _applyBoundRadiusAnimation;
  34750. /**
  34751. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34752. */
  34753. protected _clearAnimationLocks(): void;
  34754. /**
  34755. * Stops and removes all animations that have been applied to the camera
  34756. */
  34757. stopAllAnimations(): void;
  34758. }
  34759. }
  34760. declare module BABYLON {
  34761. /**
  34762. * 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.
  34763. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34764. */
  34765. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34766. /**
  34767. * Gets the name of the behavior.
  34768. */
  34769. readonly name: string;
  34770. private _mode;
  34771. private _radiusScale;
  34772. private _positionScale;
  34773. private _defaultElevation;
  34774. private _elevationReturnTime;
  34775. private _elevationReturnWaitTime;
  34776. private _zoomStopsAnimation;
  34777. private _framingTime;
  34778. /**
  34779. * The easing function used by animations
  34780. */
  34781. static EasingFunction: ExponentialEase;
  34782. /**
  34783. * The easing mode used by animations
  34784. */
  34785. static EasingMode: number;
  34786. /**
  34787. * Sets the current mode used by the behavior
  34788. */
  34789. /**
  34790. * Gets current mode used by the behavior.
  34791. */
  34792. mode: number;
  34793. /**
  34794. * Sets the scale applied to the radius (1 by default)
  34795. */
  34796. /**
  34797. * Gets the scale applied to the radius
  34798. */
  34799. radiusScale: number;
  34800. /**
  34801. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34802. */
  34803. /**
  34804. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34805. */
  34806. positionScale: number;
  34807. /**
  34808. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34809. * behaviour is triggered, in radians.
  34810. */
  34811. /**
  34812. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34813. * behaviour is triggered, in radians.
  34814. */
  34815. defaultElevation: number;
  34816. /**
  34817. * Sets the time (in milliseconds) taken to return to the default beta position.
  34818. * Negative value indicates camera should not return to default.
  34819. */
  34820. /**
  34821. * Gets the time (in milliseconds) taken to return to the default beta position.
  34822. * Negative value indicates camera should not return to default.
  34823. */
  34824. elevationReturnTime: number;
  34825. /**
  34826. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34827. */
  34828. /**
  34829. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34830. */
  34831. elevationReturnWaitTime: number;
  34832. /**
  34833. * Sets the flag that indicates if user zooming should stop animation.
  34834. */
  34835. /**
  34836. * Gets the flag that indicates if user zooming should stop animation.
  34837. */
  34838. zoomStopsAnimation: boolean;
  34839. /**
  34840. * Sets the transition time when framing the mesh, in milliseconds
  34841. */
  34842. /**
  34843. * Gets the transition time when framing the mesh, in milliseconds
  34844. */
  34845. framingTime: number;
  34846. /**
  34847. * Define if the behavior should automatically change the configured
  34848. * camera limits and sensibilities.
  34849. */
  34850. autoCorrectCameraLimitsAndSensibility: boolean;
  34851. private _onPrePointerObservableObserver;
  34852. private _onAfterCheckInputsObserver;
  34853. private _onMeshTargetChangedObserver;
  34854. private _attachedCamera;
  34855. private _isPointerDown;
  34856. private _lastInteractionTime;
  34857. /**
  34858. * Initializes the behavior.
  34859. */
  34860. init(): void;
  34861. /**
  34862. * Attaches the behavior to its arc rotate camera.
  34863. * @param camera Defines the camera to attach the behavior to
  34864. */
  34865. attach(camera: ArcRotateCamera): void;
  34866. /**
  34867. * Detaches the behavior from its current arc rotate camera.
  34868. */
  34869. detach(): void;
  34870. private _animatables;
  34871. private _betaIsAnimating;
  34872. private _betaTransition;
  34873. private _radiusTransition;
  34874. private _vectorTransition;
  34875. /**
  34876. * Targets the given mesh and updates zoom level accordingly.
  34877. * @param mesh The mesh to target.
  34878. * @param radius Optional. If a cached radius position already exists, overrides default.
  34879. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34880. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34881. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34882. */
  34883. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34884. /**
  34885. * Targets the given mesh with its children and updates zoom level accordingly.
  34886. * @param mesh The mesh to target.
  34887. * @param radius Optional. If a cached radius position already exists, overrides default.
  34888. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34889. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34890. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34891. */
  34892. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34893. /**
  34894. * Targets the given meshes with their children and updates zoom level accordingly.
  34895. * @param meshes The mesh to target.
  34896. * @param radius Optional. If a cached radius position already exists, overrides default.
  34897. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34898. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34899. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34900. */
  34901. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34902. /**
  34903. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34904. * @param minimumWorld Determines the smaller position of the bounding box extend
  34905. * @param maximumWorld Determines the bigger position of the bounding box extend
  34906. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34907. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34908. */
  34909. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34910. /**
  34911. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34912. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34913. * frustum width.
  34914. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34915. * to fully enclose the mesh in the viewing frustum.
  34916. */
  34917. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34918. /**
  34919. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34920. * is automatically returned to its default position (expected to be above ground plane).
  34921. */
  34922. private _maintainCameraAboveGround;
  34923. /**
  34924. * Returns the frustum slope based on the canvas ratio and camera FOV
  34925. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34926. */
  34927. private _getFrustumSlope;
  34928. /**
  34929. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34930. */
  34931. private _clearAnimationLocks;
  34932. /**
  34933. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34934. */
  34935. private _applyUserInteraction;
  34936. /**
  34937. * Stops and removes all animations that have been applied to the camera
  34938. */
  34939. stopAllAnimations(): void;
  34940. /**
  34941. * Gets a value indicating if the user is moving the camera
  34942. */
  34943. readonly isUserIsMoving: boolean;
  34944. /**
  34945. * The camera can move all the way towards the mesh.
  34946. */
  34947. static IgnoreBoundsSizeMode: number;
  34948. /**
  34949. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34950. */
  34951. static FitFrustumSidesMode: number;
  34952. }
  34953. }
  34954. declare module BABYLON {
  34955. /**
  34956. * Manage the pointers inputs to control an arc rotate camera.
  34957. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34958. */
  34959. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  34960. /**
  34961. * Defines the camera the input is attached to.
  34962. */
  34963. camera: ArcRotateCamera;
  34964. /**
  34965. * Defines the buttons associated with the input to handle camera move.
  34966. */
  34967. buttons: number[];
  34968. /**
  34969. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34970. */
  34971. angularSensibilityX: number;
  34972. /**
  34973. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34974. */
  34975. angularSensibilityY: number;
  34976. /**
  34977. * Defines the pointer pinch precision or how fast is the camera zooming.
  34978. */
  34979. pinchPrecision: number;
  34980. /**
  34981. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  34982. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34983. */
  34984. pinchDeltaPercentage: number;
  34985. /**
  34986. * Defines the pointer panning sensibility or how fast is the camera moving.
  34987. */
  34988. panningSensibility: number;
  34989. /**
  34990. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34991. */
  34992. multiTouchPanning: boolean;
  34993. /**
  34994. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  34995. */
  34996. multiTouchPanAndZoom: boolean;
  34997. /**
  34998. * Revers pinch action direction.
  34999. */
  35000. pinchInwards: boolean;
  35001. private _isPanClick;
  35002. private _pointerInput;
  35003. private _observer;
  35004. private _onMouseMove;
  35005. private _onGestureStart;
  35006. private _onGesture;
  35007. private _MSGestureHandler;
  35008. private _onLostFocus;
  35009. private _onContextMenu;
  35010. /**
  35011. * Attach the input controls to a specific dom element to get the input from.
  35012. * @param element Defines the element the controls should be listened from
  35013. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35014. */
  35015. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35016. /**
  35017. * Detach the current controls from the specified dom element.
  35018. * @param element Defines the element to stop listening the inputs from
  35019. */
  35020. detachControl(element: Nullable<HTMLElement>): void;
  35021. /**
  35022. * Gets the class name of the current intput.
  35023. * @returns the class name
  35024. */
  35025. getClassName(): string;
  35026. /**
  35027. * Get the friendly name associated with the input class.
  35028. * @returns the input friendly name
  35029. */
  35030. getSimpleName(): string;
  35031. }
  35032. }
  35033. declare module BABYLON {
  35034. /**
  35035. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35036. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35037. */
  35038. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35039. /**
  35040. * Defines the camera the input is attached to.
  35041. */
  35042. camera: ArcRotateCamera;
  35043. /**
  35044. * Defines the list of key codes associated with the up action (increase alpha)
  35045. */
  35046. keysUp: number[];
  35047. /**
  35048. * Defines the list of key codes associated with the down action (decrease alpha)
  35049. */
  35050. keysDown: number[];
  35051. /**
  35052. * Defines the list of key codes associated with the left action (increase beta)
  35053. */
  35054. keysLeft: number[];
  35055. /**
  35056. * Defines the list of key codes associated with the right action (decrease beta)
  35057. */
  35058. keysRight: number[];
  35059. /**
  35060. * Defines the list of key codes associated with the reset action.
  35061. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35062. */
  35063. keysReset: number[];
  35064. /**
  35065. * Defines the panning sensibility of the inputs.
  35066. * (How fast is the camera paning)
  35067. */
  35068. panningSensibility: number;
  35069. /**
  35070. * Defines the zooming sensibility of the inputs.
  35071. * (How fast is the camera zooming)
  35072. */
  35073. zoomingSensibility: number;
  35074. /**
  35075. * Defines wether maintaining the alt key down switch the movement mode from
  35076. * orientation to zoom.
  35077. */
  35078. useAltToZoom: boolean;
  35079. /**
  35080. * Rotation speed of the camera
  35081. */
  35082. angularSpeed: number;
  35083. private _keys;
  35084. private _ctrlPressed;
  35085. private _altPressed;
  35086. private _onCanvasBlurObserver;
  35087. private _onKeyboardObserver;
  35088. private _engine;
  35089. private _scene;
  35090. /**
  35091. * Attach the input controls to a specific dom element to get the input from.
  35092. * @param element Defines the element the controls should be listened from
  35093. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35094. */
  35095. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35096. /**
  35097. * Detach the current controls from the specified dom element.
  35098. * @param element Defines the element to stop listening the inputs from
  35099. */
  35100. detachControl(element: Nullable<HTMLElement>): void;
  35101. /**
  35102. * Update the current camera state depending on the inputs that have been used this frame.
  35103. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35104. */
  35105. checkInputs(): void;
  35106. /**
  35107. * Gets the class name of the current intput.
  35108. * @returns the class name
  35109. */
  35110. getClassName(): string;
  35111. /**
  35112. * Get the friendly name associated with the input class.
  35113. * @returns the input friendly name
  35114. */
  35115. getSimpleName(): string;
  35116. }
  35117. }
  35118. declare module BABYLON {
  35119. /**
  35120. * Manage the mouse wheel inputs to control an arc rotate camera.
  35121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35122. */
  35123. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35124. /**
  35125. * Defines the camera the input is attached to.
  35126. */
  35127. camera: ArcRotateCamera;
  35128. /**
  35129. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35130. */
  35131. wheelPrecision: number;
  35132. /**
  35133. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35134. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35135. */
  35136. wheelDeltaPercentage: number;
  35137. private _wheel;
  35138. private _observer;
  35139. /**
  35140. * Attach the input controls to a specific dom element to get the input from.
  35141. * @param element Defines the element the controls should be listened from
  35142. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35143. */
  35144. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35145. /**
  35146. * Detach the current controls from the specified dom element.
  35147. * @param element Defines the element to stop listening the inputs from
  35148. */
  35149. detachControl(element: Nullable<HTMLElement>): void;
  35150. /**
  35151. * Gets the class name of the current intput.
  35152. * @returns the class name
  35153. */
  35154. getClassName(): string;
  35155. /**
  35156. * Get the friendly name associated with the input class.
  35157. * @returns the input friendly name
  35158. */
  35159. getSimpleName(): string;
  35160. }
  35161. }
  35162. declare module BABYLON {
  35163. /**
  35164. * Default Inputs manager for the ArcRotateCamera.
  35165. * It groups all the default supported inputs for ease of use.
  35166. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35167. */
  35168. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35169. /**
  35170. * Instantiates a new ArcRotateCameraInputsManager.
  35171. * @param camera Defines the camera the inputs belong to
  35172. */
  35173. constructor(camera: ArcRotateCamera);
  35174. /**
  35175. * Add mouse wheel input support to the input manager.
  35176. * @returns the current input manager
  35177. */
  35178. addMouseWheel(): ArcRotateCameraInputsManager;
  35179. /**
  35180. * Add pointers input support to the input manager.
  35181. * @returns the current input manager
  35182. */
  35183. addPointers(): ArcRotateCameraInputsManager;
  35184. /**
  35185. * Add keyboard input support to the input manager.
  35186. * @returns the current input manager
  35187. */
  35188. addKeyboard(): ArcRotateCameraInputsManager;
  35189. }
  35190. }
  35191. declare module BABYLON {
  35192. /**
  35193. * This represents an orbital type of camera.
  35194. *
  35195. * 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.
  35196. * 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.
  35197. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35198. */
  35199. export class ArcRotateCamera extends TargetCamera {
  35200. /**
  35201. * Defines the rotation angle of the camera along the longitudinal axis.
  35202. */
  35203. alpha: number;
  35204. /**
  35205. * Defines the rotation angle of the camera along the latitudinal axis.
  35206. */
  35207. beta: number;
  35208. /**
  35209. * Defines the radius of the camera from it s target point.
  35210. */
  35211. radius: number;
  35212. protected _target: Vector3;
  35213. protected _targetHost: Nullable<AbstractMesh>;
  35214. /**
  35215. * Defines the target point of the camera.
  35216. * The camera looks towards it form the radius distance.
  35217. */
  35218. target: Vector3;
  35219. /**
  35220. * Current inertia value on the longitudinal axis.
  35221. * The bigger this number the longer it will take for the camera to stop.
  35222. */
  35223. inertialAlphaOffset: number;
  35224. /**
  35225. * Current inertia value on the latitudinal axis.
  35226. * The bigger this number the longer it will take for the camera to stop.
  35227. */
  35228. inertialBetaOffset: number;
  35229. /**
  35230. * Current inertia value on the radius axis.
  35231. * The bigger this number the longer it will take for the camera to stop.
  35232. */
  35233. inertialRadiusOffset: number;
  35234. /**
  35235. * Minimum allowed angle on the longitudinal axis.
  35236. * This can help limiting how the Camera is able to move in the scene.
  35237. */
  35238. lowerAlphaLimit: Nullable<number>;
  35239. /**
  35240. * Maximum allowed angle on the longitudinal axis.
  35241. * This can help limiting how the Camera is able to move in the scene.
  35242. */
  35243. upperAlphaLimit: Nullable<number>;
  35244. /**
  35245. * Minimum allowed angle on the latitudinal axis.
  35246. * This can help limiting how the Camera is able to move in the scene.
  35247. */
  35248. lowerBetaLimit: number;
  35249. /**
  35250. * Maximum allowed angle on the latitudinal axis.
  35251. * This can help limiting how the Camera is able to move in the scene.
  35252. */
  35253. upperBetaLimit: number;
  35254. /**
  35255. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35256. * This can help limiting how the Camera is able to move in the scene.
  35257. */
  35258. lowerRadiusLimit: Nullable<number>;
  35259. /**
  35260. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35261. * This can help limiting how the Camera is able to move in the scene.
  35262. */
  35263. upperRadiusLimit: Nullable<number>;
  35264. /**
  35265. * Defines the current inertia value used during panning of the camera along the X axis.
  35266. */
  35267. inertialPanningX: number;
  35268. /**
  35269. * Defines the current inertia value used during panning of the camera along the Y axis.
  35270. */
  35271. inertialPanningY: number;
  35272. /**
  35273. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35274. * Basically if your fingers moves away from more than this distance you will be considered
  35275. * in pinch mode.
  35276. */
  35277. pinchToPanMaxDistance: number;
  35278. /**
  35279. * Defines the maximum distance the camera can pan.
  35280. * This could help keeping the cammera always in your scene.
  35281. */
  35282. panningDistanceLimit: Nullable<number>;
  35283. /**
  35284. * Defines the target of the camera before paning.
  35285. */
  35286. panningOriginTarget: Vector3;
  35287. /**
  35288. * Defines the value of the inertia used during panning.
  35289. * 0 would mean stop inertia and one would mean no decelleration at all.
  35290. */
  35291. panningInertia: number;
  35292. /**
  35293. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35294. */
  35295. angularSensibilityX: number;
  35296. /**
  35297. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35298. */
  35299. angularSensibilityY: number;
  35300. /**
  35301. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35302. */
  35303. pinchPrecision: number;
  35304. /**
  35305. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35306. * It will be used instead of pinchDeltaPrecision if different from 0.
  35307. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35308. */
  35309. pinchDeltaPercentage: number;
  35310. /**
  35311. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35312. */
  35313. panningSensibility: number;
  35314. /**
  35315. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35316. */
  35317. keysUp: number[];
  35318. /**
  35319. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35320. */
  35321. keysDown: number[];
  35322. /**
  35323. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35324. */
  35325. keysLeft: number[];
  35326. /**
  35327. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35328. */
  35329. keysRight: number[];
  35330. /**
  35331. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35332. */
  35333. wheelPrecision: number;
  35334. /**
  35335. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35336. * It will be used instead of pinchDeltaPrecision if different from 0.
  35337. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35338. */
  35339. wheelDeltaPercentage: number;
  35340. /**
  35341. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35342. */
  35343. zoomOnFactor: number;
  35344. /**
  35345. * Defines a screen offset for the camera position.
  35346. */
  35347. targetScreenOffset: Vector2;
  35348. /**
  35349. * Allows the camera to be completely reversed.
  35350. * If false the camera can not arrive upside down.
  35351. */
  35352. allowUpsideDown: boolean;
  35353. /**
  35354. * Define if double tap/click is used to restore the previously saved state of the camera.
  35355. */
  35356. useInputToRestoreState: boolean;
  35357. /** @hidden */
  35358. _viewMatrix: Matrix;
  35359. /** @hidden */
  35360. _useCtrlForPanning: boolean;
  35361. /** @hidden */
  35362. _panningMouseButton: number;
  35363. /**
  35364. * Defines the input associated to the camera.
  35365. */
  35366. inputs: ArcRotateCameraInputsManager;
  35367. /** @hidden */
  35368. _reset: () => void;
  35369. /**
  35370. * Defines the allowed panning axis.
  35371. */
  35372. panningAxis: Vector3;
  35373. protected _localDirection: Vector3;
  35374. protected _transformedDirection: Vector3;
  35375. private _bouncingBehavior;
  35376. /**
  35377. * Gets the bouncing behavior of the camera if it has been enabled.
  35378. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35379. */
  35380. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35381. /**
  35382. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35383. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35384. */
  35385. useBouncingBehavior: boolean;
  35386. private _framingBehavior;
  35387. /**
  35388. * Gets the framing behavior of the camera if it has been enabled.
  35389. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35390. */
  35391. readonly framingBehavior: Nullable<FramingBehavior>;
  35392. /**
  35393. * Defines if the framing behavior of the camera is enabled on the camera.
  35394. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35395. */
  35396. useFramingBehavior: boolean;
  35397. private _autoRotationBehavior;
  35398. /**
  35399. * Gets the auto rotation behavior of the camera if it has been enabled.
  35400. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35401. */
  35402. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35403. /**
  35404. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35405. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35406. */
  35407. useAutoRotationBehavior: boolean;
  35408. /**
  35409. * Observable triggered when the mesh target has been changed on the camera.
  35410. */
  35411. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35412. /**
  35413. * Event raised when the camera is colliding with a mesh.
  35414. */
  35415. onCollide: (collidedMesh: AbstractMesh) => void;
  35416. /**
  35417. * Defines whether the camera should check collision with the objects oh the scene.
  35418. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35419. */
  35420. checkCollisions: boolean;
  35421. /**
  35422. * Defines the collision radius of the camera.
  35423. * This simulates a sphere around the camera.
  35424. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35425. */
  35426. collisionRadius: Vector3;
  35427. protected _collider: Collider;
  35428. protected _previousPosition: Vector3;
  35429. protected _collisionVelocity: Vector3;
  35430. protected _newPosition: Vector3;
  35431. protected _previousAlpha: number;
  35432. protected _previousBeta: number;
  35433. protected _previousRadius: number;
  35434. protected _collisionTriggered: boolean;
  35435. protected _targetBoundingCenter: Nullable<Vector3>;
  35436. private _computationVector;
  35437. private _tempAxisVector;
  35438. private _tempAxisRotationMatrix;
  35439. /**
  35440. * Instantiates a new ArcRotateCamera in a given scene
  35441. * @param name Defines the name of the camera
  35442. * @param alpha Defines the camera rotation along the logitudinal axis
  35443. * @param beta Defines the camera rotation along the latitudinal axis
  35444. * @param radius Defines the camera distance from its target
  35445. * @param target Defines the camera target
  35446. * @param scene Defines the scene the camera belongs to
  35447. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35448. */
  35449. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35450. /** @hidden */
  35451. _initCache(): void;
  35452. /** @hidden */
  35453. _updateCache(ignoreParentClass?: boolean): void;
  35454. protected _getTargetPosition(): Vector3;
  35455. private _storedAlpha;
  35456. private _storedBeta;
  35457. private _storedRadius;
  35458. private _storedTarget;
  35459. /**
  35460. * Stores the current state of the camera (alpha, beta, radius and target)
  35461. * @returns the camera itself
  35462. */
  35463. storeState(): Camera;
  35464. /**
  35465. * @hidden
  35466. * Restored camera state. You must call storeState() first
  35467. */
  35468. _restoreStateValues(): boolean;
  35469. /** @hidden */
  35470. _isSynchronizedViewMatrix(): boolean;
  35471. /**
  35472. * Attached controls to the current camera.
  35473. * @param element Defines the element the controls should be listened from
  35474. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35475. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35476. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35477. */
  35478. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35479. /**
  35480. * Detach the current controls from the camera.
  35481. * The camera will stop reacting to inputs.
  35482. * @param element Defines the element to stop listening the inputs from
  35483. */
  35484. detachControl(element: HTMLElement): void;
  35485. /** @hidden */
  35486. _checkInputs(): void;
  35487. protected _checkLimits(): void;
  35488. /**
  35489. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  35490. */
  35491. rebuildAnglesAndRadius(): void;
  35492. /**
  35493. * Use a position to define the current camera related information like aplha, beta and radius
  35494. * @param position Defines the position to set the camera at
  35495. */
  35496. setPosition(position: Vector3): void;
  35497. /**
  35498. * Defines the target the camera should look at.
  35499. * This will automatically adapt alpha beta and radius to fit within the new target.
  35500. * @param target Defines the new target as a Vector or a mesh
  35501. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35502. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35503. */
  35504. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35505. /** @hidden */
  35506. _getViewMatrix(): Matrix;
  35507. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35508. /**
  35509. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35510. * @param meshes Defines the mesh to zoom on
  35511. * @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)
  35512. */
  35513. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35514. /**
  35515. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35516. * The target will be changed but the radius
  35517. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35518. * @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)
  35519. */
  35520. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35521. min: Vector3;
  35522. max: Vector3;
  35523. distance: number;
  35524. }, doNotUpdateMaxZ?: boolean): void;
  35525. /**
  35526. * @override
  35527. * Override Camera.createRigCamera
  35528. */
  35529. createRigCamera(name: string, cameraIndex: number): Camera;
  35530. /**
  35531. * @hidden
  35532. * @override
  35533. * Override Camera._updateRigCameras
  35534. */
  35535. _updateRigCameras(): void;
  35536. /**
  35537. * Destroy the camera and release the current resources hold by it.
  35538. */
  35539. dispose(): void;
  35540. /**
  35541. * Gets the current object class name.
  35542. * @return the class name
  35543. */
  35544. getClassName(): string;
  35545. }
  35546. }
  35547. declare module BABYLON {
  35548. /**
  35549. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35550. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35551. */
  35552. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35553. /**
  35554. * Gets the name of the behavior.
  35555. */
  35556. readonly name: string;
  35557. private _zoomStopsAnimation;
  35558. private _idleRotationSpeed;
  35559. private _idleRotationWaitTime;
  35560. private _idleRotationSpinupTime;
  35561. /**
  35562. * Sets the flag that indicates if user zooming should stop animation.
  35563. */
  35564. /**
  35565. * Gets the flag that indicates if user zooming should stop animation.
  35566. */
  35567. zoomStopsAnimation: boolean;
  35568. /**
  35569. * Sets the default speed at which the camera rotates around the model.
  35570. */
  35571. /**
  35572. * Gets the default speed at which the camera rotates around the model.
  35573. */
  35574. idleRotationSpeed: number;
  35575. /**
  35576. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35577. */
  35578. /**
  35579. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35580. */
  35581. idleRotationWaitTime: number;
  35582. /**
  35583. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35584. */
  35585. /**
  35586. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35587. */
  35588. idleRotationSpinupTime: number;
  35589. /**
  35590. * Gets a value indicating if the camera is currently rotating because of this behavior
  35591. */
  35592. readonly rotationInProgress: boolean;
  35593. private _onPrePointerObservableObserver;
  35594. private _onAfterCheckInputsObserver;
  35595. private _attachedCamera;
  35596. private _isPointerDown;
  35597. private _lastFrameTime;
  35598. private _lastInteractionTime;
  35599. private _cameraRotationSpeed;
  35600. /**
  35601. * Initializes the behavior.
  35602. */
  35603. init(): void;
  35604. /**
  35605. * Attaches the behavior to its arc rotate camera.
  35606. * @param camera Defines the camera to attach the behavior to
  35607. */
  35608. attach(camera: ArcRotateCamera): void;
  35609. /**
  35610. * Detaches the behavior from its current arc rotate camera.
  35611. */
  35612. detach(): void;
  35613. /**
  35614. * Returns true if user is scrolling.
  35615. * @return true if user is scrolling.
  35616. */
  35617. private _userIsZooming;
  35618. private _lastFrameRadius;
  35619. private _shouldAnimationStopForInteraction;
  35620. /**
  35621. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35622. */
  35623. private _applyUserInteraction;
  35624. private _userIsMoving;
  35625. }
  35626. }
  35627. declare module BABYLON {
  35628. /**
  35629. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35630. */
  35631. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35632. private ui;
  35633. /**
  35634. * The name of the behavior
  35635. */
  35636. name: string;
  35637. /**
  35638. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35639. */
  35640. distanceAwayFromFace: number;
  35641. /**
  35642. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35643. */
  35644. distanceAwayFromBottomOfFace: number;
  35645. private _faceVectors;
  35646. private _target;
  35647. private _scene;
  35648. private _onRenderObserver;
  35649. private _tmpMatrix;
  35650. private _tmpVector;
  35651. /**
  35652. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35653. * @param ui The transform node that should be attched to the mesh
  35654. */
  35655. constructor(ui: TransformNode);
  35656. /**
  35657. * Initializes the behavior
  35658. */
  35659. init(): void;
  35660. private _closestFace;
  35661. private _zeroVector;
  35662. private _lookAtTmpMatrix;
  35663. private _lookAtToRef;
  35664. /**
  35665. * Attaches the AttachToBoxBehavior to the passed in mesh
  35666. * @param target The mesh that the specified node will be attached to
  35667. */
  35668. attach(target: Mesh): void;
  35669. /**
  35670. * Detaches the behavior from the mesh
  35671. */
  35672. detach(): void;
  35673. }
  35674. }
  35675. declare module BABYLON {
  35676. /**
  35677. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35678. */
  35679. export class FadeInOutBehavior implements Behavior<Mesh> {
  35680. /**
  35681. * Time in milliseconds to delay before fading in (Default: 0)
  35682. */
  35683. delay: number;
  35684. /**
  35685. * Time in milliseconds for the mesh to fade in (Default: 300)
  35686. */
  35687. fadeInTime: number;
  35688. private _millisecondsPerFrame;
  35689. private _hovered;
  35690. private _hoverValue;
  35691. private _ownerNode;
  35692. /**
  35693. * Instatiates the FadeInOutBehavior
  35694. */
  35695. constructor();
  35696. /**
  35697. * The name of the behavior
  35698. */
  35699. readonly name: string;
  35700. /**
  35701. * Initializes the behavior
  35702. */
  35703. init(): void;
  35704. /**
  35705. * Attaches the fade behavior on the passed in mesh
  35706. * @param ownerNode The mesh that will be faded in/out once attached
  35707. */
  35708. attach(ownerNode: Mesh): void;
  35709. /**
  35710. * Detaches the behavior from the mesh
  35711. */
  35712. detach(): void;
  35713. /**
  35714. * Triggers the mesh to begin fading in or out
  35715. * @param value if the object should fade in or out (true to fade in)
  35716. */
  35717. fadeIn(value: boolean): void;
  35718. private _update;
  35719. private _setAllVisibility;
  35720. }
  35721. }
  35722. declare module BABYLON {
  35723. /**
  35724. * Class containing a set of static utilities functions for managing Pivots
  35725. * @hidden
  35726. */
  35727. export class PivotTools {
  35728. private static _PivotCached;
  35729. private static _OldPivotPoint;
  35730. private static _PivotTranslation;
  35731. private static _PivotTmpVector;
  35732. /** @hidden */
  35733. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35734. /** @hidden */
  35735. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35736. }
  35737. }
  35738. declare module BABYLON {
  35739. /**
  35740. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35741. */
  35742. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35743. private static _AnyMouseID;
  35744. private _attachedNode;
  35745. private _dragPlane;
  35746. private _scene;
  35747. private _pointerObserver;
  35748. private _beforeRenderObserver;
  35749. private static _planeScene;
  35750. /**
  35751. * 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)
  35752. */
  35753. maxDragAngle: number;
  35754. /**
  35755. * @hidden
  35756. */
  35757. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35758. /**
  35759. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35760. */
  35761. currentDraggingPointerID: number;
  35762. /**
  35763. * The last position where the pointer hit the drag plane in world space
  35764. */
  35765. lastDragPosition: Vector3;
  35766. /**
  35767. * If the behavior is currently in a dragging state
  35768. */
  35769. dragging: boolean;
  35770. /**
  35771. * 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)
  35772. */
  35773. dragDeltaRatio: number;
  35774. /**
  35775. * If the drag plane orientation should be updated during the dragging (Default: true)
  35776. */
  35777. updateDragPlane: boolean;
  35778. private _debugMode;
  35779. private _moving;
  35780. /**
  35781. * Fires each time the attached mesh is dragged with the pointer
  35782. * * delta between last drag position and current drag position in world space
  35783. * * dragDistance along the drag axis
  35784. * * dragPlaneNormal normal of the current drag plane used during the drag
  35785. * * dragPlanePoint in world space where the drag intersects the drag plane
  35786. */
  35787. onDragObservable: Observable<{
  35788. delta: Vector3;
  35789. dragPlanePoint: Vector3;
  35790. dragPlaneNormal: Vector3;
  35791. dragDistance: number;
  35792. pointerId: number;
  35793. }>;
  35794. /**
  35795. * Fires each time a drag begins (eg. mouse down on mesh)
  35796. */
  35797. onDragStartObservable: Observable<{
  35798. dragPlanePoint: Vector3;
  35799. pointerId: number;
  35800. }>;
  35801. /**
  35802. * Fires each time a drag ends (eg. mouse release after drag)
  35803. */
  35804. onDragEndObservable: Observable<{
  35805. dragPlanePoint: Vector3;
  35806. pointerId: number;
  35807. }>;
  35808. /**
  35809. * If the attached mesh should be moved when dragged
  35810. */
  35811. moveAttached: boolean;
  35812. /**
  35813. * If the drag behavior will react to drag events (Default: true)
  35814. */
  35815. enabled: boolean;
  35816. /**
  35817. * If camera controls should be detached during the drag
  35818. */
  35819. detachCameraControls: boolean;
  35820. /**
  35821. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35822. */
  35823. useObjectOrienationForDragging: boolean;
  35824. private _options;
  35825. /**
  35826. * Creates a pointer drag behavior that can be attached to a mesh
  35827. * @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)
  35828. */
  35829. constructor(options?: {
  35830. dragAxis?: Vector3;
  35831. dragPlaneNormal?: Vector3;
  35832. });
  35833. /**
  35834. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35835. */
  35836. validateDrag: (targetPosition: Vector3) => boolean;
  35837. /**
  35838. * The name of the behavior
  35839. */
  35840. readonly name: string;
  35841. /**
  35842. * Initializes the behavior
  35843. */
  35844. init(): void;
  35845. private _tmpVector;
  35846. private _alternatePickedPoint;
  35847. private _worldDragAxis;
  35848. private _targetPosition;
  35849. private _attachedElement;
  35850. /**
  35851. * Attaches the drag behavior the passed in mesh
  35852. * @param ownerNode The mesh that will be dragged around once attached
  35853. */
  35854. attach(ownerNode: AbstractMesh): void;
  35855. /**
  35856. * Force relase the drag action by code.
  35857. */
  35858. releaseDrag(): void;
  35859. private _startDragRay;
  35860. private _lastPointerRay;
  35861. /**
  35862. * Simulates the start of a pointer drag event on the behavior
  35863. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35864. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35865. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35866. */
  35867. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35868. private _startDrag;
  35869. private _dragDelta;
  35870. private _moveDrag;
  35871. private _pickWithRayOnDragPlane;
  35872. private _pointA;
  35873. private _pointB;
  35874. private _pointC;
  35875. private _lineA;
  35876. private _lineB;
  35877. private _localAxis;
  35878. private _lookAt;
  35879. private _updateDragPlanePosition;
  35880. /**
  35881. * Detaches the behavior from the mesh
  35882. */
  35883. detach(): void;
  35884. }
  35885. }
  35886. declare module BABYLON {
  35887. /**
  35888. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35889. */
  35890. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35891. private _dragBehaviorA;
  35892. private _dragBehaviorB;
  35893. private _startDistance;
  35894. private _initialScale;
  35895. private _targetScale;
  35896. private _ownerNode;
  35897. private _sceneRenderObserver;
  35898. /**
  35899. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35900. */
  35901. constructor();
  35902. /**
  35903. * The name of the behavior
  35904. */
  35905. readonly name: string;
  35906. /**
  35907. * Initializes the behavior
  35908. */
  35909. init(): void;
  35910. private _getCurrentDistance;
  35911. /**
  35912. * Attaches the scale behavior the passed in mesh
  35913. * @param ownerNode The mesh that will be scaled around once attached
  35914. */
  35915. attach(ownerNode: Mesh): void;
  35916. /**
  35917. * Detaches the behavior from the mesh
  35918. */
  35919. detach(): void;
  35920. }
  35921. }
  35922. declare module BABYLON {
  35923. /**
  35924. * 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
  35925. */
  35926. export class SixDofDragBehavior implements Behavior<Mesh> {
  35927. private static _virtualScene;
  35928. private _ownerNode;
  35929. private _sceneRenderObserver;
  35930. private _scene;
  35931. private _targetPosition;
  35932. private _virtualOriginMesh;
  35933. private _virtualDragMesh;
  35934. private _pointerObserver;
  35935. private _moving;
  35936. private _startingOrientation;
  35937. /**
  35938. * 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)
  35939. */
  35940. private zDragFactor;
  35941. /**
  35942. * If the object should rotate to face the drag origin
  35943. */
  35944. rotateDraggedObject: boolean;
  35945. /**
  35946. * If the behavior is currently in a dragging state
  35947. */
  35948. dragging: boolean;
  35949. /**
  35950. * 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)
  35951. */
  35952. dragDeltaRatio: number;
  35953. /**
  35954. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35955. */
  35956. currentDraggingPointerID: number;
  35957. /**
  35958. * If camera controls should be detached during the drag
  35959. */
  35960. detachCameraControls: boolean;
  35961. /**
  35962. * Fires each time a drag starts
  35963. */
  35964. onDragStartObservable: Observable<{}>;
  35965. /**
  35966. * Fires each time a drag ends (eg. mouse release after drag)
  35967. */
  35968. onDragEndObservable: Observable<{}>;
  35969. /**
  35970. * 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
  35971. */
  35972. constructor();
  35973. /**
  35974. * The name of the behavior
  35975. */
  35976. readonly name: string;
  35977. /**
  35978. * Initializes the behavior
  35979. */
  35980. init(): void;
  35981. /**
  35982. * Attaches the scale behavior the passed in mesh
  35983. * @param ownerNode The mesh that will be scaled around once attached
  35984. */
  35985. attach(ownerNode: Mesh): void;
  35986. /**
  35987. * Detaches the behavior from the mesh
  35988. */
  35989. detach(): void;
  35990. }
  35991. }
  35992. declare module BABYLON {
  35993. /**
  35994. * Class used to apply inverse kinematics to bones
  35995. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35996. */
  35997. export class BoneIKController {
  35998. private static _tmpVecs;
  35999. private static _tmpQuat;
  36000. private static _tmpMats;
  36001. /**
  36002. * Gets or sets the target mesh
  36003. */
  36004. targetMesh: AbstractMesh;
  36005. /** Gets or sets the mesh used as pole */
  36006. poleTargetMesh: AbstractMesh;
  36007. /**
  36008. * Gets or sets the bone used as pole
  36009. */
  36010. poleTargetBone: Nullable<Bone>;
  36011. /**
  36012. * Gets or sets the target position
  36013. */
  36014. targetPosition: Vector3;
  36015. /**
  36016. * Gets or sets the pole target position
  36017. */
  36018. poleTargetPosition: Vector3;
  36019. /**
  36020. * Gets or sets the pole target local offset
  36021. */
  36022. poleTargetLocalOffset: Vector3;
  36023. /**
  36024. * Gets or sets the pole angle
  36025. */
  36026. poleAngle: number;
  36027. /**
  36028. * Gets or sets the mesh associated with the controller
  36029. */
  36030. mesh: AbstractMesh;
  36031. /**
  36032. * 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)
  36033. */
  36034. slerpAmount: number;
  36035. private _bone1Quat;
  36036. private _bone1Mat;
  36037. private _bone2Ang;
  36038. private _bone1;
  36039. private _bone2;
  36040. private _bone1Length;
  36041. private _bone2Length;
  36042. private _maxAngle;
  36043. private _maxReach;
  36044. private _rightHandedSystem;
  36045. private _bendAxis;
  36046. private _slerping;
  36047. private _adjustRoll;
  36048. /**
  36049. * Gets or sets maximum allowed angle
  36050. */
  36051. maxAngle: number;
  36052. /**
  36053. * Creates a new BoneIKController
  36054. * @param mesh defines the mesh to control
  36055. * @param bone defines the bone to control
  36056. * @param options defines options to set up the controller
  36057. */
  36058. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36059. targetMesh?: AbstractMesh;
  36060. poleTargetMesh?: AbstractMesh;
  36061. poleTargetBone?: Bone;
  36062. poleTargetLocalOffset?: Vector3;
  36063. poleAngle?: number;
  36064. bendAxis?: Vector3;
  36065. maxAngle?: number;
  36066. slerpAmount?: number;
  36067. });
  36068. private _setMaxAngle;
  36069. /**
  36070. * Force the controller to update the bones
  36071. */
  36072. update(): void;
  36073. }
  36074. }
  36075. declare module BABYLON {
  36076. /**
  36077. * Class used to make a bone look toward a point in space
  36078. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36079. */
  36080. export class BoneLookController {
  36081. private static _tmpVecs;
  36082. private static _tmpQuat;
  36083. private static _tmpMats;
  36084. /**
  36085. * The target Vector3 that the bone will look at
  36086. */
  36087. target: Vector3;
  36088. /**
  36089. * The mesh that the bone is attached to
  36090. */
  36091. mesh: AbstractMesh;
  36092. /**
  36093. * The bone that will be looking to the target
  36094. */
  36095. bone: Bone;
  36096. /**
  36097. * The up axis of the coordinate system that is used when the bone is rotated
  36098. */
  36099. upAxis: Vector3;
  36100. /**
  36101. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36102. */
  36103. upAxisSpace: Space;
  36104. /**
  36105. * Used to make an adjustment to the yaw of the bone
  36106. */
  36107. adjustYaw: number;
  36108. /**
  36109. * Used to make an adjustment to the pitch of the bone
  36110. */
  36111. adjustPitch: number;
  36112. /**
  36113. * Used to make an adjustment to the roll of the bone
  36114. */
  36115. adjustRoll: number;
  36116. /**
  36117. * 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)
  36118. */
  36119. slerpAmount: number;
  36120. private _minYaw;
  36121. private _maxYaw;
  36122. private _minPitch;
  36123. private _maxPitch;
  36124. private _minYawSin;
  36125. private _minYawCos;
  36126. private _maxYawSin;
  36127. private _maxYawCos;
  36128. private _midYawConstraint;
  36129. private _minPitchTan;
  36130. private _maxPitchTan;
  36131. private _boneQuat;
  36132. private _slerping;
  36133. private _transformYawPitch;
  36134. private _transformYawPitchInv;
  36135. private _firstFrameSkipped;
  36136. private _yawRange;
  36137. private _fowardAxis;
  36138. /**
  36139. * Gets or sets the minimum yaw angle that the bone can look to
  36140. */
  36141. minYaw: number;
  36142. /**
  36143. * Gets or sets the maximum yaw angle that the bone can look to
  36144. */
  36145. maxYaw: number;
  36146. /**
  36147. * Gets or sets the minimum pitch angle that the bone can look to
  36148. */
  36149. minPitch: number;
  36150. /**
  36151. * Gets or sets the maximum pitch angle that the bone can look to
  36152. */
  36153. maxPitch: number;
  36154. /**
  36155. * Create a BoneLookController
  36156. * @param mesh the mesh that the bone belongs to
  36157. * @param bone the bone that will be looking to the target
  36158. * @param target the target Vector3 to look at
  36159. * @param settings optional settings:
  36160. * * maxYaw: the maximum angle the bone will yaw to
  36161. * * minYaw: the minimum angle the bone will yaw to
  36162. * * maxPitch: the maximum angle the bone will pitch to
  36163. * * minPitch: the minimum angle the bone will yaw to
  36164. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36165. * * upAxis: the up axis of the coordinate system
  36166. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36167. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36168. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36169. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36170. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36171. * * adjustRoll: used to make an adjustment to the roll of the bone
  36172. **/
  36173. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36174. maxYaw?: number;
  36175. minYaw?: number;
  36176. maxPitch?: number;
  36177. minPitch?: number;
  36178. slerpAmount?: number;
  36179. upAxis?: Vector3;
  36180. upAxisSpace?: Space;
  36181. yawAxis?: Vector3;
  36182. pitchAxis?: Vector3;
  36183. adjustYaw?: number;
  36184. adjustPitch?: number;
  36185. adjustRoll?: number;
  36186. });
  36187. /**
  36188. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36189. */
  36190. update(): void;
  36191. private _getAngleDiff;
  36192. private _getAngleBetween;
  36193. private _isAngleBetween;
  36194. }
  36195. }
  36196. declare module BABYLON {
  36197. /**
  36198. * Manage the gamepad inputs to control an arc rotate camera.
  36199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36200. */
  36201. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36202. /**
  36203. * Defines the camera the input is attached to.
  36204. */
  36205. camera: ArcRotateCamera;
  36206. /**
  36207. * Defines the gamepad the input is gathering event from.
  36208. */
  36209. gamepad: Nullable<Gamepad>;
  36210. /**
  36211. * Defines the gamepad rotation sensiblity.
  36212. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36213. */
  36214. gamepadRotationSensibility: number;
  36215. /**
  36216. * Defines the gamepad move sensiblity.
  36217. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36218. */
  36219. gamepadMoveSensibility: number;
  36220. private _onGamepadConnectedObserver;
  36221. private _onGamepadDisconnectedObserver;
  36222. /**
  36223. * Attach the input controls to a specific dom element to get the input from.
  36224. * @param element Defines the element the controls should be listened from
  36225. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36226. */
  36227. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36228. /**
  36229. * Detach the current controls from the specified dom element.
  36230. * @param element Defines the element to stop listening the inputs from
  36231. */
  36232. detachControl(element: Nullable<HTMLElement>): void;
  36233. /**
  36234. * Update the current camera state depending on the inputs that have been used this frame.
  36235. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36236. */
  36237. checkInputs(): void;
  36238. /**
  36239. * Gets the class name of the current intput.
  36240. * @returns the class name
  36241. */
  36242. getClassName(): string;
  36243. /**
  36244. * Get the friendly name associated with the input class.
  36245. * @returns the input friendly name
  36246. */
  36247. getSimpleName(): string;
  36248. }
  36249. }
  36250. declare module BABYLON {
  36251. interface ArcRotateCameraInputsManager {
  36252. /**
  36253. * Add orientation input support to the input manager.
  36254. * @returns the current input manager
  36255. */
  36256. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36257. }
  36258. /**
  36259. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36260. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36261. */
  36262. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36263. /**
  36264. * Defines the camera the input is attached to.
  36265. */
  36266. camera: ArcRotateCamera;
  36267. /**
  36268. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36269. */
  36270. alphaCorrection: number;
  36271. /**
  36272. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36273. */
  36274. gammaCorrection: number;
  36275. private _alpha;
  36276. private _gamma;
  36277. private _dirty;
  36278. private _deviceOrientationHandler;
  36279. /**
  36280. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36281. */
  36282. constructor();
  36283. /**
  36284. * Attach the input controls to a specific dom element to get the input from.
  36285. * @param element Defines the element the controls should be listened from
  36286. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36287. */
  36288. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36289. /** @hidden */
  36290. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36291. /**
  36292. * Update the current camera state depending on the inputs that have been used this frame.
  36293. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36294. */
  36295. checkInputs(): void;
  36296. /**
  36297. * Detach the current controls from the specified dom element.
  36298. * @param element Defines the element to stop listening the inputs from
  36299. */
  36300. detachControl(element: Nullable<HTMLElement>): void;
  36301. /**
  36302. * Gets the class name of the current intput.
  36303. * @returns the class name
  36304. */
  36305. getClassName(): string;
  36306. /**
  36307. * Get the friendly name associated with the input class.
  36308. * @returns the input friendly name
  36309. */
  36310. getSimpleName(): string;
  36311. }
  36312. }
  36313. declare module BABYLON {
  36314. /**
  36315. * Listen to mouse events to control the camera.
  36316. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36317. */
  36318. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36319. /**
  36320. * Defines the camera the input is attached to.
  36321. */
  36322. camera: FlyCamera;
  36323. /**
  36324. * Defines if touch is enabled. (Default is true.)
  36325. */
  36326. touchEnabled: boolean;
  36327. /**
  36328. * Defines the buttons associated with the input to handle camera rotation.
  36329. */
  36330. buttons: number[];
  36331. /**
  36332. * Assign buttons for Yaw control.
  36333. */
  36334. buttonsYaw: number[];
  36335. /**
  36336. * Assign buttons for Pitch control.
  36337. */
  36338. buttonsPitch: number[];
  36339. /**
  36340. * Assign buttons for Roll control.
  36341. */
  36342. buttonsRoll: number[];
  36343. /**
  36344. * Detect if any button is being pressed while mouse is moved.
  36345. * -1 = Mouse locked.
  36346. * 0 = Left button.
  36347. * 1 = Middle Button.
  36348. * 2 = Right Button.
  36349. */
  36350. activeButton: number;
  36351. /**
  36352. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36353. * Higher values reduce its sensitivity.
  36354. */
  36355. angularSensibility: number;
  36356. private _mousemoveCallback;
  36357. private _observer;
  36358. private _rollObserver;
  36359. private previousPosition;
  36360. private noPreventDefault;
  36361. private element;
  36362. /**
  36363. * Listen to mouse events to control the camera.
  36364. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36365. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36366. */
  36367. constructor(touchEnabled?: boolean);
  36368. /**
  36369. * Attach the mouse control to the HTML DOM element.
  36370. * @param element Defines the element that listens to the input events.
  36371. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36372. */
  36373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36374. /**
  36375. * Detach the current controls from the specified dom element.
  36376. * @param element Defines the element to stop listening the inputs from
  36377. */
  36378. detachControl(element: Nullable<HTMLElement>): void;
  36379. /**
  36380. * Gets the class name of the current input.
  36381. * @returns the class name.
  36382. */
  36383. getClassName(): string;
  36384. /**
  36385. * Get the friendly name associated with the input class.
  36386. * @returns the input's friendly name.
  36387. */
  36388. getSimpleName(): string;
  36389. private _pointerInput;
  36390. private _onMouseMove;
  36391. /**
  36392. * Rotate camera by mouse offset.
  36393. */
  36394. private rotateCamera;
  36395. }
  36396. }
  36397. declare module BABYLON {
  36398. /**
  36399. * Default Inputs manager for the FlyCamera.
  36400. * It groups all the default supported inputs for ease of use.
  36401. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36402. */
  36403. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36404. /**
  36405. * Instantiates a new FlyCameraInputsManager.
  36406. * @param camera Defines the camera the inputs belong to.
  36407. */
  36408. constructor(camera: FlyCamera);
  36409. /**
  36410. * Add keyboard input support to the input manager.
  36411. * @returns the new FlyCameraKeyboardMoveInput().
  36412. */
  36413. addKeyboard(): FlyCameraInputsManager;
  36414. /**
  36415. * Add mouse input support to the input manager.
  36416. * @param touchEnabled Enable touch screen support.
  36417. * @returns the new FlyCameraMouseInput().
  36418. */
  36419. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36420. }
  36421. }
  36422. declare module BABYLON {
  36423. /**
  36424. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36425. * such as in a 3D Space Shooter or a Flight Simulator.
  36426. */
  36427. export class FlyCamera extends TargetCamera {
  36428. /**
  36429. * Define the collision ellipsoid of the camera.
  36430. * This is helpful for simulating a camera body, like a player's body.
  36431. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36432. */
  36433. ellipsoid: Vector3;
  36434. /**
  36435. * Define an offset for the position of the ellipsoid around the camera.
  36436. * This can be helpful if the camera is attached away from the player's body center,
  36437. * such as at its head.
  36438. */
  36439. ellipsoidOffset: Vector3;
  36440. /**
  36441. * Enable or disable collisions of the camera with the rest of the scene objects.
  36442. */
  36443. checkCollisions: boolean;
  36444. /**
  36445. * Enable or disable gravity on the camera.
  36446. */
  36447. applyGravity: boolean;
  36448. /**
  36449. * Define the current direction the camera is moving to.
  36450. */
  36451. cameraDirection: Vector3;
  36452. /**
  36453. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36454. * This overrides and empties cameraRotation.
  36455. */
  36456. rotationQuaternion: Quaternion;
  36457. /**
  36458. * Track Roll to maintain the wanted Rolling when looking around.
  36459. */
  36460. _trackRoll: number;
  36461. /**
  36462. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36463. */
  36464. rollCorrect: number;
  36465. /**
  36466. * Mimic a banked turn, Rolling the camera when Yawing.
  36467. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36468. */
  36469. bankedTurn: boolean;
  36470. /**
  36471. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36472. */
  36473. bankedTurnLimit: number;
  36474. /**
  36475. * Value of 0 disables the banked Roll.
  36476. * Value of 1 is equal to the Yaw angle in radians.
  36477. */
  36478. bankedTurnMultiplier: number;
  36479. /**
  36480. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36481. */
  36482. inputs: FlyCameraInputsManager;
  36483. /**
  36484. * Gets the input sensibility for mouse input.
  36485. * Higher values reduce sensitivity.
  36486. */
  36487. /**
  36488. * Sets the input sensibility for a mouse input.
  36489. * Higher values reduce sensitivity.
  36490. */
  36491. angularSensibility: number;
  36492. /**
  36493. * Get the keys for camera movement forward.
  36494. */
  36495. /**
  36496. * Set the keys for camera movement forward.
  36497. */
  36498. keysForward: number[];
  36499. /**
  36500. * Get the keys for camera movement backward.
  36501. */
  36502. keysBackward: number[];
  36503. /**
  36504. * Get the keys for camera movement up.
  36505. */
  36506. /**
  36507. * Set the keys for camera movement up.
  36508. */
  36509. keysUp: number[];
  36510. /**
  36511. * Get the keys for camera movement down.
  36512. */
  36513. /**
  36514. * Set the keys for camera movement down.
  36515. */
  36516. keysDown: number[];
  36517. /**
  36518. * Get the keys for camera movement left.
  36519. */
  36520. /**
  36521. * Set the keys for camera movement left.
  36522. */
  36523. keysLeft: number[];
  36524. /**
  36525. * Set the keys for camera movement right.
  36526. */
  36527. /**
  36528. * Set the keys for camera movement right.
  36529. */
  36530. keysRight: number[];
  36531. /**
  36532. * Event raised when the camera collides with a mesh in the scene.
  36533. */
  36534. onCollide: (collidedMesh: AbstractMesh) => void;
  36535. private _collider;
  36536. private _needMoveForGravity;
  36537. private _oldPosition;
  36538. private _diffPosition;
  36539. private _newPosition;
  36540. /** @hidden */
  36541. _localDirection: Vector3;
  36542. /** @hidden */
  36543. _transformedDirection: Vector3;
  36544. /**
  36545. * Instantiates a FlyCamera.
  36546. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36547. * such as in a 3D Space Shooter or a Flight Simulator.
  36548. * @param name Define the name of the camera in the scene.
  36549. * @param position Define the starting position of the camera in the scene.
  36550. * @param scene Define the scene the camera belongs to.
  36551. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36552. */
  36553. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36554. /**
  36555. * Attach a control to the HTML DOM element.
  36556. * @param element Defines the element that listens to the input events.
  36557. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36558. */
  36559. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36560. /**
  36561. * Detach a control from the HTML DOM element.
  36562. * The camera will stop reacting to that input.
  36563. * @param element Defines the element that listens to the input events.
  36564. */
  36565. detachControl(element: HTMLElement): void;
  36566. private _collisionMask;
  36567. /**
  36568. * Get the mask that the camera ignores in collision events.
  36569. */
  36570. /**
  36571. * Set the mask that the camera ignores in collision events.
  36572. */
  36573. collisionMask: number;
  36574. /** @hidden */
  36575. _collideWithWorld(displacement: Vector3): void;
  36576. /** @hidden */
  36577. private _onCollisionPositionChange;
  36578. /** @hidden */
  36579. _checkInputs(): void;
  36580. /** @hidden */
  36581. _decideIfNeedsToMove(): boolean;
  36582. /** @hidden */
  36583. _updatePosition(): void;
  36584. /**
  36585. * Restore the Roll to its target value at the rate specified.
  36586. * @param rate - Higher means slower restoring.
  36587. * @hidden
  36588. */
  36589. restoreRoll(rate: number): void;
  36590. /**
  36591. * Destroy the camera and release the current resources held by it.
  36592. */
  36593. dispose(): void;
  36594. /**
  36595. * Get the current object class name.
  36596. * @returns the class name.
  36597. */
  36598. getClassName(): string;
  36599. }
  36600. }
  36601. declare module BABYLON {
  36602. /**
  36603. * Listen to keyboard events to control the camera.
  36604. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36605. */
  36606. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36607. /**
  36608. * Defines the camera the input is attached to.
  36609. */
  36610. camera: FlyCamera;
  36611. /**
  36612. * The list of keyboard keys used to control the forward move of the camera.
  36613. */
  36614. keysForward: number[];
  36615. /**
  36616. * The list of keyboard keys used to control the backward move of the camera.
  36617. */
  36618. keysBackward: number[];
  36619. /**
  36620. * The list of keyboard keys used to control the forward move of the camera.
  36621. */
  36622. keysUp: number[];
  36623. /**
  36624. * The list of keyboard keys used to control the backward move of the camera.
  36625. */
  36626. keysDown: number[];
  36627. /**
  36628. * The list of keyboard keys used to control the right strafe move of the camera.
  36629. */
  36630. keysRight: number[];
  36631. /**
  36632. * The list of keyboard keys used to control the left strafe move of the camera.
  36633. */
  36634. keysLeft: number[];
  36635. private _keys;
  36636. private _onCanvasBlurObserver;
  36637. private _onKeyboardObserver;
  36638. private _engine;
  36639. private _scene;
  36640. /**
  36641. * Attach the input controls to a specific dom element to get the input from.
  36642. * @param element Defines the element the controls should be listened from
  36643. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36644. */
  36645. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36646. /**
  36647. * Detach the current controls from the specified dom element.
  36648. * @param element Defines the element to stop listening the inputs from
  36649. */
  36650. detachControl(element: Nullable<HTMLElement>): void;
  36651. /**
  36652. * Gets the class name of the current intput.
  36653. * @returns the class name
  36654. */
  36655. getClassName(): string;
  36656. /** @hidden */
  36657. _onLostFocus(e: FocusEvent): void;
  36658. /**
  36659. * Get the friendly name associated with the input class.
  36660. * @returns the input friendly name
  36661. */
  36662. getSimpleName(): string;
  36663. /**
  36664. * Update the current camera state depending on the inputs that have been used this frame.
  36665. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36666. */
  36667. checkInputs(): void;
  36668. }
  36669. }
  36670. declare module BABYLON {
  36671. interface FreeCameraInputsManager {
  36672. /**
  36673. * Add orientation input support to the input manager.
  36674. * @returns the current input manager
  36675. */
  36676. addDeviceOrientation(): FreeCameraInputsManager;
  36677. }
  36678. /**
  36679. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36680. * Screen rotation is taken into account.
  36681. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36682. */
  36683. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36684. private _camera;
  36685. private _screenOrientationAngle;
  36686. private _constantTranform;
  36687. private _screenQuaternion;
  36688. private _alpha;
  36689. private _beta;
  36690. private _gamma;
  36691. /**
  36692. * Instantiates a new input
  36693. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36694. */
  36695. constructor();
  36696. /**
  36697. * Define the camera controlled by the input.
  36698. */
  36699. camera: FreeCamera;
  36700. /**
  36701. * Attach the input controls to a specific dom element to get the input from.
  36702. * @param element Defines the element the controls should be listened from
  36703. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36704. */
  36705. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36706. private _orientationChanged;
  36707. private _deviceOrientation;
  36708. /**
  36709. * Detach the current controls from the specified dom element.
  36710. * @param element Defines the element to stop listening the inputs from
  36711. */
  36712. detachControl(element: Nullable<HTMLElement>): void;
  36713. /**
  36714. * Update the current camera state depending on the inputs that have been used this frame.
  36715. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36716. */
  36717. checkInputs(): void;
  36718. /**
  36719. * Gets the class name of the current intput.
  36720. * @returns the class name
  36721. */
  36722. getClassName(): string;
  36723. /**
  36724. * Get the friendly name associated with the input class.
  36725. * @returns the input friendly name
  36726. */
  36727. getSimpleName(): string;
  36728. }
  36729. }
  36730. declare module BABYLON {
  36731. /**
  36732. * Manage the gamepad inputs to control a free camera.
  36733. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36734. */
  36735. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36736. /**
  36737. * Define the camera the input is attached to.
  36738. */
  36739. camera: FreeCamera;
  36740. /**
  36741. * Define the Gamepad controlling the input
  36742. */
  36743. gamepad: Nullable<Gamepad>;
  36744. /**
  36745. * Defines the gamepad rotation sensiblity.
  36746. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36747. */
  36748. gamepadAngularSensibility: number;
  36749. /**
  36750. * Defines the gamepad move sensiblity.
  36751. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36752. */
  36753. gamepadMoveSensibility: number;
  36754. private _onGamepadConnectedObserver;
  36755. private _onGamepadDisconnectedObserver;
  36756. private _cameraTransform;
  36757. private _deltaTransform;
  36758. private _vector3;
  36759. private _vector2;
  36760. /**
  36761. * Attach the input controls to a specific dom element to get the input from.
  36762. * @param element Defines the element the controls should be listened from
  36763. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36764. */
  36765. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36766. /**
  36767. * Detach the current controls from the specified dom element.
  36768. * @param element Defines the element to stop listening the inputs from
  36769. */
  36770. detachControl(element: Nullable<HTMLElement>): void;
  36771. /**
  36772. * Update the current camera state depending on the inputs that have been used this frame.
  36773. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36774. */
  36775. checkInputs(): void;
  36776. /**
  36777. * Gets the class name of the current intput.
  36778. * @returns the class name
  36779. */
  36780. getClassName(): string;
  36781. /**
  36782. * Get the friendly name associated with the input class.
  36783. * @returns the input friendly name
  36784. */
  36785. getSimpleName(): string;
  36786. }
  36787. }
  36788. declare module BABYLON {
  36789. /**
  36790. * Defines the potential axis of a Joystick
  36791. */
  36792. export enum JoystickAxis {
  36793. /** X axis */
  36794. X = 0,
  36795. /** Y axis */
  36796. Y = 1,
  36797. /** Z axis */
  36798. Z = 2
  36799. }
  36800. /**
  36801. * Class used to define virtual joystick (used in touch mode)
  36802. */
  36803. export class VirtualJoystick {
  36804. /**
  36805. * Gets or sets a boolean indicating that left and right values must be inverted
  36806. */
  36807. reverseLeftRight: boolean;
  36808. /**
  36809. * Gets or sets a boolean indicating that up and down values must be inverted
  36810. */
  36811. reverseUpDown: boolean;
  36812. /**
  36813. * Gets the offset value for the position (ie. the change of the position value)
  36814. */
  36815. deltaPosition: Vector3;
  36816. /**
  36817. * Gets a boolean indicating if the virtual joystick was pressed
  36818. */
  36819. pressed: boolean;
  36820. /**
  36821. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36822. */
  36823. static Canvas: Nullable<HTMLCanvasElement>;
  36824. private static _globalJoystickIndex;
  36825. private static vjCanvasContext;
  36826. private static vjCanvasWidth;
  36827. private static vjCanvasHeight;
  36828. private static halfWidth;
  36829. private _action;
  36830. private _axisTargetedByLeftAndRight;
  36831. private _axisTargetedByUpAndDown;
  36832. private _joystickSensibility;
  36833. private _inversedSensibility;
  36834. private _joystickPointerID;
  36835. private _joystickColor;
  36836. private _joystickPointerPos;
  36837. private _joystickPreviousPointerPos;
  36838. private _joystickPointerStartPos;
  36839. private _deltaJoystickVector;
  36840. private _leftJoystick;
  36841. private _touches;
  36842. private _onPointerDownHandlerRef;
  36843. private _onPointerMoveHandlerRef;
  36844. private _onPointerUpHandlerRef;
  36845. private _onResize;
  36846. /**
  36847. * Creates a new virtual joystick
  36848. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36849. */
  36850. constructor(leftJoystick?: boolean);
  36851. /**
  36852. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36853. * @param newJoystickSensibility defines the new sensibility
  36854. */
  36855. setJoystickSensibility(newJoystickSensibility: number): void;
  36856. private _onPointerDown;
  36857. private _onPointerMove;
  36858. private _onPointerUp;
  36859. /**
  36860. * Change the color of the virtual joystick
  36861. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36862. */
  36863. setJoystickColor(newColor: string): void;
  36864. /**
  36865. * Defines a callback to call when the joystick is touched
  36866. * @param action defines the callback
  36867. */
  36868. setActionOnTouch(action: () => any): void;
  36869. /**
  36870. * Defines which axis you'd like to control for left & right
  36871. * @param axis defines the axis to use
  36872. */
  36873. setAxisForLeftRight(axis: JoystickAxis): void;
  36874. /**
  36875. * Defines which axis you'd like to control for up & down
  36876. * @param axis defines the axis to use
  36877. */
  36878. setAxisForUpDown(axis: JoystickAxis): void;
  36879. private _drawVirtualJoystick;
  36880. /**
  36881. * Release internal HTML canvas
  36882. */
  36883. releaseCanvas(): void;
  36884. }
  36885. }
  36886. declare module BABYLON {
  36887. interface FreeCameraInputsManager {
  36888. /**
  36889. * Add virtual joystick input support to the input manager.
  36890. * @returns the current input manager
  36891. */
  36892. addVirtualJoystick(): FreeCameraInputsManager;
  36893. }
  36894. /**
  36895. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36896. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36897. */
  36898. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36899. /**
  36900. * Defines the camera the input is attached to.
  36901. */
  36902. camera: FreeCamera;
  36903. private _leftjoystick;
  36904. private _rightjoystick;
  36905. /**
  36906. * Gets the left stick of the virtual joystick.
  36907. * @returns The virtual Joystick
  36908. */
  36909. getLeftJoystick(): VirtualJoystick;
  36910. /**
  36911. * Gets the right stick of the virtual joystick.
  36912. * @returns The virtual Joystick
  36913. */
  36914. getRightJoystick(): VirtualJoystick;
  36915. /**
  36916. * Update the current camera state depending on the inputs that have been used this frame.
  36917. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36918. */
  36919. checkInputs(): void;
  36920. /**
  36921. * Attach the input controls to a specific dom element to get the input from.
  36922. * @param element Defines the element the controls should be listened from
  36923. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36924. */
  36925. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36926. /**
  36927. * Detach the current controls from the specified dom element.
  36928. * @param element Defines the element to stop listening the inputs from
  36929. */
  36930. detachControl(element: Nullable<HTMLElement>): void;
  36931. /**
  36932. * Gets the class name of the current intput.
  36933. * @returns the class name
  36934. */
  36935. getClassName(): string;
  36936. /**
  36937. * Get the friendly name associated with the input class.
  36938. * @returns the input friendly name
  36939. */
  36940. getSimpleName(): string;
  36941. }
  36942. }
  36943. declare module BABYLON {
  36944. /**
  36945. * This represents a FPS type of camera controlled by touch.
  36946. * This is like a universal camera minus the Gamepad controls.
  36947. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36948. */
  36949. export class TouchCamera extends FreeCamera {
  36950. /**
  36951. * Defines the touch sensibility for rotation.
  36952. * The higher the faster.
  36953. */
  36954. touchAngularSensibility: number;
  36955. /**
  36956. * Defines the touch sensibility for move.
  36957. * The higher the faster.
  36958. */
  36959. touchMoveSensibility: number;
  36960. /**
  36961. * Instantiates a new touch camera.
  36962. * This represents a FPS type of camera controlled by touch.
  36963. * This is like a universal camera minus the Gamepad controls.
  36964. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36965. * @param name Define the name of the camera in the scene
  36966. * @param position Define the start position of the camera in the scene
  36967. * @param scene Define the scene the camera belongs to
  36968. */
  36969. constructor(name: string, position: Vector3, scene: Scene);
  36970. /**
  36971. * Gets the current object class name.
  36972. * @return the class name
  36973. */
  36974. getClassName(): string;
  36975. /** @hidden */
  36976. _setupInputs(): void;
  36977. }
  36978. }
  36979. declare module BABYLON {
  36980. /**
  36981. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36982. * being tilted forward or back and left or right.
  36983. */
  36984. export class DeviceOrientationCamera extends FreeCamera {
  36985. private _initialQuaternion;
  36986. private _quaternionCache;
  36987. /**
  36988. * Creates a new device orientation camera
  36989. * @param name The name of the camera
  36990. * @param position The start position camera
  36991. * @param scene The scene the camera belongs to
  36992. */
  36993. constructor(name: string, position: Vector3, scene: Scene);
  36994. /**
  36995. * Gets the current instance class name ("DeviceOrientationCamera").
  36996. * This helps avoiding instanceof at run time.
  36997. * @returns the class name
  36998. */
  36999. getClassName(): string;
  37000. /**
  37001. * @hidden
  37002. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37003. */
  37004. _checkInputs(): void;
  37005. /**
  37006. * Reset the camera to its default orientation on the specified axis only.
  37007. * @param axis The axis to reset
  37008. */
  37009. resetToCurrentRotation(axis?: Axis): void;
  37010. }
  37011. }
  37012. declare module BABYLON {
  37013. /**
  37014. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37015. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37016. */
  37017. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37018. /**
  37019. * Defines the camera the input is attached to.
  37020. */
  37021. camera: FollowCamera;
  37022. /**
  37023. * Defines the list of key codes associated with the up action (increase heightOffset)
  37024. */
  37025. keysUp: number[];
  37026. /**
  37027. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37028. */
  37029. keysDown: number[];
  37030. /**
  37031. * Defines the list of key codes associated with the left action (increase rotation)
  37032. */
  37033. keysLeft: number[];
  37034. /**
  37035. * Defines the list of key codes associated with the right action (decrease rotation)
  37036. */
  37037. keysRight: number[];
  37038. /**
  37039. * Defines the rate of change of heightOffset.
  37040. */
  37041. heightSensibility: number;
  37042. /**
  37043. * Defines the rate of change of rotationOffset.
  37044. */
  37045. rotationSensibility: number;
  37046. /**
  37047. * Defines the rate of change of radius.
  37048. */
  37049. radiusSensibility: number;
  37050. /**
  37051. * Defines the minimum heightOffset value.
  37052. */
  37053. minHeightOffset: number;
  37054. /**
  37055. * Defines the minimum radius value.
  37056. */
  37057. minRadius: number;
  37058. private _keys;
  37059. private _altPressed;
  37060. private _onCanvasBlurObserver;
  37061. private _onKeyboardObserver;
  37062. private _engine;
  37063. private _scene;
  37064. /**
  37065. * Attach the input controls to a specific dom element to get the input from.
  37066. * @param element Defines the element the controls should be listened from
  37067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37068. */
  37069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37070. /**
  37071. * Detach the current controls from the specified dom element.
  37072. * @param element Defines the element to stop listening the inputs from
  37073. */
  37074. detachControl(element: Nullable<HTMLElement>): void;
  37075. /**
  37076. * Update the current camera state depending on the inputs that have been used this frame.
  37077. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37078. */
  37079. checkInputs(): void;
  37080. /**
  37081. * Gets the class name of the current intput.
  37082. * @returns the class name
  37083. */
  37084. getClassName(): string;
  37085. /**
  37086. * Get the friendly name associated with the input class.
  37087. * @returns the input friendly name
  37088. */
  37089. getSimpleName(): string;
  37090. }
  37091. }
  37092. declare module BABYLON {
  37093. /**
  37094. * Manage the mouse wheel inputs to control a follow camera.
  37095. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37096. */
  37097. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37098. /**
  37099. * Defines the camera the input is attached to.
  37100. */
  37101. camera: FollowCamera;
  37102. /**
  37103. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  37104. */
  37105. axisControlRadius: boolean;
  37106. /**
  37107. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  37108. */
  37109. axisControlHeight: boolean;
  37110. /**
  37111. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  37112. */
  37113. axisControlRotation: boolean;
  37114. /**
  37115. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37116. * relation to mouseWheel events.
  37117. */
  37118. wheelPrecision: number;
  37119. /**
  37120. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37121. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37122. */
  37123. wheelDeltaPercentage: number;
  37124. private _wheel;
  37125. private _observer;
  37126. /**
  37127. * Attach the input controls to a specific dom element to get the input from.
  37128. * @param element Defines the element the controls should be listened from
  37129. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37130. */
  37131. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37132. /**
  37133. * Detach the current controls from the specified dom element.
  37134. * @param element Defines the element to stop listening the inputs from
  37135. */
  37136. detachControl(element: Nullable<HTMLElement>): void;
  37137. /**
  37138. * Gets the class name of the current intput.
  37139. * @returns the class name
  37140. */
  37141. getClassName(): string;
  37142. /**
  37143. * Get the friendly name associated with the input class.
  37144. * @returns the input friendly name
  37145. */
  37146. getSimpleName(): string;
  37147. }
  37148. }
  37149. declare module BABYLON {
  37150. /**
  37151. * Default Inputs manager for the FollowCamera.
  37152. * It groups all the default supported inputs for ease of use.
  37153. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37154. */
  37155. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37156. /**
  37157. * Instantiates a new FollowCameraInputsManager.
  37158. * @param camera Defines the camera the inputs belong to
  37159. */
  37160. constructor(camera: FollowCamera);
  37161. /**
  37162. * Add keyboard input support to the input manager.
  37163. * @returns the current input manager
  37164. */
  37165. addKeyboard(): FollowCameraInputsManager;
  37166. /**
  37167. * Add mouse wheel input support to the input manager.
  37168. * @returns the current input manager
  37169. */
  37170. addMouseWheel(): FollowCameraInputsManager;
  37171. /**
  37172. * Add pointers input support to the input manager.
  37173. * @returns the current input manager
  37174. */
  37175. addPointers(): FollowCameraInputsManager;
  37176. /**
  37177. * Add orientation input support to the input manager.
  37178. * @returns the current input manager
  37179. */
  37180. addVRDeviceOrientation(): FollowCameraInputsManager;
  37181. }
  37182. }
  37183. declare module BABYLON {
  37184. /**
  37185. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37186. * an arc rotate version arcFollowCamera are available.
  37187. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37188. */
  37189. export class FollowCamera extends TargetCamera {
  37190. /**
  37191. * Distance the follow camera should follow an object at
  37192. */
  37193. radius: number;
  37194. /**
  37195. * Define a rotation offset between the camera and the object it follows
  37196. */
  37197. rotationOffset: number;
  37198. /**
  37199. * Define a height offset between the camera and the object it follows.
  37200. * It can help following an object from the top (like a car chaing a plane)
  37201. */
  37202. heightOffset: number;
  37203. /**
  37204. * Define how fast the camera can accelerate to follow it s target.
  37205. */
  37206. cameraAcceleration: number;
  37207. /**
  37208. * Define the speed limit of the camera following an object.
  37209. */
  37210. maxCameraSpeed: number;
  37211. /**
  37212. * Define the target of the camera.
  37213. */
  37214. lockedTarget: Nullable<AbstractMesh>;
  37215. /**
  37216. * Defines the input associated with the camera.
  37217. */
  37218. inputs: FollowCameraInputsManager;
  37219. /**
  37220. * Instantiates the follow camera.
  37221. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37222. * @param name Define the name of the camera in the scene
  37223. * @param position Define the position of the camera
  37224. * @param scene Define the scene the camera belong to
  37225. * @param lockedTarget Define the target of the camera
  37226. */
  37227. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37228. private _follow;
  37229. /**
  37230. * Attached controls to the current camera.
  37231. * @param element Defines the element the controls should be listened from
  37232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37233. */
  37234. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37235. /**
  37236. * Detach the current controls from the camera.
  37237. * The camera will stop reacting to inputs.
  37238. * @param element Defines the element to stop listening the inputs from
  37239. */
  37240. detachControl(element: HTMLElement): void;
  37241. /** @hidden */
  37242. _checkInputs(): void;
  37243. /**
  37244. * Gets the camera class name.
  37245. * @returns the class name
  37246. */
  37247. getClassName(): string;
  37248. }
  37249. /**
  37250. * Arc Rotate version of the follow camera.
  37251. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37252. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37253. */
  37254. export class ArcFollowCamera extends TargetCamera {
  37255. /** The longitudinal angle of the camera */
  37256. alpha: number;
  37257. /** The latitudinal angle of the camera */
  37258. beta: number;
  37259. /** The radius of the camera from its target */
  37260. radius: number;
  37261. /** Define the camera target (the messh it should follow) */
  37262. target: Nullable<AbstractMesh>;
  37263. private _cartesianCoordinates;
  37264. /**
  37265. * Instantiates a new ArcFollowCamera
  37266. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37267. * @param name Define the name of the camera
  37268. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37269. * @param beta Define the rotation angle of the camera around the elevation axis
  37270. * @param radius Define the radius of the camera from its target point
  37271. * @param target Define the target of the camera
  37272. * @param scene Define the scene the camera belongs to
  37273. */
  37274. constructor(name: string,
  37275. /** The longitudinal angle of the camera */
  37276. alpha: number,
  37277. /** The latitudinal angle of the camera */
  37278. beta: number,
  37279. /** The radius of the camera from its target */
  37280. radius: number,
  37281. /** Define the camera target (the messh it should follow) */
  37282. target: Nullable<AbstractMesh>, scene: Scene);
  37283. private _follow;
  37284. /** @hidden */
  37285. _checkInputs(): void;
  37286. /**
  37287. * Returns the class name of the object.
  37288. * It is mostly used internally for serialization purposes.
  37289. */
  37290. getClassName(): string;
  37291. }
  37292. }
  37293. declare module BABYLON {
  37294. /**
  37295. * 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,
  37296. * which still works and will still be found in many Playgrounds.
  37297. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37298. */
  37299. export class UniversalCamera extends TouchCamera {
  37300. /**
  37301. * Defines the gamepad rotation sensiblity.
  37302. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37303. */
  37304. gamepadAngularSensibility: number;
  37305. /**
  37306. * Defines the gamepad move sensiblity.
  37307. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37308. */
  37309. gamepadMoveSensibility: number;
  37310. /**
  37311. * 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,
  37312. * which still works and will still be found in many Playgrounds.
  37313. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37314. * @param name Define the name of the camera in the scene
  37315. * @param position Define the start position of the camera in the scene
  37316. * @param scene Define the scene the camera belongs to
  37317. */
  37318. constructor(name: string, position: Vector3, scene: Scene);
  37319. /**
  37320. * Gets the current object class name.
  37321. * @return the class name
  37322. */
  37323. getClassName(): string;
  37324. }
  37325. }
  37326. declare module BABYLON {
  37327. /**
  37328. * This represents a FPS type of camera. This is only here for back compat purpose.
  37329. * Please use the UniversalCamera instead as both are identical.
  37330. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37331. */
  37332. export class GamepadCamera extends UniversalCamera {
  37333. /**
  37334. * Instantiates a new Gamepad Camera
  37335. * This represents a FPS type of camera. This is only here for back compat purpose.
  37336. * Please use the UniversalCamera instead as both are identical.
  37337. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37338. * @param name Define the name of the camera in the scene
  37339. * @param position Define the start position of the camera in the scene
  37340. * @param scene Define the scene the camera belongs to
  37341. */
  37342. constructor(name: string, position: Vector3, scene: Scene);
  37343. /**
  37344. * Gets the current object class name.
  37345. * @return the class name
  37346. */
  37347. getClassName(): string;
  37348. }
  37349. }
  37350. declare module BABYLON {
  37351. /** @hidden */
  37352. export var passPixelShader: {
  37353. name: string;
  37354. shader: string;
  37355. };
  37356. }
  37357. declare module BABYLON {
  37358. /** @hidden */
  37359. export var passCubePixelShader: {
  37360. name: string;
  37361. shader: string;
  37362. };
  37363. }
  37364. declare module BABYLON {
  37365. /**
  37366. * PassPostProcess which produces an output the same as it's input
  37367. */
  37368. export class PassPostProcess extends PostProcess {
  37369. /**
  37370. * Creates the PassPostProcess
  37371. * @param name The name of the effect.
  37372. * @param options The required width/height ratio to downsize to before computing the render pass.
  37373. * @param camera The camera to apply the render pass to.
  37374. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37375. * @param engine The engine which the post process will be applied. (default: current engine)
  37376. * @param reusable If the post process can be reused on the same frame. (default: false)
  37377. * @param textureType The type of texture to be used when performing the post processing.
  37378. * @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)
  37379. */
  37380. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37381. }
  37382. /**
  37383. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37384. */
  37385. export class PassCubePostProcess extends PostProcess {
  37386. private _face;
  37387. /**
  37388. * Gets or sets the cube face to display.
  37389. * * 0 is +X
  37390. * * 1 is -X
  37391. * * 2 is +Y
  37392. * * 3 is -Y
  37393. * * 4 is +Z
  37394. * * 5 is -Z
  37395. */
  37396. face: number;
  37397. /**
  37398. * Creates the PassCubePostProcess
  37399. * @param name The name of the effect.
  37400. * @param options The required width/height ratio to downsize to before computing the render pass.
  37401. * @param camera The camera to apply the render pass to.
  37402. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37403. * @param engine The engine which the post process will be applied. (default: current engine)
  37404. * @param reusable If the post process can be reused on the same frame. (default: false)
  37405. * @param textureType The type of texture to be used when performing the post processing.
  37406. * @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)
  37407. */
  37408. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37409. }
  37410. }
  37411. declare module BABYLON {
  37412. /** @hidden */
  37413. export var anaglyphPixelShader: {
  37414. name: string;
  37415. shader: string;
  37416. };
  37417. }
  37418. declare module BABYLON {
  37419. /**
  37420. * Postprocess used to generate anaglyphic rendering
  37421. */
  37422. export class AnaglyphPostProcess extends PostProcess {
  37423. private _passedProcess;
  37424. /**
  37425. * Creates a new AnaglyphPostProcess
  37426. * @param name defines postprocess name
  37427. * @param options defines creation options or target ratio scale
  37428. * @param rigCameras defines cameras using this postprocess
  37429. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37430. * @param engine defines hosting engine
  37431. * @param reusable defines if the postprocess will be reused multiple times per frame
  37432. */
  37433. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37434. }
  37435. }
  37436. declare module BABYLON {
  37437. /**
  37438. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37439. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37440. */
  37441. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37442. /**
  37443. * Creates a new AnaglyphArcRotateCamera
  37444. * @param name defines camera name
  37445. * @param alpha defines alpha angle (in radians)
  37446. * @param beta defines beta angle (in radians)
  37447. * @param radius defines radius
  37448. * @param target defines camera target
  37449. * @param interaxialDistance defines distance between each color axis
  37450. * @param scene defines the hosting scene
  37451. */
  37452. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37453. /**
  37454. * Gets camera class name
  37455. * @returns AnaglyphArcRotateCamera
  37456. */
  37457. getClassName(): string;
  37458. }
  37459. }
  37460. declare module BABYLON {
  37461. /**
  37462. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37463. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37464. */
  37465. export class AnaglyphFreeCamera extends FreeCamera {
  37466. /**
  37467. * Creates a new AnaglyphFreeCamera
  37468. * @param name defines camera name
  37469. * @param position defines initial position
  37470. * @param interaxialDistance defines distance between each color axis
  37471. * @param scene defines the hosting scene
  37472. */
  37473. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37474. /**
  37475. * Gets camera class name
  37476. * @returns AnaglyphFreeCamera
  37477. */
  37478. getClassName(): string;
  37479. }
  37480. }
  37481. declare module BABYLON {
  37482. /**
  37483. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37484. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37485. */
  37486. export class AnaglyphGamepadCamera extends GamepadCamera {
  37487. /**
  37488. * Creates a new AnaglyphGamepadCamera
  37489. * @param name defines camera name
  37490. * @param position defines initial position
  37491. * @param interaxialDistance defines distance between each color axis
  37492. * @param scene defines the hosting scene
  37493. */
  37494. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37495. /**
  37496. * Gets camera class name
  37497. * @returns AnaglyphGamepadCamera
  37498. */
  37499. getClassName(): string;
  37500. }
  37501. }
  37502. declare module BABYLON {
  37503. /**
  37504. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37505. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37506. */
  37507. export class AnaglyphUniversalCamera extends UniversalCamera {
  37508. /**
  37509. * Creates a new AnaglyphUniversalCamera
  37510. * @param name defines camera name
  37511. * @param position defines initial position
  37512. * @param interaxialDistance defines distance between each color axis
  37513. * @param scene defines the hosting scene
  37514. */
  37515. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37516. /**
  37517. * Gets camera class name
  37518. * @returns AnaglyphUniversalCamera
  37519. */
  37520. getClassName(): string;
  37521. }
  37522. }
  37523. declare module BABYLON {
  37524. /** @hidden */
  37525. export var stereoscopicInterlacePixelShader: {
  37526. name: string;
  37527. shader: string;
  37528. };
  37529. }
  37530. declare module BABYLON {
  37531. /**
  37532. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37533. */
  37534. export class StereoscopicInterlacePostProcess extends PostProcess {
  37535. private _stepSize;
  37536. private _passedProcess;
  37537. /**
  37538. * Initializes a StereoscopicInterlacePostProcess
  37539. * @param name The name of the effect.
  37540. * @param rigCameras The rig cameras to be appled to the post process
  37541. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37542. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37543. * @param engine The engine which the post process will be applied. (default: current engine)
  37544. * @param reusable If the post process can be reused on the same frame. (default: false)
  37545. */
  37546. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37547. }
  37548. }
  37549. declare module BABYLON {
  37550. /**
  37551. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37552. * @see http://doc.babylonjs.com/features/cameras
  37553. */
  37554. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37555. /**
  37556. * Creates a new StereoscopicArcRotateCamera
  37557. * @param name defines camera name
  37558. * @param alpha defines alpha angle (in radians)
  37559. * @param beta defines beta angle (in radians)
  37560. * @param radius defines radius
  37561. * @param target defines camera target
  37562. * @param interaxialDistance defines distance between each color axis
  37563. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37564. * @param scene defines the hosting scene
  37565. */
  37566. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37567. /**
  37568. * Gets camera class name
  37569. * @returns StereoscopicArcRotateCamera
  37570. */
  37571. getClassName(): string;
  37572. }
  37573. }
  37574. declare module BABYLON {
  37575. /**
  37576. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37577. * @see http://doc.babylonjs.com/features/cameras
  37578. */
  37579. export class StereoscopicFreeCamera extends FreeCamera {
  37580. /**
  37581. * Creates a new StereoscopicFreeCamera
  37582. * @param name defines camera name
  37583. * @param position defines initial position
  37584. * @param interaxialDistance defines distance between each color axis
  37585. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37586. * @param scene defines the hosting scene
  37587. */
  37588. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37589. /**
  37590. * Gets camera class name
  37591. * @returns StereoscopicFreeCamera
  37592. */
  37593. getClassName(): string;
  37594. }
  37595. }
  37596. declare module BABYLON {
  37597. /**
  37598. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37599. * @see http://doc.babylonjs.com/features/cameras
  37600. */
  37601. export class StereoscopicGamepadCamera extends GamepadCamera {
  37602. /**
  37603. * Creates a new StereoscopicGamepadCamera
  37604. * @param name defines camera name
  37605. * @param position defines initial position
  37606. * @param interaxialDistance defines distance between each color axis
  37607. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37608. * @param scene defines the hosting scene
  37609. */
  37610. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37611. /**
  37612. * Gets camera class name
  37613. * @returns StereoscopicGamepadCamera
  37614. */
  37615. getClassName(): string;
  37616. }
  37617. }
  37618. declare module BABYLON {
  37619. /**
  37620. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37621. * @see http://doc.babylonjs.com/features/cameras
  37622. */
  37623. export class StereoscopicUniversalCamera extends UniversalCamera {
  37624. /**
  37625. * Creates a new StereoscopicUniversalCamera
  37626. * @param name defines camera name
  37627. * @param position defines initial position
  37628. * @param interaxialDistance defines distance between each color axis
  37629. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37630. * @param scene defines the hosting scene
  37631. */
  37632. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37633. /**
  37634. * Gets camera class name
  37635. * @returns StereoscopicUniversalCamera
  37636. */
  37637. getClassName(): string;
  37638. }
  37639. }
  37640. declare module BABYLON {
  37641. /**
  37642. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37643. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37644. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37645. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37646. */
  37647. export class VirtualJoysticksCamera extends FreeCamera {
  37648. /**
  37649. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37650. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37651. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37652. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37653. * @param name Define the name of the camera in the scene
  37654. * @param position Define the start position of the camera in the scene
  37655. * @param scene Define the scene the camera belongs to
  37656. */
  37657. constructor(name: string, position: Vector3, scene: Scene);
  37658. /**
  37659. * Gets the current object class name.
  37660. * @return the class name
  37661. */
  37662. getClassName(): string;
  37663. }
  37664. }
  37665. declare module BABYLON {
  37666. /**
  37667. * This represents all the required metrics to create a VR camera.
  37668. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37669. */
  37670. export class VRCameraMetrics {
  37671. /**
  37672. * Define the horizontal resolution off the screen.
  37673. */
  37674. hResolution: number;
  37675. /**
  37676. * Define the vertical resolution off the screen.
  37677. */
  37678. vResolution: number;
  37679. /**
  37680. * Define the horizontal screen size.
  37681. */
  37682. hScreenSize: number;
  37683. /**
  37684. * Define the vertical screen size.
  37685. */
  37686. vScreenSize: number;
  37687. /**
  37688. * Define the vertical screen center position.
  37689. */
  37690. vScreenCenter: number;
  37691. /**
  37692. * Define the distance of the eyes to the screen.
  37693. */
  37694. eyeToScreenDistance: number;
  37695. /**
  37696. * Define the distance between both lenses
  37697. */
  37698. lensSeparationDistance: number;
  37699. /**
  37700. * Define the distance between both viewer's eyes.
  37701. */
  37702. interpupillaryDistance: number;
  37703. /**
  37704. * Define the distortion factor of the VR postprocess.
  37705. * Please, touch with care.
  37706. */
  37707. distortionK: number[];
  37708. /**
  37709. * Define the chromatic aberration correction factors for the VR post process.
  37710. */
  37711. chromaAbCorrection: number[];
  37712. /**
  37713. * Define the scale factor of the post process.
  37714. * The smaller the better but the slower.
  37715. */
  37716. postProcessScaleFactor: number;
  37717. /**
  37718. * Define an offset for the lens center.
  37719. */
  37720. lensCenterOffset: number;
  37721. /**
  37722. * Define if the current vr camera should compensate the distortion of the lense or not.
  37723. */
  37724. compensateDistortion: boolean;
  37725. /**
  37726. * Gets the rendering aspect ratio based on the provided resolutions.
  37727. */
  37728. readonly aspectRatio: number;
  37729. /**
  37730. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37731. */
  37732. readonly aspectRatioFov: number;
  37733. /**
  37734. * @hidden
  37735. */
  37736. readonly leftHMatrix: Matrix;
  37737. /**
  37738. * @hidden
  37739. */
  37740. readonly rightHMatrix: Matrix;
  37741. /**
  37742. * @hidden
  37743. */
  37744. readonly leftPreViewMatrix: Matrix;
  37745. /**
  37746. * @hidden
  37747. */
  37748. readonly rightPreViewMatrix: Matrix;
  37749. /**
  37750. * Get the default VRMetrics based on the most generic setup.
  37751. * @returns the default vr metrics
  37752. */
  37753. static GetDefault(): VRCameraMetrics;
  37754. }
  37755. }
  37756. declare module BABYLON {
  37757. /** @hidden */
  37758. export var vrDistortionCorrectionPixelShader: {
  37759. name: string;
  37760. shader: string;
  37761. };
  37762. }
  37763. declare module BABYLON {
  37764. /**
  37765. * VRDistortionCorrectionPostProcess used for mobile VR
  37766. */
  37767. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37768. private _isRightEye;
  37769. private _distortionFactors;
  37770. private _postProcessScaleFactor;
  37771. private _lensCenterOffset;
  37772. private _scaleIn;
  37773. private _scaleFactor;
  37774. private _lensCenter;
  37775. /**
  37776. * Initializes the VRDistortionCorrectionPostProcess
  37777. * @param name The name of the effect.
  37778. * @param camera The camera to apply the render pass to.
  37779. * @param isRightEye If this is for the right eye distortion
  37780. * @param vrMetrics All the required metrics for the VR camera
  37781. */
  37782. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37783. }
  37784. }
  37785. declare module BABYLON {
  37786. /**
  37787. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37788. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37789. */
  37790. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37791. /**
  37792. * Creates a new VRDeviceOrientationArcRotateCamera
  37793. * @param name defines camera name
  37794. * @param alpha defines the camera rotation along the logitudinal axis
  37795. * @param beta defines the camera rotation along the latitudinal axis
  37796. * @param radius defines the camera distance from its target
  37797. * @param target defines the camera target
  37798. * @param scene defines the scene the camera belongs to
  37799. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37800. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37801. */
  37802. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37803. /**
  37804. * Gets camera class name
  37805. * @returns VRDeviceOrientationArcRotateCamera
  37806. */
  37807. getClassName(): string;
  37808. }
  37809. }
  37810. declare module BABYLON {
  37811. /**
  37812. * Camera used to simulate VR rendering (based on FreeCamera)
  37813. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37814. */
  37815. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37816. /**
  37817. * Creates a new VRDeviceOrientationFreeCamera
  37818. * @param name defines camera name
  37819. * @param position defines the start position of the camera
  37820. * @param scene defines the scene the camera belongs to
  37821. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37822. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37823. */
  37824. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37825. /**
  37826. * Gets camera class name
  37827. * @returns VRDeviceOrientationFreeCamera
  37828. */
  37829. getClassName(): string;
  37830. }
  37831. }
  37832. declare module BABYLON {
  37833. /**
  37834. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37835. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37836. */
  37837. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37838. /**
  37839. * Creates a new VRDeviceOrientationGamepadCamera
  37840. * @param name defines camera name
  37841. * @param position defines the start position of the camera
  37842. * @param scene defines the scene the camera belongs to
  37843. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37844. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37845. */
  37846. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37847. /**
  37848. * Gets camera class name
  37849. * @returns VRDeviceOrientationGamepadCamera
  37850. */
  37851. getClassName(): string;
  37852. }
  37853. }
  37854. declare module BABYLON {
  37855. /**
  37856. * Defines supported buttons for XBox360 compatible gamepads
  37857. */
  37858. export enum Xbox360Button {
  37859. /** A */
  37860. A = 0,
  37861. /** B */
  37862. B = 1,
  37863. /** X */
  37864. X = 2,
  37865. /** Y */
  37866. Y = 3,
  37867. /** Start */
  37868. Start = 4,
  37869. /** Back */
  37870. Back = 5,
  37871. /** Left button */
  37872. LB = 6,
  37873. /** Right button */
  37874. RB = 7,
  37875. /** Left stick */
  37876. LeftStick = 8,
  37877. /** Right stick */
  37878. RightStick = 9
  37879. }
  37880. /** Defines values for XBox360 DPad */
  37881. export enum Xbox360Dpad {
  37882. /** Up */
  37883. Up = 0,
  37884. /** Down */
  37885. Down = 1,
  37886. /** Left */
  37887. Left = 2,
  37888. /** Right */
  37889. Right = 3
  37890. }
  37891. /**
  37892. * Defines a XBox360 gamepad
  37893. */
  37894. export class Xbox360Pad extends Gamepad {
  37895. private _leftTrigger;
  37896. private _rightTrigger;
  37897. private _onlefttriggerchanged;
  37898. private _onrighttriggerchanged;
  37899. private _onbuttondown;
  37900. private _onbuttonup;
  37901. private _ondpaddown;
  37902. private _ondpadup;
  37903. /** Observable raised when a button is pressed */
  37904. onButtonDownObservable: Observable<Xbox360Button>;
  37905. /** Observable raised when a button is released */
  37906. onButtonUpObservable: Observable<Xbox360Button>;
  37907. /** Observable raised when a pad is pressed */
  37908. onPadDownObservable: Observable<Xbox360Dpad>;
  37909. /** Observable raised when a pad is released */
  37910. onPadUpObservable: Observable<Xbox360Dpad>;
  37911. private _buttonA;
  37912. private _buttonB;
  37913. private _buttonX;
  37914. private _buttonY;
  37915. private _buttonBack;
  37916. private _buttonStart;
  37917. private _buttonLB;
  37918. private _buttonRB;
  37919. private _buttonLeftStick;
  37920. private _buttonRightStick;
  37921. private _dPadUp;
  37922. private _dPadDown;
  37923. private _dPadLeft;
  37924. private _dPadRight;
  37925. private _isXboxOnePad;
  37926. /**
  37927. * Creates a new XBox360 gamepad object
  37928. * @param id defines the id of this gamepad
  37929. * @param index defines its index
  37930. * @param gamepad defines the internal HTML gamepad object
  37931. * @param xboxOne defines if it is a XBox One gamepad
  37932. */
  37933. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37934. /**
  37935. * Defines the callback to call when left trigger is pressed
  37936. * @param callback defines the callback to use
  37937. */
  37938. onlefttriggerchanged(callback: (value: number) => void): void;
  37939. /**
  37940. * Defines the callback to call when right trigger is pressed
  37941. * @param callback defines the callback to use
  37942. */
  37943. onrighttriggerchanged(callback: (value: number) => void): void;
  37944. /**
  37945. * Gets the left trigger value
  37946. */
  37947. /**
  37948. * Sets the left trigger value
  37949. */
  37950. leftTrigger: number;
  37951. /**
  37952. * Gets the right trigger value
  37953. */
  37954. /**
  37955. * Sets the right trigger value
  37956. */
  37957. rightTrigger: number;
  37958. /**
  37959. * Defines the callback to call when a button is pressed
  37960. * @param callback defines the callback to use
  37961. */
  37962. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37963. /**
  37964. * Defines the callback to call when a button is released
  37965. * @param callback defines the callback to use
  37966. */
  37967. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37968. /**
  37969. * Defines the callback to call when a pad is pressed
  37970. * @param callback defines the callback to use
  37971. */
  37972. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37973. /**
  37974. * Defines the callback to call when a pad is released
  37975. * @param callback defines the callback to use
  37976. */
  37977. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37978. private _setButtonValue;
  37979. private _setDPadValue;
  37980. /**
  37981. * Gets the value of the `A` button
  37982. */
  37983. /**
  37984. * Sets the value of the `A` button
  37985. */
  37986. buttonA: number;
  37987. /**
  37988. * Gets the value of the `B` button
  37989. */
  37990. /**
  37991. * Sets the value of the `B` button
  37992. */
  37993. buttonB: number;
  37994. /**
  37995. * Gets the value of the `X` button
  37996. */
  37997. /**
  37998. * Sets the value of the `X` button
  37999. */
  38000. buttonX: number;
  38001. /**
  38002. * Gets the value of the `Y` button
  38003. */
  38004. /**
  38005. * Sets the value of the `Y` button
  38006. */
  38007. buttonY: number;
  38008. /**
  38009. * Gets the value of the `Start` button
  38010. */
  38011. /**
  38012. * Sets the value of the `Start` button
  38013. */
  38014. buttonStart: number;
  38015. /**
  38016. * Gets the value of the `Back` button
  38017. */
  38018. /**
  38019. * Sets the value of the `Back` button
  38020. */
  38021. buttonBack: number;
  38022. /**
  38023. * Gets the value of the `Left` button
  38024. */
  38025. /**
  38026. * Sets the value of the `Left` button
  38027. */
  38028. buttonLB: number;
  38029. /**
  38030. * Gets the value of the `Right` button
  38031. */
  38032. /**
  38033. * Sets the value of the `Right` button
  38034. */
  38035. buttonRB: number;
  38036. /**
  38037. * Gets the value of the Left joystick
  38038. */
  38039. /**
  38040. * Sets the value of the Left joystick
  38041. */
  38042. buttonLeftStick: number;
  38043. /**
  38044. * Gets the value of the Right joystick
  38045. */
  38046. /**
  38047. * Sets the value of the Right joystick
  38048. */
  38049. buttonRightStick: number;
  38050. /**
  38051. * Gets the value of D-pad up
  38052. */
  38053. /**
  38054. * Sets the value of D-pad up
  38055. */
  38056. dPadUp: number;
  38057. /**
  38058. * Gets the value of D-pad down
  38059. */
  38060. /**
  38061. * Sets the value of D-pad down
  38062. */
  38063. dPadDown: number;
  38064. /**
  38065. * Gets the value of D-pad left
  38066. */
  38067. /**
  38068. * Sets the value of D-pad left
  38069. */
  38070. dPadLeft: number;
  38071. /**
  38072. * Gets the value of D-pad right
  38073. */
  38074. /**
  38075. * Sets the value of D-pad right
  38076. */
  38077. dPadRight: number;
  38078. /**
  38079. * Force the gamepad to synchronize with device values
  38080. */
  38081. update(): void;
  38082. /**
  38083. * Disposes the gamepad
  38084. */
  38085. dispose(): void;
  38086. }
  38087. }
  38088. declare module BABYLON {
  38089. /**
  38090. * Base class of materials working in push mode in babylon JS
  38091. * @hidden
  38092. */
  38093. export class PushMaterial extends Material {
  38094. protected _activeEffect: Effect;
  38095. protected _normalMatrix: Matrix;
  38096. /**
  38097. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38098. * This means that the material can keep using a previous shader while a new one is being compiled.
  38099. * This is mostly used when shader parallel compilation is supported (true by default)
  38100. */
  38101. allowShaderHotSwapping: boolean;
  38102. constructor(name: string, scene: Scene);
  38103. getEffect(): Effect;
  38104. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38105. /**
  38106. * Binds the given world matrix to the active effect
  38107. *
  38108. * @param world the matrix to bind
  38109. */
  38110. bindOnlyWorldMatrix(world: Matrix): void;
  38111. /**
  38112. * Binds the given normal matrix to the active effect
  38113. *
  38114. * @param normalMatrix the matrix to bind
  38115. */
  38116. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38117. bind(world: Matrix, mesh?: Mesh): void;
  38118. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38119. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38120. }
  38121. }
  38122. declare module BABYLON {
  38123. /**
  38124. * This groups all the flags used to control the materials channel.
  38125. */
  38126. export class MaterialFlags {
  38127. private static _DiffuseTextureEnabled;
  38128. /**
  38129. * Are diffuse textures enabled in the application.
  38130. */
  38131. static DiffuseTextureEnabled: boolean;
  38132. private static _AmbientTextureEnabled;
  38133. /**
  38134. * Are ambient textures enabled in the application.
  38135. */
  38136. static AmbientTextureEnabled: boolean;
  38137. private static _OpacityTextureEnabled;
  38138. /**
  38139. * Are opacity textures enabled in the application.
  38140. */
  38141. static OpacityTextureEnabled: boolean;
  38142. private static _ReflectionTextureEnabled;
  38143. /**
  38144. * Are reflection textures enabled in the application.
  38145. */
  38146. static ReflectionTextureEnabled: boolean;
  38147. private static _EmissiveTextureEnabled;
  38148. /**
  38149. * Are emissive textures enabled in the application.
  38150. */
  38151. static EmissiveTextureEnabled: boolean;
  38152. private static _SpecularTextureEnabled;
  38153. /**
  38154. * Are specular textures enabled in the application.
  38155. */
  38156. static SpecularTextureEnabled: boolean;
  38157. private static _BumpTextureEnabled;
  38158. /**
  38159. * Are bump textures enabled in the application.
  38160. */
  38161. static BumpTextureEnabled: boolean;
  38162. private static _LightmapTextureEnabled;
  38163. /**
  38164. * Are lightmap textures enabled in the application.
  38165. */
  38166. static LightmapTextureEnabled: boolean;
  38167. private static _RefractionTextureEnabled;
  38168. /**
  38169. * Are refraction textures enabled in the application.
  38170. */
  38171. static RefractionTextureEnabled: boolean;
  38172. private static _ColorGradingTextureEnabled;
  38173. /**
  38174. * Are color grading textures enabled in the application.
  38175. */
  38176. static ColorGradingTextureEnabled: boolean;
  38177. private static _FresnelEnabled;
  38178. /**
  38179. * Are fresnels enabled in the application.
  38180. */
  38181. static FresnelEnabled: boolean;
  38182. }
  38183. }
  38184. declare module BABYLON {
  38185. /** @hidden */
  38186. export var defaultFragmentDeclaration: {
  38187. name: string;
  38188. shader: string;
  38189. };
  38190. }
  38191. declare module BABYLON {
  38192. /** @hidden */
  38193. export var defaultUboDeclaration: {
  38194. name: string;
  38195. shader: string;
  38196. };
  38197. }
  38198. declare module BABYLON {
  38199. /** @hidden */
  38200. export var lightFragmentDeclaration: {
  38201. name: string;
  38202. shader: string;
  38203. };
  38204. }
  38205. declare module BABYLON {
  38206. /** @hidden */
  38207. export var lightUboDeclaration: {
  38208. name: string;
  38209. shader: string;
  38210. };
  38211. }
  38212. declare module BABYLON {
  38213. /** @hidden */
  38214. export var lightsFragmentFunctions: {
  38215. name: string;
  38216. shader: string;
  38217. };
  38218. }
  38219. declare module BABYLON {
  38220. /** @hidden */
  38221. export var shadowsFragmentFunctions: {
  38222. name: string;
  38223. shader: string;
  38224. };
  38225. }
  38226. declare module BABYLON {
  38227. /** @hidden */
  38228. export var fresnelFunction: {
  38229. name: string;
  38230. shader: string;
  38231. };
  38232. }
  38233. declare module BABYLON {
  38234. /** @hidden */
  38235. export var reflectionFunction: {
  38236. name: string;
  38237. shader: string;
  38238. };
  38239. }
  38240. declare module BABYLON {
  38241. /** @hidden */
  38242. export var bumpFragmentFunctions: {
  38243. name: string;
  38244. shader: string;
  38245. };
  38246. }
  38247. declare module BABYLON {
  38248. /** @hidden */
  38249. export var logDepthDeclaration: {
  38250. name: string;
  38251. shader: string;
  38252. };
  38253. }
  38254. declare module BABYLON {
  38255. /** @hidden */
  38256. export var bumpFragment: {
  38257. name: string;
  38258. shader: string;
  38259. };
  38260. }
  38261. declare module BABYLON {
  38262. /** @hidden */
  38263. export var depthPrePass: {
  38264. name: string;
  38265. shader: string;
  38266. };
  38267. }
  38268. declare module BABYLON {
  38269. /** @hidden */
  38270. export var lightFragment: {
  38271. name: string;
  38272. shader: string;
  38273. };
  38274. }
  38275. declare module BABYLON {
  38276. /** @hidden */
  38277. export var logDepthFragment: {
  38278. name: string;
  38279. shader: string;
  38280. };
  38281. }
  38282. declare module BABYLON {
  38283. /** @hidden */
  38284. export var defaultPixelShader: {
  38285. name: string;
  38286. shader: string;
  38287. };
  38288. }
  38289. declare module BABYLON {
  38290. /** @hidden */
  38291. export var defaultVertexDeclaration: {
  38292. name: string;
  38293. shader: string;
  38294. };
  38295. }
  38296. declare module BABYLON {
  38297. /** @hidden */
  38298. export var bumpVertexDeclaration: {
  38299. name: string;
  38300. shader: string;
  38301. };
  38302. }
  38303. declare module BABYLON {
  38304. /** @hidden */
  38305. export var bumpVertex: {
  38306. name: string;
  38307. shader: string;
  38308. };
  38309. }
  38310. declare module BABYLON {
  38311. /** @hidden */
  38312. export var fogVertex: {
  38313. name: string;
  38314. shader: string;
  38315. };
  38316. }
  38317. declare module BABYLON {
  38318. /** @hidden */
  38319. export var shadowsVertex: {
  38320. name: string;
  38321. shader: string;
  38322. };
  38323. }
  38324. declare module BABYLON {
  38325. /** @hidden */
  38326. export var pointCloudVertex: {
  38327. name: string;
  38328. shader: string;
  38329. };
  38330. }
  38331. declare module BABYLON {
  38332. /** @hidden */
  38333. export var logDepthVertex: {
  38334. name: string;
  38335. shader: string;
  38336. };
  38337. }
  38338. declare module BABYLON {
  38339. /** @hidden */
  38340. export var defaultVertexShader: {
  38341. name: string;
  38342. shader: string;
  38343. };
  38344. }
  38345. declare module BABYLON {
  38346. /** @hidden */
  38347. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38348. MAINUV1: boolean;
  38349. MAINUV2: boolean;
  38350. DIFFUSE: boolean;
  38351. DIFFUSEDIRECTUV: number;
  38352. AMBIENT: boolean;
  38353. AMBIENTDIRECTUV: number;
  38354. OPACITY: boolean;
  38355. OPACITYDIRECTUV: number;
  38356. OPACITYRGB: boolean;
  38357. REFLECTION: boolean;
  38358. EMISSIVE: boolean;
  38359. EMISSIVEDIRECTUV: number;
  38360. SPECULAR: boolean;
  38361. SPECULARDIRECTUV: number;
  38362. BUMP: boolean;
  38363. BUMPDIRECTUV: number;
  38364. PARALLAX: boolean;
  38365. PARALLAXOCCLUSION: boolean;
  38366. SPECULAROVERALPHA: boolean;
  38367. CLIPPLANE: boolean;
  38368. CLIPPLANE2: boolean;
  38369. CLIPPLANE3: boolean;
  38370. CLIPPLANE4: boolean;
  38371. ALPHATEST: boolean;
  38372. DEPTHPREPASS: boolean;
  38373. ALPHAFROMDIFFUSE: boolean;
  38374. POINTSIZE: boolean;
  38375. FOG: boolean;
  38376. SPECULARTERM: boolean;
  38377. DIFFUSEFRESNEL: boolean;
  38378. OPACITYFRESNEL: boolean;
  38379. REFLECTIONFRESNEL: boolean;
  38380. REFRACTIONFRESNEL: boolean;
  38381. EMISSIVEFRESNEL: boolean;
  38382. FRESNEL: boolean;
  38383. NORMAL: boolean;
  38384. UV1: boolean;
  38385. UV2: boolean;
  38386. VERTEXCOLOR: boolean;
  38387. VERTEXALPHA: boolean;
  38388. NUM_BONE_INFLUENCERS: number;
  38389. BonesPerMesh: number;
  38390. BONETEXTURE: boolean;
  38391. INSTANCES: boolean;
  38392. GLOSSINESS: boolean;
  38393. ROUGHNESS: boolean;
  38394. EMISSIVEASILLUMINATION: boolean;
  38395. LINKEMISSIVEWITHDIFFUSE: boolean;
  38396. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38397. LIGHTMAP: boolean;
  38398. LIGHTMAPDIRECTUV: number;
  38399. OBJECTSPACE_NORMALMAP: boolean;
  38400. USELIGHTMAPASSHADOWMAP: boolean;
  38401. REFLECTIONMAP_3D: boolean;
  38402. REFLECTIONMAP_SPHERICAL: boolean;
  38403. REFLECTIONMAP_PLANAR: boolean;
  38404. REFLECTIONMAP_CUBIC: boolean;
  38405. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38406. REFLECTIONMAP_PROJECTION: boolean;
  38407. REFLECTIONMAP_SKYBOX: boolean;
  38408. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38409. REFLECTIONMAP_EXPLICIT: boolean;
  38410. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38411. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38412. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38413. INVERTCUBICMAP: boolean;
  38414. LOGARITHMICDEPTH: boolean;
  38415. REFRACTION: boolean;
  38416. REFRACTIONMAP_3D: boolean;
  38417. REFLECTIONOVERALPHA: boolean;
  38418. TWOSIDEDLIGHTING: boolean;
  38419. SHADOWFLOAT: boolean;
  38420. MORPHTARGETS: boolean;
  38421. MORPHTARGETS_NORMAL: boolean;
  38422. MORPHTARGETS_TANGENT: boolean;
  38423. NUM_MORPH_INFLUENCERS: number;
  38424. NONUNIFORMSCALING: boolean;
  38425. PREMULTIPLYALPHA: boolean;
  38426. IMAGEPROCESSING: boolean;
  38427. VIGNETTE: boolean;
  38428. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38429. VIGNETTEBLENDMODEOPAQUE: boolean;
  38430. TONEMAPPING: boolean;
  38431. TONEMAPPING_ACES: boolean;
  38432. CONTRAST: boolean;
  38433. COLORCURVES: boolean;
  38434. COLORGRADING: boolean;
  38435. COLORGRADING3D: boolean;
  38436. SAMPLER3DGREENDEPTH: boolean;
  38437. SAMPLER3DBGRMAP: boolean;
  38438. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38439. /**
  38440. * If the reflection texture on this material is in linear color space
  38441. * @hidden
  38442. */
  38443. IS_REFLECTION_LINEAR: boolean;
  38444. /**
  38445. * If the refraction texture on this material is in linear color space
  38446. * @hidden
  38447. */
  38448. IS_REFRACTION_LINEAR: boolean;
  38449. EXPOSURE: boolean;
  38450. constructor();
  38451. setReflectionMode(modeToEnable: string): void;
  38452. }
  38453. /**
  38454. * This is the default material used in Babylon. It is the best trade off between quality
  38455. * and performances.
  38456. * @see http://doc.babylonjs.com/babylon101/materials
  38457. */
  38458. export class StandardMaterial extends PushMaterial {
  38459. private _diffuseTexture;
  38460. /**
  38461. * The basic texture of the material as viewed under a light.
  38462. */
  38463. diffuseTexture: Nullable<BaseTexture>;
  38464. private _ambientTexture;
  38465. /**
  38466. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38467. */
  38468. ambientTexture: Nullable<BaseTexture>;
  38469. private _opacityTexture;
  38470. /**
  38471. * Define the transparency of the material from a texture.
  38472. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38473. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38474. */
  38475. opacityTexture: Nullable<BaseTexture>;
  38476. private _reflectionTexture;
  38477. /**
  38478. * Define the texture used to display the reflection.
  38479. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38480. */
  38481. reflectionTexture: Nullable<BaseTexture>;
  38482. private _emissiveTexture;
  38483. /**
  38484. * Define texture of the material as if self lit.
  38485. * This will be mixed in the final result even in the absence of light.
  38486. */
  38487. emissiveTexture: Nullable<BaseTexture>;
  38488. private _specularTexture;
  38489. /**
  38490. * Define how the color and intensity of the highlight given by the light in the material.
  38491. */
  38492. specularTexture: Nullable<BaseTexture>;
  38493. private _bumpTexture;
  38494. /**
  38495. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38496. * 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.
  38497. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38498. */
  38499. bumpTexture: Nullable<BaseTexture>;
  38500. private _lightmapTexture;
  38501. /**
  38502. * Complex lighting can be computationally expensive to compute at runtime.
  38503. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38504. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38505. */
  38506. lightmapTexture: Nullable<BaseTexture>;
  38507. private _refractionTexture;
  38508. /**
  38509. * Define the texture used to display the refraction.
  38510. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38511. */
  38512. refractionTexture: Nullable<BaseTexture>;
  38513. /**
  38514. * The color of the material lit by the environmental background lighting.
  38515. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38516. */
  38517. ambientColor: Color3;
  38518. /**
  38519. * The basic color of the material as viewed under a light.
  38520. */
  38521. diffuseColor: Color3;
  38522. /**
  38523. * Define how the color and intensity of the highlight given by the light in the material.
  38524. */
  38525. specularColor: Color3;
  38526. /**
  38527. * Define the color of the material as if self lit.
  38528. * This will be mixed in the final result even in the absence of light.
  38529. */
  38530. emissiveColor: Color3;
  38531. /**
  38532. * Defines how sharp are the highlights in the material.
  38533. * The bigger the value the sharper giving a more glossy feeling to the result.
  38534. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38535. */
  38536. specularPower: number;
  38537. private _useAlphaFromDiffuseTexture;
  38538. /**
  38539. * Does the transparency come from the diffuse texture alpha channel.
  38540. */
  38541. useAlphaFromDiffuseTexture: boolean;
  38542. private _useEmissiveAsIllumination;
  38543. /**
  38544. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38545. */
  38546. useEmissiveAsIllumination: boolean;
  38547. private _linkEmissiveWithDiffuse;
  38548. /**
  38549. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38550. * the emissive level when the final color is close to one.
  38551. */
  38552. linkEmissiveWithDiffuse: boolean;
  38553. private _useSpecularOverAlpha;
  38554. /**
  38555. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38556. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38557. */
  38558. useSpecularOverAlpha: boolean;
  38559. private _useReflectionOverAlpha;
  38560. /**
  38561. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38562. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38563. */
  38564. useReflectionOverAlpha: boolean;
  38565. private _disableLighting;
  38566. /**
  38567. * Does lights from the scene impacts this material.
  38568. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38569. */
  38570. disableLighting: boolean;
  38571. private _useObjectSpaceNormalMap;
  38572. /**
  38573. * Allows using an object space normal map (instead of tangent space).
  38574. */
  38575. useObjectSpaceNormalMap: boolean;
  38576. private _useParallax;
  38577. /**
  38578. * Is parallax enabled or not.
  38579. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38580. */
  38581. useParallax: boolean;
  38582. private _useParallaxOcclusion;
  38583. /**
  38584. * Is parallax occlusion enabled or not.
  38585. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38586. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38587. */
  38588. useParallaxOcclusion: boolean;
  38589. /**
  38590. * 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.
  38591. */
  38592. parallaxScaleBias: number;
  38593. private _roughness;
  38594. /**
  38595. * Helps to define how blurry the reflections should appears in the material.
  38596. */
  38597. roughness: number;
  38598. /**
  38599. * In case of refraction, define the value of the indice of refraction.
  38600. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38601. */
  38602. indexOfRefraction: number;
  38603. /**
  38604. * Invert the refraction texture alongside the y axis.
  38605. * It can be useful with procedural textures or probe for instance.
  38606. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38607. */
  38608. invertRefractionY: boolean;
  38609. /**
  38610. * Defines the alpha limits in alpha test mode.
  38611. */
  38612. alphaCutOff: number;
  38613. private _useLightmapAsShadowmap;
  38614. /**
  38615. * In case of light mapping, define whether the map contains light or shadow informations.
  38616. */
  38617. useLightmapAsShadowmap: boolean;
  38618. private _diffuseFresnelParameters;
  38619. /**
  38620. * Define the diffuse fresnel parameters of the material.
  38621. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38622. */
  38623. diffuseFresnelParameters: FresnelParameters;
  38624. private _opacityFresnelParameters;
  38625. /**
  38626. * Define the opacity fresnel parameters of the material.
  38627. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38628. */
  38629. opacityFresnelParameters: FresnelParameters;
  38630. private _reflectionFresnelParameters;
  38631. /**
  38632. * Define the reflection fresnel parameters of the material.
  38633. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38634. */
  38635. reflectionFresnelParameters: FresnelParameters;
  38636. private _refractionFresnelParameters;
  38637. /**
  38638. * Define the refraction fresnel parameters of the material.
  38639. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38640. */
  38641. refractionFresnelParameters: FresnelParameters;
  38642. private _emissiveFresnelParameters;
  38643. /**
  38644. * Define the emissive fresnel parameters of the material.
  38645. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38646. */
  38647. emissiveFresnelParameters: FresnelParameters;
  38648. private _useReflectionFresnelFromSpecular;
  38649. /**
  38650. * If true automatically deducts the fresnels values from the material specularity.
  38651. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38652. */
  38653. useReflectionFresnelFromSpecular: boolean;
  38654. private _useGlossinessFromSpecularMapAlpha;
  38655. /**
  38656. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38657. */
  38658. useGlossinessFromSpecularMapAlpha: boolean;
  38659. private _maxSimultaneousLights;
  38660. /**
  38661. * Defines the maximum number of lights that can be used in the material
  38662. */
  38663. maxSimultaneousLights: number;
  38664. private _invertNormalMapX;
  38665. /**
  38666. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38667. */
  38668. invertNormalMapX: boolean;
  38669. private _invertNormalMapY;
  38670. /**
  38671. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38672. */
  38673. invertNormalMapY: boolean;
  38674. private _twoSidedLighting;
  38675. /**
  38676. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38677. */
  38678. twoSidedLighting: boolean;
  38679. /**
  38680. * Default configuration related to image processing available in the standard Material.
  38681. */
  38682. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38683. /**
  38684. * Gets the image processing configuration used either in this material.
  38685. */
  38686. /**
  38687. * Sets the Default image processing configuration used either in the this material.
  38688. *
  38689. * If sets to null, the scene one is in use.
  38690. */
  38691. imageProcessingConfiguration: ImageProcessingConfiguration;
  38692. /**
  38693. * Keep track of the image processing observer to allow dispose and replace.
  38694. */
  38695. private _imageProcessingObserver;
  38696. /**
  38697. * Attaches a new image processing configuration to the Standard Material.
  38698. * @param configuration
  38699. */
  38700. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38701. /**
  38702. * Gets wether the color curves effect is enabled.
  38703. */
  38704. /**
  38705. * Sets wether the color curves effect is enabled.
  38706. */
  38707. cameraColorCurvesEnabled: boolean;
  38708. /**
  38709. * Gets wether the color grading effect is enabled.
  38710. */
  38711. /**
  38712. * Gets wether the color grading effect is enabled.
  38713. */
  38714. cameraColorGradingEnabled: boolean;
  38715. /**
  38716. * Gets wether tonemapping is enabled or not.
  38717. */
  38718. /**
  38719. * Sets wether tonemapping is enabled or not
  38720. */
  38721. cameraToneMappingEnabled: boolean;
  38722. /**
  38723. * The camera exposure used on this material.
  38724. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38725. * This corresponds to a photographic exposure.
  38726. */
  38727. /**
  38728. * The camera exposure used on this material.
  38729. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38730. * This corresponds to a photographic exposure.
  38731. */
  38732. cameraExposure: number;
  38733. /**
  38734. * Gets The camera contrast used on this material.
  38735. */
  38736. /**
  38737. * Sets The camera contrast used on this material.
  38738. */
  38739. cameraContrast: number;
  38740. /**
  38741. * Gets the Color Grading 2D Lookup Texture.
  38742. */
  38743. /**
  38744. * Sets the Color Grading 2D Lookup Texture.
  38745. */
  38746. cameraColorGradingTexture: Nullable<BaseTexture>;
  38747. /**
  38748. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38749. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38750. * 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;
  38751. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38752. */
  38753. /**
  38754. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38755. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38756. * 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;
  38757. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38758. */
  38759. cameraColorCurves: Nullable<ColorCurves>;
  38760. /**
  38761. * Custom callback helping to override the default shader used in the material.
  38762. */
  38763. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38764. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38765. protected _worldViewProjectionMatrix: Matrix;
  38766. protected _globalAmbientColor: Color3;
  38767. protected _useLogarithmicDepth: boolean;
  38768. /**
  38769. * Instantiates a new standard material.
  38770. * This is the default material used in Babylon. It is the best trade off between quality
  38771. * and performances.
  38772. * @see http://doc.babylonjs.com/babylon101/materials
  38773. * @param name Define the name of the material in the scene
  38774. * @param scene Define the scene the material belong to
  38775. */
  38776. constructor(name: string, scene: Scene);
  38777. /**
  38778. * Gets a boolean indicating that current material needs to register RTT
  38779. */
  38780. readonly hasRenderTargetTextures: boolean;
  38781. /**
  38782. * Gets the current class name of the material e.g. "StandardMaterial"
  38783. * Mainly use in serialization.
  38784. * @returns the class name
  38785. */
  38786. getClassName(): string;
  38787. /**
  38788. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38789. * You can try switching to logarithmic depth.
  38790. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38791. */
  38792. useLogarithmicDepth: boolean;
  38793. /**
  38794. * Specifies if the material will require alpha blending
  38795. * @returns a boolean specifying if alpha blending is needed
  38796. */
  38797. needAlphaBlending(): boolean;
  38798. /**
  38799. * Specifies if this material should be rendered in alpha test mode
  38800. * @returns a boolean specifying if an alpha test is needed.
  38801. */
  38802. needAlphaTesting(): boolean;
  38803. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38804. /**
  38805. * Get the texture used for alpha test purpose.
  38806. * @returns the diffuse texture in case of the standard material.
  38807. */
  38808. getAlphaTestTexture(): Nullable<BaseTexture>;
  38809. /**
  38810. * Get if the submesh is ready to be used and all its information available.
  38811. * Child classes can use it to update shaders
  38812. * @param mesh defines the mesh to check
  38813. * @param subMesh defines which submesh to check
  38814. * @param useInstances specifies that instances should be used
  38815. * @returns a boolean indicating that the submesh is ready or not
  38816. */
  38817. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38818. /**
  38819. * Builds the material UBO layouts.
  38820. * Used internally during the effect preparation.
  38821. */
  38822. buildUniformLayout(): void;
  38823. /**
  38824. * Unbinds the material from the mesh
  38825. */
  38826. unbind(): void;
  38827. /**
  38828. * Binds the submesh to this material by preparing the effect and shader to draw
  38829. * @param world defines the world transformation matrix
  38830. * @param mesh defines the mesh containing the submesh
  38831. * @param subMesh defines the submesh to bind the material to
  38832. */
  38833. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38834. /**
  38835. * Get the list of animatables in the material.
  38836. * @returns the list of animatables object used in the material
  38837. */
  38838. getAnimatables(): IAnimatable[];
  38839. /**
  38840. * Gets the active textures from the material
  38841. * @returns an array of textures
  38842. */
  38843. getActiveTextures(): BaseTexture[];
  38844. /**
  38845. * Specifies if the material uses a texture
  38846. * @param texture defines the texture to check against the material
  38847. * @returns a boolean specifying if the material uses the texture
  38848. */
  38849. hasTexture(texture: BaseTexture): boolean;
  38850. /**
  38851. * Disposes the material
  38852. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38853. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38854. */
  38855. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38856. /**
  38857. * Makes a duplicate of the material, and gives it a new name
  38858. * @param name defines the new name for the duplicated material
  38859. * @returns the cloned material
  38860. */
  38861. clone(name: string): StandardMaterial;
  38862. /**
  38863. * Serializes this material in a JSON representation
  38864. * @returns the serialized material object
  38865. */
  38866. serialize(): any;
  38867. /**
  38868. * Creates a standard material from parsed material data
  38869. * @param source defines the JSON representation of the material
  38870. * @param scene defines the hosting scene
  38871. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38872. * @returns a new standard material
  38873. */
  38874. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38875. /**
  38876. * Are diffuse textures enabled in the application.
  38877. */
  38878. static DiffuseTextureEnabled: boolean;
  38879. /**
  38880. * Are ambient textures enabled in the application.
  38881. */
  38882. static AmbientTextureEnabled: boolean;
  38883. /**
  38884. * Are opacity textures enabled in the application.
  38885. */
  38886. static OpacityTextureEnabled: boolean;
  38887. /**
  38888. * Are reflection textures enabled in the application.
  38889. */
  38890. static ReflectionTextureEnabled: boolean;
  38891. /**
  38892. * Are emissive textures enabled in the application.
  38893. */
  38894. static EmissiveTextureEnabled: boolean;
  38895. /**
  38896. * Are specular textures enabled in the application.
  38897. */
  38898. static SpecularTextureEnabled: boolean;
  38899. /**
  38900. * Are bump textures enabled in the application.
  38901. */
  38902. static BumpTextureEnabled: boolean;
  38903. /**
  38904. * Are lightmap textures enabled in the application.
  38905. */
  38906. static LightmapTextureEnabled: boolean;
  38907. /**
  38908. * Are refraction textures enabled in the application.
  38909. */
  38910. static RefractionTextureEnabled: boolean;
  38911. /**
  38912. * Are color grading textures enabled in the application.
  38913. */
  38914. static ColorGradingTextureEnabled: boolean;
  38915. /**
  38916. * Are fresnels enabled in the application.
  38917. */
  38918. static FresnelEnabled: boolean;
  38919. }
  38920. }
  38921. declare module BABYLON {
  38922. /**
  38923. * A class extending Texture allowing drawing on a texture
  38924. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38925. */
  38926. export class DynamicTexture extends Texture {
  38927. private _generateMipMaps;
  38928. private _canvas;
  38929. private _context;
  38930. private _engine;
  38931. /**
  38932. * Creates a DynamicTexture
  38933. * @param name defines the name of the texture
  38934. * @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
  38935. * @param scene defines the scene where you want the texture
  38936. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38937. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38938. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38939. */
  38940. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38941. /**
  38942. * Get the current class name of the texture useful for serialization or dynamic coding.
  38943. * @returns "DynamicTexture"
  38944. */
  38945. getClassName(): string;
  38946. /**
  38947. * Gets the current state of canRescale
  38948. */
  38949. readonly canRescale: boolean;
  38950. private _recreate;
  38951. /**
  38952. * Scales the texture
  38953. * @param ratio the scale factor to apply to both width and height
  38954. */
  38955. scale(ratio: number): void;
  38956. /**
  38957. * Resizes the texture
  38958. * @param width the new width
  38959. * @param height the new height
  38960. */
  38961. scaleTo(width: number, height: number): void;
  38962. /**
  38963. * Gets the context of the canvas used by the texture
  38964. * @returns the canvas context of the dynamic texture
  38965. */
  38966. getContext(): CanvasRenderingContext2D;
  38967. /**
  38968. * Clears the texture
  38969. */
  38970. clear(): void;
  38971. /**
  38972. * Updates the texture
  38973. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38974. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  38975. */
  38976. update(invertY?: boolean, premulAlpha?: boolean): void;
  38977. /**
  38978. * Draws text onto the texture
  38979. * @param text defines the text to be drawn
  38980. * @param x defines the placement of the text from the left
  38981. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  38982. * @param font defines the font to be used with font-style, font-size, font-name
  38983. * @param color defines the color used for the text
  38984. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  38985. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38986. * @param update defines whether texture is immediately update (default is true)
  38987. */
  38988. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  38989. /**
  38990. * Clones the texture
  38991. * @returns the clone of the texture.
  38992. */
  38993. clone(): DynamicTexture;
  38994. /**
  38995. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  38996. * @returns a serialized dynamic texture object
  38997. */
  38998. serialize(): any;
  38999. /** @hidden */
  39000. _rebuild(): void;
  39001. }
  39002. }
  39003. declare module BABYLON {
  39004. /** @hidden */
  39005. export var imageProcessingPixelShader: {
  39006. name: string;
  39007. shader: string;
  39008. };
  39009. }
  39010. declare module BABYLON {
  39011. /**
  39012. * ImageProcessingPostProcess
  39013. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39014. */
  39015. export class ImageProcessingPostProcess extends PostProcess {
  39016. /**
  39017. * Default configuration related to image processing available in the PBR Material.
  39018. */
  39019. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39020. /**
  39021. * Gets the image processing configuration used either in this material.
  39022. */
  39023. /**
  39024. * Sets the Default image processing configuration used either in the this material.
  39025. *
  39026. * If sets to null, the scene one is in use.
  39027. */
  39028. imageProcessingConfiguration: ImageProcessingConfiguration;
  39029. /**
  39030. * Keep track of the image processing observer to allow dispose and replace.
  39031. */
  39032. private _imageProcessingObserver;
  39033. /**
  39034. * Attaches a new image processing configuration to the PBR Material.
  39035. * @param configuration
  39036. */
  39037. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39038. /**
  39039. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39040. */
  39041. /**
  39042. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39043. */
  39044. colorCurves: Nullable<ColorCurves>;
  39045. /**
  39046. * Gets wether the color curves effect is enabled.
  39047. */
  39048. /**
  39049. * Sets wether the color curves effect is enabled.
  39050. */
  39051. colorCurvesEnabled: boolean;
  39052. /**
  39053. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39054. */
  39055. /**
  39056. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39057. */
  39058. colorGradingTexture: Nullable<BaseTexture>;
  39059. /**
  39060. * Gets wether the color grading effect is enabled.
  39061. */
  39062. /**
  39063. * Gets wether the color grading effect is enabled.
  39064. */
  39065. colorGradingEnabled: boolean;
  39066. /**
  39067. * Gets exposure used in the effect.
  39068. */
  39069. /**
  39070. * Sets exposure used in the effect.
  39071. */
  39072. exposure: number;
  39073. /**
  39074. * Gets wether tonemapping is enabled or not.
  39075. */
  39076. /**
  39077. * Sets wether tonemapping is enabled or not
  39078. */
  39079. toneMappingEnabled: boolean;
  39080. /**
  39081. * Gets contrast used in the effect.
  39082. */
  39083. /**
  39084. * Sets contrast used in the effect.
  39085. */
  39086. contrast: number;
  39087. /**
  39088. * Gets Vignette stretch size.
  39089. */
  39090. /**
  39091. * Sets Vignette stretch size.
  39092. */
  39093. vignetteStretch: number;
  39094. /**
  39095. * Gets Vignette centre X Offset.
  39096. */
  39097. /**
  39098. * Sets Vignette centre X Offset.
  39099. */
  39100. vignetteCentreX: number;
  39101. /**
  39102. * Gets Vignette centre Y Offset.
  39103. */
  39104. /**
  39105. * Sets Vignette centre Y Offset.
  39106. */
  39107. vignetteCentreY: number;
  39108. /**
  39109. * Gets Vignette weight or intensity of the vignette effect.
  39110. */
  39111. /**
  39112. * Sets Vignette weight or intensity of the vignette effect.
  39113. */
  39114. vignetteWeight: number;
  39115. /**
  39116. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39117. * if vignetteEnabled is set to true.
  39118. */
  39119. /**
  39120. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39121. * if vignetteEnabled is set to true.
  39122. */
  39123. vignetteColor: Color4;
  39124. /**
  39125. * Gets Camera field of view used by the Vignette effect.
  39126. */
  39127. /**
  39128. * Sets Camera field of view used by the Vignette effect.
  39129. */
  39130. vignetteCameraFov: number;
  39131. /**
  39132. * Gets the vignette blend mode allowing different kind of effect.
  39133. */
  39134. /**
  39135. * Sets the vignette blend mode allowing different kind of effect.
  39136. */
  39137. vignetteBlendMode: number;
  39138. /**
  39139. * Gets wether the vignette effect is enabled.
  39140. */
  39141. /**
  39142. * Sets wether the vignette effect is enabled.
  39143. */
  39144. vignetteEnabled: boolean;
  39145. private _fromLinearSpace;
  39146. /**
  39147. * Gets wether the input of the processing is in Gamma or Linear Space.
  39148. */
  39149. /**
  39150. * Sets wether the input of the processing is in Gamma or Linear Space.
  39151. */
  39152. fromLinearSpace: boolean;
  39153. /**
  39154. * Defines cache preventing GC.
  39155. */
  39156. private _defines;
  39157. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39158. /**
  39159. * "ImageProcessingPostProcess"
  39160. * @returns "ImageProcessingPostProcess"
  39161. */
  39162. getClassName(): string;
  39163. protected _updateParameters(): void;
  39164. dispose(camera?: Camera): void;
  39165. }
  39166. }
  39167. declare module BABYLON {
  39168. /**
  39169. * Options to modify the vr teleportation behavior.
  39170. */
  39171. export interface VRTeleportationOptions {
  39172. /**
  39173. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39174. */
  39175. floorMeshName?: string;
  39176. /**
  39177. * A list of meshes to be used as the teleportation floor. (default: empty)
  39178. */
  39179. floorMeshes?: Mesh[];
  39180. }
  39181. /**
  39182. * Options to modify the vr experience helper's behavior.
  39183. */
  39184. export interface VRExperienceHelperOptions extends WebVROptions {
  39185. /**
  39186. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39187. */
  39188. createDeviceOrientationCamera?: boolean;
  39189. /**
  39190. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39191. */
  39192. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39193. /**
  39194. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39195. */
  39196. laserToggle?: boolean;
  39197. /**
  39198. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39199. */
  39200. floorMeshes?: Mesh[];
  39201. }
  39202. /**
  39203. * Helps to quickly add VR support to an existing scene.
  39204. * See http://doc.babylonjs.com/how_to/webvr_helper
  39205. */
  39206. export class VRExperienceHelper {
  39207. /** Options to modify the vr experience helper's behavior. */
  39208. webVROptions: VRExperienceHelperOptions;
  39209. private _scene;
  39210. private _position;
  39211. private _btnVR;
  39212. private _btnVRDisplayed;
  39213. private _webVRsupported;
  39214. private _webVRready;
  39215. private _webVRrequesting;
  39216. private _webVRpresenting;
  39217. private _hasEnteredVR;
  39218. private _fullscreenVRpresenting;
  39219. private _canvas;
  39220. private _webVRCamera;
  39221. private _vrDeviceOrientationCamera;
  39222. private _deviceOrientationCamera;
  39223. private _existingCamera;
  39224. private _onKeyDown;
  39225. private _onVrDisplayPresentChange;
  39226. private _onVRDisplayChanged;
  39227. private _onVRRequestPresentStart;
  39228. private _onVRRequestPresentComplete;
  39229. /**
  39230. * Observable raised when entering VR.
  39231. */
  39232. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39233. /**
  39234. * Observable raised when exiting VR.
  39235. */
  39236. onExitingVRObservable: Observable<VRExperienceHelper>;
  39237. /**
  39238. * Observable raised when controller mesh is loaded.
  39239. */
  39240. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39241. /** Return this.onEnteringVRObservable
  39242. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39243. */
  39244. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39245. /** Return this.onExitingVRObservable
  39246. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39247. */
  39248. readonly onExitingVR: Observable<VRExperienceHelper>;
  39249. /** Return this.onControllerMeshLoadedObservable
  39250. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39251. */
  39252. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39253. private _rayLength;
  39254. private _useCustomVRButton;
  39255. private _teleportationRequested;
  39256. private _teleportActive;
  39257. private _floorMeshName;
  39258. private _floorMeshesCollection;
  39259. private _rotationAllowed;
  39260. private _teleportBackwardsVector;
  39261. private _teleportationTarget;
  39262. private _isDefaultTeleportationTarget;
  39263. private _postProcessMove;
  39264. private _teleportationFillColor;
  39265. private _teleportationBorderColor;
  39266. private _rotationAngle;
  39267. private _haloCenter;
  39268. private _cameraGazer;
  39269. private _padSensibilityUp;
  39270. private _padSensibilityDown;
  39271. private _leftController;
  39272. private _rightController;
  39273. /**
  39274. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39275. */
  39276. onNewMeshSelected: Observable<AbstractMesh>;
  39277. /**
  39278. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39279. */
  39280. onNewMeshPicked: Observable<PickingInfo>;
  39281. private _circleEase;
  39282. /**
  39283. * Observable raised before camera teleportation
  39284. */
  39285. onBeforeCameraTeleport: Observable<Vector3>;
  39286. /**
  39287. * Observable raised after camera teleportation
  39288. */
  39289. onAfterCameraTeleport: Observable<Vector3>;
  39290. /**
  39291. * Observable raised when current selected mesh gets unselected
  39292. */
  39293. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39294. private _raySelectionPredicate;
  39295. /**
  39296. * To be optionaly changed by user to define custom ray selection
  39297. */
  39298. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39299. /**
  39300. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39301. */
  39302. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39303. /**
  39304. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39305. */
  39306. teleportationEnabled: boolean;
  39307. private _defaultHeight;
  39308. private _teleportationInitialized;
  39309. private _interactionsEnabled;
  39310. private _interactionsRequested;
  39311. private _displayGaze;
  39312. private _displayLaserPointer;
  39313. /**
  39314. * The mesh used to display where the user is going to teleport.
  39315. */
  39316. /**
  39317. * Sets the mesh to be used to display where the user is going to teleport.
  39318. */
  39319. teleportationTarget: Mesh;
  39320. /**
  39321. * 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
  39322. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39323. * See http://doc.babylonjs.com/resources/baking_transformations
  39324. */
  39325. gazeTrackerMesh: Mesh;
  39326. /**
  39327. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39328. */
  39329. updateGazeTrackerScale: boolean;
  39330. /**
  39331. * If the gaze trackers color should be updated when selecting meshes
  39332. */
  39333. updateGazeTrackerColor: boolean;
  39334. /**
  39335. * The gaze tracking mesh corresponding to the left controller
  39336. */
  39337. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39338. /**
  39339. * The gaze tracking mesh corresponding to the right controller
  39340. */
  39341. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39342. /**
  39343. * If the ray of the gaze should be displayed.
  39344. */
  39345. /**
  39346. * Sets if the ray of the gaze should be displayed.
  39347. */
  39348. displayGaze: boolean;
  39349. /**
  39350. * If the ray of the LaserPointer should be displayed.
  39351. */
  39352. /**
  39353. * Sets if the ray of the LaserPointer should be displayed.
  39354. */
  39355. displayLaserPointer: boolean;
  39356. /**
  39357. * The deviceOrientationCamera used as the camera when not in VR.
  39358. */
  39359. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39360. /**
  39361. * Based on the current WebVR support, returns the current VR camera used.
  39362. */
  39363. readonly currentVRCamera: Nullable<Camera>;
  39364. /**
  39365. * The webVRCamera which is used when in VR.
  39366. */
  39367. readonly webVRCamera: WebVRFreeCamera;
  39368. /**
  39369. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39370. */
  39371. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39372. private readonly _teleportationRequestInitiated;
  39373. /**
  39374. * Instantiates a VRExperienceHelper.
  39375. * Helps to quickly add VR support to an existing scene.
  39376. * @param scene The scene the VRExperienceHelper belongs to.
  39377. * @param webVROptions Options to modify the vr experience helper's behavior.
  39378. */
  39379. constructor(scene: Scene,
  39380. /** Options to modify the vr experience helper's behavior. */
  39381. webVROptions?: VRExperienceHelperOptions);
  39382. private _onDefaultMeshLoaded;
  39383. private _onResize;
  39384. private _onFullscreenChange;
  39385. /**
  39386. * Gets a value indicating if we are currently in VR mode.
  39387. */
  39388. readonly isInVRMode: boolean;
  39389. private onVrDisplayPresentChange;
  39390. private onVRDisplayChanged;
  39391. private moveButtonToBottomRight;
  39392. private displayVRButton;
  39393. private updateButtonVisibility;
  39394. private _cachedAngularSensibility;
  39395. /**
  39396. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39397. * Otherwise, will use the fullscreen API.
  39398. */
  39399. enterVR(): void;
  39400. /**
  39401. * Attempt to exit VR, or fullscreen.
  39402. */
  39403. exitVR(): void;
  39404. /**
  39405. * The position of the vr experience helper.
  39406. */
  39407. /**
  39408. * Sets the position of the vr experience helper.
  39409. */
  39410. position: Vector3;
  39411. /**
  39412. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39413. */
  39414. enableInteractions(): void;
  39415. private readonly _noControllerIsActive;
  39416. private beforeRender;
  39417. private _isTeleportationFloor;
  39418. /**
  39419. * Adds a floor mesh to be used for teleportation.
  39420. * @param floorMesh the mesh to be used for teleportation.
  39421. */
  39422. addFloorMesh(floorMesh: Mesh): void;
  39423. /**
  39424. * Removes a floor mesh from being used for teleportation.
  39425. * @param floorMesh the mesh to be removed.
  39426. */
  39427. removeFloorMesh(floorMesh: Mesh): void;
  39428. /**
  39429. * Enables interactions and teleportation using the VR controllers and gaze.
  39430. * @param vrTeleportationOptions options to modify teleportation behavior.
  39431. */
  39432. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39433. private _onNewGamepadConnected;
  39434. private _tryEnableInteractionOnController;
  39435. private _onNewGamepadDisconnected;
  39436. private _enableInteractionOnController;
  39437. private _checkTeleportWithRay;
  39438. private _checkRotate;
  39439. private _checkTeleportBackwards;
  39440. private _enableTeleportationOnController;
  39441. private _createTeleportationCircles;
  39442. private _displayTeleportationTarget;
  39443. private _hideTeleportationTarget;
  39444. private _rotateCamera;
  39445. private _moveTeleportationSelectorTo;
  39446. private _workingVector;
  39447. private _workingQuaternion;
  39448. private _workingMatrix;
  39449. /**
  39450. * Teleports the users feet to the desired location
  39451. * @param location The location where the user's feet should be placed
  39452. */
  39453. teleportCamera(location: Vector3): void;
  39454. private _convertNormalToDirectionOfRay;
  39455. private _castRayAndSelectObject;
  39456. private _notifySelectedMeshUnselected;
  39457. /**
  39458. * Sets the color of the laser ray from the vr controllers.
  39459. * @param color new color for the ray.
  39460. */
  39461. changeLaserColor(color: Color3): void;
  39462. /**
  39463. * Sets the color of the ray from the vr headsets gaze.
  39464. * @param color new color for the ray.
  39465. */
  39466. changeGazeColor(color: Color3): void;
  39467. /**
  39468. * Exits VR and disposes of the vr experience helper
  39469. */
  39470. dispose(): void;
  39471. /**
  39472. * Gets the name of the VRExperienceHelper class
  39473. * @returns "VRExperienceHelper"
  39474. */
  39475. getClassName(): string;
  39476. }
  39477. }
  39478. declare module BABYLON {
  39479. /**
  39480. * Manages an XRSession
  39481. * @see https://doc.babylonjs.com/how_to/webxr
  39482. */
  39483. export class WebXRSessionManager implements IDisposable {
  39484. private scene;
  39485. /**
  39486. * Fires every time a new xrFrame arrives which can be used to update the camera
  39487. */
  39488. onXRFrameObservable: Observable<any>;
  39489. /**
  39490. * Fires when the xr session is ended either by the device or manually done
  39491. */
  39492. onXRSessionEnded: Observable<any>;
  39493. /** @hidden */
  39494. _xrSession: XRSession;
  39495. /** @hidden */
  39496. _frameOfReference: XRFrameOfReference;
  39497. /** @hidden */
  39498. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39499. /** @hidden */
  39500. _currentXRFrame: Nullable<XRFrame>;
  39501. private _xrNavigator;
  39502. private _xrDevice;
  39503. private _tmpMatrix;
  39504. /**
  39505. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39506. * @param scene The scene which the session should be created for
  39507. */
  39508. constructor(scene: Scene);
  39509. /**
  39510. * Initializes the manager
  39511. * After initialization enterXR can be called to start an XR session
  39512. * @returns Promise which resolves after it is initialized
  39513. */
  39514. initializeAsync(): Promise<void>;
  39515. /**
  39516. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39517. * @param sessionCreationOptions xr options to create the session with
  39518. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39519. * @returns Promise which resolves after it enters XR
  39520. */
  39521. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39522. /**
  39523. * Stops the xrSession and restores the renderloop
  39524. * @returns Promise which resolves after it exits XR
  39525. */
  39526. exitXRAsync(): Promise<void>;
  39527. /**
  39528. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39529. * @param ray ray to cast into the environment
  39530. * @returns Promise which resolves with a collision point in the environment if it exists
  39531. */
  39532. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39533. /**
  39534. * Checks if a session would be supported for the creation options specified
  39535. * @param options creation options to check if they are supported
  39536. * @returns true if supported
  39537. */
  39538. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39539. /**
  39540. * @hidden
  39541. * Converts the render layer of xrSession to a render target
  39542. * @param session session to create render target for
  39543. * @param scene scene the new render target should be created for
  39544. */
  39545. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39546. /**
  39547. * Disposes of the session manager
  39548. */
  39549. dispose(): void;
  39550. }
  39551. }
  39552. declare module BABYLON {
  39553. /**
  39554. * WebXR Camera which holds the views for the xrSession
  39555. * @see https://doc.babylonjs.com/how_to/webxr
  39556. */
  39557. export class WebXRCamera extends FreeCamera {
  39558. private static _TmpMatrix;
  39559. /**
  39560. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39561. * @param name the name of the camera
  39562. * @param scene the scene to add the camera to
  39563. */
  39564. constructor(name: string, scene: Scene);
  39565. private _updateNumberOfRigCameras;
  39566. /** @hidden */
  39567. _updateForDualEyeDebugging(pupilDistance?: number): void;
  39568. /**
  39569. * Updates the cameras position from the current pose information of the XR session
  39570. * @param xrSessionManager the session containing pose information
  39571. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39572. */
  39573. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39574. }
  39575. }
  39576. declare module BABYLON {
  39577. /**
  39578. * States of the webXR experience
  39579. */
  39580. export enum WebXRState {
  39581. /**
  39582. * Transitioning to being in XR mode
  39583. */
  39584. ENTERING_XR = 0,
  39585. /**
  39586. * Transitioning to non XR mode
  39587. */
  39588. EXITING_XR = 1,
  39589. /**
  39590. * In XR mode and presenting
  39591. */
  39592. IN_XR = 2,
  39593. /**
  39594. * Not entered XR mode
  39595. */
  39596. NOT_IN_XR = 3
  39597. }
  39598. /**
  39599. * Helper class used to enable XR
  39600. * @see https://doc.babylonjs.com/how_to/webxr
  39601. */
  39602. export class WebXRExperienceHelper implements IDisposable {
  39603. private scene;
  39604. /**
  39605. * 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
  39606. */
  39607. container: AbstractMesh;
  39608. /**
  39609. * Camera used to render xr content
  39610. */
  39611. camera: WebXRCamera;
  39612. /**
  39613. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39614. */
  39615. state: WebXRState;
  39616. private _setState;
  39617. private static _TmpVector;
  39618. /**
  39619. * Fires when the state of the experience helper has changed
  39620. */
  39621. onStateChangedObservable: Observable<WebXRState>;
  39622. /** @hidden */
  39623. _sessionManager: WebXRSessionManager;
  39624. private _nonVRCamera;
  39625. private _originalSceneAutoClear;
  39626. private _supported;
  39627. /**
  39628. * Creates the experience helper
  39629. * @param scene the scene to attach the experience helper to
  39630. * @returns a promise for the experience helper
  39631. */
  39632. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39633. /**
  39634. * Creates a WebXRExperienceHelper
  39635. * @param scene The scene the helper should be created in
  39636. */
  39637. private constructor();
  39638. /**
  39639. * Exits XR mode and returns the scene to its original state
  39640. * @returns promise that resolves after xr mode has exited
  39641. */
  39642. exitXRAsync(): Promise<void>;
  39643. /**
  39644. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39645. * @param sessionCreationOptions options for the XR session
  39646. * @param frameOfReference frame of reference of the XR session
  39647. * @returns promise that resolves after xr mode has entered
  39648. */
  39649. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39650. /**
  39651. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39652. * @param ray ray to cast into the environment
  39653. * @returns Promise which resolves with a collision point in the environment if it exists
  39654. */
  39655. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39656. /**
  39657. * Updates the global position of the camera by moving the camera's container
  39658. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39659. * @param position The desired global position of the camera
  39660. */
  39661. setPositionOfCameraUsingContainer(position: Vector3): void;
  39662. /**
  39663. * Rotates the xr camera by rotating the camera's container around the camera's position
  39664. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39665. * @param rotation the desired quaternion rotation to apply to the camera
  39666. */
  39667. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39668. /**
  39669. * Checks if the creation options are supported by the xr session
  39670. * @param options creation options
  39671. * @returns true if supported
  39672. */
  39673. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39674. /**
  39675. * Disposes of the experience helper
  39676. */
  39677. dispose(): void;
  39678. }
  39679. }
  39680. declare module BABYLON {
  39681. /**
  39682. * Button which can be used to enter a different mode of XR
  39683. */
  39684. export class WebXREnterExitUIButton {
  39685. /** button element */
  39686. element: HTMLElement;
  39687. /** XR initialization options for the button */
  39688. initializationOptions: XRSessionCreationOptions;
  39689. /**
  39690. * Creates a WebXREnterExitUIButton
  39691. * @param element button element
  39692. * @param initializationOptions XR initialization options for the button
  39693. */
  39694. constructor(
  39695. /** button element */
  39696. element: HTMLElement,
  39697. /** XR initialization options for the button */
  39698. initializationOptions: XRSessionCreationOptions);
  39699. /**
  39700. * Overwritable function which can be used to update the button's visuals when the state changes
  39701. * @param activeButton the current active button in the UI
  39702. */
  39703. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39704. }
  39705. /**
  39706. * Options to create the webXR UI
  39707. */
  39708. export class WebXREnterExitUIOptions {
  39709. /**
  39710. * Context to enter xr with
  39711. */
  39712. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39713. /**
  39714. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39715. */
  39716. customButtons?: Array<WebXREnterExitUIButton>;
  39717. }
  39718. /**
  39719. * UI to allow the user to enter/exit XR mode
  39720. */
  39721. export class WebXREnterExitUI implements IDisposable {
  39722. private scene;
  39723. private _overlay;
  39724. private _buttons;
  39725. private _activeButton;
  39726. /**
  39727. * Fired every time the active button is changed.
  39728. *
  39729. * When xr is entered via a button that launches xr that button will be the callback parameter
  39730. *
  39731. * When exiting xr the callback parameter will be null)
  39732. */
  39733. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  39734. /**
  39735. * Creates UI to allow the user to enter/exit XR mode
  39736. * @param scene the scene to add the ui to
  39737. * @param helper the xr experience helper to enter/exit xr with
  39738. * @param options options to configure the UI
  39739. * @returns the created ui
  39740. */
  39741. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  39742. private constructor();
  39743. private _updateButtons;
  39744. /**
  39745. * Disposes of the object
  39746. */
  39747. dispose(): void;
  39748. }
  39749. }
  39750. declare module BABYLON {
  39751. /**
  39752. * Represents an XR input
  39753. */
  39754. export class WebXRController {
  39755. /**
  39756. * 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
  39757. */
  39758. grip?: AbstractMesh;
  39759. /**
  39760. * Pointer which can be used to select objects or attach a visible laser to
  39761. */
  39762. pointer: AbstractMesh;
  39763. /**
  39764. * Creates the controller
  39765. * @see https://doc.babylonjs.com/how_to/webxr
  39766. * @param scene the scene which the controller should be associated to
  39767. */
  39768. constructor(scene: Scene);
  39769. /**
  39770. * Disposes of the object
  39771. */
  39772. dispose(): void;
  39773. }
  39774. /**
  39775. * XR input used to track XR inputs such as controllers/rays
  39776. */
  39777. export class WebXRInput implements IDisposable {
  39778. private helper;
  39779. /**
  39780. * XR controllers being tracked
  39781. */
  39782. controllers: Array<WebXRController>;
  39783. private _tmpMatrix;
  39784. private _frameObserver;
  39785. /**
  39786. * Initializes the WebXRInput
  39787. * @param helper experience helper which the input should be created for
  39788. */
  39789. constructor(helper: WebXRExperienceHelper);
  39790. /**
  39791. * Disposes of the object
  39792. */
  39793. dispose(): void;
  39794. }
  39795. }
  39796. declare module BABYLON {
  39797. /**
  39798. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  39799. */
  39800. export class WebXRManagedOutputCanvas implements IDisposable {
  39801. private _canvas;
  39802. /**
  39803. * xrpresent context of the canvas which can be used to display/mirror xr content
  39804. */
  39805. canvasContext: Nullable<WebGLRenderingContext>;
  39806. /**
  39807. * Initializes the canvas to be added/removed upon entering/exiting xr
  39808. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  39809. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  39810. */
  39811. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  39812. /**
  39813. * Disposes of the object
  39814. */
  39815. dispose(): void;
  39816. private _setManagedOutputCanvas;
  39817. private _addCanvas;
  39818. private _removeCanvas;
  39819. }
  39820. }
  39821. declare module BABYLON {
  39822. /**
  39823. * Contains an array of blocks representing the octree
  39824. */
  39825. export interface IOctreeContainer<T> {
  39826. /**
  39827. * Blocks within the octree
  39828. */
  39829. blocks: Array<OctreeBlock<T>>;
  39830. }
  39831. /**
  39832. * Class used to store a cell in an octree
  39833. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39834. */
  39835. export class OctreeBlock<T> {
  39836. /**
  39837. * Gets the content of the current block
  39838. */
  39839. entries: T[];
  39840. /**
  39841. * Gets the list of block children
  39842. */
  39843. blocks: Array<OctreeBlock<T>>;
  39844. private _depth;
  39845. private _maxDepth;
  39846. private _capacity;
  39847. private _minPoint;
  39848. private _maxPoint;
  39849. private _boundingVectors;
  39850. private _creationFunc;
  39851. /**
  39852. * Creates a new block
  39853. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  39854. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  39855. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39856. * @param depth defines the current depth of this block in the octree
  39857. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  39858. * @param creationFunc defines a callback to call when an element is added to the block
  39859. */
  39860. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  39861. /**
  39862. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39863. */
  39864. readonly capacity: number;
  39865. /**
  39866. * Gets the minimum vector (in world space) of the block's bounding box
  39867. */
  39868. readonly minPoint: Vector3;
  39869. /**
  39870. * Gets the maximum vector (in world space) of the block's bounding box
  39871. */
  39872. readonly maxPoint: Vector3;
  39873. /**
  39874. * Add a new element to this block
  39875. * @param entry defines the element to add
  39876. */
  39877. addEntry(entry: T): void;
  39878. /**
  39879. * Remove an element from this block
  39880. * @param entry defines the element to remove
  39881. */
  39882. removeEntry(entry: T): void;
  39883. /**
  39884. * Add an array of elements to this block
  39885. * @param entries defines the array of elements to add
  39886. */
  39887. addEntries(entries: T[]): void;
  39888. /**
  39889. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  39890. * @param frustumPlanes defines the frustum planes to test
  39891. * @param selection defines the array to store current content if selection is positive
  39892. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39893. */
  39894. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39895. /**
  39896. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  39897. * @param sphereCenter defines the bounding sphere center
  39898. * @param sphereRadius defines the bounding sphere radius
  39899. * @param selection defines the array to store current content if selection is positive
  39900. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39901. */
  39902. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39903. /**
  39904. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  39905. * @param ray defines the ray to test with
  39906. * @param selection defines the array to store current content if selection is positive
  39907. */
  39908. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  39909. /**
  39910. * Subdivide the content into child blocks (this block will then be empty)
  39911. */
  39912. createInnerBlocks(): void;
  39913. /**
  39914. * @hidden
  39915. */
  39916. 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;
  39917. }
  39918. }
  39919. declare module BABYLON {
  39920. /**
  39921. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  39922. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39923. */
  39924. export class Octree<T> {
  39925. /** 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.) */
  39926. maxDepth: number;
  39927. /**
  39928. * Blocks within the octree containing objects
  39929. */
  39930. blocks: Array<OctreeBlock<T>>;
  39931. /**
  39932. * Content stored in the octree
  39933. */
  39934. dynamicContent: T[];
  39935. private _maxBlockCapacity;
  39936. private _selectionContent;
  39937. private _creationFunc;
  39938. /**
  39939. * Creates a octree
  39940. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39941. * @param creationFunc function to be used to instatiate the octree
  39942. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  39943. * @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.)
  39944. */
  39945. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  39946. /** 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.) */
  39947. maxDepth?: number);
  39948. /**
  39949. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  39950. * @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);
  39951. * @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);
  39952. * @param entries meshes to be added to the octree blocks
  39953. */
  39954. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  39955. /**
  39956. * Adds a mesh to the octree
  39957. * @param entry Mesh to add to the octree
  39958. */
  39959. addMesh(entry: T): void;
  39960. /**
  39961. * Remove an element from the octree
  39962. * @param entry defines the element to remove
  39963. */
  39964. removeMesh(entry: T): void;
  39965. /**
  39966. * Selects an array of meshes within the frustum
  39967. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  39968. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  39969. * @returns array of meshes within the frustum
  39970. */
  39971. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  39972. /**
  39973. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  39974. * @param sphereCenter defines the bounding sphere center
  39975. * @param sphereRadius defines the bounding sphere radius
  39976. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39977. * @returns an array of objects that intersect the sphere
  39978. */
  39979. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  39980. /**
  39981. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  39982. * @param ray defines the ray to test with
  39983. * @returns array of intersected objects
  39984. */
  39985. intersectsRay(ray: Ray): SmartArray<T>;
  39986. /**
  39987. * Adds a mesh into the octree block if it intersects the block
  39988. */
  39989. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  39990. /**
  39991. * Adds a submesh into the octree block if it intersects the block
  39992. */
  39993. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  39994. }
  39995. }
  39996. declare module BABYLON {
  39997. interface Scene {
  39998. /**
  39999. * @hidden
  40000. * Backing Filed
  40001. */
  40002. _selectionOctree: Octree<AbstractMesh>;
  40003. /**
  40004. * Gets the octree used to boost mesh selection (picking)
  40005. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40006. */
  40007. selectionOctree: Octree<AbstractMesh>;
  40008. /**
  40009. * Creates or updates the octree used to boost selection (picking)
  40010. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40011. * @param maxCapacity defines the maximum capacity per leaf
  40012. * @param maxDepth defines the maximum depth of the octree
  40013. * @returns an octree of AbstractMesh
  40014. */
  40015. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40016. }
  40017. interface AbstractMesh {
  40018. /**
  40019. * @hidden
  40020. * Backing Field
  40021. */
  40022. _submeshesOctree: Octree<SubMesh>;
  40023. /**
  40024. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40025. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40026. * @param maxCapacity defines the maximum size of each block (64 by default)
  40027. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40028. * @returns the new octree
  40029. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40030. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40031. */
  40032. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40033. }
  40034. /**
  40035. * Defines the octree scene component responsible to manage any octrees
  40036. * in a given scene.
  40037. */
  40038. export class OctreeSceneComponent {
  40039. /**
  40040. * The component name helpfull to identify the component in the list of scene components.
  40041. */
  40042. readonly name: string;
  40043. /**
  40044. * The scene the component belongs to.
  40045. */
  40046. scene: Scene;
  40047. /**
  40048. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40049. */
  40050. readonly checksIsEnabled: boolean;
  40051. /**
  40052. * Creates a new instance of the component for the given scene
  40053. * @param scene Defines the scene to register the component in
  40054. */
  40055. constructor(scene: Scene);
  40056. /**
  40057. * Registers the component in a given scene
  40058. */
  40059. register(): void;
  40060. /**
  40061. * Return the list of active meshes
  40062. * @returns the list of active meshes
  40063. */
  40064. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40065. /**
  40066. * Return the list of active sub meshes
  40067. * @param mesh The mesh to get the candidates sub meshes from
  40068. * @returns the list of active sub meshes
  40069. */
  40070. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40071. private _tempRay;
  40072. /**
  40073. * Return the list of sub meshes intersecting with a given local ray
  40074. * @param mesh defines the mesh to find the submesh for
  40075. * @param localRay defines the ray in local space
  40076. * @returns the list of intersecting sub meshes
  40077. */
  40078. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40079. /**
  40080. * Return the list of sub meshes colliding with a collider
  40081. * @param mesh defines the mesh to find the submesh for
  40082. * @param collider defines the collider to evaluate the collision against
  40083. * @returns the list of colliding sub meshes
  40084. */
  40085. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40086. /**
  40087. * Rebuilds the elements related to this component in case of
  40088. * context lost for instance.
  40089. */
  40090. rebuild(): void;
  40091. /**
  40092. * Disposes the component and the associated ressources.
  40093. */
  40094. dispose(): void;
  40095. }
  40096. }
  40097. declare module BABYLON {
  40098. /**
  40099. * Renders a layer on top of an existing scene
  40100. */
  40101. export class UtilityLayerRenderer implements IDisposable {
  40102. /** the original scene that will be rendered on top of */
  40103. originalScene: Scene;
  40104. private _pointerCaptures;
  40105. private _lastPointerEvents;
  40106. private static _DefaultUtilityLayer;
  40107. private static _DefaultKeepDepthUtilityLayer;
  40108. /**
  40109. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40110. */
  40111. pickUtilitySceneFirst: boolean;
  40112. /**
  40113. * 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)
  40114. */
  40115. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40116. /**
  40117. * 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)
  40118. */
  40119. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40120. /**
  40121. * The scene that is rendered on top of the original scene
  40122. */
  40123. utilityLayerScene: Scene;
  40124. /**
  40125. * If the utility layer should automatically be rendered on top of existing scene
  40126. */
  40127. shouldRender: boolean;
  40128. /**
  40129. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40130. */
  40131. onlyCheckPointerDownEvents: boolean;
  40132. /**
  40133. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40134. */
  40135. processAllEvents: boolean;
  40136. /**
  40137. * Observable raised when the pointer move from the utility layer scene to the main scene
  40138. */
  40139. onPointerOutObservable: Observable<number>;
  40140. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40141. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40142. private _afterRenderObserver;
  40143. private _sceneDisposeObserver;
  40144. private _originalPointerObserver;
  40145. /**
  40146. * Instantiates a UtilityLayerRenderer
  40147. * @param originalScene the original scene that will be rendered on top of
  40148. * @param handleEvents boolean indicating if the utility layer should handle events
  40149. */
  40150. constructor(
  40151. /** the original scene that will be rendered on top of */
  40152. originalScene: Scene, handleEvents?: boolean);
  40153. private _notifyObservers;
  40154. /**
  40155. * Renders the utility layers scene on top of the original scene
  40156. */
  40157. render(): void;
  40158. /**
  40159. * Disposes of the renderer
  40160. */
  40161. dispose(): void;
  40162. private _updateCamera;
  40163. }
  40164. }
  40165. declare module BABYLON {
  40166. /**
  40167. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40168. */
  40169. export class Gizmo implements IDisposable {
  40170. /** The utility layer the gizmo will be added to */
  40171. gizmoLayer: UtilityLayerRenderer;
  40172. /**
  40173. * The root mesh of the gizmo
  40174. */
  40175. protected _rootMesh: Mesh;
  40176. private _attachedMesh;
  40177. /**
  40178. * Ratio for the scale of the gizmo (Default: 1)
  40179. */
  40180. scaleRatio: number;
  40181. private _tmpMatrix;
  40182. /**
  40183. * If a custom mesh has been set (Default: false)
  40184. */
  40185. protected _customMeshSet: boolean;
  40186. /**
  40187. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40188. * * When set, interactions will be enabled
  40189. */
  40190. attachedMesh: Nullable<AbstractMesh>;
  40191. /**
  40192. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40193. * @param mesh The mesh to replace the default mesh of the gizmo
  40194. */
  40195. setCustomMesh(mesh: Mesh): void;
  40196. /**
  40197. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40198. */
  40199. updateGizmoRotationToMatchAttachedMesh: boolean;
  40200. /**
  40201. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40202. */
  40203. updateGizmoPositionToMatchAttachedMesh: boolean;
  40204. /**
  40205. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40206. */
  40207. protected _updateScale: boolean;
  40208. protected _interactionsEnabled: boolean;
  40209. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40210. private _beforeRenderObserver;
  40211. /**
  40212. * Creates a gizmo
  40213. * @param gizmoLayer The utility layer the gizmo will be added to
  40214. */
  40215. constructor(
  40216. /** The utility layer the gizmo will be added to */
  40217. gizmoLayer?: UtilityLayerRenderer);
  40218. private _tempVector;
  40219. /**
  40220. * @hidden
  40221. * Updates the gizmo to match the attached mesh's position/rotation
  40222. */
  40223. protected _update(): void;
  40224. /**
  40225. * Disposes of the gizmo
  40226. */
  40227. dispose(): void;
  40228. }
  40229. }
  40230. declare module BABYLON {
  40231. /**
  40232. * Single axis drag gizmo
  40233. */
  40234. export class AxisDragGizmo extends Gizmo {
  40235. /**
  40236. * Drag behavior responsible for the gizmos dragging interactions
  40237. */
  40238. dragBehavior: PointerDragBehavior;
  40239. private _pointerObserver;
  40240. /**
  40241. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40242. */
  40243. snapDistance: number;
  40244. /**
  40245. * Event that fires each time the gizmo snaps to a new location.
  40246. * * snapDistance is the the change in distance
  40247. */
  40248. onSnapObservable: Observable<{
  40249. snapDistance: number;
  40250. }>;
  40251. /** @hidden */
  40252. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40253. /** @hidden */
  40254. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40255. /**
  40256. * Creates an AxisDragGizmo
  40257. * @param gizmoLayer The utility layer the gizmo will be added to
  40258. * @param dragAxis The axis which the gizmo will be able to drag on
  40259. * @param color The color of the gizmo
  40260. */
  40261. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40262. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40263. /**
  40264. * Disposes of the gizmo
  40265. */
  40266. dispose(): void;
  40267. }
  40268. }
  40269. declare module BABYLON.Debug {
  40270. /**
  40271. * The Axes viewer will show 3 axes in a specific point in space
  40272. */
  40273. export class AxesViewer {
  40274. private _xAxis;
  40275. private _yAxis;
  40276. private _zAxis;
  40277. private _scaleLinesFactor;
  40278. private _instanced;
  40279. /**
  40280. * Gets the hosting scene
  40281. */
  40282. scene: Scene;
  40283. /**
  40284. * Gets or sets a number used to scale line length
  40285. */
  40286. scaleLines: number;
  40287. /** Gets the node hierarchy used to render x-axis */
  40288. readonly xAxis: TransformNode;
  40289. /** Gets the node hierarchy used to render y-axis */
  40290. readonly yAxis: TransformNode;
  40291. /** Gets the node hierarchy used to render z-axis */
  40292. readonly zAxis: TransformNode;
  40293. /**
  40294. * Creates a new AxesViewer
  40295. * @param scene defines the hosting scene
  40296. * @param scaleLines defines a number used to scale line length (1 by default)
  40297. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40298. * @param xAxis defines the node hierarchy used to render the x-axis
  40299. * @param yAxis defines the node hierarchy used to render the y-axis
  40300. * @param zAxis defines the node hierarchy used to render the z-axis
  40301. */
  40302. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40303. /**
  40304. * Force the viewer to update
  40305. * @param position defines the position of the viewer
  40306. * @param xaxis defines the x axis of the viewer
  40307. * @param yaxis defines the y axis of the viewer
  40308. * @param zaxis defines the z axis of the viewer
  40309. */
  40310. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40311. /**
  40312. * Creates an instance of this axes viewer.
  40313. * @returns a new axes viewer with instanced meshes
  40314. */
  40315. createInstance(): AxesViewer;
  40316. /** Releases resources */
  40317. dispose(): void;
  40318. private static _SetRenderingGroupId;
  40319. }
  40320. }
  40321. declare module BABYLON.Debug {
  40322. /**
  40323. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40324. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40325. */
  40326. export class BoneAxesViewer extends AxesViewer {
  40327. /**
  40328. * Gets or sets the target mesh where to display the axes viewer
  40329. */
  40330. mesh: Nullable<Mesh>;
  40331. /**
  40332. * Gets or sets the target bone where to display the axes viewer
  40333. */
  40334. bone: Nullable<Bone>;
  40335. /** Gets current position */
  40336. pos: Vector3;
  40337. /** Gets direction of X axis */
  40338. xaxis: Vector3;
  40339. /** Gets direction of Y axis */
  40340. yaxis: Vector3;
  40341. /** Gets direction of Z axis */
  40342. zaxis: Vector3;
  40343. /**
  40344. * Creates a new BoneAxesViewer
  40345. * @param scene defines the hosting scene
  40346. * @param bone defines the target bone
  40347. * @param mesh defines the target mesh
  40348. * @param scaleLines defines a scaling factor for line length (1 by default)
  40349. */
  40350. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40351. /**
  40352. * Force the viewer to update
  40353. */
  40354. update(): void;
  40355. /** Releases resources */
  40356. dispose(): void;
  40357. }
  40358. }
  40359. declare module BABYLON {
  40360. /**
  40361. * Interface used to define scene explorer extensibility option
  40362. */
  40363. export interface IExplorerExtensibilityOption {
  40364. /**
  40365. * Define the option label
  40366. */
  40367. label: string;
  40368. /**
  40369. * Defines the action to execute on click
  40370. */
  40371. action: (entity: any) => void;
  40372. }
  40373. /**
  40374. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40375. */
  40376. export interface IExplorerExtensibilityGroup {
  40377. /**
  40378. * Defines a predicate to test if a given type mut be extended
  40379. */
  40380. predicate: (entity: any) => boolean;
  40381. /**
  40382. * Gets the list of options added to a type
  40383. */
  40384. entries: IExplorerExtensibilityOption[];
  40385. }
  40386. /**
  40387. * Interface used to define the options to use to create the Inspector
  40388. */
  40389. export interface IInspectorOptions {
  40390. /**
  40391. * Display in overlay mode (default: false)
  40392. */
  40393. overlay?: boolean;
  40394. /**
  40395. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40396. */
  40397. globalRoot?: HTMLElement;
  40398. /**
  40399. * Display the Scene explorer
  40400. */
  40401. showExplorer?: boolean;
  40402. /**
  40403. * Display the property inspector
  40404. */
  40405. showInspector?: boolean;
  40406. /**
  40407. * Display in embed mode (both panes on the right)
  40408. */
  40409. embedMode?: boolean;
  40410. /**
  40411. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40412. */
  40413. handleResize?: boolean;
  40414. /**
  40415. * Allow the panes to popup (default: true)
  40416. */
  40417. enablePopup?: boolean;
  40418. /**
  40419. * Allow the panes to be closed by users (default: true)
  40420. */
  40421. enableClose?: boolean;
  40422. /**
  40423. * Optional list of extensibility entries
  40424. */
  40425. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40426. }
  40427. interface Scene {
  40428. /**
  40429. * @hidden
  40430. * Backing field
  40431. */
  40432. _debugLayer: DebugLayer;
  40433. /**
  40434. * Gets the debug layer (aka Inspector) associated with the scene
  40435. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40436. */
  40437. debugLayer: DebugLayer;
  40438. }
  40439. /**
  40440. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40441. * what is happening in your scene
  40442. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40443. */
  40444. export class DebugLayer {
  40445. /**
  40446. * Define the url to get the inspector script from.
  40447. * By default it uses the babylonjs CDN.
  40448. * @ignoreNaming
  40449. */
  40450. static InspectorURL: string;
  40451. private _scene;
  40452. private BJSINSPECTOR;
  40453. /**
  40454. * Observable triggered when a property is changed through the inspector.
  40455. */
  40456. onPropertyChangedObservable: Observable<{
  40457. object: any;
  40458. property: string;
  40459. value: any;
  40460. initialValue: any;
  40461. }>;
  40462. /**
  40463. * Instantiates a new debug layer.
  40464. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40465. * what is happening in your scene
  40466. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40467. * @param scene Defines the scene to inspect
  40468. */
  40469. constructor(scene: Scene);
  40470. /** Creates the inspector window. */
  40471. private _createInspector;
  40472. /** Get the inspector from bundle or global */
  40473. private _getGlobalInspector;
  40474. /**
  40475. * Get if the inspector is visible or not.
  40476. * @returns true if visible otherwise, false
  40477. */
  40478. isVisible(): boolean;
  40479. /**
  40480. * Hide the inspector and close its window.
  40481. */
  40482. hide(): void;
  40483. /**
  40484. * Launch the debugLayer.
  40485. * @param config Define the configuration of the inspector
  40486. */
  40487. show(config?: IInspectorOptions): void;
  40488. }
  40489. }
  40490. declare module BABYLON.Debug {
  40491. /**
  40492. * Used to show the physics impostor around the specific mesh
  40493. */
  40494. export class PhysicsViewer {
  40495. /** @hidden */
  40496. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40497. /** @hidden */
  40498. protected _meshes: Array<Nullable<AbstractMesh>>;
  40499. /** @hidden */
  40500. protected _scene: Nullable<Scene>;
  40501. /** @hidden */
  40502. protected _numMeshes: number;
  40503. /** @hidden */
  40504. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40505. private _renderFunction;
  40506. private _utilityLayer;
  40507. private _debugBoxMesh;
  40508. private _debugSphereMesh;
  40509. private _debugMaterial;
  40510. /**
  40511. * Creates a new PhysicsViewer
  40512. * @param scene defines the hosting scene
  40513. */
  40514. constructor(scene: Scene);
  40515. /** @hidden */
  40516. protected _updateDebugMeshes(): void;
  40517. /**
  40518. * Renders a specified physic impostor
  40519. * @param impostor defines the impostor to render
  40520. * @returns the new debug mesh used to render the impostor
  40521. */
  40522. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  40523. /**
  40524. * Hides a specified physic impostor
  40525. * @param impostor defines the impostor to hide
  40526. */
  40527. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  40528. private _getDebugMaterial;
  40529. private _getDebugBoxMesh;
  40530. private _getDebugSphereMesh;
  40531. private _getDebugMesh;
  40532. /** Releases all resources */
  40533. dispose(): void;
  40534. }
  40535. }
  40536. declare module BABYLON {
  40537. /**
  40538. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40539. * in order to better appreciate the issue one might have.
  40540. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40541. */
  40542. export class RayHelper {
  40543. /**
  40544. * Defines the ray we are currently tryin to visualize.
  40545. */
  40546. ray: Nullable<Ray>;
  40547. private _renderPoints;
  40548. private _renderLine;
  40549. private _renderFunction;
  40550. private _scene;
  40551. private _updateToMeshFunction;
  40552. private _attachedToMesh;
  40553. private _meshSpaceDirection;
  40554. private _meshSpaceOrigin;
  40555. /**
  40556. * Helper function to create a colored helper in a scene in one line.
  40557. * @param ray Defines the ray we are currently tryin to visualize
  40558. * @param scene Defines the scene the ray is used in
  40559. * @param color Defines the color we want to see the ray in
  40560. * @returns The newly created ray helper.
  40561. */
  40562. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  40563. /**
  40564. * Instantiate a new ray helper.
  40565. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40566. * in order to better appreciate the issue one might have.
  40567. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40568. * @param ray Defines the ray we are currently tryin to visualize
  40569. */
  40570. constructor(ray: Ray);
  40571. /**
  40572. * Shows the ray we are willing to debug.
  40573. * @param scene Defines the scene the ray needs to be rendered in
  40574. * @param color Defines the color the ray needs to be rendered in
  40575. */
  40576. show(scene: Scene, color?: Color3): void;
  40577. /**
  40578. * Hides the ray we are debugging.
  40579. */
  40580. hide(): void;
  40581. private _render;
  40582. /**
  40583. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  40584. * @param mesh Defines the mesh we want the helper attached to
  40585. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  40586. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  40587. * @param length Defines the length of the ray
  40588. */
  40589. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  40590. /**
  40591. * Detach the ray helper from the mesh it has previously been attached to.
  40592. */
  40593. detachFromMesh(): void;
  40594. private _updateToMesh;
  40595. /**
  40596. * Dispose the helper and release its associated resources.
  40597. */
  40598. dispose(): void;
  40599. }
  40600. }
  40601. declare module BABYLON.Debug {
  40602. /**
  40603. * Class used to render a debug view of a given skeleton
  40604. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  40605. */
  40606. export class SkeletonViewer {
  40607. /** defines the skeleton to render */
  40608. skeleton: Skeleton;
  40609. /** defines the mesh attached to the skeleton */
  40610. mesh: AbstractMesh;
  40611. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40612. autoUpdateBonesMatrices: boolean;
  40613. /** defines the rendering group id to use with the viewer */
  40614. renderingGroupId: number;
  40615. /** Gets or sets the color used to render the skeleton */
  40616. color: Color3;
  40617. private _scene;
  40618. private _debugLines;
  40619. private _debugMesh;
  40620. private _isEnabled;
  40621. private _renderFunction;
  40622. private _utilityLayer;
  40623. /**
  40624. * Returns the mesh used to render the bones
  40625. */
  40626. readonly debugMesh: Nullable<LinesMesh>;
  40627. /**
  40628. * Creates a new SkeletonViewer
  40629. * @param skeleton defines the skeleton to render
  40630. * @param mesh defines the mesh attached to the skeleton
  40631. * @param scene defines the hosting scene
  40632. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  40633. * @param renderingGroupId defines the rendering group id to use with the viewer
  40634. */
  40635. constructor(
  40636. /** defines the skeleton to render */
  40637. skeleton: Skeleton,
  40638. /** defines the mesh attached to the skeleton */
  40639. mesh: AbstractMesh, scene: Scene,
  40640. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40641. autoUpdateBonesMatrices?: boolean,
  40642. /** defines the rendering group id to use with the viewer */
  40643. renderingGroupId?: number);
  40644. /** Gets or sets a boolean indicating if the viewer is enabled */
  40645. isEnabled: boolean;
  40646. private _getBonePosition;
  40647. private _getLinesForBonesWithLength;
  40648. private _getLinesForBonesNoLength;
  40649. /** Update the viewer to sync with current skeleton state */
  40650. update(): void;
  40651. /** Release associated resources */
  40652. dispose(): void;
  40653. }
  40654. }
  40655. declare module BABYLON {
  40656. /**
  40657. * Options to create the null engine
  40658. */
  40659. export class NullEngineOptions {
  40660. /**
  40661. * Render width (Default: 512)
  40662. */
  40663. renderWidth: number;
  40664. /**
  40665. * Render height (Default: 256)
  40666. */
  40667. renderHeight: number;
  40668. /**
  40669. * Texture size (Default: 512)
  40670. */
  40671. textureSize: number;
  40672. /**
  40673. * If delta time between frames should be constant
  40674. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40675. */
  40676. deterministicLockstep: boolean;
  40677. /**
  40678. * Maximum about of steps between frames (Default: 4)
  40679. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40680. */
  40681. lockstepMaxSteps: number;
  40682. }
  40683. /**
  40684. * The null engine class provides support for headless version of babylon.js.
  40685. * This can be used in server side scenario or for testing purposes
  40686. */
  40687. export class NullEngine extends Engine {
  40688. private _options;
  40689. /**
  40690. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40691. */
  40692. isDeterministicLockStep(): boolean;
  40693. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  40694. getLockstepMaxSteps(): number;
  40695. /**
  40696. * Sets hardware scaling, used to save performance if needed
  40697. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  40698. */
  40699. getHardwareScalingLevel(): number;
  40700. constructor(options?: NullEngineOptions);
  40701. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  40702. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  40703. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40704. getRenderWidth(useScreen?: boolean): number;
  40705. getRenderHeight(useScreen?: boolean): number;
  40706. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  40707. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  40708. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  40709. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  40710. bindSamplers(effect: Effect): void;
  40711. enableEffect(effect: Effect): void;
  40712. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40713. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  40714. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  40715. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  40716. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  40717. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  40718. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  40719. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  40720. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  40721. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  40722. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  40723. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  40724. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  40725. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  40726. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  40727. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40728. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40729. setFloat(uniform: WebGLUniformLocation, value: number): void;
  40730. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  40731. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  40732. setBool(uniform: WebGLUniformLocation, bool: number): void;
  40733. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  40734. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  40735. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  40736. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  40737. bindBuffers(vertexBuffers: {
  40738. [key: string]: VertexBuffer;
  40739. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  40740. wipeCaches(bruteForce?: boolean): void;
  40741. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40742. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40743. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40744. /** @hidden */
  40745. _createTexture(): WebGLTexture;
  40746. /** @hidden */
  40747. _releaseTexture(texture: InternalTexture): void;
  40748. 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;
  40749. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  40750. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  40751. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  40752. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40753. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  40754. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  40755. areAllEffectsReady(): boolean;
  40756. /**
  40757. * @hidden
  40758. * Get the current error code of the webGL context
  40759. * @returns the error code
  40760. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40761. */
  40762. getError(): number;
  40763. /** @hidden */
  40764. _getUnpackAlignement(): number;
  40765. /** @hidden */
  40766. _unpackFlipY(value: boolean): void;
  40767. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  40768. /**
  40769. * Updates a dynamic vertex buffer.
  40770. * @param vertexBuffer the vertex buffer to update
  40771. * @param data the data used to update the vertex buffer
  40772. * @param byteOffset the byte offset of the data (optional)
  40773. * @param byteLength the byte length of the data (optional)
  40774. */
  40775. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  40776. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  40777. /** @hidden */
  40778. _bindTexture(channel: number, texture: InternalTexture): void;
  40779. /** @hidden */
  40780. _releaseBuffer(buffer: WebGLBuffer): boolean;
  40781. releaseEffects(): void;
  40782. displayLoadingUI(): void;
  40783. hideLoadingUI(): void;
  40784. /** @hidden */
  40785. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40786. /** @hidden */
  40787. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40788. /** @hidden */
  40789. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40790. /** @hidden */
  40791. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  40792. }
  40793. }
  40794. declare module BABYLON {
  40795. /** @hidden */
  40796. export class _OcclusionDataStorage {
  40797. /** @hidden */
  40798. occlusionInternalRetryCounter: number;
  40799. /** @hidden */
  40800. isOcclusionQueryInProgress: boolean;
  40801. /** @hidden */
  40802. isOccluded: boolean;
  40803. /** @hidden */
  40804. occlusionRetryCount: number;
  40805. /** @hidden */
  40806. occlusionType: number;
  40807. /** @hidden */
  40808. occlusionQueryAlgorithmType: number;
  40809. }
  40810. interface Engine {
  40811. /**
  40812. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  40813. * @return the new query
  40814. */
  40815. createQuery(): WebGLQuery;
  40816. /**
  40817. * Delete and release a webGL query
  40818. * @param query defines the query to delete
  40819. * @return the current engine
  40820. */
  40821. deleteQuery(query: WebGLQuery): Engine;
  40822. /**
  40823. * Check if a given query has resolved and got its value
  40824. * @param query defines the query to check
  40825. * @returns true if the query got its value
  40826. */
  40827. isQueryResultAvailable(query: WebGLQuery): boolean;
  40828. /**
  40829. * Gets the value of a given query
  40830. * @param query defines the query to check
  40831. * @returns the value of the query
  40832. */
  40833. getQueryResult(query: WebGLQuery): number;
  40834. /**
  40835. * Initiates an occlusion query
  40836. * @param algorithmType defines the algorithm to use
  40837. * @param query defines the query to use
  40838. * @returns the current engine
  40839. * @see http://doc.babylonjs.com/features/occlusionquery
  40840. */
  40841. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  40842. /**
  40843. * Ends an occlusion query
  40844. * @see http://doc.babylonjs.com/features/occlusionquery
  40845. * @param algorithmType defines the algorithm to use
  40846. * @returns the current engine
  40847. */
  40848. endOcclusionQuery(algorithmType: number): Engine;
  40849. /**
  40850. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  40851. * Please note that only one query can be issued at a time
  40852. * @returns a time token used to track the time span
  40853. */
  40854. startTimeQuery(): Nullable<_TimeToken>;
  40855. /**
  40856. * Ends a time query
  40857. * @param token defines the token used to measure the time span
  40858. * @returns the time spent (in ns)
  40859. */
  40860. endTimeQuery(token: _TimeToken): int;
  40861. /** @hidden */
  40862. _currentNonTimestampToken: Nullable<_TimeToken>;
  40863. /** @hidden */
  40864. _createTimeQuery(): WebGLQuery;
  40865. /** @hidden */
  40866. _deleteTimeQuery(query: WebGLQuery): void;
  40867. /** @hidden */
  40868. _getGlAlgorithmType(algorithmType: number): number;
  40869. /** @hidden */
  40870. _getTimeQueryResult(query: WebGLQuery): any;
  40871. /** @hidden */
  40872. _getTimeQueryAvailability(query: WebGLQuery): any;
  40873. }
  40874. interface AbstractMesh {
  40875. /**
  40876. * Backing filed
  40877. * @hidden
  40878. */
  40879. __occlusionDataStorage: _OcclusionDataStorage;
  40880. /**
  40881. * Access property
  40882. * @hidden
  40883. */
  40884. _occlusionDataStorage: _OcclusionDataStorage;
  40885. /**
  40886. * 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.
  40887. * The default value is -1 which means don't break the query and wait till the result
  40888. * @see http://doc.babylonjs.com/features/occlusionquery
  40889. */
  40890. occlusionRetryCount: number;
  40891. /**
  40892. * 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:
  40893. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  40894. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  40895. * * 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.
  40896. * @see http://doc.babylonjs.com/features/occlusionquery
  40897. */
  40898. occlusionType: number;
  40899. /**
  40900. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  40901. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  40902. * * 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.
  40903. * @see http://doc.babylonjs.com/features/occlusionquery
  40904. */
  40905. occlusionQueryAlgorithmType: number;
  40906. /**
  40907. * 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
  40908. * @see http://doc.babylonjs.com/features/occlusionquery
  40909. */
  40910. isOccluded: boolean;
  40911. /**
  40912. * Flag to check the progress status of the query
  40913. * @see http://doc.babylonjs.com/features/occlusionquery
  40914. */
  40915. isOcclusionQueryInProgress: boolean;
  40916. }
  40917. }
  40918. declare module BABYLON {
  40919. /** @hidden */
  40920. export var _forceTransformFeedbackToBundle: boolean;
  40921. interface Engine {
  40922. /**
  40923. * Creates a webGL transform feedback object
  40924. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  40925. * @returns the webGL transform feedback object
  40926. */
  40927. createTransformFeedback(): WebGLTransformFeedback;
  40928. /**
  40929. * Delete a webGL transform feedback object
  40930. * @param value defines the webGL transform feedback object to delete
  40931. */
  40932. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  40933. /**
  40934. * Bind a webGL transform feedback object to the webgl context
  40935. * @param value defines the webGL transform feedback object to bind
  40936. */
  40937. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  40938. /**
  40939. * Begins a transform feedback operation
  40940. * @param usePoints defines if points or triangles must be used
  40941. */
  40942. beginTransformFeedback(usePoints: boolean): void;
  40943. /**
  40944. * Ends a transform feedback operation
  40945. */
  40946. endTransformFeedback(): void;
  40947. /**
  40948. * Specify the varyings to use with transform feedback
  40949. * @param program defines the associated webGL program
  40950. * @param value defines the list of strings representing the varying names
  40951. */
  40952. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  40953. /**
  40954. * Bind a webGL buffer for a transform feedback operation
  40955. * @param value defines the webGL buffer to bind
  40956. */
  40957. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  40958. }
  40959. }
  40960. declare module BABYLON {
  40961. /**
  40962. * Gather the list of clipboard event types as constants.
  40963. */
  40964. export class ClipboardEventTypes {
  40965. /**
  40966. * The clipboard event is fired when a copy command is active (pressed).
  40967. */
  40968. static readonly COPY: number;
  40969. /**
  40970. * The clipboard event is fired when a cut command is active (pressed).
  40971. */
  40972. static readonly CUT: number;
  40973. /**
  40974. * The clipboard event is fired when a paste command is active (pressed).
  40975. */
  40976. static readonly PASTE: number;
  40977. }
  40978. /**
  40979. * This class is used to store clipboard related info for the onClipboardObservable event.
  40980. */
  40981. export class ClipboardInfo {
  40982. /**
  40983. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40984. */
  40985. type: number;
  40986. /**
  40987. * Defines the related dom event
  40988. */
  40989. event: ClipboardEvent;
  40990. /**
  40991. *Creates an instance of ClipboardInfo.
  40992. * @param {number} type
  40993. * @param {ClipboardEvent} event
  40994. */
  40995. constructor(
  40996. /**
  40997. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40998. */
  40999. type: number,
  41000. /**
  41001. * Defines the related dom event
  41002. */
  41003. event: ClipboardEvent);
  41004. /**
  41005. * Get the clipboard event's type from the keycode.
  41006. * @param keyCode Defines the keyCode for the current keyboard event.
  41007. * @return {number}
  41008. */
  41009. static GetTypeFromCharacter(keyCode: number): number;
  41010. }
  41011. }
  41012. declare module BABYLON {
  41013. /**
  41014. * Class used to represent data loading progression
  41015. */
  41016. export class SceneLoaderProgressEvent {
  41017. /** defines if data length to load can be evaluated */
  41018. readonly lengthComputable: boolean;
  41019. /** defines the loaded data length */
  41020. readonly loaded: number;
  41021. /** defines the data length to load */
  41022. readonly total: number;
  41023. /**
  41024. * Create a new progress event
  41025. * @param lengthComputable defines if data length to load can be evaluated
  41026. * @param loaded defines the loaded data length
  41027. * @param total defines the data length to load
  41028. */
  41029. constructor(
  41030. /** defines if data length to load can be evaluated */
  41031. lengthComputable: boolean,
  41032. /** defines the loaded data length */
  41033. loaded: number,
  41034. /** defines the data length to load */
  41035. total: number);
  41036. /**
  41037. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41038. * @param event defines the source event
  41039. * @returns a new SceneLoaderProgressEvent
  41040. */
  41041. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41042. }
  41043. /**
  41044. * Interface used by SceneLoader plugins to define supported file extensions
  41045. */
  41046. export interface ISceneLoaderPluginExtensions {
  41047. /**
  41048. * Defines the list of supported extensions
  41049. */
  41050. [extension: string]: {
  41051. isBinary: boolean;
  41052. };
  41053. }
  41054. /**
  41055. * Interface used by SceneLoader plugin factory
  41056. */
  41057. export interface ISceneLoaderPluginFactory {
  41058. /**
  41059. * Defines the name of the factory
  41060. */
  41061. name: string;
  41062. /**
  41063. * Function called to create a new plugin
  41064. * @return the new plugin
  41065. */
  41066. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41067. /**
  41068. * Boolean indicating if the plugin can direct load specific data
  41069. */
  41070. canDirectLoad?: (data: string) => boolean;
  41071. }
  41072. /**
  41073. * Interface used to define a SceneLoader plugin
  41074. */
  41075. export interface ISceneLoaderPlugin {
  41076. /**
  41077. * The friendly name of this plugin.
  41078. */
  41079. name: string;
  41080. /**
  41081. * The file extensions supported by this plugin.
  41082. */
  41083. extensions: string | ISceneLoaderPluginExtensions;
  41084. /**
  41085. * Import meshes into a scene.
  41086. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41087. * @param scene The scene to import into
  41088. * @param data The data to import
  41089. * @param rootUrl The root url for scene and resources
  41090. * @param meshes The meshes array to import into
  41091. * @param particleSystems The particle systems array to import into
  41092. * @param skeletons The skeletons array to import into
  41093. * @param onError The callback when import fails
  41094. * @returns True if successful or false otherwise
  41095. */
  41096. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41097. /**
  41098. * Load into a scene.
  41099. * @param scene The scene to load into
  41100. * @param data The data to import
  41101. * @param rootUrl The root url for scene and resources
  41102. * @param onError The callback when import fails
  41103. * @returns true if successful or false otherwise
  41104. */
  41105. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41106. /**
  41107. * The callback that returns true if the data can be directly loaded.
  41108. */
  41109. canDirectLoad?: (data: string) => boolean;
  41110. /**
  41111. * The callback that allows custom handling of the root url based on the response url.
  41112. */
  41113. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41114. /**
  41115. * Load into an asset container.
  41116. * @param scene The scene to load into
  41117. * @param data The data to import
  41118. * @param rootUrl The root url for scene and resources
  41119. * @param onError The callback when import fails
  41120. * @returns The loaded asset container
  41121. */
  41122. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41123. }
  41124. /**
  41125. * Interface used to define an async SceneLoader plugin
  41126. */
  41127. export interface ISceneLoaderPluginAsync {
  41128. /**
  41129. * The friendly name of this plugin.
  41130. */
  41131. name: string;
  41132. /**
  41133. * The file extensions supported by this plugin.
  41134. */
  41135. extensions: string | ISceneLoaderPluginExtensions;
  41136. /**
  41137. * Import meshes into a scene.
  41138. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41139. * @param scene The scene to import into
  41140. * @param data The data to import
  41141. * @param rootUrl The root url for scene and resources
  41142. * @param onProgress The callback when the load progresses
  41143. * @param fileName Defines the name of the file to load
  41144. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41145. */
  41146. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41147. meshes: AbstractMesh[];
  41148. particleSystems: IParticleSystem[];
  41149. skeletons: Skeleton[];
  41150. animationGroups: AnimationGroup[];
  41151. }>;
  41152. /**
  41153. * Load into a scene.
  41154. * @param scene The scene to load into
  41155. * @param data The data to import
  41156. * @param rootUrl The root url for scene and resources
  41157. * @param onProgress The callback when the load progresses
  41158. * @param fileName Defines the name of the file to load
  41159. * @returns Nothing
  41160. */
  41161. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41162. /**
  41163. * The callback that returns true if the data can be directly loaded.
  41164. */
  41165. canDirectLoad?: (data: string) => boolean;
  41166. /**
  41167. * The callback that allows custom handling of the root url based on the response url.
  41168. */
  41169. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41170. /**
  41171. * Load into an asset container.
  41172. * @param scene The scene to load into
  41173. * @param data The data to import
  41174. * @param rootUrl The root url for scene and resources
  41175. * @param onProgress The callback when the load progresses
  41176. * @param fileName Defines the name of the file to load
  41177. * @returns The loaded asset container
  41178. */
  41179. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41180. }
  41181. /**
  41182. * Class used to load scene from various file formats using registered plugins
  41183. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41184. */
  41185. export class SceneLoader {
  41186. /**
  41187. * No logging while loading
  41188. */
  41189. static readonly NO_LOGGING: number;
  41190. /**
  41191. * Minimal logging while loading
  41192. */
  41193. static readonly MINIMAL_LOGGING: number;
  41194. /**
  41195. * Summary logging while loading
  41196. */
  41197. static readonly SUMMARY_LOGGING: number;
  41198. /**
  41199. * Detailled logging while loading
  41200. */
  41201. static readonly DETAILED_LOGGING: number;
  41202. /**
  41203. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41204. */
  41205. static ForceFullSceneLoadingForIncremental: boolean;
  41206. /**
  41207. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41208. */
  41209. static ShowLoadingScreen: boolean;
  41210. /**
  41211. * Defines the current logging level (while loading the scene)
  41212. * @ignorenaming
  41213. */
  41214. static loggingLevel: number;
  41215. /**
  41216. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41217. */
  41218. static CleanBoneMatrixWeights: boolean;
  41219. /**
  41220. * Event raised when a plugin is used to load a scene
  41221. */
  41222. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41223. private static _registeredPlugins;
  41224. private static _getDefaultPlugin;
  41225. private static _getPluginForExtension;
  41226. private static _getPluginForDirectLoad;
  41227. private static _getPluginForFilename;
  41228. private static _getDirectLoad;
  41229. private static _loadData;
  41230. private static _getFileInfo;
  41231. /**
  41232. * Gets a plugin that can load the given extension
  41233. * @param extension defines the extension to load
  41234. * @returns a plugin or null if none works
  41235. */
  41236. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41237. /**
  41238. * Gets a boolean indicating that the given extension can be loaded
  41239. * @param extension defines the extension to load
  41240. * @returns true if the extension is supported
  41241. */
  41242. static IsPluginForExtensionAvailable(extension: string): boolean;
  41243. /**
  41244. * Adds a new plugin to the list of registered plugins
  41245. * @param plugin defines the plugin to add
  41246. */
  41247. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41248. /**
  41249. * Import meshes into a scene
  41250. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41251. * @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)
  41252. * @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)
  41253. * @param scene the instance of BABYLON.Scene to append to
  41254. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41255. * @param onProgress a callback with a progress event for each file being loaded
  41256. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41257. * @param pluginExtension the extension used to determine the plugin
  41258. * @returns The loaded plugin
  41259. */
  41260. 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>;
  41261. /**
  41262. * Import meshes into a scene
  41263. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41264. * @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)
  41265. * @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)
  41266. * @param scene the instance of BABYLON.Scene to append to
  41267. * @param onProgress a callback with a progress event for each file being loaded
  41268. * @param pluginExtension the extension used to determine the plugin
  41269. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41270. */
  41271. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41272. meshes: AbstractMesh[];
  41273. particleSystems: IParticleSystem[];
  41274. skeletons: Skeleton[];
  41275. animationGroups: AnimationGroup[];
  41276. }>;
  41277. /**
  41278. * Load a scene
  41279. * @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)
  41280. * @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)
  41281. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41282. * @param onSuccess a callback with the scene when import succeeds
  41283. * @param onProgress a callback with a progress event for each file being loaded
  41284. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41285. * @param pluginExtension the extension used to determine the plugin
  41286. * @returns The loaded plugin
  41287. */
  41288. 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>;
  41289. /**
  41290. * Load a scene
  41291. * @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)
  41292. * @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)
  41293. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41294. * @param onProgress a callback with a progress event for each file being loaded
  41295. * @param pluginExtension the extension used to determine the plugin
  41296. * @returns The loaded scene
  41297. */
  41298. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41299. /**
  41300. * Append a scene
  41301. * @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)
  41302. * @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)
  41303. * @param scene is the instance of BABYLON.Scene to append to
  41304. * @param onSuccess a callback with the scene when import succeeds
  41305. * @param onProgress a callback with a progress event for each file being loaded
  41306. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41307. * @param pluginExtension the extension used to determine the plugin
  41308. * @returns The loaded plugin
  41309. */
  41310. 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>;
  41311. /**
  41312. * Append a scene
  41313. * @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)
  41314. * @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)
  41315. * @param scene is the instance of BABYLON.Scene to append to
  41316. * @param onProgress a callback with a progress event for each file being loaded
  41317. * @param pluginExtension the extension used to determine the plugin
  41318. * @returns The given scene
  41319. */
  41320. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41321. /**
  41322. * Load a scene into an asset container
  41323. * @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)
  41324. * @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)
  41325. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41326. * @param onSuccess a callback with the scene when import succeeds
  41327. * @param onProgress a callback with a progress event for each file being loaded
  41328. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41329. * @param pluginExtension the extension used to determine the plugin
  41330. * @returns The loaded plugin
  41331. */
  41332. 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>;
  41333. /**
  41334. * Load a scene into an asset container
  41335. * @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)
  41336. * @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)
  41337. * @param scene is the instance of Scene to append to
  41338. * @param onProgress a callback with a progress event for each file being loaded
  41339. * @param pluginExtension the extension used to determine the plugin
  41340. * @returns The loaded asset container
  41341. */
  41342. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41343. }
  41344. }
  41345. declare module BABYLON {
  41346. /**
  41347. * Google Daydream controller
  41348. */
  41349. export class DaydreamController extends WebVRController {
  41350. /**
  41351. * Base Url for the controller model.
  41352. */
  41353. static MODEL_BASE_URL: string;
  41354. /**
  41355. * File name for the controller model.
  41356. */
  41357. static MODEL_FILENAME: string;
  41358. /**
  41359. * Gamepad Id prefix used to identify Daydream Controller.
  41360. */
  41361. static readonly GAMEPAD_ID_PREFIX: string;
  41362. /**
  41363. * Creates a new DaydreamController from a gamepad
  41364. * @param vrGamepad the gamepad that the controller should be created from
  41365. */
  41366. constructor(vrGamepad: any);
  41367. /**
  41368. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41369. * @param scene scene in which to add meshes
  41370. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41371. */
  41372. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41373. /**
  41374. * Called once for each button that changed state since the last frame
  41375. * @param buttonIdx Which button index changed
  41376. * @param state New state of the button
  41377. * @param changes Which properties on the state changed since last frame
  41378. */
  41379. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41380. }
  41381. }
  41382. declare module BABYLON {
  41383. /**
  41384. * Gear VR Controller
  41385. */
  41386. export class GearVRController extends WebVRController {
  41387. /**
  41388. * Base Url for the controller model.
  41389. */
  41390. static MODEL_BASE_URL: string;
  41391. /**
  41392. * File name for the controller model.
  41393. */
  41394. static MODEL_FILENAME: string;
  41395. /**
  41396. * Gamepad Id prefix used to identify this controller.
  41397. */
  41398. static readonly GAMEPAD_ID_PREFIX: string;
  41399. private readonly _buttonIndexToObservableNameMap;
  41400. /**
  41401. * Creates a new GearVRController from a gamepad
  41402. * @param vrGamepad the gamepad that the controller should be created from
  41403. */
  41404. constructor(vrGamepad: any);
  41405. /**
  41406. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41407. * @param scene scene in which to add meshes
  41408. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41409. */
  41410. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41411. /**
  41412. * Called once for each button that changed state since the last frame
  41413. * @param buttonIdx Which button index changed
  41414. * @param state New state of the button
  41415. * @param changes Which properties on the state changed since last frame
  41416. */
  41417. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41418. }
  41419. }
  41420. declare module BABYLON {
  41421. /**
  41422. * Generic Controller
  41423. */
  41424. export class GenericController extends WebVRController {
  41425. /**
  41426. * Base Url for the controller model.
  41427. */
  41428. static readonly MODEL_BASE_URL: string;
  41429. /**
  41430. * File name for the controller model.
  41431. */
  41432. static readonly MODEL_FILENAME: string;
  41433. /**
  41434. * Creates a new GenericController from a gamepad
  41435. * @param vrGamepad the gamepad that the controller should be created from
  41436. */
  41437. constructor(vrGamepad: any);
  41438. /**
  41439. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41440. * @param scene scene in which to add meshes
  41441. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41442. */
  41443. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41444. /**
  41445. * Called once for each button that changed state since the last frame
  41446. * @param buttonIdx Which button index changed
  41447. * @param state New state of the button
  41448. * @param changes Which properties on the state changed since last frame
  41449. */
  41450. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41451. }
  41452. }
  41453. declare module BABYLON {
  41454. /**
  41455. * Oculus Touch Controller
  41456. */
  41457. export class OculusTouchController extends WebVRController {
  41458. /**
  41459. * Base Url for the controller model.
  41460. */
  41461. static MODEL_BASE_URL: string;
  41462. /**
  41463. * File name for the left controller model.
  41464. */
  41465. static MODEL_LEFT_FILENAME: string;
  41466. /**
  41467. * File name for the right controller model.
  41468. */
  41469. static MODEL_RIGHT_FILENAME: string;
  41470. /**
  41471. * Fired when the secondary trigger on this controller is modified
  41472. */
  41473. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41474. /**
  41475. * Fired when the thumb rest on this controller is modified
  41476. */
  41477. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41478. /**
  41479. * Creates a new OculusTouchController from a gamepad
  41480. * @param vrGamepad the gamepad that the controller should be created from
  41481. */
  41482. constructor(vrGamepad: any);
  41483. /**
  41484. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41485. * @param scene scene in which to add meshes
  41486. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41487. */
  41488. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41489. /**
  41490. * Fired when the A button on this controller is modified
  41491. */
  41492. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41493. /**
  41494. * Fired when the B button on this controller is modified
  41495. */
  41496. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41497. /**
  41498. * Fired when the X button on this controller is modified
  41499. */
  41500. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41501. /**
  41502. * Fired when the Y button on this controller is modified
  41503. */
  41504. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41505. /**
  41506. * Called once for each button that changed state since the last frame
  41507. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41508. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41509. * 2) secondary trigger (same)
  41510. * 3) A (right) X (left), touch, pressed = value
  41511. * 4) B / Y
  41512. * 5) thumb rest
  41513. * @param buttonIdx Which button index changed
  41514. * @param state New state of the button
  41515. * @param changes Which properties on the state changed since last frame
  41516. */
  41517. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41518. }
  41519. }
  41520. declare module BABYLON {
  41521. /**
  41522. * Vive Controller
  41523. */
  41524. export class ViveController extends WebVRController {
  41525. /**
  41526. * Base Url for the controller model.
  41527. */
  41528. static MODEL_BASE_URL: string;
  41529. /**
  41530. * File name for the controller model.
  41531. */
  41532. static MODEL_FILENAME: string;
  41533. /**
  41534. * Creates a new ViveController from a gamepad
  41535. * @param vrGamepad the gamepad that the controller should be created from
  41536. */
  41537. constructor(vrGamepad: any);
  41538. /**
  41539. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41540. * @param scene scene in which to add meshes
  41541. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41542. */
  41543. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41544. /**
  41545. * Fired when the left button on this controller is modified
  41546. */
  41547. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41548. /**
  41549. * Fired when the right button on this controller is modified
  41550. */
  41551. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41552. /**
  41553. * Fired when the menu button on this controller is modified
  41554. */
  41555. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41556. /**
  41557. * Called once for each button that changed state since the last frame
  41558. * Vive mapping:
  41559. * 0: touchpad
  41560. * 1: trigger
  41561. * 2: left AND right buttons
  41562. * 3: menu button
  41563. * @param buttonIdx Which button index changed
  41564. * @param state New state of the button
  41565. * @param changes Which properties on the state changed since last frame
  41566. */
  41567. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41568. }
  41569. }
  41570. declare module BABYLON {
  41571. /**
  41572. * Defines the WindowsMotionController object that the state of the windows motion controller
  41573. */
  41574. export class WindowsMotionController extends WebVRController {
  41575. /**
  41576. * The base url used to load the left and right controller models
  41577. */
  41578. static MODEL_BASE_URL: string;
  41579. /**
  41580. * The name of the left controller model file
  41581. */
  41582. static MODEL_LEFT_FILENAME: string;
  41583. /**
  41584. * The name of the right controller model file
  41585. */
  41586. static MODEL_RIGHT_FILENAME: string;
  41587. /**
  41588. * The controller name prefix for this controller type
  41589. */
  41590. static readonly GAMEPAD_ID_PREFIX: string;
  41591. /**
  41592. * The controller id pattern for this controller type
  41593. */
  41594. private static readonly GAMEPAD_ID_PATTERN;
  41595. private _loadedMeshInfo;
  41596. private readonly _mapping;
  41597. /**
  41598. * Fired when the trackpad on this controller is clicked
  41599. */
  41600. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41601. /**
  41602. * Fired when the trackpad on this controller is modified
  41603. */
  41604. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41605. /**
  41606. * The current x and y values of this controller's trackpad
  41607. */
  41608. trackpad: StickValues;
  41609. /**
  41610. * Creates a new WindowsMotionController from a gamepad
  41611. * @param vrGamepad the gamepad that the controller should be created from
  41612. */
  41613. constructor(vrGamepad: any);
  41614. /**
  41615. * Fired when the trigger on this controller is modified
  41616. */
  41617. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41618. /**
  41619. * Fired when the menu button on this controller is modified
  41620. */
  41621. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41622. /**
  41623. * Fired when the grip button on this controller is modified
  41624. */
  41625. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41626. /**
  41627. * Fired when the thumbstick button on this controller is modified
  41628. */
  41629. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41630. /**
  41631. * Fired when the touchpad button on this controller is modified
  41632. */
  41633. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41634. /**
  41635. * Fired when the touchpad values on this controller are modified
  41636. */
  41637. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41638. private _updateTrackpad;
  41639. /**
  41640. * Called once per frame by the engine.
  41641. */
  41642. update(): void;
  41643. /**
  41644. * Called once for each button that changed state since the last frame
  41645. * @param buttonIdx Which button index changed
  41646. * @param state New state of the button
  41647. * @param changes Which properties on the state changed since last frame
  41648. */
  41649. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41650. /**
  41651. * Moves the buttons on the controller mesh based on their current state
  41652. * @param buttonName the name of the button to move
  41653. * @param buttonValue the value of the button which determines the buttons new position
  41654. */
  41655. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41656. /**
  41657. * Moves the axis on the controller mesh based on its current state
  41658. * @param axis the index of the axis
  41659. * @param axisValue the value of the axis which determines the meshes new position
  41660. * @hidden
  41661. */
  41662. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41663. /**
  41664. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41665. * @param scene scene in which to add meshes
  41666. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41667. */
  41668. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41669. /**
  41670. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41671. * can be transformed by button presses and axes values, based on this._mapping.
  41672. *
  41673. * @param scene scene in which the meshes exist
  41674. * @param meshes list of meshes that make up the controller model to process
  41675. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41676. */
  41677. private processModel;
  41678. private createMeshInfo;
  41679. /**
  41680. * Gets the ray of the controller in the direction the controller is pointing
  41681. * @param length the length the resulting ray should be
  41682. * @returns a ray in the direction the controller is pointing
  41683. */
  41684. getForwardRay(length?: number): Ray;
  41685. /**
  41686. * Disposes of the controller
  41687. */
  41688. dispose(): void;
  41689. }
  41690. }
  41691. declare module BABYLON {
  41692. /**
  41693. * Manager for handling gamepads
  41694. */
  41695. export class GamepadManager {
  41696. private _scene?;
  41697. private _babylonGamepads;
  41698. private _oneGamepadConnected;
  41699. /** @hidden */
  41700. _isMonitoring: boolean;
  41701. private _gamepadEventSupported;
  41702. private _gamepadSupport;
  41703. /**
  41704. * observable to be triggered when the gamepad controller has been connected
  41705. */
  41706. onGamepadConnectedObservable: Observable<Gamepad>;
  41707. /**
  41708. * observable to be triggered when the gamepad controller has been disconnected
  41709. */
  41710. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41711. private _onGamepadConnectedEvent;
  41712. private _onGamepadDisconnectedEvent;
  41713. /**
  41714. * Initializes the gamepad manager
  41715. * @param _scene BabylonJS scene
  41716. */
  41717. constructor(_scene?: Scene | undefined);
  41718. /**
  41719. * The gamepads in the game pad manager
  41720. */
  41721. readonly gamepads: Gamepad[];
  41722. /**
  41723. * Get the gamepad controllers based on type
  41724. * @param type The type of gamepad controller
  41725. * @returns Nullable gamepad
  41726. */
  41727. getGamepadByType(type?: number): Nullable<Gamepad>;
  41728. /**
  41729. * Disposes the gamepad manager
  41730. */
  41731. dispose(): void;
  41732. private _addNewGamepad;
  41733. private _startMonitoringGamepads;
  41734. private _stopMonitoringGamepads;
  41735. /** @hidden */
  41736. _checkGamepadsStatus(): void;
  41737. private _updateGamepadObjects;
  41738. }
  41739. }
  41740. declare module BABYLON {
  41741. interface Scene {
  41742. /** @hidden */
  41743. _gamepadManager: Nullable<GamepadManager>;
  41744. /**
  41745. * Gets the gamepad manager associated with the scene
  41746. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41747. */
  41748. gamepadManager: GamepadManager;
  41749. }
  41750. /**
  41751. * Interface representing a free camera inputs manager
  41752. */
  41753. interface FreeCameraInputsManager {
  41754. /**
  41755. * Adds gamepad input support to the FreeCameraInputsManager.
  41756. * @returns the FreeCameraInputsManager
  41757. */
  41758. addGamepad(): FreeCameraInputsManager;
  41759. }
  41760. /**
  41761. * Interface representing an arc rotate camera inputs manager
  41762. */
  41763. interface ArcRotateCameraInputsManager {
  41764. /**
  41765. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41766. * @returns the camera inputs manager
  41767. */
  41768. addGamepad(): ArcRotateCameraInputsManager;
  41769. }
  41770. /**
  41771. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41772. */
  41773. export class GamepadSystemSceneComponent implements ISceneComponent {
  41774. /**
  41775. * The component name helpfull to identify the component in the list of scene components.
  41776. */
  41777. readonly name: string;
  41778. /**
  41779. * The scene the component belongs to.
  41780. */
  41781. scene: Scene;
  41782. /**
  41783. * Creates a new instance of the component for the given scene
  41784. * @param scene Defines the scene to register the component in
  41785. */
  41786. constructor(scene: Scene);
  41787. /**
  41788. * Registers the component in a given scene
  41789. */
  41790. register(): void;
  41791. /**
  41792. * Rebuilds the elements related to this component in case of
  41793. * context lost for instance.
  41794. */
  41795. rebuild(): void;
  41796. /**
  41797. * Disposes the component and the associated ressources
  41798. */
  41799. dispose(): void;
  41800. private _beforeCameraUpdate;
  41801. }
  41802. }
  41803. declare module BABYLON {
  41804. /**
  41805. * Single axis scale gizmo
  41806. */
  41807. export class AxisScaleGizmo extends Gizmo {
  41808. private _coloredMaterial;
  41809. /**
  41810. * Drag behavior responsible for the gizmos dragging interactions
  41811. */
  41812. dragBehavior: PointerDragBehavior;
  41813. private _pointerObserver;
  41814. /**
  41815. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41816. */
  41817. snapDistance: number;
  41818. /**
  41819. * Event that fires each time the gizmo snaps to a new location.
  41820. * * snapDistance is the the change in distance
  41821. */
  41822. onSnapObservable: Observable<{
  41823. snapDistance: number;
  41824. }>;
  41825. /**
  41826. * If the scaling operation should be done on all axis (default: false)
  41827. */
  41828. uniformScaling: boolean;
  41829. /**
  41830. * Creates an AxisScaleGizmo
  41831. * @param gizmoLayer The utility layer the gizmo will be added to
  41832. * @param dragAxis The axis which the gizmo will be able to scale on
  41833. * @param color The color of the gizmo
  41834. */
  41835. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41836. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41837. /**
  41838. * Disposes of the gizmo
  41839. */
  41840. dispose(): void;
  41841. /**
  41842. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41843. * @param mesh The mesh to replace the default mesh of the gizmo
  41844. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  41845. */
  41846. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  41847. }
  41848. }
  41849. declare module BABYLON {
  41850. /**
  41851. * Bounding box gizmo
  41852. */
  41853. export class BoundingBoxGizmo extends Gizmo {
  41854. private _lineBoundingBox;
  41855. private _rotateSpheresParent;
  41856. private _scaleBoxesParent;
  41857. private _boundingDimensions;
  41858. private _renderObserver;
  41859. private _pointerObserver;
  41860. private _scaleDragSpeed;
  41861. private _tmpQuaternion;
  41862. private _tmpVector;
  41863. private _tmpRotationMatrix;
  41864. /**
  41865. * 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)
  41866. */
  41867. ignoreChildren: boolean;
  41868. /**
  41869. * 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)
  41870. */
  41871. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  41872. /**
  41873. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  41874. */
  41875. rotationSphereSize: number;
  41876. /**
  41877. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  41878. */
  41879. scaleBoxSize: number;
  41880. /**
  41881. * 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)
  41882. */
  41883. fixedDragMeshScreenSize: boolean;
  41884. /**
  41885. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  41886. */
  41887. fixedDragMeshScreenSizeDistanceFactor: number;
  41888. /**
  41889. * Fired when a rotation sphere or scale box is dragged
  41890. */
  41891. onDragStartObservable: Observable<{}>;
  41892. /**
  41893. * Fired when a scale box is dragged
  41894. */
  41895. onScaleBoxDragObservable: Observable<{}>;
  41896. /**
  41897. * Fired when a scale box drag is ended
  41898. */
  41899. onScaleBoxDragEndObservable: Observable<{}>;
  41900. /**
  41901. * Fired when a rotation sphere is dragged
  41902. */
  41903. onRotationSphereDragObservable: Observable<{}>;
  41904. /**
  41905. * Fired when a rotation sphere drag is ended
  41906. */
  41907. onRotationSphereDragEndObservable: Observable<{}>;
  41908. /**
  41909. * 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)
  41910. */
  41911. scalePivot: Nullable<Vector3>;
  41912. private _anchorMesh;
  41913. private _existingMeshScale;
  41914. private _dragMesh;
  41915. private pointerDragBehavior;
  41916. /**
  41917. * Creates an BoundingBoxGizmo
  41918. * @param gizmoLayer The utility layer the gizmo will be added to
  41919. * @param color The color of the gizmo
  41920. */
  41921. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41922. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41923. private _selectNode;
  41924. /**
  41925. * Updates the bounding box information for the Gizmo
  41926. */
  41927. updateBoundingBox(): void;
  41928. private _updateRotationSpheres;
  41929. private _updateScaleBoxes;
  41930. /**
  41931. * Enables rotation on the specified axis and disables rotation on the others
  41932. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  41933. */
  41934. setEnabledRotationAxis(axis: string): void;
  41935. /**
  41936. * Enables/disables scaling
  41937. * @param enable if scaling should be enabled
  41938. */
  41939. setEnabledScaling(enable: boolean): void;
  41940. private _updateDummy;
  41941. /**
  41942. * Enables a pointer drag behavior on the bounding box of the gizmo
  41943. */
  41944. enableDragBehavior(): void;
  41945. /**
  41946. * Disposes of the gizmo
  41947. */
  41948. dispose(): void;
  41949. /**
  41950. * 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)
  41951. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  41952. * @returns the bounding box mesh with the passed in mesh as a child
  41953. */
  41954. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  41955. /**
  41956. * CustomMeshes are not supported by this gizmo
  41957. * @param mesh The mesh to replace the default mesh of the gizmo
  41958. */
  41959. setCustomMesh(mesh: Mesh): void;
  41960. }
  41961. }
  41962. declare module BABYLON {
  41963. /**
  41964. * Single plane rotation gizmo
  41965. */
  41966. export class PlaneRotationGizmo extends Gizmo {
  41967. /**
  41968. * Drag behavior responsible for the gizmos dragging interactions
  41969. */
  41970. dragBehavior: PointerDragBehavior;
  41971. private _pointerObserver;
  41972. /**
  41973. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  41974. */
  41975. snapDistance: number;
  41976. /**
  41977. * Event that fires each time the gizmo snaps to a new location.
  41978. * * snapDistance is the the change in distance
  41979. */
  41980. onSnapObservable: Observable<{
  41981. snapDistance: number;
  41982. }>;
  41983. /**
  41984. * Creates a PlaneRotationGizmo
  41985. * @param gizmoLayer The utility layer the gizmo will be added to
  41986. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  41987. * @param color The color of the gizmo
  41988. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41989. */
  41990. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41991. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41992. /**
  41993. * Disposes of the gizmo
  41994. */
  41995. dispose(): void;
  41996. }
  41997. }
  41998. declare module BABYLON {
  41999. /**
  42000. * Gizmo that enables rotating a mesh along 3 axis
  42001. */
  42002. export class RotationGizmo extends Gizmo {
  42003. /**
  42004. * Internal gizmo used for interactions on the x axis
  42005. */
  42006. xGizmo: PlaneRotationGizmo;
  42007. /**
  42008. * Internal gizmo used for interactions on the y axis
  42009. */
  42010. yGizmo: PlaneRotationGizmo;
  42011. /**
  42012. * Internal gizmo used for interactions on the z axis
  42013. */
  42014. zGizmo: PlaneRotationGizmo;
  42015. /** Fires an event when any of it's sub gizmos are dragged */
  42016. onDragStartObservable: Observable<{}>;
  42017. /** Fires an event when any of it's sub gizmos are released from dragging */
  42018. onDragEndObservable: Observable<{}>;
  42019. attachedMesh: Nullable<AbstractMesh>;
  42020. /**
  42021. * Creates a RotationGizmo
  42022. * @param gizmoLayer The utility layer the gizmo will be added to
  42023. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42024. */
  42025. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42026. updateGizmoRotationToMatchAttachedMesh: boolean;
  42027. /**
  42028. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42029. */
  42030. snapDistance: number;
  42031. /**
  42032. * Ratio for the scale of the gizmo (Default: 1)
  42033. */
  42034. scaleRatio: number;
  42035. /**
  42036. * Disposes of the gizmo
  42037. */
  42038. dispose(): void;
  42039. /**
  42040. * CustomMeshes are not supported by this gizmo
  42041. * @param mesh The mesh to replace the default mesh of the gizmo
  42042. */
  42043. setCustomMesh(mesh: Mesh): void;
  42044. }
  42045. }
  42046. declare module BABYLON {
  42047. /**
  42048. * Gizmo that enables dragging a mesh along 3 axis
  42049. */
  42050. export class PositionGizmo extends Gizmo {
  42051. /**
  42052. * Internal gizmo used for interactions on the x axis
  42053. */
  42054. xGizmo: AxisDragGizmo;
  42055. /**
  42056. * Internal gizmo used for interactions on the y axis
  42057. */
  42058. yGizmo: AxisDragGizmo;
  42059. /**
  42060. * Internal gizmo used for interactions on the z axis
  42061. */
  42062. zGizmo: AxisDragGizmo;
  42063. /** Fires an event when any of it's sub gizmos are dragged */
  42064. onDragStartObservable: Observable<{}>;
  42065. /** Fires an event when any of it's sub gizmos are released from dragging */
  42066. onDragEndObservable: Observable<{}>;
  42067. attachedMesh: Nullable<AbstractMesh>;
  42068. /**
  42069. * Creates a PositionGizmo
  42070. * @param gizmoLayer The utility layer the gizmo will be added to
  42071. */
  42072. constructor(gizmoLayer?: UtilityLayerRenderer);
  42073. updateGizmoRotationToMatchAttachedMesh: boolean;
  42074. /**
  42075. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42076. */
  42077. snapDistance: number;
  42078. /**
  42079. * Ratio for the scale of the gizmo (Default: 1)
  42080. */
  42081. scaleRatio: number;
  42082. /**
  42083. * Disposes of the gizmo
  42084. */
  42085. dispose(): void;
  42086. /**
  42087. * CustomMeshes are not supported by this gizmo
  42088. * @param mesh The mesh to replace the default mesh of the gizmo
  42089. */
  42090. setCustomMesh(mesh: Mesh): void;
  42091. }
  42092. }
  42093. declare module BABYLON {
  42094. /**
  42095. * Gizmo that enables scaling a mesh along 3 axis
  42096. */
  42097. export class ScaleGizmo extends Gizmo {
  42098. /**
  42099. * Internal gizmo used for interactions on the x axis
  42100. */
  42101. xGizmo: AxisScaleGizmo;
  42102. /**
  42103. * Internal gizmo used for interactions on the y axis
  42104. */
  42105. yGizmo: AxisScaleGizmo;
  42106. /**
  42107. * Internal gizmo used for interactions on the z axis
  42108. */
  42109. zGizmo: AxisScaleGizmo;
  42110. /**
  42111. * Internal gizmo used to scale all axis equally
  42112. */
  42113. uniformScaleGizmo: AxisScaleGizmo;
  42114. /** Fires an event when any of it's sub gizmos are dragged */
  42115. onDragStartObservable: Observable<{}>;
  42116. /** Fires an event when any of it's sub gizmos are released from dragging */
  42117. onDragEndObservable: Observable<{}>;
  42118. attachedMesh: Nullable<AbstractMesh>;
  42119. /**
  42120. * Creates a ScaleGizmo
  42121. * @param gizmoLayer The utility layer the gizmo will be added to
  42122. */
  42123. constructor(gizmoLayer?: UtilityLayerRenderer);
  42124. updateGizmoRotationToMatchAttachedMesh: boolean;
  42125. /**
  42126. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42127. */
  42128. snapDistance: number;
  42129. /**
  42130. * Ratio for the scale of the gizmo (Default: 1)
  42131. */
  42132. scaleRatio: number;
  42133. /**
  42134. * Disposes of the gizmo
  42135. */
  42136. dispose(): void;
  42137. }
  42138. }
  42139. declare module BABYLON {
  42140. /**
  42141. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42142. */
  42143. export class GizmoManager implements IDisposable {
  42144. private scene;
  42145. /**
  42146. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42147. */
  42148. gizmos: {
  42149. positionGizmo: Nullable<PositionGizmo>;
  42150. rotationGizmo: Nullable<RotationGizmo>;
  42151. scaleGizmo: Nullable<ScaleGizmo>;
  42152. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42153. };
  42154. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42155. clearGizmoOnEmptyPointerEvent: boolean;
  42156. /** Fires an event when the manager is attached to a mesh */
  42157. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42158. private _gizmosEnabled;
  42159. private _pointerObserver;
  42160. private _attachedMesh;
  42161. private _boundingBoxColor;
  42162. private _defaultUtilityLayer;
  42163. private _defaultKeepDepthUtilityLayer;
  42164. /**
  42165. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42166. */
  42167. boundingBoxDragBehavior: SixDofDragBehavior;
  42168. /**
  42169. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42170. */
  42171. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42172. /**
  42173. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42174. */
  42175. usePointerToAttachGizmos: boolean;
  42176. /**
  42177. * Instatiates a gizmo manager
  42178. * @param scene the scene to overlay the gizmos on top of
  42179. */
  42180. constructor(scene: Scene);
  42181. /**
  42182. * Attaches a set of gizmos to the specified mesh
  42183. * @param mesh The mesh the gizmo's should be attached to
  42184. */
  42185. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42186. /**
  42187. * If the position gizmo is enabled
  42188. */
  42189. positionGizmoEnabled: boolean;
  42190. /**
  42191. * If the rotation gizmo is enabled
  42192. */
  42193. rotationGizmoEnabled: boolean;
  42194. /**
  42195. * If the scale gizmo is enabled
  42196. */
  42197. scaleGizmoEnabled: boolean;
  42198. /**
  42199. * If the boundingBox gizmo is enabled
  42200. */
  42201. boundingBoxGizmoEnabled: boolean;
  42202. /**
  42203. * Disposes of the gizmo manager
  42204. */
  42205. dispose(): void;
  42206. }
  42207. }
  42208. declare module BABYLON {
  42209. /** @hidden */
  42210. export var backgroundFragmentDeclaration: {
  42211. name: string;
  42212. shader: string;
  42213. };
  42214. }
  42215. declare module BABYLON {
  42216. /** @hidden */
  42217. export var backgroundUboDeclaration: {
  42218. name: string;
  42219. shader: string;
  42220. };
  42221. }
  42222. declare module BABYLON {
  42223. /** @hidden */
  42224. export var backgroundPixelShader: {
  42225. name: string;
  42226. shader: string;
  42227. };
  42228. }
  42229. declare module BABYLON {
  42230. /** @hidden */
  42231. export var backgroundVertexDeclaration: {
  42232. name: string;
  42233. shader: string;
  42234. };
  42235. }
  42236. declare module BABYLON {
  42237. /** @hidden */
  42238. export var backgroundVertexShader: {
  42239. name: string;
  42240. shader: string;
  42241. };
  42242. }
  42243. declare module BABYLON {
  42244. /**
  42245. * Background material used to create an efficient environement around your scene.
  42246. */
  42247. export class BackgroundMaterial extends PushMaterial {
  42248. /**
  42249. * Standard reflectance value at parallel view angle.
  42250. */
  42251. static StandardReflectance0: number;
  42252. /**
  42253. * Standard reflectance value at grazing angle.
  42254. */
  42255. static StandardReflectance90: number;
  42256. protected _primaryColor: Color3;
  42257. /**
  42258. * Key light Color (multiply against the environement texture)
  42259. */
  42260. primaryColor: Color3;
  42261. protected __perceptualColor: Nullable<Color3>;
  42262. /**
  42263. * Experimental Internal Use Only.
  42264. *
  42265. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  42266. * This acts as a helper to set the primary color to a more "human friendly" value.
  42267. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  42268. * output color as close as possible from the chosen value.
  42269. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  42270. * part of lighting setup.)
  42271. */
  42272. _perceptualColor: Nullable<Color3>;
  42273. protected _primaryColorShadowLevel: float;
  42274. /**
  42275. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  42276. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  42277. */
  42278. primaryColorShadowLevel: float;
  42279. protected _primaryColorHighlightLevel: float;
  42280. /**
  42281. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  42282. * The primary color is used at the level chosen to define what the white area would look.
  42283. */
  42284. primaryColorHighlightLevel: float;
  42285. protected _reflectionTexture: Nullable<BaseTexture>;
  42286. /**
  42287. * Reflection Texture used in the material.
  42288. * Should be author in a specific way for the best result (refer to the documentation).
  42289. */
  42290. reflectionTexture: Nullable<BaseTexture>;
  42291. protected _reflectionBlur: float;
  42292. /**
  42293. * Reflection Texture level of blur.
  42294. *
  42295. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  42296. * texture twice.
  42297. */
  42298. reflectionBlur: float;
  42299. protected _diffuseTexture: Nullable<BaseTexture>;
  42300. /**
  42301. * Diffuse Texture used in the material.
  42302. * Should be author in a specific way for the best result (refer to the documentation).
  42303. */
  42304. diffuseTexture: Nullable<BaseTexture>;
  42305. protected _shadowLights: Nullable<IShadowLight[]>;
  42306. /**
  42307. * Specify the list of lights casting shadow on the material.
  42308. * All scene shadow lights will be included if null.
  42309. */
  42310. shadowLights: Nullable<IShadowLight[]>;
  42311. protected _shadowLevel: float;
  42312. /**
  42313. * Helps adjusting the shadow to a softer level if required.
  42314. * 0 means black shadows and 1 means no shadows.
  42315. */
  42316. shadowLevel: float;
  42317. protected _sceneCenter: Vector3;
  42318. /**
  42319. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  42320. * It is usually zero but might be interesting to modify according to your setup.
  42321. */
  42322. sceneCenter: Vector3;
  42323. protected _opacityFresnel: boolean;
  42324. /**
  42325. * This helps specifying that the material is falling off to the sky box at grazing angle.
  42326. * This helps ensuring a nice transition when the camera goes under the ground.
  42327. */
  42328. opacityFresnel: boolean;
  42329. protected _reflectionFresnel: boolean;
  42330. /**
  42331. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  42332. * This helps adding a mirror texture on the ground.
  42333. */
  42334. reflectionFresnel: boolean;
  42335. protected _reflectionFalloffDistance: number;
  42336. /**
  42337. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  42338. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  42339. */
  42340. reflectionFalloffDistance: number;
  42341. protected _reflectionAmount: number;
  42342. /**
  42343. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  42344. */
  42345. reflectionAmount: number;
  42346. protected _reflectionReflectance0: number;
  42347. /**
  42348. * This specifies the weight of the reflection at grazing angle.
  42349. */
  42350. reflectionReflectance0: number;
  42351. protected _reflectionReflectance90: number;
  42352. /**
  42353. * This specifies the weight of the reflection at a perpendicular point of view.
  42354. */
  42355. reflectionReflectance90: number;
  42356. /**
  42357. * Sets the reflection reflectance fresnel values according to the default standard
  42358. * empirically know to work well :-)
  42359. */
  42360. reflectionStandardFresnelWeight: number;
  42361. protected _useRGBColor: boolean;
  42362. /**
  42363. * Helps to directly use the maps channels instead of their level.
  42364. */
  42365. useRGBColor: boolean;
  42366. protected _enableNoise: boolean;
  42367. /**
  42368. * This helps reducing the banding effect that could occur on the background.
  42369. */
  42370. enableNoise: boolean;
  42371. /**
  42372. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42373. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  42374. * Recommended to be keep at 1.0 except for special cases.
  42375. */
  42376. fovMultiplier: number;
  42377. private _fovMultiplier;
  42378. /**
  42379. * Enable the FOV adjustment feature controlled by fovMultiplier.
  42380. */
  42381. useEquirectangularFOV: boolean;
  42382. private _maxSimultaneousLights;
  42383. /**
  42384. * Number of Simultaneous lights allowed on the material.
  42385. */
  42386. maxSimultaneousLights: int;
  42387. /**
  42388. * Default configuration related to image processing available in the Background Material.
  42389. */
  42390. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42391. /**
  42392. * Keep track of the image processing observer to allow dispose and replace.
  42393. */
  42394. private _imageProcessingObserver;
  42395. /**
  42396. * Attaches a new image processing configuration to the PBR Material.
  42397. * @param configuration (if null the scene configuration will be use)
  42398. */
  42399. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42400. /**
  42401. * Gets the image processing configuration used either in this material.
  42402. */
  42403. /**
  42404. * Sets the Default image processing configuration used either in the this material.
  42405. *
  42406. * If sets to null, the scene one is in use.
  42407. */
  42408. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  42409. /**
  42410. * Gets wether the color curves effect is enabled.
  42411. */
  42412. /**
  42413. * Sets wether the color curves effect is enabled.
  42414. */
  42415. cameraColorCurvesEnabled: boolean;
  42416. /**
  42417. * Gets wether the color grading effect is enabled.
  42418. */
  42419. /**
  42420. * Gets wether the color grading effect is enabled.
  42421. */
  42422. cameraColorGradingEnabled: boolean;
  42423. /**
  42424. * Gets wether tonemapping is enabled or not.
  42425. */
  42426. /**
  42427. * Sets wether tonemapping is enabled or not
  42428. */
  42429. cameraToneMappingEnabled: boolean;
  42430. /**
  42431. * The camera exposure used on this material.
  42432. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42433. * This corresponds to a photographic exposure.
  42434. */
  42435. /**
  42436. * The camera exposure used on this material.
  42437. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42438. * This corresponds to a photographic exposure.
  42439. */
  42440. cameraExposure: float;
  42441. /**
  42442. * Gets The camera contrast used on this material.
  42443. */
  42444. /**
  42445. * Sets The camera contrast used on this material.
  42446. */
  42447. cameraContrast: float;
  42448. /**
  42449. * Gets the Color Grading 2D Lookup Texture.
  42450. */
  42451. /**
  42452. * Sets the Color Grading 2D Lookup Texture.
  42453. */
  42454. cameraColorGradingTexture: Nullable<BaseTexture>;
  42455. /**
  42456. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42457. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42458. * 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;
  42459. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42460. */
  42461. /**
  42462. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42463. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42464. * 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;
  42465. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42466. */
  42467. cameraColorCurves: Nullable<ColorCurves>;
  42468. /**
  42469. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  42470. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  42471. */
  42472. switchToBGR: boolean;
  42473. private _renderTargets;
  42474. private _reflectionControls;
  42475. private _white;
  42476. private _primaryShadowColor;
  42477. private _primaryHighlightColor;
  42478. /**
  42479. * Instantiates a Background Material in the given scene
  42480. * @param name The friendly name of the material
  42481. * @param scene The scene to add the material to
  42482. */
  42483. constructor(name: string, scene: Scene);
  42484. /**
  42485. * Gets a boolean indicating that current material needs to register RTT
  42486. */
  42487. readonly hasRenderTargetTextures: boolean;
  42488. /**
  42489. * The entire material has been created in order to prevent overdraw.
  42490. * @returns false
  42491. */
  42492. needAlphaTesting(): boolean;
  42493. /**
  42494. * The entire material has been created in order to prevent overdraw.
  42495. * @returns true if blending is enable
  42496. */
  42497. needAlphaBlending(): boolean;
  42498. /**
  42499. * Checks wether the material is ready to be rendered for a given mesh.
  42500. * @param mesh The mesh to render
  42501. * @param subMesh The submesh to check against
  42502. * @param useInstances Specify wether or not the material is used with instances
  42503. * @returns true if all the dependencies are ready (Textures, Effects...)
  42504. */
  42505. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42506. /**
  42507. * Compute the primary color according to the chosen perceptual color.
  42508. */
  42509. private _computePrimaryColorFromPerceptualColor;
  42510. /**
  42511. * Compute the highlights and shadow colors according to their chosen levels.
  42512. */
  42513. private _computePrimaryColors;
  42514. /**
  42515. * Build the uniform buffer used in the material.
  42516. */
  42517. buildUniformLayout(): void;
  42518. /**
  42519. * Unbind the material.
  42520. */
  42521. unbind(): void;
  42522. /**
  42523. * Bind only the world matrix to the material.
  42524. * @param world The world matrix to bind.
  42525. */
  42526. bindOnlyWorldMatrix(world: Matrix): void;
  42527. /**
  42528. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  42529. * @param world The world matrix to bind.
  42530. * @param subMesh The submesh to bind for.
  42531. */
  42532. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42533. /**
  42534. * Dispose the material.
  42535. * @param forceDisposeEffect Force disposal of the associated effect.
  42536. * @param forceDisposeTextures Force disposal of the associated textures.
  42537. */
  42538. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42539. /**
  42540. * Clones the material.
  42541. * @param name The cloned name.
  42542. * @returns The cloned material.
  42543. */
  42544. clone(name: string): BackgroundMaterial;
  42545. /**
  42546. * Serializes the current material to its JSON representation.
  42547. * @returns The JSON representation.
  42548. */
  42549. serialize(): any;
  42550. /**
  42551. * Gets the class name of the material
  42552. * @returns "BackgroundMaterial"
  42553. */
  42554. getClassName(): string;
  42555. /**
  42556. * Parse a JSON input to create back a background material.
  42557. * @param source The JSON data to parse
  42558. * @param scene The scene to create the parsed material in
  42559. * @param rootUrl The root url of the assets the material depends upon
  42560. * @returns the instantiated BackgroundMaterial.
  42561. */
  42562. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  42563. }
  42564. }
  42565. declare module BABYLON {
  42566. /**
  42567. * Represents the different options available during the creation of
  42568. * a Environment helper.
  42569. *
  42570. * This can control the default ground, skybox and image processing setup of your scene.
  42571. */
  42572. export interface IEnvironmentHelperOptions {
  42573. /**
  42574. * Specifies wether or not to create a ground.
  42575. * True by default.
  42576. */
  42577. createGround: boolean;
  42578. /**
  42579. * Specifies the ground size.
  42580. * 15 by default.
  42581. */
  42582. groundSize: number;
  42583. /**
  42584. * The texture used on the ground for the main color.
  42585. * Comes from the BabylonJS CDN by default.
  42586. *
  42587. * Remarks: Can be either a texture or a url.
  42588. */
  42589. groundTexture: string | BaseTexture;
  42590. /**
  42591. * The color mixed in the ground texture by default.
  42592. * BabylonJS clearColor by default.
  42593. */
  42594. groundColor: Color3;
  42595. /**
  42596. * Specifies the ground opacity.
  42597. * 1 by default.
  42598. */
  42599. groundOpacity: number;
  42600. /**
  42601. * Enables the ground to receive shadows.
  42602. * True by default.
  42603. */
  42604. enableGroundShadow: boolean;
  42605. /**
  42606. * Helps preventing the shadow to be fully black on the ground.
  42607. * 0.5 by default.
  42608. */
  42609. groundShadowLevel: number;
  42610. /**
  42611. * Creates a mirror texture attach to the ground.
  42612. * false by default.
  42613. */
  42614. enableGroundMirror: boolean;
  42615. /**
  42616. * Specifies the ground mirror size ratio.
  42617. * 0.3 by default as the default kernel is 64.
  42618. */
  42619. groundMirrorSizeRatio: number;
  42620. /**
  42621. * Specifies the ground mirror blur kernel size.
  42622. * 64 by default.
  42623. */
  42624. groundMirrorBlurKernel: number;
  42625. /**
  42626. * Specifies the ground mirror visibility amount.
  42627. * 1 by default
  42628. */
  42629. groundMirrorAmount: number;
  42630. /**
  42631. * Specifies the ground mirror reflectance weight.
  42632. * This uses the standard weight of the background material to setup the fresnel effect
  42633. * of the mirror.
  42634. * 1 by default.
  42635. */
  42636. groundMirrorFresnelWeight: number;
  42637. /**
  42638. * Specifies the ground mirror Falloff distance.
  42639. * This can helps reducing the size of the reflection.
  42640. * 0 by Default.
  42641. */
  42642. groundMirrorFallOffDistance: number;
  42643. /**
  42644. * Specifies the ground mirror texture type.
  42645. * Unsigned Int by Default.
  42646. */
  42647. groundMirrorTextureType: number;
  42648. /**
  42649. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  42650. * the shown objects.
  42651. */
  42652. groundYBias: number;
  42653. /**
  42654. * Specifies wether or not to create a skybox.
  42655. * True by default.
  42656. */
  42657. createSkybox: boolean;
  42658. /**
  42659. * Specifies the skybox size.
  42660. * 20 by default.
  42661. */
  42662. skyboxSize: number;
  42663. /**
  42664. * The texture used on the skybox for the main color.
  42665. * Comes from the BabylonJS CDN by default.
  42666. *
  42667. * Remarks: Can be either a texture or a url.
  42668. */
  42669. skyboxTexture: string | BaseTexture;
  42670. /**
  42671. * The color mixed in the skybox texture by default.
  42672. * BabylonJS clearColor by default.
  42673. */
  42674. skyboxColor: Color3;
  42675. /**
  42676. * The background rotation around the Y axis of the scene.
  42677. * This helps aligning the key lights of your scene with the background.
  42678. * 0 by default.
  42679. */
  42680. backgroundYRotation: number;
  42681. /**
  42682. * Compute automatically the size of the elements to best fit with the scene.
  42683. */
  42684. sizeAuto: boolean;
  42685. /**
  42686. * Default position of the rootMesh if autoSize is not true.
  42687. */
  42688. rootPosition: Vector3;
  42689. /**
  42690. * Sets up the image processing in the scene.
  42691. * true by default.
  42692. */
  42693. setupImageProcessing: boolean;
  42694. /**
  42695. * The texture used as your environment texture in the scene.
  42696. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  42697. *
  42698. * Remarks: Can be either a texture or a url.
  42699. */
  42700. environmentTexture: string | BaseTexture;
  42701. /**
  42702. * The value of the exposure to apply to the scene.
  42703. * 0.6 by default if setupImageProcessing is true.
  42704. */
  42705. cameraExposure: number;
  42706. /**
  42707. * The value of the contrast to apply to the scene.
  42708. * 1.6 by default if setupImageProcessing is true.
  42709. */
  42710. cameraContrast: number;
  42711. /**
  42712. * Specifies wether or not tonemapping should be enabled in the scene.
  42713. * true by default if setupImageProcessing is true.
  42714. */
  42715. toneMappingEnabled: boolean;
  42716. }
  42717. /**
  42718. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  42719. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  42720. * It also helps with the default setup of your imageProcessing configuration.
  42721. */
  42722. export class EnvironmentHelper {
  42723. /**
  42724. * Default ground texture URL.
  42725. */
  42726. private static _groundTextureCDNUrl;
  42727. /**
  42728. * Default skybox texture URL.
  42729. */
  42730. private static _skyboxTextureCDNUrl;
  42731. /**
  42732. * Default environment texture URL.
  42733. */
  42734. private static _environmentTextureCDNUrl;
  42735. /**
  42736. * Creates the default options for the helper.
  42737. */
  42738. private static _getDefaultOptions;
  42739. private _rootMesh;
  42740. /**
  42741. * Gets the root mesh created by the helper.
  42742. */
  42743. readonly rootMesh: Mesh;
  42744. private _skybox;
  42745. /**
  42746. * Gets the skybox created by the helper.
  42747. */
  42748. readonly skybox: Nullable<Mesh>;
  42749. private _skyboxTexture;
  42750. /**
  42751. * Gets the skybox texture created by the helper.
  42752. */
  42753. readonly skyboxTexture: Nullable<BaseTexture>;
  42754. private _skyboxMaterial;
  42755. /**
  42756. * Gets the skybox material created by the helper.
  42757. */
  42758. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  42759. private _ground;
  42760. /**
  42761. * Gets the ground mesh created by the helper.
  42762. */
  42763. readonly ground: Nullable<Mesh>;
  42764. private _groundTexture;
  42765. /**
  42766. * Gets the ground texture created by the helper.
  42767. */
  42768. readonly groundTexture: Nullable<BaseTexture>;
  42769. private _groundMirror;
  42770. /**
  42771. * Gets the ground mirror created by the helper.
  42772. */
  42773. readonly groundMirror: Nullable<MirrorTexture>;
  42774. /**
  42775. * Gets the ground mirror render list to helps pushing the meshes
  42776. * you wish in the ground reflection.
  42777. */
  42778. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  42779. private _groundMaterial;
  42780. /**
  42781. * Gets the ground material created by the helper.
  42782. */
  42783. readonly groundMaterial: Nullable<BackgroundMaterial>;
  42784. /**
  42785. * Stores the creation options.
  42786. */
  42787. private readonly _scene;
  42788. private _options;
  42789. /**
  42790. * This observable will be notified with any error during the creation of the environment,
  42791. * mainly texture creation errors.
  42792. */
  42793. onErrorObservable: Observable<{
  42794. message?: string;
  42795. exception?: any;
  42796. }>;
  42797. /**
  42798. * constructor
  42799. * @param options
  42800. * @param scene The scene to add the material to
  42801. */
  42802. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  42803. /**
  42804. * Updates the background according to the new options
  42805. * @param options
  42806. */
  42807. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  42808. /**
  42809. * Sets the primary color of all the available elements.
  42810. * @param color the main color to affect to the ground and the background
  42811. */
  42812. setMainColor(color: Color3): void;
  42813. /**
  42814. * Setup the image processing according to the specified options.
  42815. */
  42816. private _setupImageProcessing;
  42817. /**
  42818. * Setup the environment texture according to the specified options.
  42819. */
  42820. private _setupEnvironmentTexture;
  42821. /**
  42822. * Setup the background according to the specified options.
  42823. */
  42824. private _setupBackground;
  42825. /**
  42826. * Get the scene sizes according to the setup.
  42827. */
  42828. private _getSceneSize;
  42829. /**
  42830. * Setup the ground according to the specified options.
  42831. */
  42832. private _setupGround;
  42833. /**
  42834. * Setup the ground material according to the specified options.
  42835. */
  42836. private _setupGroundMaterial;
  42837. /**
  42838. * Setup the ground diffuse texture according to the specified options.
  42839. */
  42840. private _setupGroundDiffuseTexture;
  42841. /**
  42842. * Setup the ground mirror texture according to the specified options.
  42843. */
  42844. private _setupGroundMirrorTexture;
  42845. /**
  42846. * Setup the ground to receive the mirror texture.
  42847. */
  42848. private _setupMirrorInGroundMaterial;
  42849. /**
  42850. * Setup the skybox according to the specified options.
  42851. */
  42852. private _setupSkybox;
  42853. /**
  42854. * Setup the skybox material according to the specified options.
  42855. */
  42856. private _setupSkyboxMaterial;
  42857. /**
  42858. * Setup the skybox reflection texture according to the specified options.
  42859. */
  42860. private _setupSkyboxReflectionTexture;
  42861. private _errorHandler;
  42862. /**
  42863. * Dispose all the elements created by the Helper.
  42864. */
  42865. dispose(): void;
  42866. }
  42867. }
  42868. declare module BABYLON {
  42869. /**
  42870. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  42871. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  42872. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  42873. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  42874. */
  42875. export class PhotoDome extends TransformNode {
  42876. private _useDirectMapping;
  42877. /**
  42878. * The texture being displayed on the sphere
  42879. */
  42880. protected _photoTexture: Texture;
  42881. /**
  42882. * Gets or sets the texture being displayed on the sphere
  42883. */
  42884. photoTexture: Texture;
  42885. /**
  42886. * Observable raised when an error occured while loading the 360 image
  42887. */
  42888. onLoadErrorObservable: Observable<string>;
  42889. /**
  42890. * The skybox material
  42891. */
  42892. protected _material: BackgroundMaterial;
  42893. /**
  42894. * The surface used for the skybox
  42895. */
  42896. protected _mesh: Mesh;
  42897. /**
  42898. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42899. * Also see the options.resolution property.
  42900. */
  42901. fovMultiplier: number;
  42902. /**
  42903. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  42904. * @param name Element's name, child elements will append suffixes for their own names.
  42905. * @param urlsOfPhoto defines the url of the photo to display
  42906. * @param options defines an object containing optional or exposed sub element properties
  42907. * @param onError defines a callback called when an error occured while loading the texture
  42908. */
  42909. constructor(name: string, urlOfPhoto: string, options: {
  42910. resolution?: number;
  42911. size?: number;
  42912. useDirectMapping?: boolean;
  42913. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  42914. /**
  42915. * Releases resources associated with this node.
  42916. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  42917. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  42918. */
  42919. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  42920. }
  42921. }
  42922. declare module BABYLON {
  42923. /**
  42924. * Class used to host texture specific utilities
  42925. */
  42926. export class TextureTools {
  42927. /**
  42928. * Uses the GPU to create a copy texture rescaled at a given size
  42929. * @param texture Texture to copy from
  42930. * @param width defines the desired width
  42931. * @param height defines the desired height
  42932. * @param useBilinearMode defines if bilinear mode has to be used
  42933. * @return the generated texture
  42934. */
  42935. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  42936. /**
  42937. * Gets an environment BRDF texture for a given scene
  42938. * @param scene defines the hosting scene
  42939. * @returns the environment BRDF texture
  42940. */
  42941. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  42942. private static _environmentBRDFBase64Texture;
  42943. }
  42944. }
  42945. declare module BABYLON {
  42946. /** @hidden */
  42947. export var pbrFragmentDeclaration: {
  42948. name: string;
  42949. shader: string;
  42950. };
  42951. }
  42952. declare module BABYLON {
  42953. /** @hidden */
  42954. export var pbrUboDeclaration: {
  42955. name: string;
  42956. shader: string;
  42957. };
  42958. }
  42959. declare module BABYLON {
  42960. /** @hidden */
  42961. export var pbrFunctions: {
  42962. name: string;
  42963. shader: string;
  42964. };
  42965. }
  42966. declare module BABYLON {
  42967. /** @hidden */
  42968. export var harmonicsFunctions: {
  42969. name: string;
  42970. shader: string;
  42971. };
  42972. }
  42973. declare module BABYLON {
  42974. /** @hidden */
  42975. export var pbrLightFunctions: {
  42976. name: string;
  42977. shader: string;
  42978. };
  42979. }
  42980. declare module BABYLON {
  42981. /** @hidden */
  42982. export var pbrPixelShader: {
  42983. name: string;
  42984. shader: string;
  42985. };
  42986. }
  42987. declare module BABYLON {
  42988. /** @hidden */
  42989. export var pbrVertexDeclaration: {
  42990. name: string;
  42991. shader: string;
  42992. };
  42993. }
  42994. declare module BABYLON {
  42995. /** @hidden */
  42996. export var pbrVertexShader: {
  42997. name: string;
  42998. shader: string;
  42999. };
  43000. }
  43001. declare module BABYLON {
  43002. /**
  43003. * The Physically based material base class of BJS.
  43004. *
  43005. * This offers the main features of a standard PBR material.
  43006. * For more information, please refer to the documentation :
  43007. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  43008. */
  43009. export abstract class PBRBaseMaterial extends PushMaterial {
  43010. /**
  43011. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  43012. */
  43013. static readonly PBRMATERIAL_OPAQUE: number;
  43014. /**
  43015. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  43016. */
  43017. static readonly PBRMATERIAL_ALPHATEST: number;
  43018. /**
  43019. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43020. */
  43021. static readonly PBRMATERIAL_ALPHABLEND: number;
  43022. /**
  43023. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43024. * They are also discarded below the alpha cutoff threshold to improve performances.
  43025. */
  43026. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  43027. /**
  43028. * Defines the default value of how much AO map is occluding the analytical lights
  43029. * (point spot...).
  43030. */
  43031. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  43032. /**
  43033. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  43034. */
  43035. static readonly LIGHTFALLOFF_PHYSICAL: number;
  43036. /**
  43037. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  43038. * to enhance interoperability with other engines.
  43039. */
  43040. static readonly LIGHTFALLOFF_GLTF: number;
  43041. /**
  43042. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  43043. * to enhance interoperability with other materials.
  43044. */
  43045. static readonly LIGHTFALLOFF_STANDARD: number;
  43046. /**
  43047. * Intensity of the direct lights e.g. the four lights available in your scene.
  43048. * This impacts both the direct diffuse and specular highlights.
  43049. */
  43050. protected _directIntensity: number;
  43051. /**
  43052. * Intensity of the emissive part of the material.
  43053. * This helps controlling the emissive effect without modifying the emissive color.
  43054. */
  43055. protected _emissiveIntensity: number;
  43056. /**
  43057. * Intensity of the environment e.g. how much the environment will light the object
  43058. * either through harmonics for rough material or through the refelction for shiny ones.
  43059. */
  43060. protected _environmentIntensity: number;
  43061. /**
  43062. * This is a special control allowing the reduction of the specular highlights coming from the
  43063. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  43064. */
  43065. protected _specularIntensity: number;
  43066. /**
  43067. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  43068. */
  43069. private _lightingInfos;
  43070. /**
  43071. * Debug Control allowing disabling the bump map on this material.
  43072. */
  43073. protected _disableBumpMap: boolean;
  43074. /**
  43075. * AKA Diffuse Texture in standard nomenclature.
  43076. */
  43077. protected _albedoTexture: BaseTexture;
  43078. /**
  43079. * AKA Occlusion Texture in other nomenclature.
  43080. */
  43081. protected _ambientTexture: BaseTexture;
  43082. /**
  43083. * AKA Occlusion Texture Intensity in other nomenclature.
  43084. */
  43085. protected _ambientTextureStrength: number;
  43086. /**
  43087. * Defines how much the AO map is occluding the analytical lights (point spot...).
  43088. * 1 means it completely occludes it
  43089. * 0 mean it has no impact
  43090. */
  43091. protected _ambientTextureImpactOnAnalyticalLights: number;
  43092. /**
  43093. * Stores the alpha values in a texture.
  43094. */
  43095. protected _opacityTexture: BaseTexture;
  43096. /**
  43097. * Stores the reflection values in a texture.
  43098. */
  43099. protected _reflectionTexture: BaseTexture;
  43100. /**
  43101. * Stores the refraction values in a texture.
  43102. */
  43103. protected _refractionTexture: BaseTexture;
  43104. /**
  43105. * Stores the emissive values in a texture.
  43106. */
  43107. protected _emissiveTexture: BaseTexture;
  43108. /**
  43109. * AKA Specular texture in other nomenclature.
  43110. */
  43111. protected _reflectivityTexture: BaseTexture;
  43112. /**
  43113. * Used to switch from specular/glossiness to metallic/roughness workflow.
  43114. */
  43115. protected _metallicTexture: BaseTexture;
  43116. /**
  43117. * Specifies the metallic scalar of the metallic/roughness workflow.
  43118. * Can also be used to scale the metalness values of the metallic texture.
  43119. */
  43120. protected _metallic: Nullable<number>;
  43121. /**
  43122. * Specifies the roughness scalar of the metallic/roughness workflow.
  43123. * Can also be used to scale the roughness values of the metallic texture.
  43124. */
  43125. protected _roughness: Nullable<number>;
  43126. /**
  43127. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  43128. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  43129. */
  43130. protected _microSurfaceTexture: BaseTexture;
  43131. /**
  43132. * Stores surface normal data used to displace a mesh in a texture.
  43133. */
  43134. protected _bumpTexture: BaseTexture;
  43135. /**
  43136. * Stores the pre-calculated light information of a mesh in a texture.
  43137. */
  43138. protected _lightmapTexture: BaseTexture;
  43139. /**
  43140. * The color of a material in ambient lighting.
  43141. */
  43142. protected _ambientColor: Color3;
  43143. /**
  43144. * AKA Diffuse Color in other nomenclature.
  43145. */
  43146. protected _albedoColor: Color3;
  43147. /**
  43148. * AKA Specular Color in other nomenclature.
  43149. */
  43150. protected _reflectivityColor: Color3;
  43151. /**
  43152. * The color applied when light is reflected from a material.
  43153. */
  43154. protected _reflectionColor: Color3;
  43155. /**
  43156. * The color applied when light is emitted from a material.
  43157. */
  43158. protected _emissiveColor: Color3;
  43159. /**
  43160. * AKA Glossiness in other nomenclature.
  43161. */
  43162. protected _microSurface: number;
  43163. /**
  43164. * source material index of refraction (IOR)' / 'destination material IOR.
  43165. */
  43166. protected _indexOfRefraction: number;
  43167. /**
  43168. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  43169. */
  43170. protected _invertRefractionY: boolean;
  43171. /**
  43172. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43173. * Materials half opaque for instance using refraction could benefit from this control.
  43174. */
  43175. protected _linkRefractionWithTransparency: boolean;
  43176. /**
  43177. * Specifies that the material will use the light map as a show map.
  43178. */
  43179. protected _useLightmapAsShadowmap: boolean;
  43180. /**
  43181. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  43182. * makes the reflect vector face the model (under horizon).
  43183. */
  43184. protected _useHorizonOcclusion: boolean;
  43185. /**
  43186. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  43187. * too much the area relying on ambient texture to define their ambient occlusion.
  43188. */
  43189. protected _useRadianceOcclusion: boolean;
  43190. /**
  43191. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  43192. */
  43193. protected _useAlphaFromAlbedoTexture: boolean;
  43194. /**
  43195. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  43196. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  43197. */
  43198. protected _useSpecularOverAlpha: boolean;
  43199. /**
  43200. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  43201. */
  43202. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  43203. /**
  43204. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  43205. */
  43206. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  43207. /**
  43208. * Specifies if the metallic texture contains the roughness information in its green channel.
  43209. */
  43210. protected _useRoughnessFromMetallicTextureGreen: boolean;
  43211. /**
  43212. * Specifies if the metallic texture contains the metallness information in its blue channel.
  43213. */
  43214. protected _useMetallnessFromMetallicTextureBlue: boolean;
  43215. /**
  43216. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  43217. */
  43218. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  43219. /**
  43220. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  43221. */
  43222. protected _useAmbientInGrayScale: boolean;
  43223. /**
  43224. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  43225. * The material will try to infer what glossiness each pixel should be.
  43226. */
  43227. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  43228. /**
  43229. * Defines the falloff type used in this material.
  43230. * It by default is Physical.
  43231. */
  43232. protected _lightFalloff: number;
  43233. /**
  43234. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  43235. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  43236. */
  43237. protected _useRadianceOverAlpha: boolean;
  43238. /**
  43239. * Allows using an object space normal map (instead of tangent space).
  43240. */
  43241. protected _useObjectSpaceNormalMap: boolean;
  43242. /**
  43243. * Allows using the bump map in parallax mode.
  43244. */
  43245. protected _useParallax: boolean;
  43246. /**
  43247. * Allows using the bump map in parallax occlusion mode.
  43248. */
  43249. protected _useParallaxOcclusion: boolean;
  43250. /**
  43251. * Controls the scale bias of the parallax mode.
  43252. */
  43253. protected _parallaxScaleBias: number;
  43254. /**
  43255. * If sets to true, disables all the lights affecting the material.
  43256. */
  43257. protected _disableLighting: boolean;
  43258. /**
  43259. * Number of Simultaneous lights allowed on the material.
  43260. */
  43261. protected _maxSimultaneousLights: number;
  43262. /**
  43263. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43264. */
  43265. protected _invertNormalMapX: boolean;
  43266. /**
  43267. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43268. */
  43269. protected _invertNormalMapY: boolean;
  43270. /**
  43271. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  43272. */
  43273. protected _twoSidedLighting: boolean;
  43274. /**
  43275. * Defines the alpha limits in alpha test mode.
  43276. */
  43277. protected _alphaCutOff: number;
  43278. /**
  43279. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  43280. */
  43281. protected _forceAlphaTest: boolean;
  43282. /**
  43283. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43284. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  43285. */
  43286. protected _useAlphaFresnel: boolean;
  43287. /**
  43288. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43289. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  43290. */
  43291. protected _useLinearAlphaFresnel: boolean;
  43292. /**
  43293. * The transparency mode of the material.
  43294. */
  43295. protected _transparencyMode: Nullable<number>;
  43296. /**
  43297. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  43298. * from cos thetav and roughness:
  43299. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  43300. */
  43301. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  43302. /**
  43303. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  43304. */
  43305. protected _forceIrradianceInFragment: boolean;
  43306. /**
  43307. * Force normal to face away from face.
  43308. */
  43309. protected _forceNormalForward: boolean;
  43310. /**
  43311. * Enables specular anti aliasing in the PBR shader.
  43312. * It will both interacts on the Geometry for analytical and IBL lighting.
  43313. * It also prefilter the roughness map based on the bump values.
  43314. */
  43315. protected _enableSpecularAntiAliasing: boolean;
  43316. /**
  43317. * Default configuration related to image processing available in the PBR Material.
  43318. */
  43319. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43320. /**
  43321. * Keep track of the image processing observer to allow dispose and replace.
  43322. */
  43323. private _imageProcessingObserver;
  43324. /**
  43325. * Attaches a new image processing configuration to the PBR Material.
  43326. * @param configuration
  43327. */
  43328. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43329. /**
  43330. * Stores the available render targets.
  43331. */
  43332. private _renderTargets;
  43333. /**
  43334. * Sets the global ambient color for the material used in lighting calculations.
  43335. */
  43336. private _globalAmbientColor;
  43337. /**
  43338. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  43339. */
  43340. private _useLogarithmicDepth;
  43341. /**
  43342. * If set to true, no lighting calculations will be applied.
  43343. */
  43344. private _unlit;
  43345. /**
  43346. * Instantiates a new PBRMaterial instance.
  43347. *
  43348. * @param name The material name
  43349. * @param scene The scene the material will be use in.
  43350. */
  43351. constructor(name: string, scene: Scene);
  43352. /**
  43353. * Gets a boolean indicating that current material needs to register RTT
  43354. */
  43355. readonly hasRenderTargetTextures: boolean;
  43356. /**
  43357. * Gets the name of the material class.
  43358. */
  43359. getClassName(): string;
  43360. /**
  43361. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  43362. */
  43363. /**
  43364. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  43365. */
  43366. useLogarithmicDepth: boolean;
  43367. /**
  43368. * Gets the current transparency mode.
  43369. */
  43370. /**
  43371. * Sets the transparency mode of the material.
  43372. *
  43373. * | Value | Type | Description |
  43374. * | ----- | ----------------------------------- | ----------- |
  43375. * | 0 | OPAQUE | |
  43376. * | 1 | ALPHATEST | |
  43377. * | 2 | ALPHABLEND | |
  43378. * | 3 | ALPHATESTANDBLEND | |
  43379. *
  43380. */
  43381. transparencyMode: Nullable<number>;
  43382. /**
  43383. * Returns true if alpha blending should be disabled.
  43384. */
  43385. private readonly _disableAlphaBlending;
  43386. /**
  43387. * Specifies whether or not this material should be rendered in alpha blend mode.
  43388. */
  43389. needAlphaBlending(): boolean;
  43390. /**
  43391. * Specifies if the mesh will require alpha blending.
  43392. * @param mesh - BJS mesh.
  43393. */
  43394. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  43395. /**
  43396. * Specifies whether or not this material should be rendered in alpha test mode.
  43397. */
  43398. needAlphaTesting(): boolean;
  43399. /**
  43400. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  43401. */
  43402. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  43403. /**
  43404. * Gets the texture used for the alpha test.
  43405. */
  43406. getAlphaTestTexture(): BaseTexture;
  43407. /**
  43408. * Specifies that the submesh is ready to be used.
  43409. * @param mesh - BJS mesh.
  43410. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  43411. * @param useInstances - Specifies that instances should be used.
  43412. * @returns - boolean indicating that the submesh is ready or not.
  43413. */
  43414. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43415. /**
  43416. * Specifies if the material uses metallic roughness workflow.
  43417. * @returns boolean specifiying if the material uses metallic roughness workflow.
  43418. */
  43419. isMetallicWorkflow(): boolean;
  43420. private _prepareEffect;
  43421. private _prepareDefines;
  43422. /**
  43423. * Force shader compilation
  43424. */
  43425. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  43426. clipPlane: boolean;
  43427. }>): void;
  43428. /**
  43429. * Initializes the uniform buffer layout for the shader.
  43430. */
  43431. buildUniformLayout(): void;
  43432. /**
  43433. * Unbinds the textures.
  43434. */
  43435. unbind(): void;
  43436. /**
  43437. * Binds the submesh data.
  43438. * @param world - The world matrix.
  43439. * @param mesh - The BJS mesh.
  43440. * @param subMesh - A submesh of the BJS mesh.
  43441. */
  43442. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43443. /**
  43444. * Returns the animatable textures.
  43445. * @returns - Array of animatable textures.
  43446. */
  43447. getAnimatables(): IAnimatable[];
  43448. /**
  43449. * Returns the texture used for reflections.
  43450. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  43451. */
  43452. private _getReflectionTexture;
  43453. /**
  43454. * Returns the texture used for refraction or null if none is used.
  43455. * @returns - Refection texture if present. If no refraction texture and refraction
  43456. * is linked with transparency, returns environment texture. Otherwise, returns null.
  43457. */
  43458. private _getRefractionTexture;
  43459. /**
  43460. * Disposes the resources of the material.
  43461. * @param forceDisposeEffect - Forces the disposal of effects.
  43462. * @param forceDisposeTextures - Forces the disposal of all textures.
  43463. */
  43464. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43465. }
  43466. }
  43467. declare module BABYLON {
  43468. /**
  43469. * The Physically based material of BJS.
  43470. *
  43471. * This offers the main features of a standard PBR material.
  43472. * For more information, please refer to the documentation :
  43473. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  43474. */
  43475. export class PBRMaterial extends PBRBaseMaterial {
  43476. /**
  43477. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  43478. */
  43479. static readonly PBRMATERIAL_OPAQUE: number;
  43480. /**
  43481. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  43482. */
  43483. static readonly PBRMATERIAL_ALPHATEST: number;
  43484. /**
  43485. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43486. */
  43487. static readonly PBRMATERIAL_ALPHABLEND: number;
  43488. /**
  43489. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43490. * They are also discarded below the alpha cutoff threshold to improve performances.
  43491. */
  43492. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  43493. /**
  43494. * Defines the default value of how much AO map is occluding the analytical lights
  43495. * (point spot...).
  43496. */
  43497. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  43498. /**
  43499. * Intensity of the direct lights e.g. the four lights available in your scene.
  43500. * This impacts both the direct diffuse and specular highlights.
  43501. */
  43502. directIntensity: number;
  43503. /**
  43504. * Intensity of the emissive part of the material.
  43505. * This helps controlling the emissive effect without modifying the emissive color.
  43506. */
  43507. emissiveIntensity: number;
  43508. /**
  43509. * Intensity of the environment e.g. how much the environment will light the object
  43510. * either through harmonics for rough material or through the refelction for shiny ones.
  43511. */
  43512. environmentIntensity: number;
  43513. /**
  43514. * This is a special control allowing the reduction of the specular highlights coming from the
  43515. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  43516. */
  43517. specularIntensity: number;
  43518. /**
  43519. * Debug Control allowing disabling the bump map on this material.
  43520. */
  43521. disableBumpMap: boolean;
  43522. /**
  43523. * AKA Diffuse Texture in standard nomenclature.
  43524. */
  43525. albedoTexture: BaseTexture;
  43526. /**
  43527. * AKA Occlusion Texture in other nomenclature.
  43528. */
  43529. ambientTexture: BaseTexture;
  43530. /**
  43531. * AKA Occlusion Texture Intensity in other nomenclature.
  43532. */
  43533. ambientTextureStrength: number;
  43534. /**
  43535. * Defines how much the AO map is occluding the analytical lights (point spot...).
  43536. * 1 means it completely occludes it
  43537. * 0 mean it has no impact
  43538. */
  43539. ambientTextureImpactOnAnalyticalLights: number;
  43540. /**
  43541. * Stores the alpha values in a texture.
  43542. */
  43543. opacityTexture: BaseTexture;
  43544. /**
  43545. * Stores the reflection values in a texture.
  43546. */
  43547. reflectionTexture: Nullable<BaseTexture>;
  43548. /**
  43549. * Stores the emissive values in a texture.
  43550. */
  43551. emissiveTexture: BaseTexture;
  43552. /**
  43553. * AKA Specular texture in other nomenclature.
  43554. */
  43555. reflectivityTexture: BaseTexture;
  43556. /**
  43557. * Used to switch from specular/glossiness to metallic/roughness workflow.
  43558. */
  43559. metallicTexture: BaseTexture;
  43560. /**
  43561. * Specifies the metallic scalar of the metallic/roughness workflow.
  43562. * Can also be used to scale the metalness values of the metallic texture.
  43563. */
  43564. metallic: Nullable<number>;
  43565. /**
  43566. * Specifies the roughness scalar of the metallic/roughness workflow.
  43567. * Can also be used to scale the roughness values of the metallic texture.
  43568. */
  43569. roughness: Nullable<number>;
  43570. /**
  43571. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  43572. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  43573. */
  43574. microSurfaceTexture: BaseTexture;
  43575. /**
  43576. * Stores surface normal data used to displace a mesh in a texture.
  43577. */
  43578. bumpTexture: BaseTexture;
  43579. /**
  43580. * Stores the pre-calculated light information of a mesh in a texture.
  43581. */
  43582. lightmapTexture: BaseTexture;
  43583. /**
  43584. * Stores the refracted light information in a texture.
  43585. */
  43586. refractionTexture: BaseTexture;
  43587. /**
  43588. * The color of a material in ambient lighting.
  43589. */
  43590. ambientColor: Color3;
  43591. /**
  43592. * AKA Diffuse Color in other nomenclature.
  43593. */
  43594. albedoColor: Color3;
  43595. /**
  43596. * AKA Specular Color in other nomenclature.
  43597. */
  43598. reflectivityColor: Color3;
  43599. /**
  43600. * The color reflected from the material.
  43601. */
  43602. reflectionColor: Color3;
  43603. /**
  43604. * The color emitted from the material.
  43605. */
  43606. emissiveColor: Color3;
  43607. /**
  43608. * AKA Glossiness in other nomenclature.
  43609. */
  43610. microSurface: number;
  43611. /**
  43612. * source material index of refraction (IOR)' / 'destination material IOR.
  43613. */
  43614. indexOfRefraction: number;
  43615. /**
  43616. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  43617. */
  43618. invertRefractionY: boolean;
  43619. /**
  43620. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43621. * Materials half opaque for instance using refraction could benefit from this control.
  43622. */
  43623. linkRefractionWithTransparency: boolean;
  43624. /**
  43625. * If true, the light map contains occlusion information instead of lighting info.
  43626. */
  43627. useLightmapAsShadowmap: boolean;
  43628. /**
  43629. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  43630. */
  43631. useAlphaFromAlbedoTexture: boolean;
  43632. /**
  43633. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  43634. */
  43635. forceAlphaTest: boolean;
  43636. /**
  43637. * Defines the alpha limits in alpha test mode.
  43638. */
  43639. alphaCutOff: number;
  43640. /**
  43641. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  43642. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  43643. */
  43644. useSpecularOverAlpha: boolean;
  43645. /**
  43646. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  43647. */
  43648. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  43649. /**
  43650. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  43651. */
  43652. useRoughnessFromMetallicTextureAlpha: boolean;
  43653. /**
  43654. * Specifies if the metallic texture contains the roughness information in its green channel.
  43655. */
  43656. useRoughnessFromMetallicTextureGreen: boolean;
  43657. /**
  43658. * Specifies if the metallic texture contains the metallness information in its blue channel.
  43659. */
  43660. useMetallnessFromMetallicTextureBlue: boolean;
  43661. /**
  43662. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  43663. */
  43664. useAmbientOcclusionFromMetallicTextureRed: boolean;
  43665. /**
  43666. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  43667. */
  43668. useAmbientInGrayScale: boolean;
  43669. /**
  43670. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  43671. * The material will try to infer what glossiness each pixel should be.
  43672. */
  43673. useAutoMicroSurfaceFromReflectivityMap: boolean;
  43674. /**
  43675. * BJS is using an harcoded light falloff based on a manually sets up range.
  43676. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  43677. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  43678. */
  43679. /**
  43680. * BJS is using an harcoded light falloff based on a manually sets up range.
  43681. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  43682. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  43683. */
  43684. usePhysicalLightFalloff: boolean;
  43685. /**
  43686. * In order to support the falloff compatibility with gltf, a special mode has been added
  43687. * to reproduce the gltf light falloff.
  43688. */
  43689. /**
  43690. * In order to support the falloff compatibility with gltf, a special mode has been added
  43691. * to reproduce the gltf light falloff.
  43692. */
  43693. useGLTFLightFalloff: boolean;
  43694. /**
  43695. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  43696. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  43697. */
  43698. useRadianceOverAlpha: boolean;
  43699. /**
  43700. * Allows using an object space normal map (instead of tangent space).
  43701. */
  43702. useObjectSpaceNormalMap: boolean;
  43703. /**
  43704. * Allows using the bump map in parallax mode.
  43705. */
  43706. useParallax: boolean;
  43707. /**
  43708. * Allows using the bump map in parallax occlusion mode.
  43709. */
  43710. useParallaxOcclusion: boolean;
  43711. /**
  43712. * Controls the scale bias of the parallax mode.
  43713. */
  43714. parallaxScaleBias: number;
  43715. /**
  43716. * If sets to true, disables all the lights affecting the material.
  43717. */
  43718. disableLighting: boolean;
  43719. /**
  43720. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  43721. */
  43722. forceIrradianceInFragment: boolean;
  43723. /**
  43724. * Number of Simultaneous lights allowed on the material.
  43725. */
  43726. maxSimultaneousLights: number;
  43727. /**
  43728. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  43729. */
  43730. invertNormalMapX: boolean;
  43731. /**
  43732. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  43733. */
  43734. invertNormalMapY: boolean;
  43735. /**
  43736. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  43737. */
  43738. twoSidedLighting: boolean;
  43739. /**
  43740. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43741. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  43742. */
  43743. useAlphaFresnel: boolean;
  43744. /**
  43745. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43746. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  43747. */
  43748. useLinearAlphaFresnel: boolean;
  43749. /**
  43750. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43751. * And/Or occlude the blended part.
  43752. */
  43753. environmentBRDFTexture: Nullable<BaseTexture>;
  43754. /**
  43755. * Force normal to face away from face.
  43756. */
  43757. forceNormalForward: boolean;
  43758. /**
  43759. * Enables specular anti aliasing in the PBR shader.
  43760. * It will both interacts on the Geometry for analytical and IBL lighting.
  43761. * It also prefilter the roughness map based on the bump values.
  43762. */
  43763. enableSpecularAntiAliasing: boolean;
  43764. /**
  43765. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  43766. * makes the reflect vector face the model (under horizon).
  43767. */
  43768. useHorizonOcclusion: boolean;
  43769. /**
  43770. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  43771. * too much the area relying on ambient texture to define their ambient occlusion.
  43772. */
  43773. useRadianceOcclusion: boolean;
  43774. /**
  43775. * If set to true, no lighting calculations will be applied.
  43776. */
  43777. unlit: boolean;
  43778. /**
  43779. * Gets the image processing configuration used either in this material.
  43780. */
  43781. /**
  43782. * Sets the Default image processing configuration used either in the this material.
  43783. *
  43784. * If sets to null, the scene one is in use.
  43785. */
  43786. imageProcessingConfiguration: ImageProcessingConfiguration;
  43787. /**
  43788. * Gets wether the color curves effect is enabled.
  43789. */
  43790. /**
  43791. * Sets wether the color curves effect is enabled.
  43792. */
  43793. cameraColorCurvesEnabled: boolean;
  43794. /**
  43795. * Gets wether the color grading effect is enabled.
  43796. */
  43797. /**
  43798. * Gets wether the color grading effect is enabled.
  43799. */
  43800. cameraColorGradingEnabled: boolean;
  43801. /**
  43802. * Gets wether tonemapping is enabled or not.
  43803. */
  43804. /**
  43805. * Sets wether tonemapping is enabled or not
  43806. */
  43807. cameraToneMappingEnabled: boolean;
  43808. /**
  43809. * The camera exposure used on this material.
  43810. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43811. * This corresponds to a photographic exposure.
  43812. */
  43813. /**
  43814. * The camera exposure used on this material.
  43815. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43816. * This corresponds to a photographic exposure.
  43817. */
  43818. cameraExposure: number;
  43819. /**
  43820. * Gets The camera contrast used on this material.
  43821. */
  43822. /**
  43823. * Sets The camera contrast used on this material.
  43824. */
  43825. cameraContrast: number;
  43826. /**
  43827. * Gets the Color Grading 2D Lookup Texture.
  43828. */
  43829. /**
  43830. * Sets the Color Grading 2D Lookup Texture.
  43831. */
  43832. cameraColorGradingTexture: Nullable<BaseTexture>;
  43833. /**
  43834. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43835. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43836. * 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;
  43837. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43838. */
  43839. /**
  43840. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43841. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43842. * 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;
  43843. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43844. */
  43845. cameraColorCurves: Nullable<ColorCurves>;
  43846. /**
  43847. * Instantiates a new PBRMaterial instance.
  43848. *
  43849. * @param name The material name
  43850. * @param scene The scene the material will be use in.
  43851. */
  43852. constructor(name: string, scene: Scene);
  43853. /**
  43854. * Returns the name of this material class.
  43855. */
  43856. getClassName(): string;
  43857. /**
  43858. * Returns an array of the actively used textures.
  43859. * @returns - Array of BaseTextures
  43860. */
  43861. getActiveTextures(): BaseTexture[];
  43862. /**
  43863. * Checks to see if a texture is used in the material.
  43864. * @param texture - Base texture to use.
  43865. * @returns - Boolean specifying if a texture is used in the material.
  43866. */
  43867. hasTexture(texture: BaseTexture): boolean;
  43868. /**
  43869. * Makes a duplicate of the current material.
  43870. * @param name - name to use for the new material.
  43871. */
  43872. clone(name: string): PBRMaterial;
  43873. /**
  43874. * Serializes this PBR Material.
  43875. * @returns - An object with the serialized material.
  43876. */
  43877. serialize(): any;
  43878. /**
  43879. * Parses a PBR Material from a serialized object.
  43880. * @param source - Serialized object.
  43881. * @param scene - BJS scene instance.
  43882. * @param rootUrl - url for the scene object
  43883. * @returns - PBRMaterial
  43884. */
  43885. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  43886. }
  43887. }
  43888. declare module BABYLON {
  43889. /** @hidden */
  43890. export var _forceSceneHelpersToBundle: boolean;
  43891. interface Scene {
  43892. /**
  43893. * Creates a default light for the scene.
  43894. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  43895. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  43896. */
  43897. createDefaultLight(replace?: boolean): void;
  43898. /**
  43899. * Creates a default camera for the scene.
  43900. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  43901. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  43902. * @param replace has default false, when true replaces the active camera in the scene
  43903. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  43904. */
  43905. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  43906. /**
  43907. * Creates a default camera and a default light.
  43908. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  43909. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  43910. * @param replace has the default false, when true replaces the active camera/light in the scene
  43911. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  43912. */
  43913. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  43914. /**
  43915. * Creates a new sky box
  43916. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  43917. * @param environmentTexture defines the texture to use as environment texture
  43918. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  43919. * @param scale defines the overall scale of the skybox
  43920. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  43921. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  43922. * @returns a new mesh holding the sky box
  43923. */
  43924. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  43925. /**
  43926. * Creates a new environment
  43927. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  43928. * @param options defines the options you can use to configure the environment
  43929. * @returns the new EnvironmentHelper
  43930. */
  43931. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  43932. /**
  43933. * Creates a new VREXperienceHelper
  43934. * @see http://doc.babylonjs.com/how_to/webvr_helper
  43935. * @param webVROptions defines the options used to create the new VREXperienceHelper
  43936. * @returns a new VREXperienceHelper
  43937. */
  43938. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  43939. /**
  43940. * Creates a new XREXperienceHelper
  43941. * @see http://doc.babylonjs.com/how_to/webxr
  43942. * @returns a promise for a new XREXperienceHelper
  43943. */
  43944. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  43945. }
  43946. }
  43947. declare module BABYLON {
  43948. /**
  43949. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  43950. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  43951. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  43952. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43953. */
  43954. export class VideoDome extends TransformNode {
  43955. private _useDirectMapping;
  43956. /**
  43957. * The video texture being displayed on the sphere
  43958. */
  43959. protected _videoTexture: VideoTexture;
  43960. /**
  43961. * Gets the video texture being displayed on the sphere
  43962. */
  43963. readonly videoTexture: VideoTexture;
  43964. /**
  43965. * The skybox material
  43966. */
  43967. protected _material: BackgroundMaterial;
  43968. /**
  43969. * The surface used for the skybox
  43970. */
  43971. protected _mesh: Mesh;
  43972. /**
  43973. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43974. * Also see the options.resolution property.
  43975. */
  43976. fovMultiplier: number;
  43977. /**
  43978. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  43979. * @param name Element's name, child elements will append suffixes for their own names.
  43980. * @param urlsOrVideo defines the url(s) or the video element to use
  43981. * @param options An object containing optional or exposed sub element properties
  43982. */
  43983. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  43984. resolution?: number;
  43985. clickToPlay?: boolean;
  43986. autoPlay?: boolean;
  43987. loop?: boolean;
  43988. size?: number;
  43989. poster?: string;
  43990. useDirectMapping?: boolean;
  43991. }, scene: Scene);
  43992. /**
  43993. * Releases resources associated with this node.
  43994. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43995. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43996. */
  43997. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43998. }
  43999. }
  44000. declare module BABYLON {
  44001. /**
  44002. * This class can be used to get instrumentation data from a Babylon engine
  44003. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  44004. */
  44005. export class EngineInstrumentation implements IDisposable {
  44006. /**
  44007. * Define the instrumented engine.
  44008. */
  44009. engine: Engine;
  44010. private _captureGPUFrameTime;
  44011. private _gpuFrameTimeToken;
  44012. private _gpuFrameTime;
  44013. private _captureShaderCompilationTime;
  44014. private _shaderCompilationTime;
  44015. private _onBeginFrameObserver;
  44016. private _onEndFrameObserver;
  44017. private _onBeforeShaderCompilationObserver;
  44018. private _onAfterShaderCompilationObserver;
  44019. /**
  44020. * Gets the perf counter used for GPU frame time
  44021. */
  44022. readonly gpuFrameTimeCounter: PerfCounter;
  44023. /**
  44024. * Gets the GPU frame time capture status
  44025. */
  44026. /**
  44027. * Enable or disable the GPU frame time capture
  44028. */
  44029. captureGPUFrameTime: boolean;
  44030. /**
  44031. * Gets the perf counter used for shader compilation time
  44032. */
  44033. readonly shaderCompilationTimeCounter: PerfCounter;
  44034. /**
  44035. * Gets the shader compilation time capture status
  44036. */
  44037. /**
  44038. * Enable or disable the shader compilation time capture
  44039. */
  44040. captureShaderCompilationTime: boolean;
  44041. /**
  44042. * Instantiates a new engine instrumentation.
  44043. * This class can be used to get instrumentation data from a Babylon engine
  44044. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  44045. * @param engine Defines the engine to instrument
  44046. */
  44047. constructor(
  44048. /**
  44049. * Define the instrumented engine.
  44050. */
  44051. engine: Engine);
  44052. /**
  44053. * Dispose and release associated resources.
  44054. */
  44055. dispose(): void;
  44056. }
  44057. }
  44058. declare module BABYLON {
  44059. /**
  44060. * This class can be used to get instrumentation data from a Babylon engine
  44061. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  44062. */
  44063. export class SceneInstrumentation implements IDisposable {
  44064. /**
  44065. * Defines the scene to instrument
  44066. */
  44067. scene: Scene;
  44068. private _captureActiveMeshesEvaluationTime;
  44069. private _activeMeshesEvaluationTime;
  44070. private _captureRenderTargetsRenderTime;
  44071. private _renderTargetsRenderTime;
  44072. private _captureFrameTime;
  44073. private _frameTime;
  44074. private _captureRenderTime;
  44075. private _renderTime;
  44076. private _captureInterFrameTime;
  44077. private _interFrameTime;
  44078. private _captureParticlesRenderTime;
  44079. private _particlesRenderTime;
  44080. private _captureSpritesRenderTime;
  44081. private _spritesRenderTime;
  44082. private _capturePhysicsTime;
  44083. private _physicsTime;
  44084. private _captureAnimationsTime;
  44085. private _animationsTime;
  44086. private _captureCameraRenderTime;
  44087. private _cameraRenderTime;
  44088. private _onBeforeActiveMeshesEvaluationObserver;
  44089. private _onAfterActiveMeshesEvaluationObserver;
  44090. private _onBeforeRenderTargetsRenderObserver;
  44091. private _onAfterRenderTargetsRenderObserver;
  44092. private _onAfterRenderObserver;
  44093. private _onBeforeDrawPhaseObserver;
  44094. private _onAfterDrawPhaseObserver;
  44095. private _onBeforeAnimationsObserver;
  44096. private _onBeforeParticlesRenderingObserver;
  44097. private _onAfterParticlesRenderingObserver;
  44098. private _onBeforeSpritesRenderingObserver;
  44099. private _onAfterSpritesRenderingObserver;
  44100. private _onBeforePhysicsObserver;
  44101. private _onAfterPhysicsObserver;
  44102. private _onAfterAnimationsObserver;
  44103. private _onBeforeCameraRenderObserver;
  44104. private _onAfterCameraRenderObserver;
  44105. /**
  44106. * Gets the perf counter used for active meshes evaluation time
  44107. */
  44108. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  44109. /**
  44110. * Gets the active meshes evaluation time capture status
  44111. */
  44112. /**
  44113. * Enable or disable the active meshes evaluation time capture
  44114. */
  44115. captureActiveMeshesEvaluationTime: boolean;
  44116. /**
  44117. * Gets the perf counter used for render targets render time
  44118. */
  44119. readonly renderTargetsRenderTimeCounter: PerfCounter;
  44120. /**
  44121. * Gets the render targets render time capture status
  44122. */
  44123. /**
  44124. * Enable or disable the render targets render time capture
  44125. */
  44126. captureRenderTargetsRenderTime: boolean;
  44127. /**
  44128. * Gets the perf counter used for particles render time
  44129. */
  44130. readonly particlesRenderTimeCounter: PerfCounter;
  44131. /**
  44132. * Gets the particles render time capture status
  44133. */
  44134. /**
  44135. * Enable or disable the particles render time capture
  44136. */
  44137. captureParticlesRenderTime: boolean;
  44138. /**
  44139. * Gets the perf counter used for sprites render time
  44140. */
  44141. readonly spritesRenderTimeCounter: PerfCounter;
  44142. /**
  44143. * Gets the sprites render time capture status
  44144. */
  44145. /**
  44146. * Enable or disable the sprites render time capture
  44147. */
  44148. captureSpritesRenderTime: boolean;
  44149. /**
  44150. * Gets the perf counter used for physics time
  44151. */
  44152. readonly physicsTimeCounter: PerfCounter;
  44153. /**
  44154. * Gets the physics time capture status
  44155. */
  44156. /**
  44157. * Enable or disable the physics time capture
  44158. */
  44159. capturePhysicsTime: boolean;
  44160. /**
  44161. * Gets the perf counter used for animations time
  44162. */
  44163. readonly animationsTimeCounter: PerfCounter;
  44164. /**
  44165. * Gets the animations time capture status
  44166. */
  44167. /**
  44168. * Enable or disable the animations time capture
  44169. */
  44170. captureAnimationsTime: boolean;
  44171. /**
  44172. * Gets the perf counter used for frame time capture
  44173. */
  44174. readonly frameTimeCounter: PerfCounter;
  44175. /**
  44176. * Gets the frame time capture status
  44177. */
  44178. /**
  44179. * Enable or disable the frame time capture
  44180. */
  44181. captureFrameTime: boolean;
  44182. /**
  44183. * Gets the perf counter used for inter-frames time capture
  44184. */
  44185. readonly interFrameTimeCounter: PerfCounter;
  44186. /**
  44187. * Gets the inter-frames time capture status
  44188. */
  44189. /**
  44190. * Enable or disable the inter-frames time capture
  44191. */
  44192. captureInterFrameTime: boolean;
  44193. /**
  44194. * Gets the perf counter used for render time capture
  44195. */
  44196. readonly renderTimeCounter: PerfCounter;
  44197. /**
  44198. * Gets the render time capture status
  44199. */
  44200. /**
  44201. * Enable or disable the render time capture
  44202. */
  44203. captureRenderTime: boolean;
  44204. /**
  44205. * Gets the perf counter used for camera render time capture
  44206. */
  44207. readonly cameraRenderTimeCounter: PerfCounter;
  44208. /**
  44209. * Gets the camera render time capture status
  44210. */
  44211. /**
  44212. * Enable or disable the camera render time capture
  44213. */
  44214. captureCameraRenderTime: boolean;
  44215. /**
  44216. * Gets the perf counter used for draw calls
  44217. */
  44218. readonly drawCallsCounter: PerfCounter;
  44219. /**
  44220. * Gets the perf counter used for texture collisions
  44221. */
  44222. readonly textureCollisionsCounter: PerfCounter;
  44223. /**
  44224. * Instantiates a new scene instrumentation.
  44225. * This class can be used to get instrumentation data from a Babylon engine
  44226. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  44227. * @param scene Defines the scene to instrument
  44228. */
  44229. constructor(
  44230. /**
  44231. * Defines the scene to instrument
  44232. */
  44233. scene: Scene);
  44234. /**
  44235. * Dispose and release associated resources.
  44236. */
  44237. dispose(): void;
  44238. }
  44239. }
  44240. declare module BABYLON {
  44241. /** @hidden */
  44242. export var glowMapGenerationPixelShader: {
  44243. name: string;
  44244. shader: string;
  44245. };
  44246. }
  44247. declare module BABYLON {
  44248. /** @hidden */
  44249. export var glowMapGenerationVertexShader: {
  44250. name: string;
  44251. shader: string;
  44252. };
  44253. }
  44254. declare module BABYLON {
  44255. /**
  44256. * Effect layer options. This helps customizing the behaviour
  44257. * of the effect layer.
  44258. */
  44259. export interface IEffectLayerOptions {
  44260. /**
  44261. * Multiplication factor apply to the canvas size to compute the render target size
  44262. * used to generated the objects (the smaller the faster).
  44263. */
  44264. mainTextureRatio: number;
  44265. /**
  44266. * Enforces a fixed size texture to ensure effect stability across devices.
  44267. */
  44268. mainTextureFixedSize?: number;
  44269. /**
  44270. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  44271. */
  44272. alphaBlendingMode: number;
  44273. /**
  44274. * The camera attached to the layer.
  44275. */
  44276. camera: Nullable<Camera>;
  44277. /**
  44278. * The rendering group to draw the layer in.
  44279. */
  44280. renderingGroupId: number;
  44281. }
  44282. /**
  44283. * The effect layer Helps adding post process effect blended with the main pass.
  44284. *
  44285. * This can be for instance use to generate glow or higlight effects on the scene.
  44286. *
  44287. * The effect layer class can not be used directly and is intented to inherited from to be
  44288. * customized per effects.
  44289. */
  44290. export abstract class EffectLayer {
  44291. private _vertexBuffers;
  44292. private _indexBuffer;
  44293. private _cachedDefines;
  44294. private _effectLayerMapGenerationEffect;
  44295. private _effectLayerOptions;
  44296. private _mergeEffect;
  44297. protected _scene: Scene;
  44298. protected _engine: Engine;
  44299. protected _maxSize: number;
  44300. protected _mainTextureDesiredSize: ISize;
  44301. protected _mainTexture: RenderTargetTexture;
  44302. protected _shouldRender: boolean;
  44303. protected _postProcesses: PostProcess[];
  44304. protected _textures: BaseTexture[];
  44305. protected _emissiveTextureAndColor: {
  44306. texture: Nullable<BaseTexture>;
  44307. color: Color4;
  44308. };
  44309. /**
  44310. * The name of the layer
  44311. */
  44312. name: string;
  44313. /**
  44314. * The clear color of the texture used to generate the glow map.
  44315. */
  44316. neutralColor: Color4;
  44317. /**
  44318. * Specifies wether the highlight layer is enabled or not.
  44319. */
  44320. isEnabled: boolean;
  44321. /**
  44322. * Gets the camera attached to the layer.
  44323. */
  44324. readonly camera: Nullable<Camera>;
  44325. /**
  44326. * Gets the rendering group id the layer should render in.
  44327. */
  44328. readonly renderingGroupId: number;
  44329. /**
  44330. * An event triggered when the effect layer has been disposed.
  44331. */
  44332. onDisposeObservable: Observable<EffectLayer>;
  44333. /**
  44334. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  44335. */
  44336. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  44337. /**
  44338. * An event triggered when the generated texture is being merged in the scene.
  44339. */
  44340. onBeforeComposeObservable: Observable<EffectLayer>;
  44341. /**
  44342. * An event triggered when the generated texture has been merged in the scene.
  44343. */
  44344. onAfterComposeObservable: Observable<EffectLayer>;
  44345. /**
  44346. * An event triggered when the efffect layer changes its size.
  44347. */
  44348. onSizeChangedObservable: Observable<EffectLayer>;
  44349. /** @hidden */
  44350. static _SceneComponentInitialization: (scene: Scene) => void;
  44351. /**
  44352. * Instantiates a new effect Layer and references it in the scene.
  44353. * @param name The name of the layer
  44354. * @param scene The scene to use the layer in
  44355. */
  44356. constructor(
  44357. /** The Friendly of the effect in the scene */
  44358. name: string, scene: Scene);
  44359. /**
  44360. * Get the effect name of the layer.
  44361. * @return The effect name
  44362. */
  44363. abstract getEffectName(): string;
  44364. /**
  44365. * Checks for the readiness of the element composing the layer.
  44366. * @param subMesh the mesh to check for
  44367. * @param useInstances specify wether or not to use instances to render the mesh
  44368. * @return true if ready otherwise, false
  44369. */
  44370. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44371. /**
  44372. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  44373. * @returns true if the effect requires stencil during the main canvas render pass.
  44374. */
  44375. abstract needStencil(): boolean;
  44376. /**
  44377. * Create the merge effect. This is the shader use to blit the information back
  44378. * to the main canvas at the end of the scene rendering.
  44379. * @returns The effect containing the shader used to merge the effect on the main canvas
  44380. */
  44381. protected abstract _createMergeEffect(): Effect;
  44382. /**
  44383. * Creates the render target textures and post processes used in the effect layer.
  44384. */
  44385. protected abstract _createTextureAndPostProcesses(): void;
  44386. /**
  44387. * Implementation specific of rendering the generating effect on the main canvas.
  44388. * @param effect The effect used to render through
  44389. */
  44390. protected abstract _internalRender(effect: Effect): void;
  44391. /**
  44392. * Sets the required values for both the emissive texture and and the main color.
  44393. */
  44394. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  44395. /**
  44396. * Free any resources and references associated to a mesh.
  44397. * Internal use
  44398. * @param mesh The mesh to free.
  44399. */
  44400. abstract _disposeMesh(mesh: Mesh): void;
  44401. /**
  44402. * Serializes this layer (Glow or Highlight for example)
  44403. * @returns a serialized layer object
  44404. */
  44405. abstract serialize?(): any;
  44406. /**
  44407. * Initializes the effect layer with the required options.
  44408. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  44409. */
  44410. protected _init(options: Partial<IEffectLayerOptions>): void;
  44411. /**
  44412. * Generates the index buffer of the full screen quad blending to the main canvas.
  44413. */
  44414. private _generateIndexBuffer;
  44415. /**
  44416. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  44417. */
  44418. private _genrateVertexBuffer;
  44419. /**
  44420. * Sets the main texture desired size which is the closest power of two
  44421. * of the engine canvas size.
  44422. */
  44423. private _setMainTextureSize;
  44424. /**
  44425. * Creates the main texture for the effect layer.
  44426. */
  44427. protected _createMainTexture(): void;
  44428. /**
  44429. * Adds specific effects defines.
  44430. * @param defines The defines to add specifics to.
  44431. */
  44432. protected _addCustomEffectDefines(defines: string[]): void;
  44433. /**
  44434. * Checks for the readiness of the element composing the layer.
  44435. * @param subMesh the mesh to check for
  44436. * @param useInstances specify wether or not to use instances to render the mesh
  44437. * @param emissiveTexture the associated emissive texture used to generate the glow
  44438. * @return true if ready otherwise, false
  44439. */
  44440. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  44441. /**
  44442. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  44443. */
  44444. render(): void;
  44445. /**
  44446. * Determine if a given mesh will be used in the current effect.
  44447. * @param mesh mesh to test
  44448. * @returns true if the mesh will be used
  44449. */
  44450. hasMesh(mesh: AbstractMesh): boolean;
  44451. /**
  44452. * Returns true if the layer contains information to display, otherwise false.
  44453. * @returns true if the glow layer should be rendered
  44454. */
  44455. shouldRender(): boolean;
  44456. /**
  44457. * Returns true if the mesh should render, otherwise false.
  44458. * @param mesh The mesh to render
  44459. * @returns true if it should render otherwise false
  44460. */
  44461. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  44462. /**
  44463. * Returns true if the mesh can be rendered, otherwise false.
  44464. * @param mesh The mesh to render
  44465. * @param material The material used on the mesh
  44466. * @returns true if it can be rendered otherwise false
  44467. */
  44468. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  44469. /**
  44470. * Returns true if the mesh should render, otherwise false.
  44471. * @param mesh The mesh to render
  44472. * @returns true if it should render otherwise false
  44473. */
  44474. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  44475. /**
  44476. * Renders the submesh passed in parameter to the generation map.
  44477. */
  44478. protected _renderSubMesh(subMesh: SubMesh): void;
  44479. /**
  44480. * Rebuild the required buffers.
  44481. * @hidden Internal use only.
  44482. */
  44483. _rebuild(): void;
  44484. /**
  44485. * Dispose only the render target textures and post process.
  44486. */
  44487. private _disposeTextureAndPostProcesses;
  44488. /**
  44489. * Dispose the highlight layer and free resources.
  44490. */
  44491. dispose(): void;
  44492. /**
  44493. * Gets the class name of the effect layer
  44494. * @returns the string with the class name of the effect layer
  44495. */
  44496. getClassName(): string;
  44497. /**
  44498. * Creates an effect layer from parsed effect layer data
  44499. * @param parsedEffectLayer defines effect layer data
  44500. * @param scene defines the current scene
  44501. * @param rootUrl defines the root URL containing the effect layer information
  44502. * @returns a parsed effect Layer
  44503. */
  44504. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  44505. }
  44506. }
  44507. declare module BABYLON {
  44508. interface AbstractScene {
  44509. /**
  44510. * The list of effect layers (highlights/glow) added to the scene
  44511. * @see http://doc.babylonjs.com/how_to/highlight_layer
  44512. * @see http://doc.babylonjs.com/how_to/glow_layer
  44513. */
  44514. effectLayers: Array<EffectLayer>;
  44515. /**
  44516. * Removes the given effect layer from this scene.
  44517. * @param toRemove defines the effect layer to remove
  44518. * @returns the index of the removed effect layer
  44519. */
  44520. removeEffectLayer(toRemove: EffectLayer): number;
  44521. /**
  44522. * Adds the given effect layer to this scene
  44523. * @param newEffectLayer defines the effect layer to add
  44524. */
  44525. addEffectLayer(newEffectLayer: EffectLayer): void;
  44526. }
  44527. /**
  44528. * Defines the layer scene component responsible to manage any effect layers
  44529. * in a given scene.
  44530. */
  44531. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  44532. /**
  44533. * The component name helpfull to identify the component in the list of scene components.
  44534. */
  44535. readonly name: string;
  44536. /**
  44537. * The scene the component belongs to.
  44538. */
  44539. scene: Scene;
  44540. private _engine;
  44541. private _renderEffects;
  44542. private _needStencil;
  44543. private _previousStencilState;
  44544. /**
  44545. * Creates a new instance of the component for the given scene
  44546. * @param scene Defines the scene to register the component in
  44547. */
  44548. constructor(scene: Scene);
  44549. /**
  44550. * Registers the component in a given scene
  44551. */
  44552. register(): void;
  44553. /**
  44554. * Rebuilds the elements related to this component in case of
  44555. * context lost for instance.
  44556. */
  44557. rebuild(): void;
  44558. /**
  44559. * Serializes the component data to the specified json object
  44560. * @param serializationObject The object to serialize to
  44561. */
  44562. serialize(serializationObject: any): void;
  44563. /**
  44564. * Adds all the element from the container to the scene
  44565. * @param container the container holding the elements
  44566. */
  44567. addFromContainer(container: AbstractScene): void;
  44568. /**
  44569. * Removes all the elements in the container from the scene
  44570. * @param container contains the elements to remove
  44571. */
  44572. removeFromContainer(container: AbstractScene): void;
  44573. /**
  44574. * Disposes the component and the associated ressources.
  44575. */
  44576. dispose(): void;
  44577. private _isReadyForMesh;
  44578. private _renderMainTexture;
  44579. private _setStencil;
  44580. private _setStencilBack;
  44581. private _draw;
  44582. private _drawCamera;
  44583. private _drawRenderingGroup;
  44584. }
  44585. }
  44586. declare module BABYLON {
  44587. /** @hidden */
  44588. export var glowMapMergePixelShader: {
  44589. name: string;
  44590. shader: string;
  44591. };
  44592. }
  44593. declare module BABYLON {
  44594. /** @hidden */
  44595. export var glowMapMergeVertexShader: {
  44596. name: string;
  44597. shader: string;
  44598. };
  44599. }
  44600. declare module BABYLON {
  44601. interface AbstractScene {
  44602. /**
  44603. * Return a the first highlight layer of the scene with a given name.
  44604. * @param name The name of the highlight layer to look for.
  44605. * @return The highlight layer if found otherwise null.
  44606. */
  44607. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  44608. }
  44609. /**
  44610. * Glow layer options. This helps customizing the behaviour
  44611. * of the glow layer.
  44612. */
  44613. export interface IGlowLayerOptions {
  44614. /**
  44615. * Multiplication factor apply to the canvas size to compute the render target size
  44616. * used to generated the glowing objects (the smaller the faster).
  44617. */
  44618. mainTextureRatio: number;
  44619. /**
  44620. * Enforces a fixed size texture to ensure resize independant blur.
  44621. */
  44622. mainTextureFixedSize?: number;
  44623. /**
  44624. * How big is the kernel of the blur texture.
  44625. */
  44626. blurKernelSize: number;
  44627. /**
  44628. * The camera attached to the layer.
  44629. */
  44630. camera: Nullable<Camera>;
  44631. /**
  44632. * Enable MSAA by chosing the number of samples.
  44633. */
  44634. mainTextureSamples?: number;
  44635. /**
  44636. * The rendering group to draw the layer in.
  44637. */
  44638. renderingGroupId: number;
  44639. }
  44640. /**
  44641. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  44642. *
  44643. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  44644. * glowy meshes to your scene.
  44645. *
  44646. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  44647. */
  44648. export class GlowLayer extends EffectLayer {
  44649. /**
  44650. * Effect Name of the layer.
  44651. */
  44652. static readonly EffectName: string;
  44653. /**
  44654. * The default blur kernel size used for the glow.
  44655. */
  44656. static DefaultBlurKernelSize: number;
  44657. /**
  44658. * The default texture size ratio used for the glow.
  44659. */
  44660. static DefaultTextureRatio: number;
  44661. /**
  44662. * Sets the kernel size of the blur.
  44663. */
  44664. /**
  44665. * Gets the kernel size of the blur.
  44666. */
  44667. blurKernelSize: number;
  44668. /**
  44669. * Sets the glow intensity.
  44670. */
  44671. /**
  44672. * Gets the glow intensity.
  44673. */
  44674. intensity: number;
  44675. private _options;
  44676. private _intensity;
  44677. private _horizontalBlurPostprocess1;
  44678. private _verticalBlurPostprocess1;
  44679. private _horizontalBlurPostprocess2;
  44680. private _verticalBlurPostprocess2;
  44681. private _blurTexture1;
  44682. private _blurTexture2;
  44683. private _postProcesses1;
  44684. private _postProcesses2;
  44685. private _includedOnlyMeshes;
  44686. private _excludedMeshes;
  44687. /**
  44688. * Callback used to let the user override the color selection on a per mesh basis
  44689. */
  44690. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  44691. /**
  44692. * Callback used to let the user override the texture selection on a per mesh basis
  44693. */
  44694. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  44695. /**
  44696. * Instantiates a new glow Layer and references it to the scene.
  44697. * @param name The name of the layer
  44698. * @param scene The scene to use the layer in
  44699. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  44700. */
  44701. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  44702. /**
  44703. * Get the effect name of the layer.
  44704. * @return The effect name
  44705. */
  44706. getEffectName(): string;
  44707. /**
  44708. * Create the merge effect. This is the shader use to blit the information back
  44709. * to the main canvas at the end of the scene rendering.
  44710. */
  44711. protected _createMergeEffect(): Effect;
  44712. /**
  44713. * Creates the render target textures and post processes used in the glow layer.
  44714. */
  44715. protected _createTextureAndPostProcesses(): void;
  44716. /**
  44717. * Checks for the readiness of the element composing the layer.
  44718. * @param subMesh the mesh to check for
  44719. * @param useInstances specify wether or not to use instances to render the mesh
  44720. * @param emissiveTexture the associated emissive texture used to generate the glow
  44721. * @return true if ready otherwise, false
  44722. */
  44723. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44724. /**
  44725. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  44726. */
  44727. needStencil(): boolean;
  44728. /**
  44729. * Returns true if the mesh can be rendered, otherwise false.
  44730. * @param mesh The mesh to render
  44731. * @param material The material used on the mesh
  44732. * @returns true if it can be rendered otherwise false
  44733. */
  44734. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  44735. /**
  44736. * Implementation specific of rendering the generating effect on the main canvas.
  44737. * @param effect The effect used to render through
  44738. */
  44739. protected _internalRender(effect: Effect): void;
  44740. /**
  44741. * Sets the required values for both the emissive texture and and the main color.
  44742. */
  44743. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  44744. /**
  44745. * Returns true if the mesh should render, otherwise false.
  44746. * @param mesh The mesh to render
  44747. * @returns true if it should render otherwise false
  44748. */
  44749. protected _shouldRenderMesh(mesh: Mesh): boolean;
  44750. /**
  44751. * Adds specific effects defines.
  44752. * @param defines The defines to add specifics to.
  44753. */
  44754. protected _addCustomEffectDefines(defines: string[]): void;
  44755. /**
  44756. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  44757. * @param mesh The mesh to exclude from the glow layer
  44758. */
  44759. addExcludedMesh(mesh: Mesh): void;
  44760. /**
  44761. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  44762. * @param mesh The mesh to remove
  44763. */
  44764. removeExcludedMesh(mesh: Mesh): void;
  44765. /**
  44766. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  44767. * @param mesh The mesh to include in the glow layer
  44768. */
  44769. addIncludedOnlyMesh(mesh: Mesh): void;
  44770. /**
  44771. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  44772. * @param mesh The mesh to remove
  44773. */
  44774. removeIncludedOnlyMesh(mesh: Mesh): void;
  44775. /**
  44776. * Determine if a given mesh will be used in the glow layer
  44777. * @param mesh The mesh to test
  44778. * @returns true if the mesh will be highlighted by the current glow layer
  44779. */
  44780. hasMesh(mesh: AbstractMesh): boolean;
  44781. /**
  44782. * Free any resources and references associated to a mesh.
  44783. * Internal use
  44784. * @param mesh The mesh to free.
  44785. * @hidden
  44786. */
  44787. _disposeMesh(mesh: Mesh): void;
  44788. /**
  44789. * Gets the class name of the effect layer
  44790. * @returns the string with the class name of the effect layer
  44791. */
  44792. getClassName(): string;
  44793. /**
  44794. * Serializes this glow layer
  44795. * @returns a serialized glow layer object
  44796. */
  44797. serialize(): any;
  44798. /**
  44799. * Creates a Glow Layer from parsed glow layer data
  44800. * @param parsedGlowLayer defines glow layer data
  44801. * @param scene defines the current scene
  44802. * @param rootUrl defines the root URL containing the glow layer information
  44803. * @returns a parsed Glow Layer
  44804. */
  44805. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  44806. }
  44807. }
  44808. declare module BABYLON {
  44809. /** @hidden */
  44810. export var glowBlurPostProcessPixelShader: {
  44811. name: string;
  44812. shader: string;
  44813. };
  44814. }
  44815. declare module BABYLON {
  44816. interface AbstractScene {
  44817. /**
  44818. * Return a the first highlight layer of the scene with a given name.
  44819. * @param name The name of the highlight layer to look for.
  44820. * @return The highlight layer if found otherwise null.
  44821. */
  44822. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  44823. }
  44824. /**
  44825. * Highlight layer options. This helps customizing the behaviour
  44826. * of the highlight layer.
  44827. */
  44828. export interface IHighlightLayerOptions {
  44829. /**
  44830. * Multiplication factor apply to the canvas size to compute the render target size
  44831. * used to generated the glowing objects (the smaller the faster).
  44832. */
  44833. mainTextureRatio: number;
  44834. /**
  44835. * Enforces a fixed size texture to ensure resize independant blur.
  44836. */
  44837. mainTextureFixedSize?: number;
  44838. /**
  44839. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  44840. * of the picture to blur (the smaller the faster).
  44841. */
  44842. blurTextureSizeRatio: number;
  44843. /**
  44844. * How big in texel of the blur texture is the vertical blur.
  44845. */
  44846. blurVerticalSize: number;
  44847. /**
  44848. * How big in texel of the blur texture is the horizontal blur.
  44849. */
  44850. blurHorizontalSize: number;
  44851. /**
  44852. * Alpha blending mode used to apply the blur. Default is combine.
  44853. */
  44854. alphaBlendingMode: number;
  44855. /**
  44856. * The camera attached to the layer.
  44857. */
  44858. camera: Nullable<Camera>;
  44859. /**
  44860. * Should we display highlight as a solid stroke?
  44861. */
  44862. isStroke?: boolean;
  44863. /**
  44864. * The rendering group to draw the layer in.
  44865. */
  44866. renderingGroupId: number;
  44867. }
  44868. /**
  44869. * The highlight layer Helps adding a glow effect around a mesh.
  44870. *
  44871. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  44872. * glowy meshes to your scene.
  44873. *
  44874. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  44875. */
  44876. export class HighlightLayer extends EffectLayer {
  44877. name: string;
  44878. /**
  44879. * Effect Name of the highlight layer.
  44880. */
  44881. static readonly EffectName: string;
  44882. /**
  44883. * The neutral color used during the preparation of the glow effect.
  44884. * This is black by default as the blend operation is a blend operation.
  44885. */
  44886. static NeutralColor: Color4;
  44887. /**
  44888. * Stencil value used for glowing meshes.
  44889. */
  44890. static GlowingMeshStencilReference: number;
  44891. /**
  44892. * Stencil value used for the other meshes in the scene.
  44893. */
  44894. static NormalMeshStencilReference: number;
  44895. /**
  44896. * Specifies whether or not the inner glow is ACTIVE in the layer.
  44897. */
  44898. innerGlow: boolean;
  44899. /**
  44900. * Specifies whether or not the outer glow is ACTIVE in the layer.
  44901. */
  44902. outerGlow: boolean;
  44903. /**
  44904. * Specifies the horizontal size of the blur.
  44905. */
  44906. /**
  44907. * Gets the horizontal size of the blur.
  44908. */
  44909. blurHorizontalSize: number;
  44910. /**
  44911. * Specifies the vertical size of the blur.
  44912. */
  44913. /**
  44914. * Gets the vertical size of the blur.
  44915. */
  44916. blurVerticalSize: number;
  44917. /**
  44918. * An event triggered when the highlight layer is being blurred.
  44919. */
  44920. onBeforeBlurObservable: Observable<HighlightLayer>;
  44921. /**
  44922. * An event triggered when the highlight layer has been blurred.
  44923. */
  44924. onAfterBlurObservable: Observable<HighlightLayer>;
  44925. private _instanceGlowingMeshStencilReference;
  44926. private _options;
  44927. private _downSamplePostprocess;
  44928. private _horizontalBlurPostprocess;
  44929. private _verticalBlurPostprocess;
  44930. private _blurTexture;
  44931. private _meshes;
  44932. private _excludedMeshes;
  44933. /**
  44934. * Instantiates a new highlight Layer and references it to the scene..
  44935. * @param name The name of the layer
  44936. * @param scene The scene to use the layer in
  44937. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  44938. */
  44939. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  44940. /**
  44941. * Get the effect name of the layer.
  44942. * @return The effect name
  44943. */
  44944. getEffectName(): string;
  44945. /**
  44946. * Create the merge effect. This is the shader use to blit the information back
  44947. * to the main canvas at the end of the scene rendering.
  44948. */
  44949. protected _createMergeEffect(): Effect;
  44950. /**
  44951. * Creates the render target textures and post processes used in the highlight layer.
  44952. */
  44953. protected _createTextureAndPostProcesses(): void;
  44954. /**
  44955. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  44956. */
  44957. needStencil(): boolean;
  44958. /**
  44959. * Checks for the readiness of the element composing the layer.
  44960. * @param subMesh the mesh to check for
  44961. * @param useInstances specify wether or not to use instances to render the mesh
  44962. * @param emissiveTexture the associated emissive texture used to generate the glow
  44963. * @return true if ready otherwise, false
  44964. */
  44965. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44966. /**
  44967. * Implementation specific of rendering the generating effect on the main canvas.
  44968. * @param effect The effect used to render through
  44969. */
  44970. protected _internalRender(effect: Effect): void;
  44971. /**
  44972. * Returns true if the layer contains information to display, otherwise false.
  44973. */
  44974. shouldRender(): boolean;
  44975. /**
  44976. * Returns true if the mesh should render, otherwise false.
  44977. * @param mesh The mesh to render
  44978. * @returns true if it should render otherwise false
  44979. */
  44980. protected _shouldRenderMesh(mesh: Mesh): boolean;
  44981. /**
  44982. * Sets the required values for both the emissive texture and and the main color.
  44983. */
  44984. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  44985. /**
  44986. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  44987. * @param mesh The mesh to exclude from the highlight layer
  44988. */
  44989. addExcludedMesh(mesh: Mesh): void;
  44990. /**
  44991. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  44992. * @param mesh The mesh to highlight
  44993. */
  44994. removeExcludedMesh(mesh: Mesh): void;
  44995. /**
  44996. * Determine if a given mesh will be highlighted by the current HighlightLayer
  44997. * @param mesh mesh to test
  44998. * @returns true if the mesh will be highlighted by the current HighlightLayer
  44999. */
  45000. hasMesh(mesh: AbstractMesh): boolean;
  45001. /**
  45002. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  45003. * @param mesh The mesh to highlight
  45004. * @param color The color of the highlight
  45005. * @param glowEmissiveOnly Extract the glow from the emissive texture
  45006. */
  45007. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  45008. /**
  45009. * Remove a mesh from the highlight layer in order to make it stop glowing.
  45010. * @param mesh The mesh to highlight
  45011. */
  45012. removeMesh(mesh: Mesh): void;
  45013. /**
  45014. * Force the stencil to the normal expected value for none glowing parts
  45015. */
  45016. private _defaultStencilReference;
  45017. /**
  45018. * Free any resources and references associated to a mesh.
  45019. * Internal use
  45020. * @param mesh The mesh to free.
  45021. * @hidden
  45022. */
  45023. _disposeMesh(mesh: Mesh): void;
  45024. /**
  45025. * Dispose the highlight layer and free resources.
  45026. */
  45027. dispose(): void;
  45028. /**
  45029. * Gets the class name of the effect layer
  45030. * @returns the string with the class name of the effect layer
  45031. */
  45032. getClassName(): string;
  45033. /**
  45034. * Serializes this Highlight layer
  45035. * @returns a serialized Highlight layer object
  45036. */
  45037. serialize(): any;
  45038. /**
  45039. * Creates a Highlight layer from parsed Highlight layer data
  45040. * @param parsedHightlightLayer defines the Highlight layer data
  45041. * @param scene defines the current scene
  45042. * @param rootUrl defines the root URL containing the Highlight layer information
  45043. * @returns a parsed Highlight layer
  45044. */
  45045. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  45046. }
  45047. }
  45048. declare module BABYLON {
  45049. /** @hidden */
  45050. export var lensFlarePixelShader: {
  45051. name: string;
  45052. shader: string;
  45053. };
  45054. }
  45055. declare module BABYLON {
  45056. /** @hidden */
  45057. export var lensFlareVertexShader: {
  45058. name: string;
  45059. shader: string;
  45060. };
  45061. }
  45062. declare module BABYLON {
  45063. /**
  45064. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  45065. * It is usually composed of several `lensFlare`.
  45066. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  45067. */
  45068. export class LensFlareSystem {
  45069. /**
  45070. * Define the name of the lens flare system
  45071. */
  45072. name: string;
  45073. /**
  45074. * List of lens flares used in this system.
  45075. */
  45076. lensFlares: LensFlare[];
  45077. /**
  45078. * Define a limit from the border the lens flare can be visible.
  45079. */
  45080. borderLimit: number;
  45081. /**
  45082. * Define a viewport border we do not want to see the lens flare in.
  45083. */
  45084. viewportBorder: number;
  45085. /**
  45086. * Define a predicate which could limit the list of meshes able to occlude the effect.
  45087. */
  45088. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45089. /**
  45090. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  45091. */
  45092. layerMask: number;
  45093. /**
  45094. * Define the id of the lens flare system in the scene.
  45095. * (equal to name by default)
  45096. */
  45097. id: string;
  45098. private _scene;
  45099. private _emitter;
  45100. private _vertexBuffers;
  45101. private _indexBuffer;
  45102. private _effect;
  45103. private _positionX;
  45104. private _positionY;
  45105. private _isEnabled;
  45106. /** @hidden */
  45107. static _SceneComponentInitialization: (scene: Scene) => void;
  45108. /**
  45109. * Instantiates a lens flare system.
  45110. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  45111. * It is usually composed of several `lensFlare`.
  45112. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  45113. * @param name Define the name of the lens flare system in the scene
  45114. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  45115. * @param scene Define the scene the lens flare system belongs to
  45116. */
  45117. constructor(
  45118. /**
  45119. * Define the name of the lens flare system
  45120. */
  45121. name: string, emitter: any, scene: Scene);
  45122. /**
  45123. * Define if the lens flare system is enabled.
  45124. */
  45125. isEnabled: boolean;
  45126. /**
  45127. * Get the scene the effects belongs to.
  45128. * @returns the scene holding the lens flare system
  45129. */
  45130. getScene(): Scene;
  45131. /**
  45132. * Get the emitter of the lens flare system.
  45133. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  45134. * @returns the emitter of the lens flare system
  45135. */
  45136. getEmitter(): any;
  45137. /**
  45138. * Set the emitter of the lens flare system.
  45139. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  45140. * @param newEmitter Define the new emitter of the system
  45141. */
  45142. setEmitter(newEmitter: any): void;
  45143. /**
  45144. * Get the lens flare system emitter position.
  45145. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  45146. * @returns the position
  45147. */
  45148. getEmitterPosition(): Vector3;
  45149. /**
  45150. * @hidden
  45151. */
  45152. computeEffectivePosition(globalViewport: Viewport): boolean;
  45153. /** @hidden */
  45154. _isVisible(): boolean;
  45155. /**
  45156. * @hidden
  45157. */
  45158. render(): boolean;
  45159. /**
  45160. * Dispose and release the lens flare with its associated resources.
  45161. */
  45162. dispose(): void;
  45163. /**
  45164. * Parse a lens flare system from a JSON repressentation
  45165. * @param parsedLensFlareSystem Define the JSON to parse
  45166. * @param scene Define the scene the parsed system should be instantiated in
  45167. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  45168. * @returns the parsed system
  45169. */
  45170. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  45171. /**
  45172. * Serialize the current Lens Flare System into a JSON representation.
  45173. * @returns the serialized JSON
  45174. */
  45175. serialize(): any;
  45176. }
  45177. }
  45178. declare module BABYLON {
  45179. /**
  45180. * This represents one of the lens effect in a `lensFlareSystem`.
  45181. * It controls one of the indiviual texture used in the effect.
  45182. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  45183. */
  45184. export class LensFlare {
  45185. /**
  45186. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  45187. */
  45188. size: number;
  45189. /**
  45190. * 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.
  45191. */
  45192. position: number;
  45193. /**
  45194. * Define the lens color.
  45195. */
  45196. color: Color3;
  45197. /**
  45198. * Define the lens texture.
  45199. */
  45200. texture: Nullable<Texture>;
  45201. /**
  45202. * Define the alpha mode to render this particular lens.
  45203. */
  45204. alphaMode: number;
  45205. private _system;
  45206. /**
  45207. * Creates a new Lens Flare.
  45208. * This represents one of the lens effect in a `lensFlareSystem`.
  45209. * It controls one of the indiviual texture used in the effect.
  45210. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  45211. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  45212. * @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.
  45213. * @param color Define the lens color
  45214. * @param imgUrl Define the lens texture url
  45215. * @param system Define the `lensFlareSystem` this flare is part of
  45216. * @returns The newly created Lens Flare
  45217. */
  45218. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  45219. /**
  45220. * Instantiates a new Lens Flare.
  45221. * This represents one of the lens effect in a `lensFlareSystem`.
  45222. * It controls one of the indiviual texture used in the effect.
  45223. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  45224. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  45225. * @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.
  45226. * @param color Define the lens color
  45227. * @param imgUrl Define the lens texture url
  45228. * @param system Define the `lensFlareSystem` this flare is part of
  45229. */
  45230. constructor(
  45231. /**
  45232. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  45233. */
  45234. size: number,
  45235. /**
  45236. * 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.
  45237. */
  45238. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  45239. /**
  45240. * Dispose and release the lens flare with its associated resources.
  45241. */
  45242. dispose(): void;
  45243. }
  45244. }
  45245. declare module BABYLON {
  45246. interface AbstractScene {
  45247. /**
  45248. * The list of lens flare system added to the scene
  45249. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  45250. */
  45251. lensFlareSystems: Array<LensFlareSystem>;
  45252. /**
  45253. * Removes the given lens flare system from this scene.
  45254. * @param toRemove The lens flare system to remove
  45255. * @returns The index of the removed lens flare system
  45256. */
  45257. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  45258. /**
  45259. * Adds the given lens flare system to this scene
  45260. * @param newLensFlareSystem The lens flare system to add
  45261. */
  45262. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  45263. /**
  45264. * Gets a lens flare system using its name
  45265. * @param name defines the name to look for
  45266. * @returns the lens flare system or null if not found
  45267. */
  45268. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  45269. /**
  45270. * Gets a lens flare system using its id
  45271. * @param id defines the id to look for
  45272. * @returns the lens flare system or null if not found
  45273. */
  45274. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  45275. }
  45276. /**
  45277. * Defines the lens flare scene component responsible to manage any lens flares
  45278. * in a given scene.
  45279. */
  45280. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  45281. /**
  45282. * The component name helpfull to identify the component in the list of scene components.
  45283. */
  45284. readonly name: string;
  45285. /**
  45286. * The scene the component belongs to.
  45287. */
  45288. scene: Scene;
  45289. /**
  45290. * Creates a new instance of the component for the given scene
  45291. * @param scene Defines the scene to register the component in
  45292. */
  45293. constructor(scene: Scene);
  45294. /**
  45295. * Registers the component in a given scene
  45296. */
  45297. register(): void;
  45298. /**
  45299. * Rebuilds the elements related to this component in case of
  45300. * context lost for instance.
  45301. */
  45302. rebuild(): void;
  45303. /**
  45304. * Adds all the element from the container to the scene
  45305. * @param container the container holding the elements
  45306. */
  45307. addFromContainer(container: AbstractScene): void;
  45308. /**
  45309. * Removes all the elements in the container from the scene
  45310. * @param container contains the elements to remove
  45311. */
  45312. removeFromContainer(container: AbstractScene): void;
  45313. /**
  45314. * Serializes the component data to the specified json object
  45315. * @param serializationObject The object to serialize to
  45316. */
  45317. serialize(serializationObject: any): void;
  45318. /**
  45319. * Disposes the component and the associated ressources.
  45320. */
  45321. dispose(): void;
  45322. private _draw;
  45323. }
  45324. }
  45325. declare module BABYLON {
  45326. /**
  45327. * Defines the shadow generator component responsible to manage any shadow generators
  45328. * in a given scene.
  45329. */
  45330. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  45331. /**
  45332. * The component name helpfull to identify the component in the list of scene components.
  45333. */
  45334. readonly name: string;
  45335. /**
  45336. * The scene the component belongs to.
  45337. */
  45338. scene: Scene;
  45339. /**
  45340. * Creates a new instance of the component for the given scene
  45341. * @param scene Defines the scene to register the component in
  45342. */
  45343. constructor(scene: Scene);
  45344. /**
  45345. * Registers the component in a given scene
  45346. */
  45347. register(): void;
  45348. /**
  45349. * Rebuilds the elements related to this component in case of
  45350. * context lost for instance.
  45351. */
  45352. rebuild(): void;
  45353. /**
  45354. * Serializes the component data to the specified json object
  45355. * @param serializationObject The object to serialize to
  45356. */
  45357. serialize(serializationObject: any): void;
  45358. /**
  45359. * Adds all the element from the container to the scene
  45360. * @param container the container holding the elements
  45361. */
  45362. addFromContainer(container: AbstractScene): void;
  45363. /**
  45364. * Removes all the elements in the container from the scene
  45365. * @param container contains the elements to remove
  45366. */
  45367. removeFromContainer(container: AbstractScene): void;
  45368. /**
  45369. * Rebuilds the elements related to this component in case of
  45370. * context lost for instance.
  45371. */
  45372. dispose(): void;
  45373. private _gatherRenderTargets;
  45374. }
  45375. }
  45376. declare module BABYLON {
  45377. /**
  45378. * A directional light is defined by a direction (what a surprise!).
  45379. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45380. * 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.
  45381. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45382. */
  45383. export class DirectionalLight extends ShadowLight {
  45384. private _shadowFrustumSize;
  45385. /**
  45386. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45387. */
  45388. /**
  45389. * Specifies a fix frustum size for the shadow generation.
  45390. */
  45391. shadowFrustumSize: number;
  45392. private _shadowOrthoScale;
  45393. /**
  45394. * Gets the shadow projection scale against the optimal computed one.
  45395. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45396. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45397. */
  45398. /**
  45399. * Sets the shadow projection scale against the optimal computed one.
  45400. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45401. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45402. */
  45403. shadowOrthoScale: number;
  45404. /**
  45405. * Automatically compute the projection matrix to best fit (including all the casters)
  45406. * on each frame.
  45407. */
  45408. autoUpdateExtends: boolean;
  45409. private _orthoLeft;
  45410. private _orthoRight;
  45411. private _orthoTop;
  45412. private _orthoBottom;
  45413. /**
  45414. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45415. * The directional light is emitted from everywhere in the given direction.
  45416. * It can cast shadows.
  45417. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45418. * @param name The friendly name of the light
  45419. * @param direction The direction of the light
  45420. * @param scene The scene the light belongs to
  45421. */
  45422. constructor(name: string, direction: Vector3, scene: Scene);
  45423. /**
  45424. * Returns the string "DirectionalLight".
  45425. * @return The class name
  45426. */
  45427. getClassName(): string;
  45428. /**
  45429. * Returns the integer 1.
  45430. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45431. */
  45432. getTypeID(): number;
  45433. /**
  45434. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45435. * Returns the DirectionalLight Shadow projection matrix.
  45436. */
  45437. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45438. /**
  45439. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45440. * Returns the DirectionalLight Shadow projection matrix.
  45441. */
  45442. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45443. /**
  45444. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45445. * Returns the DirectionalLight Shadow projection matrix.
  45446. */
  45447. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45448. protected _buildUniformLayout(): void;
  45449. /**
  45450. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45451. * @param effect The effect to update
  45452. * @param lightIndex The index of the light in the effect to update
  45453. * @returns The directional light
  45454. */
  45455. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45456. /**
  45457. * Gets the minZ used for shadow according to both the scene and the light.
  45458. *
  45459. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45460. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45461. * @param activeCamera The camera we are returning the min for
  45462. * @returns the depth min z
  45463. */
  45464. getDepthMinZ(activeCamera: Camera): number;
  45465. /**
  45466. * Gets the maxZ used for shadow according to both the scene and the light.
  45467. *
  45468. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45469. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45470. * @param activeCamera The camera we are returning the max for
  45471. * @returns the depth max z
  45472. */
  45473. getDepthMaxZ(activeCamera: Camera): number;
  45474. /**
  45475. * Prepares the list of defines specific to the light type.
  45476. * @param defines the list of defines
  45477. * @param lightIndex defines the index of the light for the effect
  45478. */
  45479. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45480. }
  45481. }
  45482. declare module BABYLON {
  45483. /**
  45484. * A point light is a light defined by an unique point in world space.
  45485. * The light is emitted in every direction from this point.
  45486. * A good example of a point light is a standard light bulb.
  45487. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45488. */
  45489. export class PointLight extends ShadowLight {
  45490. private _shadowAngle;
  45491. /**
  45492. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  45493. * This specifies what angle the shadow will use to be created.
  45494. *
  45495. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  45496. */
  45497. /**
  45498. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  45499. * This specifies what angle the shadow will use to be created.
  45500. *
  45501. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  45502. */
  45503. shadowAngle: number;
  45504. /**
  45505. * Gets the direction if it has been set.
  45506. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  45507. */
  45508. /**
  45509. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  45510. */
  45511. direction: Vector3;
  45512. /**
  45513. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  45514. * A PointLight emits the light in every direction.
  45515. * It can cast shadows.
  45516. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  45517. * ```javascript
  45518. * var pointLight = new PointLight("pl", camera.position, scene);
  45519. * ```
  45520. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45521. * @param name The light friendly name
  45522. * @param position The position of the point light in the scene
  45523. * @param scene The scene the lights belongs to
  45524. */
  45525. constructor(name: string, position: Vector3, scene: Scene);
  45526. /**
  45527. * Returns the string "PointLight"
  45528. * @returns the class name
  45529. */
  45530. getClassName(): string;
  45531. /**
  45532. * Returns the integer 0.
  45533. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45534. */
  45535. getTypeID(): number;
  45536. /**
  45537. * Specifies wether or not the shadowmap should be a cube texture.
  45538. * @returns true if the shadowmap needs to be a cube texture.
  45539. */
  45540. needCube(): boolean;
  45541. /**
  45542. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  45543. * @param faceIndex The index of the face we are computed the direction to generate shadow
  45544. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  45545. */
  45546. getShadowDirection(faceIndex?: number): Vector3;
  45547. /**
  45548. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  45549. * - fov = PI / 2
  45550. * - aspect ratio : 1.0
  45551. * - z-near and far equal to the active camera minZ and maxZ.
  45552. * Returns the PointLight.
  45553. */
  45554. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45555. protected _buildUniformLayout(): void;
  45556. /**
  45557. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  45558. * @param effect The effect to update
  45559. * @param lightIndex The index of the light in the effect to update
  45560. * @returns The point light
  45561. */
  45562. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  45563. /**
  45564. * Prepares the list of defines specific to the light type.
  45565. * @param defines the list of defines
  45566. * @param lightIndex defines the index of the light for the effect
  45567. */
  45568. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45569. }
  45570. }
  45571. declare module BABYLON {
  45572. /**
  45573. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45574. * These values define a cone of light starting from the position, emitting toward the direction.
  45575. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45576. * and the exponent defines the speed of the decay of the light with distance (reach).
  45577. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45578. */
  45579. export class SpotLight extends ShadowLight {
  45580. private _angle;
  45581. private _innerAngle;
  45582. private _cosHalfAngle;
  45583. private _lightAngleScale;
  45584. private _lightAngleOffset;
  45585. /**
  45586. * Gets the cone angle of the spot light in Radians.
  45587. */
  45588. /**
  45589. * Sets the cone angle of the spot light in Radians.
  45590. */
  45591. angle: number;
  45592. /**
  45593. * Only used in gltf falloff mode, this defines the angle where
  45594. * the directional falloff will start before cutting at angle which could be seen
  45595. * as outer angle.
  45596. */
  45597. /**
  45598. * Only used in gltf falloff mode, this defines the angle where
  45599. * the directional falloff will start before cutting at angle which could be seen
  45600. * as outer angle.
  45601. */
  45602. innerAngle: number;
  45603. private _shadowAngleScale;
  45604. /**
  45605. * Allows scaling the angle of the light for shadow generation only.
  45606. */
  45607. /**
  45608. * Allows scaling the angle of the light for shadow generation only.
  45609. */
  45610. shadowAngleScale: number;
  45611. /**
  45612. * The light decay speed with the distance from the emission spot.
  45613. */
  45614. exponent: number;
  45615. private _projectionTextureMatrix;
  45616. /**
  45617. * Allows reading the projecton texture
  45618. */
  45619. readonly projectionTextureMatrix: Matrix;
  45620. protected _projectionTextureLightNear: number;
  45621. /**
  45622. * Gets the near clip of the Spotlight for texture projection.
  45623. */
  45624. /**
  45625. * Sets the near clip of the Spotlight for texture projection.
  45626. */
  45627. projectionTextureLightNear: number;
  45628. protected _projectionTextureLightFar: number;
  45629. /**
  45630. * Gets the far clip of the Spotlight for texture projection.
  45631. */
  45632. /**
  45633. * Sets the far clip of the Spotlight for texture projection.
  45634. */
  45635. projectionTextureLightFar: number;
  45636. protected _projectionTextureUpDirection: Vector3;
  45637. /**
  45638. * Gets the Up vector of the Spotlight for texture projection.
  45639. */
  45640. /**
  45641. * Sets the Up vector of the Spotlight for texture projection.
  45642. */
  45643. projectionTextureUpDirection: Vector3;
  45644. private _projectionTexture;
  45645. /**
  45646. * Gets the projection texture of the light.
  45647. */
  45648. /**
  45649. * Sets the projection texture of the light.
  45650. */
  45651. projectionTexture: Nullable<BaseTexture>;
  45652. private _projectionTextureViewLightDirty;
  45653. private _projectionTextureProjectionLightDirty;
  45654. private _projectionTextureDirty;
  45655. private _projectionTextureViewTargetVector;
  45656. private _projectionTextureViewLightMatrix;
  45657. private _projectionTextureProjectionLightMatrix;
  45658. private _projectionTextureScalingMatrix;
  45659. /**
  45660. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45661. * It can cast shadows.
  45662. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45663. * @param name The light friendly name
  45664. * @param position The position of the spot light in the scene
  45665. * @param direction The direction of the light in the scene
  45666. * @param angle The cone angle of the light in Radians
  45667. * @param exponent The light decay speed with the distance from the emission spot
  45668. * @param scene The scene the lights belongs to
  45669. */
  45670. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45671. /**
  45672. * Returns the string "SpotLight".
  45673. * @returns the class name
  45674. */
  45675. getClassName(): string;
  45676. /**
  45677. * Returns the integer 2.
  45678. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45679. */
  45680. getTypeID(): number;
  45681. /**
  45682. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45683. */
  45684. protected _setDirection(value: Vector3): void;
  45685. /**
  45686. * Overrides the position setter to recompute the projection texture view light Matrix.
  45687. */
  45688. protected _setPosition(value: Vector3): void;
  45689. /**
  45690. * 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.
  45691. * Returns the SpotLight.
  45692. */
  45693. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45694. protected _computeProjectionTextureViewLightMatrix(): void;
  45695. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45696. /**
  45697. * Main function for light texture projection matrix computing.
  45698. */
  45699. protected _computeProjectionTextureMatrix(): void;
  45700. protected _buildUniformLayout(): void;
  45701. private _computeAngleValues;
  45702. /**
  45703. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45704. * @param effect The effect to update
  45705. * @param lightIndex The index of the light in the effect to update
  45706. * @returns The spot light
  45707. */
  45708. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45709. /**
  45710. * Disposes the light and the associated resources.
  45711. */
  45712. dispose(): void;
  45713. /**
  45714. * Prepares the list of defines specific to the light type.
  45715. * @param defines the list of defines
  45716. * @param lightIndex defines the index of the light for the effect
  45717. */
  45718. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45719. }
  45720. }
  45721. declare module BABYLON {
  45722. /**
  45723. * Header information of HDR texture files.
  45724. */
  45725. export interface HDRInfo {
  45726. /**
  45727. * The height of the texture in pixels.
  45728. */
  45729. height: number;
  45730. /**
  45731. * The width of the texture in pixels.
  45732. */
  45733. width: number;
  45734. /**
  45735. * The index of the beginning of the data in the binary file.
  45736. */
  45737. dataPosition: number;
  45738. }
  45739. /**
  45740. * This groups tools to convert HDR texture to native colors array.
  45741. */
  45742. export class HDRTools {
  45743. private static Ldexp;
  45744. private static Rgbe2float;
  45745. private static readStringLine;
  45746. /**
  45747. * Reads header information from an RGBE texture stored in a native array.
  45748. * More information on this format are available here:
  45749. * https://en.wikipedia.org/wiki/RGBE_image_format
  45750. *
  45751. * @param uint8array The binary file stored in native array.
  45752. * @return The header information.
  45753. */
  45754. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  45755. /**
  45756. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  45757. * This RGBE texture needs to store the information as a panorama.
  45758. *
  45759. * More information on this format are available here:
  45760. * https://en.wikipedia.org/wiki/RGBE_image_format
  45761. *
  45762. * @param buffer The binary file stored in an array buffer.
  45763. * @param size The expected size of the extracted cubemap.
  45764. * @return The Cube Map information.
  45765. */
  45766. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  45767. /**
  45768. * Returns the pixels data extracted from an RGBE texture.
  45769. * This pixels will be stored left to right up to down in the R G B order in one array.
  45770. *
  45771. * More information on this format are available here:
  45772. * https://en.wikipedia.org/wiki/RGBE_image_format
  45773. *
  45774. * @param uint8array The binary file stored in an array buffer.
  45775. * @param hdrInfo The header information of the file.
  45776. * @return The pixels data in RGB right to left up to down order.
  45777. */
  45778. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  45779. private static RGBE_ReadPixels_RLE;
  45780. }
  45781. }
  45782. declare module BABYLON {
  45783. /**
  45784. * This represents a texture coming from an HDR input.
  45785. *
  45786. * The only supported format is currently panorama picture stored in RGBE format.
  45787. * Example of such files can be found on HDRLib: http://hdrlib.com/
  45788. */
  45789. export class HDRCubeTexture extends BaseTexture {
  45790. private static _facesMapping;
  45791. private _generateHarmonics;
  45792. private _noMipmap;
  45793. private _textureMatrix;
  45794. private _size;
  45795. private _onLoad;
  45796. private _onError;
  45797. /**
  45798. * The texture URL.
  45799. */
  45800. url: string;
  45801. /**
  45802. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  45803. */
  45804. coordinatesMode: number;
  45805. protected _isBlocking: boolean;
  45806. /**
  45807. * Sets wether or not the texture is blocking during loading.
  45808. */
  45809. /**
  45810. * Gets wether or not the texture is blocking during loading.
  45811. */
  45812. isBlocking: boolean;
  45813. protected _rotationY: number;
  45814. /**
  45815. * Sets texture matrix rotation angle around Y axis in radians.
  45816. */
  45817. /**
  45818. * Gets texture matrix rotation angle around Y axis radians.
  45819. */
  45820. rotationY: number;
  45821. /**
  45822. * Gets or sets the center of the bounding box associated with the cube texture
  45823. * It must define where the camera used to render the texture was set
  45824. */
  45825. boundingBoxPosition: Vector3;
  45826. private _boundingBoxSize;
  45827. /**
  45828. * Gets or sets the size of the bounding box associated with the cube texture
  45829. * When defined, the cubemap will switch to local mode
  45830. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  45831. * @example https://www.babylonjs-playground.com/#RNASML
  45832. */
  45833. boundingBoxSize: Vector3;
  45834. /**
  45835. * Instantiates an HDRTexture from the following parameters.
  45836. *
  45837. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  45838. * @param scene The scene the texture will be used in
  45839. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  45840. * @param noMipmap Forces to not generate the mipmap if true
  45841. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  45842. * @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)
  45843. * @param reserved Reserved flag for internal use.
  45844. */
  45845. 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>);
  45846. /**
  45847. * Get the current class name of the texture useful for serialization or dynamic coding.
  45848. * @returns "HDRCubeTexture"
  45849. */
  45850. getClassName(): string;
  45851. /**
  45852. * Occurs when the file is raw .hdr file.
  45853. */
  45854. private loadTexture;
  45855. clone(): HDRCubeTexture;
  45856. delayLoad(): void;
  45857. /**
  45858. * Get the texture reflection matrix used to rotate/transform the reflection.
  45859. * @returns the reflection matrix
  45860. */
  45861. getReflectionTextureMatrix(): Matrix;
  45862. /**
  45863. * Set the texture reflection matrix used to rotate/transform the reflection.
  45864. * @param value Define the reflection matrix to set
  45865. */
  45866. setReflectionTextureMatrix(value: Matrix): void;
  45867. /**
  45868. * Parses a JSON representation of an HDR Texture in order to create the texture
  45869. * @param parsedTexture Define the JSON representation
  45870. * @param scene Define the scene the texture should be created in
  45871. * @param rootUrl Define the root url in case we need to load relative dependencies
  45872. * @returns the newly created texture after parsing
  45873. */
  45874. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  45875. serialize(): any;
  45876. }
  45877. }
  45878. declare module BABYLON {
  45879. /**
  45880. * Class used to control physics engine
  45881. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  45882. */
  45883. export class PhysicsEngine implements IPhysicsEngine {
  45884. private _physicsPlugin;
  45885. /**
  45886. * Global value used to control the smallest number supported by the simulation
  45887. */
  45888. static Epsilon: number;
  45889. private _impostors;
  45890. private _joints;
  45891. /**
  45892. * Gets the gravity vector used by the simulation
  45893. */
  45894. gravity: Vector3;
  45895. /**
  45896. * Factory used to create the default physics plugin.
  45897. * @returns The default physics plugin
  45898. */
  45899. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  45900. /**
  45901. * Creates a new Physics Engine
  45902. * @param gravity defines the gravity vector used by the simulation
  45903. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  45904. */
  45905. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  45906. /**
  45907. * Sets the gravity vector used by the simulation
  45908. * @param gravity defines the gravity vector to use
  45909. */
  45910. setGravity(gravity: Vector3): void;
  45911. /**
  45912. * Set the time step of the physics engine.
  45913. * Default is 1/60.
  45914. * To slow it down, enter 1/600 for example.
  45915. * To speed it up, 1/30
  45916. * @param newTimeStep defines the new timestep to apply to this world.
  45917. */
  45918. setTimeStep(newTimeStep?: number): void;
  45919. /**
  45920. * Get the time step of the physics engine.
  45921. * @returns the current time step
  45922. */
  45923. getTimeStep(): number;
  45924. /**
  45925. * Release all resources
  45926. */
  45927. dispose(): void;
  45928. /**
  45929. * Gets the name of the current physics plugin
  45930. * @returns the name of the plugin
  45931. */
  45932. getPhysicsPluginName(): string;
  45933. /**
  45934. * Adding a new impostor for the impostor tracking.
  45935. * This will be done by the impostor itself.
  45936. * @param impostor the impostor to add
  45937. */
  45938. addImpostor(impostor: PhysicsImpostor): void;
  45939. /**
  45940. * Remove an impostor from the engine.
  45941. * This impostor and its mesh will not longer be updated by the physics engine.
  45942. * @param impostor the impostor to remove
  45943. */
  45944. removeImpostor(impostor: PhysicsImpostor): void;
  45945. /**
  45946. * Add a joint to the physics engine
  45947. * @param mainImpostor defines the main impostor to which the joint is added.
  45948. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  45949. * @param joint defines the joint that will connect both impostors.
  45950. */
  45951. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  45952. /**
  45953. * Removes a joint from the simulation
  45954. * @param mainImpostor defines the impostor used with the joint
  45955. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  45956. * @param joint defines the joint to remove
  45957. */
  45958. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  45959. /**
  45960. * Called by the scene. No need to call it.
  45961. * @param delta defines the timespam between frames
  45962. */
  45963. _step(delta: number): void;
  45964. /**
  45965. * Gets the current plugin used to run the simulation
  45966. * @returns current plugin
  45967. */
  45968. getPhysicsPlugin(): IPhysicsEnginePlugin;
  45969. /**
  45970. * Gets the list of physic impostors
  45971. * @returns an array of PhysicsImpostor
  45972. */
  45973. getImpostors(): Array<PhysicsImpostor>;
  45974. /**
  45975. * Gets the impostor for a physics enabled object
  45976. * @param object defines the object impersonated by the impostor
  45977. * @returns the PhysicsImpostor or null if not found
  45978. */
  45979. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  45980. /**
  45981. * Gets the impostor for a physics body object
  45982. * @param body defines physics body used by the impostor
  45983. * @returns the PhysicsImpostor or null if not found
  45984. */
  45985. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  45986. }
  45987. }
  45988. declare module BABYLON {
  45989. /** @hidden */
  45990. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  45991. private _useDeltaForWorldStep;
  45992. world: any;
  45993. name: string;
  45994. private _physicsMaterials;
  45995. private _fixedTimeStep;
  45996. BJSCANNON: any;
  45997. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  45998. setGravity(gravity: Vector3): void;
  45999. setTimeStep(timeStep: number): void;
  46000. getTimeStep(): number;
  46001. executeStep(delta: number): void;
  46002. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  46003. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  46004. generatePhysicsBody(impostor: PhysicsImpostor): void;
  46005. private _processChildMeshes;
  46006. removePhysicsBody(impostor: PhysicsImpostor): void;
  46007. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  46008. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  46009. private _addMaterial;
  46010. private _checkWithEpsilon;
  46011. private _createShape;
  46012. private _createHeightmap;
  46013. private _minus90X;
  46014. private _plus90X;
  46015. private _tmpPosition;
  46016. private _tmpDeltaPosition;
  46017. private _tmpUnityRotation;
  46018. private _updatePhysicsBodyTransformation;
  46019. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  46020. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  46021. isSupported(): boolean;
  46022. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  46023. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  46024. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  46025. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  46026. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  46027. getBodyMass(impostor: PhysicsImpostor): number;
  46028. getBodyFriction(impostor: PhysicsImpostor): number;
  46029. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  46030. getBodyRestitution(impostor: PhysicsImpostor): number;
  46031. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  46032. sleepBody(impostor: PhysicsImpostor): void;
  46033. wakeUpBody(impostor: PhysicsImpostor): void;
  46034. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  46035. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  46036. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  46037. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  46038. getRadius(impostor: PhysicsImpostor): number;
  46039. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  46040. dispose(): void;
  46041. private _extendNamespace;
  46042. }
  46043. }
  46044. declare module BABYLON {
  46045. /** @hidden */
  46046. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  46047. world: any;
  46048. name: string;
  46049. BJSOIMO: any;
  46050. constructor(iterations?: number, oimoInjection?: any);
  46051. setGravity(gravity: Vector3): void;
  46052. setTimeStep(timeStep: number): void;
  46053. getTimeStep(): number;
  46054. private _tmpImpostorsArray;
  46055. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  46056. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  46057. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  46058. generatePhysicsBody(impostor: PhysicsImpostor): void;
  46059. private _tmpPositionVector;
  46060. removePhysicsBody(impostor: PhysicsImpostor): void;
  46061. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  46062. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  46063. isSupported(): boolean;
  46064. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  46065. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  46066. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  46067. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  46068. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  46069. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  46070. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  46071. getBodyMass(impostor: PhysicsImpostor): number;
  46072. getBodyFriction(impostor: PhysicsImpostor): number;
  46073. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  46074. getBodyRestitution(impostor: PhysicsImpostor): number;
  46075. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  46076. sleepBody(impostor: PhysicsImpostor): void;
  46077. wakeUpBody(impostor: PhysicsImpostor): void;
  46078. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  46079. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  46080. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  46081. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  46082. getRadius(impostor: PhysicsImpostor): number;
  46083. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  46084. dispose(): void;
  46085. }
  46086. }
  46087. declare module BABYLON {
  46088. interface AbstractScene {
  46089. /**
  46090. * The list of reflection probes added to the scene
  46091. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  46092. */
  46093. reflectionProbes: Array<ReflectionProbe>;
  46094. /**
  46095. * Removes the given reflection probe from this scene.
  46096. * @param toRemove The reflection probe to remove
  46097. * @returns The index of the removed reflection probe
  46098. */
  46099. removeReflectionProbe(toRemove: ReflectionProbe): number;
  46100. /**
  46101. * Adds the given reflection probe to this scene.
  46102. * @param newReflectionProbe The reflection probe to add
  46103. */
  46104. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  46105. }
  46106. /**
  46107. * Class used to generate realtime reflection / refraction cube textures
  46108. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  46109. */
  46110. export class ReflectionProbe {
  46111. /** defines the name of the probe */
  46112. name: string;
  46113. private _scene;
  46114. private _renderTargetTexture;
  46115. private _projectionMatrix;
  46116. private _viewMatrix;
  46117. private _target;
  46118. private _add;
  46119. private _attachedMesh;
  46120. private _invertYAxis;
  46121. /** Gets or sets probe position (center of the cube map) */
  46122. position: Vector3;
  46123. /**
  46124. * Creates a new reflection probe
  46125. * @param name defines the name of the probe
  46126. * @param size defines the texture resolution (for each face)
  46127. * @param scene defines the hosting scene
  46128. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  46129. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  46130. */
  46131. constructor(
  46132. /** defines the name of the probe */
  46133. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  46134. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  46135. samples: number;
  46136. /** Gets or sets the refresh rate to use (on every frame by default) */
  46137. refreshRate: number;
  46138. /**
  46139. * Gets the hosting scene
  46140. * @returns a Scene
  46141. */
  46142. getScene(): Scene;
  46143. /** Gets the internal CubeTexture used to render to */
  46144. readonly cubeTexture: RenderTargetTexture;
  46145. /** Gets the list of meshes to render */
  46146. readonly renderList: Nullable<AbstractMesh[]>;
  46147. /**
  46148. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  46149. * @param mesh defines the mesh to attach to
  46150. */
  46151. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46152. /**
  46153. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  46154. * @param renderingGroupId The rendering group id corresponding to its index
  46155. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  46156. */
  46157. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  46158. /**
  46159. * Clean all associated resources
  46160. */
  46161. dispose(): void;
  46162. /**
  46163. * Converts the reflection probe information to a readable string for debug purpose.
  46164. * @param fullDetails Supports for multiple levels of logging within scene loading
  46165. * @returns the human readable reflection probe info
  46166. */
  46167. toString(fullDetails?: boolean): string;
  46168. /**
  46169. * Get the class name of the relfection probe.
  46170. * @returns "ReflectionProbe"
  46171. */
  46172. getClassName(): string;
  46173. /**
  46174. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  46175. * @returns The JSON representation of the texture
  46176. */
  46177. serialize(): any;
  46178. /**
  46179. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  46180. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  46181. * @param scene Define the scene the parsed reflection probe should be instantiated in
  46182. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  46183. * @returns The parsed reflection probe if successful
  46184. */
  46185. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  46186. }
  46187. }
  46188. declare module BABYLON {
  46189. /** @hidden */
  46190. export var _BabylonLoaderRegistered: boolean;
  46191. }
  46192. declare module BABYLON {
  46193. /**
  46194. * The Physically based simple base material of BJS.
  46195. *
  46196. * This enables better naming and convention enforcements on top of the pbrMaterial.
  46197. * It is used as the base class for both the specGloss and metalRough conventions.
  46198. */
  46199. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  46200. /**
  46201. * Number of Simultaneous lights allowed on the material.
  46202. */
  46203. maxSimultaneousLights: number;
  46204. /**
  46205. * If sets to true, disables all the lights affecting the material.
  46206. */
  46207. disableLighting: boolean;
  46208. /**
  46209. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  46210. */
  46211. environmentTexture: BaseTexture;
  46212. /**
  46213. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46214. */
  46215. invertNormalMapX: boolean;
  46216. /**
  46217. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46218. */
  46219. invertNormalMapY: boolean;
  46220. /**
  46221. * Normal map used in the model.
  46222. */
  46223. normalTexture: BaseTexture;
  46224. /**
  46225. * Emissivie color used to self-illuminate the model.
  46226. */
  46227. emissiveColor: Color3;
  46228. /**
  46229. * Emissivie texture used to self-illuminate the model.
  46230. */
  46231. emissiveTexture: BaseTexture;
  46232. /**
  46233. * Occlusion Channel Strenght.
  46234. */
  46235. occlusionStrength: number;
  46236. /**
  46237. * Occlusion Texture of the material (adding extra occlusion effects).
  46238. */
  46239. occlusionTexture: BaseTexture;
  46240. /**
  46241. * Defines the alpha limits in alpha test mode.
  46242. */
  46243. alphaCutOff: number;
  46244. /**
  46245. * Gets the current double sided mode.
  46246. */
  46247. /**
  46248. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46249. */
  46250. doubleSided: boolean;
  46251. /**
  46252. * Stores the pre-calculated light information of a mesh in a texture.
  46253. */
  46254. lightmapTexture: BaseTexture;
  46255. /**
  46256. * If true, the light map contains occlusion information instead of lighting info.
  46257. */
  46258. useLightmapAsShadowmap: boolean;
  46259. /**
  46260. * Return the active textures of the material.
  46261. */
  46262. getActiveTextures(): BaseTexture[];
  46263. hasTexture(texture: BaseTexture): boolean;
  46264. /**
  46265. * Instantiates a new PBRMaterial instance.
  46266. *
  46267. * @param name The material name
  46268. * @param scene The scene the material will be use in.
  46269. */
  46270. constructor(name: string, scene: Scene);
  46271. getClassName(): string;
  46272. }
  46273. }
  46274. declare module BABYLON {
  46275. /**
  46276. * The PBR material of BJS following the metal roughness convention.
  46277. *
  46278. * This fits to the PBR convention in the GLTF definition:
  46279. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  46280. */
  46281. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  46282. /**
  46283. * The base color has two different interpretations depending on the value of metalness.
  46284. * When the material is a metal, the base color is the specific measured reflectance value
  46285. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  46286. * of the material.
  46287. */
  46288. baseColor: Color3;
  46289. /**
  46290. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  46291. * well as opacity information in the alpha channel.
  46292. */
  46293. baseTexture: BaseTexture;
  46294. /**
  46295. * Specifies the metallic scalar value of the material.
  46296. * Can also be used to scale the metalness values of the metallic texture.
  46297. */
  46298. metallic: number;
  46299. /**
  46300. * Specifies the roughness scalar value of the material.
  46301. * Can also be used to scale the roughness values of the metallic texture.
  46302. */
  46303. roughness: number;
  46304. /**
  46305. * Texture containing both the metallic value in the B channel and the
  46306. * roughness value in the G channel to keep better precision.
  46307. */
  46308. metallicRoughnessTexture: BaseTexture;
  46309. /**
  46310. * Instantiates a new PBRMetalRoughnessMaterial instance.
  46311. *
  46312. * @param name The material name
  46313. * @param scene The scene the material will be use in.
  46314. */
  46315. constructor(name: string, scene: Scene);
  46316. /**
  46317. * Return the currrent class name of the material.
  46318. */
  46319. getClassName(): string;
  46320. /**
  46321. * Return the active textures of the material.
  46322. */
  46323. getActiveTextures(): BaseTexture[];
  46324. /**
  46325. * Checks to see if a texture is used in the material.
  46326. * @param texture - Base texture to use.
  46327. * @returns - Boolean specifying if a texture is used in the material.
  46328. */
  46329. hasTexture(texture: BaseTexture): boolean;
  46330. /**
  46331. * Makes a duplicate of the current material.
  46332. * @param name - name to use for the new material.
  46333. */
  46334. clone(name: string): PBRMetallicRoughnessMaterial;
  46335. /**
  46336. * Serialize the material to a parsable JSON object.
  46337. */
  46338. serialize(): any;
  46339. /**
  46340. * Parses a JSON object correponding to the serialize function.
  46341. */
  46342. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  46343. }
  46344. }
  46345. declare module BABYLON {
  46346. /**
  46347. * The PBR material of BJS following the specular glossiness convention.
  46348. *
  46349. * This fits to the PBR convention in the GLTF definition:
  46350. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  46351. */
  46352. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  46353. /**
  46354. * Specifies the diffuse color of the material.
  46355. */
  46356. diffuseColor: Color3;
  46357. /**
  46358. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  46359. * channel.
  46360. */
  46361. diffuseTexture: BaseTexture;
  46362. /**
  46363. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  46364. */
  46365. specularColor: Color3;
  46366. /**
  46367. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  46368. */
  46369. glossiness: number;
  46370. /**
  46371. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  46372. */
  46373. specularGlossinessTexture: BaseTexture;
  46374. /**
  46375. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  46376. *
  46377. * @param name The material name
  46378. * @param scene The scene the material will be use in.
  46379. */
  46380. constructor(name: string, scene: Scene);
  46381. /**
  46382. * Return the currrent class name of the material.
  46383. */
  46384. getClassName(): string;
  46385. /**
  46386. * Return the active textures of the material.
  46387. */
  46388. getActiveTextures(): BaseTexture[];
  46389. /**
  46390. * Checks to see if a texture is used in the material.
  46391. * @param texture - Base texture to use.
  46392. * @returns - Boolean specifying if a texture is used in the material.
  46393. */
  46394. hasTexture(texture: BaseTexture): boolean;
  46395. /**
  46396. * Makes a duplicate of the current material.
  46397. * @param name - name to use for the new material.
  46398. */
  46399. clone(name: string): PBRSpecularGlossinessMaterial;
  46400. /**
  46401. * Serialize the material to a parsable JSON object.
  46402. */
  46403. serialize(): any;
  46404. /**
  46405. * Parses a JSON object correponding to the serialize function.
  46406. */
  46407. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  46408. }
  46409. }
  46410. declare module BABYLON {
  46411. /**
  46412. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  46413. * It can help converting any input color in a desired output one. This can then be used to create effects
  46414. * from sepia, black and white to sixties or futuristic rendering...
  46415. *
  46416. * The only supported format is currently 3dl.
  46417. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  46418. */
  46419. export class ColorGradingTexture extends BaseTexture {
  46420. /**
  46421. * The current texture matrix. (will always be identity in color grading texture)
  46422. */
  46423. private _textureMatrix;
  46424. /**
  46425. * The texture URL.
  46426. */
  46427. url: string;
  46428. /**
  46429. * Empty line regex stored for GC.
  46430. */
  46431. private static _noneEmptyLineRegex;
  46432. private _engine;
  46433. /**
  46434. * Instantiates a ColorGradingTexture from the following parameters.
  46435. *
  46436. * @param url The location of the color gradind data (currently only supporting 3dl)
  46437. * @param scene The scene the texture will be used in
  46438. */
  46439. constructor(url: string, scene: Scene);
  46440. /**
  46441. * Returns the texture matrix used in most of the material.
  46442. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  46443. */
  46444. getTextureMatrix(): Matrix;
  46445. /**
  46446. * Occurs when the file being loaded is a .3dl LUT file.
  46447. */
  46448. private load3dlTexture;
  46449. /**
  46450. * Starts the loading process of the texture.
  46451. */
  46452. private loadTexture;
  46453. /**
  46454. * Clones the color gradind texture.
  46455. */
  46456. clone(): ColorGradingTexture;
  46457. /**
  46458. * Called during delayed load for textures.
  46459. */
  46460. delayLoad(): void;
  46461. /**
  46462. * Parses a color grading texture serialized by Babylon.
  46463. * @param parsedTexture The texture information being parsedTexture
  46464. * @param scene The scene to load the texture in
  46465. * @param rootUrl The root url of the data assets to load
  46466. * @return A color gradind texture
  46467. */
  46468. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  46469. /**
  46470. * Serializes the LUT texture to json format.
  46471. */
  46472. serialize(): any;
  46473. }
  46474. }
  46475. declare module BABYLON {
  46476. /**
  46477. * Direct draw surface info
  46478. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46479. */
  46480. export interface DDSInfo {
  46481. /**
  46482. * Width of the texture
  46483. */
  46484. width: number;
  46485. /**
  46486. * Width of the texture
  46487. */
  46488. height: number;
  46489. /**
  46490. * Number of Mipmaps for the texture
  46491. * @see https://en.wikipedia.org/wiki/Mipmap
  46492. */
  46493. mipmapCount: number;
  46494. /**
  46495. * If the textures format is a known fourCC format
  46496. * @see https://www.fourcc.org/
  46497. */
  46498. isFourCC: boolean;
  46499. /**
  46500. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46501. */
  46502. isRGB: boolean;
  46503. /**
  46504. * If the texture is a lumincance format
  46505. */
  46506. isLuminance: boolean;
  46507. /**
  46508. * If this is a cube texture
  46509. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46510. */
  46511. isCube: boolean;
  46512. /**
  46513. * If the texture is a compressed format eg. FOURCC_DXT1
  46514. */
  46515. isCompressed: boolean;
  46516. /**
  46517. * The dxgiFormat of the texture
  46518. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46519. */
  46520. dxgiFormat: number;
  46521. /**
  46522. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46523. */
  46524. textureType: number;
  46525. /**
  46526. * Sphericle polynomial created for the dds texture
  46527. */
  46528. sphericalPolynomial?: SphericalPolynomial;
  46529. }
  46530. /**
  46531. * Class used to provide DDS decompression tools
  46532. */
  46533. export class DDSTools {
  46534. /**
  46535. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46536. */
  46537. static StoreLODInAlphaChannel: boolean;
  46538. /**
  46539. * Gets DDS information from an array buffer
  46540. * @param arrayBuffer defines the array buffer to read data from
  46541. * @returns the DDS information
  46542. */
  46543. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46544. private static _FloatView;
  46545. private static _Int32View;
  46546. private static _ToHalfFloat;
  46547. private static _FromHalfFloat;
  46548. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46549. private static _GetHalfFloatRGBAArrayBuffer;
  46550. private static _GetFloatRGBAArrayBuffer;
  46551. private static _GetFloatAsUIntRGBAArrayBuffer;
  46552. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46553. private static _GetRGBAArrayBuffer;
  46554. private static _ExtractLongWordOrder;
  46555. private static _GetRGBArrayBuffer;
  46556. private static _GetLuminanceArrayBuffer;
  46557. /**
  46558. * Uploads DDS Levels to a Babylon Texture
  46559. * @hidden
  46560. */
  46561. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46562. }
  46563. interface Engine {
  46564. /**
  46565. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46566. * @param rootUrl defines the url where the file to load is located
  46567. * @param scene defines the current scene
  46568. * @param lodScale defines scale to apply to the mip map selection
  46569. * @param lodOffset defines offset to apply to the mip map selection
  46570. * @param onLoad defines an optional callback raised when the texture is loaded
  46571. * @param onError defines an optional callback raised if there is an issue to load the texture
  46572. * @param format defines the format of the data
  46573. * @param forcedExtension defines the extension to use to pick the right loader
  46574. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46575. * @returns the cube texture as an InternalTexture
  46576. */
  46577. 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;
  46578. }
  46579. }
  46580. declare module BABYLON {
  46581. /**
  46582. * Implementation of the DDS Texture Loader.
  46583. * @hidden
  46584. */
  46585. export class _DDSTextureLoader implements IInternalTextureLoader {
  46586. /**
  46587. * Defines wether the loader supports cascade loading the different faces.
  46588. */
  46589. readonly supportCascades: boolean;
  46590. /**
  46591. * This returns if the loader support the current file information.
  46592. * @param extension defines the file extension of the file being loaded
  46593. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46594. * @param fallback defines the fallback internal texture if any
  46595. * @param isBase64 defines whether the texture is encoded as a base64
  46596. * @param isBuffer defines whether the texture data are stored as a buffer
  46597. * @returns true if the loader can load the specified file
  46598. */
  46599. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46600. /**
  46601. * Transform the url before loading if required.
  46602. * @param rootUrl the url of the texture
  46603. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46604. * @returns the transformed texture
  46605. */
  46606. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46607. /**
  46608. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46609. * @param rootUrl the url of the texture
  46610. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46611. * @returns the fallback texture
  46612. */
  46613. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46614. /**
  46615. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46616. * @param data contains the texture data
  46617. * @param texture defines the BabylonJS internal texture
  46618. * @param createPolynomials will be true if polynomials have been requested
  46619. * @param onLoad defines the callback to trigger once the texture is ready
  46620. * @param onError defines the callback to trigger in case of error
  46621. */
  46622. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46623. /**
  46624. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46625. * @param data contains the texture data
  46626. * @param texture defines the BabylonJS internal texture
  46627. * @param callback defines the method to call once ready to upload
  46628. */
  46629. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46630. }
  46631. }
  46632. declare module BABYLON {
  46633. /** @hidden */
  46634. export var rgbdEncodePixelShader: {
  46635. name: string;
  46636. shader: string;
  46637. };
  46638. }
  46639. declare module BABYLON {
  46640. /** @hidden */
  46641. export var rgbdDecodePixelShader: {
  46642. name: string;
  46643. shader: string;
  46644. };
  46645. }
  46646. declare module BABYLON {
  46647. /**
  46648. * Raw texture data and descriptor sufficient for WebGL texture upload
  46649. */
  46650. export interface EnvironmentTextureInfo {
  46651. /**
  46652. * Version of the environment map
  46653. */
  46654. version: number;
  46655. /**
  46656. * Width of image
  46657. */
  46658. width: number;
  46659. /**
  46660. * Irradiance information stored in the file.
  46661. */
  46662. irradiance: any;
  46663. /**
  46664. * Specular information stored in the file.
  46665. */
  46666. specular: any;
  46667. }
  46668. /**
  46669. * Sets of helpers addressing the serialization and deserialization of environment texture
  46670. * stored in a BabylonJS env file.
  46671. * Those files are usually stored as .env files.
  46672. */
  46673. export class EnvironmentTextureTools {
  46674. /**
  46675. * Magic number identifying the env file.
  46676. */
  46677. private static _MagicBytes;
  46678. /**
  46679. * Gets the environment info from an env file.
  46680. * @param data The array buffer containing the .env bytes.
  46681. * @returns the environment file info (the json header) if successfully parsed.
  46682. */
  46683. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46684. /**
  46685. * Creates an environment texture from a loaded cube texture.
  46686. * @param texture defines the cube texture to convert in env file
  46687. * @return a promise containing the environment data if succesfull.
  46688. */
  46689. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46690. /**
  46691. * Creates a JSON representation of the spherical data.
  46692. * @param texture defines the texture containing the polynomials
  46693. * @return the JSON representation of the spherical info
  46694. */
  46695. private static _CreateEnvTextureIrradiance;
  46696. /**
  46697. * Uploads the texture info contained in the env file to the GPU.
  46698. * @param texture defines the internal texture to upload to
  46699. * @param arrayBuffer defines the buffer cotaining the data to load
  46700. * @param info defines the texture info retrieved through the GetEnvInfo method
  46701. * @returns a promise
  46702. */
  46703. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46704. /**
  46705. * Uploads the levels of image data to the GPU.
  46706. * @param texture defines the internal texture to upload to
  46707. * @param imageData defines the array buffer views of image data [mipmap][face]
  46708. * @returns a promise
  46709. */
  46710. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46711. /**
  46712. * Uploads spherical polynomials information to the texture.
  46713. * @param texture defines the texture we are trying to upload the information to
  46714. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46715. */
  46716. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46717. /** @hidden */
  46718. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46719. }
  46720. }
  46721. declare module BABYLON {
  46722. /**
  46723. * Implementation of the ENV Texture Loader.
  46724. * @hidden
  46725. */
  46726. export class _ENVTextureLoader implements IInternalTextureLoader {
  46727. /**
  46728. * Defines wether the loader supports cascade loading the different faces.
  46729. */
  46730. readonly supportCascades: boolean;
  46731. /**
  46732. * This returns if the loader support the current file information.
  46733. * @param extension defines the file extension of the file being loaded
  46734. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46735. * @param fallback defines the fallback internal texture if any
  46736. * @param isBase64 defines whether the texture is encoded as a base64
  46737. * @param isBuffer defines whether the texture data are stored as a buffer
  46738. * @returns true if the loader can load the specified file
  46739. */
  46740. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46741. /**
  46742. * Transform the url before loading if required.
  46743. * @param rootUrl the url of the texture
  46744. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46745. * @returns the transformed texture
  46746. */
  46747. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46748. /**
  46749. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46750. * @param rootUrl the url of the texture
  46751. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46752. * @returns the fallback texture
  46753. */
  46754. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46755. /**
  46756. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46757. * @param data contains the texture data
  46758. * @param texture defines the BabylonJS internal texture
  46759. * @param createPolynomials will be true if polynomials have been requested
  46760. * @param onLoad defines the callback to trigger once the texture is ready
  46761. * @param onError defines the callback to trigger in case of error
  46762. */
  46763. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46764. /**
  46765. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46766. * @param data contains the texture data
  46767. * @param texture defines the BabylonJS internal texture
  46768. * @param callback defines the method to call once ready to upload
  46769. */
  46770. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46771. }
  46772. }
  46773. declare module BABYLON {
  46774. /**
  46775. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46776. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46777. */
  46778. export class KhronosTextureContainer {
  46779. /** contents of the KTX container file */
  46780. arrayBuffer: any;
  46781. private static HEADER_LEN;
  46782. private static COMPRESSED_2D;
  46783. private static COMPRESSED_3D;
  46784. private static TEX_2D;
  46785. private static TEX_3D;
  46786. /**
  46787. * Gets the openGL type
  46788. */
  46789. glType: number;
  46790. /**
  46791. * Gets the openGL type size
  46792. */
  46793. glTypeSize: number;
  46794. /**
  46795. * Gets the openGL format
  46796. */
  46797. glFormat: number;
  46798. /**
  46799. * Gets the openGL internal format
  46800. */
  46801. glInternalFormat: number;
  46802. /**
  46803. * Gets the base internal format
  46804. */
  46805. glBaseInternalFormat: number;
  46806. /**
  46807. * Gets image width in pixel
  46808. */
  46809. pixelWidth: number;
  46810. /**
  46811. * Gets image height in pixel
  46812. */
  46813. pixelHeight: number;
  46814. /**
  46815. * Gets image depth in pixels
  46816. */
  46817. pixelDepth: number;
  46818. /**
  46819. * Gets the number of array elements
  46820. */
  46821. numberOfArrayElements: number;
  46822. /**
  46823. * Gets the number of faces
  46824. */
  46825. numberOfFaces: number;
  46826. /**
  46827. * Gets the number of mipmap levels
  46828. */
  46829. numberOfMipmapLevels: number;
  46830. /**
  46831. * Gets the bytes of key value data
  46832. */
  46833. bytesOfKeyValueData: number;
  46834. /**
  46835. * Gets the load type
  46836. */
  46837. loadType: number;
  46838. /**
  46839. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46840. */
  46841. isInvalid: boolean;
  46842. /**
  46843. * Creates a new KhronosTextureContainer
  46844. * @param arrayBuffer contents of the KTX container file
  46845. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46846. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46847. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46848. */
  46849. constructor(
  46850. /** contents of the KTX container file */
  46851. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46852. /**
  46853. * Uploads KTX content to a Babylon Texture.
  46854. * It is assumed that the texture has already been created & is currently bound
  46855. * @hidden
  46856. */
  46857. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46858. private _upload2DCompressedLevels;
  46859. }
  46860. }
  46861. declare module BABYLON {
  46862. /**
  46863. * Implementation of the KTX Texture Loader.
  46864. * @hidden
  46865. */
  46866. export class _KTXTextureLoader implements IInternalTextureLoader {
  46867. /**
  46868. * Defines wether the loader supports cascade loading the different faces.
  46869. */
  46870. readonly supportCascades: boolean;
  46871. /**
  46872. * This returns if the loader support the current file information.
  46873. * @param extension defines the file extension of the file being loaded
  46874. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46875. * @param fallback defines the fallback internal texture if any
  46876. * @param isBase64 defines whether the texture is encoded as a base64
  46877. * @param isBuffer defines whether the texture data are stored as a buffer
  46878. * @returns true if the loader can load the specified file
  46879. */
  46880. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46881. /**
  46882. * Transform the url before loading if required.
  46883. * @param rootUrl the url of the texture
  46884. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46885. * @returns the transformed texture
  46886. */
  46887. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46888. /**
  46889. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46890. * @param rootUrl the url of the texture
  46891. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46892. * @returns the fallback texture
  46893. */
  46894. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46895. /**
  46896. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46897. * @param data contains the texture data
  46898. * @param texture defines the BabylonJS internal texture
  46899. * @param createPolynomials will be true if polynomials have been requested
  46900. * @param onLoad defines the callback to trigger once the texture is ready
  46901. * @param onError defines the callback to trigger in case of error
  46902. */
  46903. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46904. /**
  46905. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46906. * @param data contains the texture data
  46907. * @param texture defines the BabylonJS internal texture
  46908. * @param callback defines the method to call once ready to upload
  46909. */
  46910. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46911. }
  46912. }
  46913. declare module BABYLON {
  46914. /**
  46915. * Based on jsTGALoader - Javascript loader for TGA file
  46916. * By Vincent Thibault
  46917. * @see http://blog.robrowser.com/javascript-tga-loader.html
  46918. */
  46919. export class TGATools {
  46920. private static _TYPE_INDEXED;
  46921. private static _TYPE_RGB;
  46922. private static _TYPE_GREY;
  46923. private static _TYPE_RLE_INDEXED;
  46924. private static _TYPE_RLE_RGB;
  46925. private static _TYPE_RLE_GREY;
  46926. private static _ORIGIN_MASK;
  46927. private static _ORIGIN_SHIFT;
  46928. private static _ORIGIN_BL;
  46929. private static _ORIGIN_BR;
  46930. private static _ORIGIN_UL;
  46931. private static _ORIGIN_UR;
  46932. /**
  46933. * Gets the header of a TGA file
  46934. * @param data defines the TGA data
  46935. * @returns the header
  46936. */
  46937. static GetTGAHeader(data: Uint8Array): any;
  46938. /**
  46939. * Uploads TGA content to a Babylon Texture
  46940. * @hidden
  46941. */
  46942. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  46943. /** @hidden */
  46944. 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;
  46945. /** @hidden */
  46946. 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;
  46947. /** @hidden */
  46948. 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;
  46949. /** @hidden */
  46950. 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;
  46951. /** @hidden */
  46952. 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;
  46953. /** @hidden */
  46954. 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;
  46955. }
  46956. }
  46957. declare module BABYLON {
  46958. /**
  46959. * Implementation of the TGA Texture Loader.
  46960. * @hidden
  46961. */
  46962. export class _TGATextureLoader implements IInternalTextureLoader {
  46963. /**
  46964. * Defines wether the loader supports cascade loading the different faces.
  46965. */
  46966. readonly supportCascades: boolean;
  46967. /**
  46968. * This returns if the loader support the current file information.
  46969. * @param extension defines the file extension of the file being loaded
  46970. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46971. * @param fallback defines the fallback internal texture if any
  46972. * @param isBase64 defines whether the texture is encoded as a base64
  46973. * @param isBuffer defines whether the texture data are stored as a buffer
  46974. * @returns true if the loader can load the specified file
  46975. */
  46976. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46977. /**
  46978. * Transform the url before loading if required.
  46979. * @param rootUrl the url of the texture
  46980. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46981. * @returns the transformed texture
  46982. */
  46983. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46984. /**
  46985. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46986. * @param rootUrl the url of the texture
  46987. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46988. * @returns the fallback texture
  46989. */
  46990. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46991. /**
  46992. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46993. * @param data contains the texture data
  46994. * @param texture defines the BabylonJS internal texture
  46995. * @param createPolynomials will be true if polynomials have been requested
  46996. * @param onLoad defines the callback to trigger once the texture is ready
  46997. * @param onError defines the callback to trigger in case of error
  46998. */
  46999. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47000. /**
  47001. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47002. * @param data contains the texture data
  47003. * @param texture defines the BabylonJS internal texture
  47004. * @param callback defines the method to call once ready to upload
  47005. */
  47006. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47007. }
  47008. }
  47009. declare module BABYLON {
  47010. /**
  47011. * 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.
  47012. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  47013. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  47014. */
  47015. export class CustomProceduralTexture extends ProceduralTexture {
  47016. private _animate;
  47017. private _time;
  47018. private _config;
  47019. private _texturePath;
  47020. /**
  47021. * Instantiates a new Custom Procedural Texture.
  47022. * 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.
  47023. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  47024. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  47025. * @param name Define the name of the texture
  47026. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  47027. * @param size Define the size of the texture to create
  47028. * @param scene Define the scene the texture belongs to
  47029. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  47030. * @param generateMipMaps Define if the texture should creates mip maps or not
  47031. */
  47032. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  47033. private _loadJson;
  47034. /**
  47035. * Is the texture ready to be used ? (rendered at least once)
  47036. * @returns true if ready, otherwise, false.
  47037. */
  47038. isReady(): boolean;
  47039. /**
  47040. * Render the texture to its associated render target.
  47041. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  47042. */
  47043. render(useCameraPostProcess?: boolean): void;
  47044. /**
  47045. * Update the list of dependant textures samplers in the shader.
  47046. */
  47047. updateTextures(): void;
  47048. /**
  47049. * Update the uniform values of the procedural texture in the shader.
  47050. */
  47051. updateShaderUniforms(): void;
  47052. /**
  47053. * Define if the texture animates or not.
  47054. */
  47055. animate: boolean;
  47056. }
  47057. }
  47058. declare module BABYLON {
  47059. /** @hidden */
  47060. export var noisePixelShader: {
  47061. name: string;
  47062. shader: string;
  47063. };
  47064. }
  47065. declare module BABYLON {
  47066. /**
  47067. * Class used to generate noise procedural textures
  47068. */
  47069. export class NoiseProceduralTexture extends ProceduralTexture {
  47070. private _time;
  47071. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  47072. brightness: number;
  47073. /** Defines the number of octaves to process */
  47074. octaves: number;
  47075. /** Defines the level of persistence (0.8 by default) */
  47076. persistence: number;
  47077. /** Gets or sets animation speed factor (default is 1) */
  47078. animationSpeedFactor: number;
  47079. /**
  47080. * Creates a new NoiseProceduralTexture
  47081. * @param name defines the name fo the texture
  47082. * @param size defines the size of the texture (default is 256)
  47083. * @param scene defines the hosting scene
  47084. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  47085. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  47086. */
  47087. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  47088. private _updateShaderUniforms;
  47089. protected _getDefines(): string;
  47090. /** Generate the current state of the procedural texture */
  47091. render(useCameraPostProcess?: boolean): void;
  47092. /**
  47093. * Serializes this noise procedural texture
  47094. * @returns a serialized noise procedural texture object
  47095. */
  47096. serialize(): any;
  47097. /**
  47098. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  47099. * @param parsedTexture defines parsed texture data
  47100. * @param scene defines the current scene
  47101. * @param rootUrl defines the root URL containing noise procedural texture information
  47102. * @returns a parsed NoiseProceduralTexture
  47103. */
  47104. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  47105. }
  47106. }
  47107. declare module BABYLON {
  47108. /**
  47109. * Raw cube texture where the raw buffers are passed in
  47110. */
  47111. export class RawCubeTexture extends CubeTexture {
  47112. /**
  47113. * Creates a cube texture where the raw buffers are passed in.
  47114. * @param scene defines the scene the texture is attached to
  47115. * @param data defines the array of data to use to create each face
  47116. * @param size defines the size of the textures
  47117. * @param format defines the format of the data
  47118. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  47119. * @param generateMipMaps defines if the engine should generate the mip levels
  47120. * @param invertY defines if data must be stored with Y axis inverted
  47121. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  47122. * @param compression defines the compression used (null by default)
  47123. */
  47124. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  47125. /**
  47126. * Updates the raw cube texture.
  47127. * @param data defines the data to store
  47128. * @param format defines the data format
  47129. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47130. * @param invertY defines if data must be stored with Y axis inverted
  47131. * @param compression defines the compression used (null by default)
  47132. * @param level defines which level of the texture to update
  47133. */
  47134. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  47135. /**
  47136. * Updates a raw cube texture with RGBD encoded data.
  47137. * @param data defines the array of data [mipmap][face] to use to create each face
  47138. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  47139. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47140. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47141. * @returns a promsie that resolves when the operation is complete
  47142. */
  47143. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  47144. /**
  47145. * Clones the raw cube texture.
  47146. * @return a new cube texture
  47147. */
  47148. clone(): CubeTexture;
  47149. /** @hidden */
  47150. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47151. }
  47152. }
  47153. declare module BABYLON {
  47154. /**
  47155. * Class used to store 3D textures containing user data
  47156. */
  47157. export class RawTexture3D extends Texture {
  47158. /** Gets or sets the texture format to use */
  47159. format: number;
  47160. private _engine;
  47161. /**
  47162. * Create a new RawTexture3D
  47163. * @param data defines the data of the texture
  47164. * @param width defines the width of the texture
  47165. * @param height defines the height of the texture
  47166. * @param depth defines the depth of the texture
  47167. * @param format defines the texture format to use
  47168. * @param scene defines the hosting scene
  47169. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  47170. * @param invertY defines if texture must be stored with Y axis inverted
  47171. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  47172. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47173. */
  47174. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  47175. /** Gets or sets the texture format to use */
  47176. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  47177. /**
  47178. * Update the texture with new data
  47179. * @param data defines the data to store in the texture
  47180. */
  47181. update(data: ArrayBufferView): void;
  47182. }
  47183. }
  47184. declare module BABYLON {
  47185. /**
  47186. * Creates a refraction texture used by refraction channel of the standard material.
  47187. * It is like a mirror but to see through a material.
  47188. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47189. */
  47190. export class RefractionTexture extends RenderTargetTexture {
  47191. /**
  47192. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  47193. * 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.
  47194. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47195. */
  47196. refractionPlane: Plane;
  47197. /**
  47198. * Define how deep under the surface we should see.
  47199. */
  47200. depth: number;
  47201. /**
  47202. * Creates a refraction texture used by refraction channel of the standard material.
  47203. * It is like a mirror but to see through a material.
  47204. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47205. * @param name Define the texture name
  47206. * @param size Define the size of the underlying texture
  47207. * @param scene Define the scene the refraction belongs to
  47208. * @param generateMipMaps Define if we need to generate mips level for the refraction
  47209. */
  47210. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  47211. /**
  47212. * Clone the refraction texture.
  47213. * @returns the cloned texture
  47214. */
  47215. clone(): RefractionTexture;
  47216. /**
  47217. * Serialize the texture to a JSON representation you could use in Parse later on
  47218. * @returns the serialized JSON representation
  47219. */
  47220. serialize(): any;
  47221. }
  47222. }
  47223. declare module BABYLON {
  47224. /**
  47225. * Configuration for Draco compression
  47226. */
  47227. export interface IDracoCompressionConfiguration {
  47228. /**
  47229. * Configuration for the decoder.
  47230. */
  47231. decoder?: {
  47232. /**
  47233. * The url to the WebAssembly module.
  47234. */
  47235. wasmUrl?: string;
  47236. /**
  47237. * The url to the WebAssembly binary.
  47238. */
  47239. wasmBinaryUrl?: string;
  47240. /**
  47241. * The url to the fallback JavaScript module.
  47242. */
  47243. fallbackUrl?: string;
  47244. };
  47245. }
  47246. /**
  47247. * Draco compression (https://google.github.io/draco/)
  47248. *
  47249. * This class wraps the Draco module.
  47250. *
  47251. * **Encoder**
  47252. *
  47253. * The encoder is not currently implemented.
  47254. *
  47255. * **Decoder**
  47256. *
  47257. * 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.
  47258. *
  47259. * To update the configuration, use the following code:
  47260. * ```javascript
  47261. * DracoCompression.Configuration = {
  47262. * decoder: {
  47263. * wasmUrl: "<url to the WebAssembly library>",
  47264. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  47265. * fallbackUrl: "<url to the fallback JavaScript library>",
  47266. * }
  47267. * };
  47268. * ```
  47269. *
  47270. * 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.
  47271. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  47272. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  47273. *
  47274. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  47275. * ```javascript
  47276. * var dracoCompression = new DracoCompression();
  47277. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  47278. * [VertexBuffer.PositionKind]: 0
  47279. * });
  47280. * ```
  47281. *
  47282. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  47283. */
  47284. export class DracoCompression implements IDisposable {
  47285. private static _DecoderModulePromise;
  47286. /**
  47287. * The configuration. Defaults to the following urls:
  47288. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  47289. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  47290. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  47291. */
  47292. static Configuration: IDracoCompressionConfiguration;
  47293. /**
  47294. * Returns true if the decoder is available.
  47295. */
  47296. static readonly DecoderAvailable: boolean;
  47297. /**
  47298. * Constructor
  47299. */
  47300. constructor();
  47301. /**
  47302. * Stop all async operations and release resources.
  47303. */
  47304. dispose(): void;
  47305. /**
  47306. * Decode Draco compressed mesh data to vertex data.
  47307. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  47308. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  47309. * @returns A promise that resolves with the decoded vertex data
  47310. */
  47311. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  47312. [kind: string]: number;
  47313. }): Promise<VertexData>;
  47314. private static _GetDecoderModule;
  47315. private static _LoadScriptAsync;
  47316. private static _LoadFileAsync;
  47317. }
  47318. }
  47319. declare module BABYLON {
  47320. /**
  47321. * Class for building Constructive Solid Geometry
  47322. */
  47323. export class CSG {
  47324. private polygons;
  47325. /**
  47326. * The world matrix
  47327. */
  47328. matrix: Matrix;
  47329. /**
  47330. * Stores the position
  47331. */
  47332. position: Vector3;
  47333. /**
  47334. * Stores the rotation
  47335. */
  47336. rotation: Vector3;
  47337. /**
  47338. * Stores the rotation quaternion
  47339. */
  47340. rotationQuaternion: Nullable<Quaternion>;
  47341. /**
  47342. * Stores the scaling vector
  47343. */
  47344. scaling: Vector3;
  47345. /**
  47346. * Convert the Mesh to CSG
  47347. * @param mesh The Mesh to convert to CSG
  47348. * @returns A new CSG from the Mesh
  47349. */
  47350. static FromMesh(mesh: Mesh): CSG;
  47351. /**
  47352. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  47353. * @param polygons Polygons used to construct a CSG solid
  47354. */
  47355. private static FromPolygons;
  47356. /**
  47357. * Clones, or makes a deep copy, of the CSG
  47358. * @returns A new CSG
  47359. */
  47360. clone(): CSG;
  47361. /**
  47362. * Unions this CSG with another CSG
  47363. * @param csg The CSG to union against this CSG
  47364. * @returns The unioned CSG
  47365. */
  47366. union(csg: CSG): CSG;
  47367. /**
  47368. * Unions this CSG with another CSG in place
  47369. * @param csg The CSG to union against this CSG
  47370. */
  47371. unionInPlace(csg: CSG): void;
  47372. /**
  47373. * Subtracts this CSG with another CSG
  47374. * @param csg The CSG to subtract against this CSG
  47375. * @returns A new CSG
  47376. */
  47377. subtract(csg: CSG): CSG;
  47378. /**
  47379. * Subtracts this CSG with another CSG in place
  47380. * @param csg The CSG to subtact against this CSG
  47381. */
  47382. subtractInPlace(csg: CSG): void;
  47383. /**
  47384. * Intersect this CSG with another CSG
  47385. * @param csg The CSG to intersect against this CSG
  47386. * @returns A new CSG
  47387. */
  47388. intersect(csg: CSG): CSG;
  47389. /**
  47390. * Intersects this CSG with another CSG in place
  47391. * @param csg The CSG to intersect against this CSG
  47392. */
  47393. intersectInPlace(csg: CSG): void;
  47394. /**
  47395. * Return a new CSG solid with solid and empty space switched. This solid is
  47396. * not modified.
  47397. * @returns A new CSG solid with solid and empty space switched
  47398. */
  47399. inverse(): CSG;
  47400. /**
  47401. * Inverses the CSG in place
  47402. */
  47403. inverseInPlace(): void;
  47404. /**
  47405. * This is used to keep meshes transformations so they can be restored
  47406. * when we build back a Babylon Mesh
  47407. * NB : All CSG operations are performed in world coordinates
  47408. * @param csg The CSG to copy the transform attributes from
  47409. * @returns This CSG
  47410. */
  47411. copyTransformAttributes(csg: CSG): CSG;
  47412. /**
  47413. * Build Raw mesh from CSG
  47414. * Coordinates here are in world space
  47415. * @param name The name of the mesh geometry
  47416. * @param scene The Scene
  47417. * @param keepSubMeshes Specifies if the submeshes should be kept
  47418. * @returns A new Mesh
  47419. */
  47420. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  47421. /**
  47422. * Build Mesh from CSG taking material and transforms into account
  47423. * @param name The name of the Mesh
  47424. * @param material The material of the Mesh
  47425. * @param scene The Scene
  47426. * @param keepSubMeshes Specifies if submeshes should be kept
  47427. * @returns The new Mesh
  47428. */
  47429. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  47430. }
  47431. }
  47432. declare module BABYLON {
  47433. /**
  47434. * A simplifier interface for future simplification implementations
  47435. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47436. */
  47437. export interface ISimplifier {
  47438. /**
  47439. * Simplification of a given mesh according to the given settings.
  47440. * Since this requires computation, it is assumed that the function runs async.
  47441. * @param settings The settings of the simplification, including quality and distance
  47442. * @param successCallback A callback that will be called after the mesh was simplified.
  47443. * @param errorCallback in case of an error, this callback will be called. optional.
  47444. */
  47445. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  47446. }
  47447. /**
  47448. * Expected simplification settings.
  47449. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  47450. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47451. */
  47452. export interface ISimplificationSettings {
  47453. /**
  47454. * Gets or sets the expected quality
  47455. */
  47456. quality: number;
  47457. /**
  47458. * Gets or sets the distance when this optimized version should be used
  47459. */
  47460. distance: number;
  47461. /**
  47462. * Gets an already optimized mesh
  47463. */
  47464. optimizeMesh?: boolean;
  47465. }
  47466. /**
  47467. * Class used to specify simplification options
  47468. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47469. */
  47470. export class SimplificationSettings implements ISimplificationSettings {
  47471. /** expected quality */
  47472. quality: number;
  47473. /** distance when this optimized version should be used */
  47474. distance: number;
  47475. /** already optimized mesh */
  47476. optimizeMesh?: boolean | undefined;
  47477. /**
  47478. * Creates a SimplificationSettings
  47479. * @param quality expected quality
  47480. * @param distance distance when this optimized version should be used
  47481. * @param optimizeMesh already optimized mesh
  47482. */
  47483. constructor(
  47484. /** expected quality */
  47485. quality: number,
  47486. /** distance when this optimized version should be used */
  47487. distance: number,
  47488. /** already optimized mesh */
  47489. optimizeMesh?: boolean | undefined);
  47490. }
  47491. /**
  47492. * Interface used to define a simplification task
  47493. */
  47494. export interface ISimplificationTask {
  47495. /**
  47496. * Array of settings
  47497. */
  47498. settings: Array<ISimplificationSettings>;
  47499. /**
  47500. * Simplification type
  47501. */
  47502. simplificationType: SimplificationType;
  47503. /**
  47504. * Mesh to simplify
  47505. */
  47506. mesh: Mesh;
  47507. /**
  47508. * Callback called on success
  47509. */
  47510. successCallback?: () => void;
  47511. /**
  47512. * Defines if parallel processing can be used
  47513. */
  47514. parallelProcessing: boolean;
  47515. }
  47516. /**
  47517. * Queue used to order the simplification tasks
  47518. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47519. */
  47520. export class SimplificationQueue {
  47521. private _simplificationArray;
  47522. /**
  47523. * Gets a boolean indicating that the process is still running
  47524. */
  47525. running: boolean;
  47526. /**
  47527. * Creates a new queue
  47528. */
  47529. constructor();
  47530. /**
  47531. * Adds a new simplification task
  47532. * @param task defines a task to add
  47533. */
  47534. addTask(task: ISimplificationTask): void;
  47535. /**
  47536. * Execute next task
  47537. */
  47538. executeNext(): void;
  47539. /**
  47540. * Execute a simplification task
  47541. * @param task defines the task to run
  47542. */
  47543. runSimplification(task: ISimplificationTask): void;
  47544. private getSimplifier;
  47545. }
  47546. /**
  47547. * The implemented types of simplification
  47548. * At the moment only Quadratic Error Decimation is implemented
  47549. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47550. */
  47551. export enum SimplificationType {
  47552. /** Quadratic error decimation */
  47553. QUADRATIC = 0
  47554. }
  47555. }
  47556. declare module BABYLON {
  47557. interface Scene {
  47558. /** @hidden (Backing field) */
  47559. _simplificationQueue: SimplificationQueue;
  47560. /**
  47561. * Gets or sets the simplification queue attached to the scene
  47562. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47563. */
  47564. simplificationQueue: SimplificationQueue;
  47565. }
  47566. interface Mesh {
  47567. /**
  47568. * Simplify the mesh according to the given array of settings.
  47569. * Function will return immediately and will simplify async
  47570. * @param settings a collection of simplification settings
  47571. * @param parallelProcessing should all levels calculate parallel or one after the other
  47572. * @param simplificationType the type of simplification to run
  47573. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  47574. * @returns the current mesh
  47575. */
  47576. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  47577. }
  47578. /**
  47579. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  47580. * created in a scene
  47581. */
  47582. export class SimplicationQueueSceneComponent implements ISceneComponent {
  47583. /**
  47584. * The component name helpfull to identify the component in the list of scene components.
  47585. */
  47586. readonly name: string;
  47587. /**
  47588. * The scene the component belongs to.
  47589. */
  47590. scene: Scene;
  47591. /**
  47592. * Creates a new instance of the component for the given scene
  47593. * @param scene Defines the scene to register the component in
  47594. */
  47595. constructor(scene: Scene);
  47596. /**
  47597. * Registers the component in a given scene
  47598. */
  47599. register(): void;
  47600. /**
  47601. * Rebuilds the elements related to this component in case of
  47602. * context lost for instance.
  47603. */
  47604. rebuild(): void;
  47605. /**
  47606. * Disposes the component and the associated ressources
  47607. */
  47608. dispose(): void;
  47609. private _beforeCameraUpdate;
  47610. }
  47611. }
  47612. declare module BABYLON {
  47613. /**
  47614. * Class used to enable access to IndexedDB
  47615. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  47616. */
  47617. export class Database implements IOfflineProvider {
  47618. private _callbackManifestChecked;
  47619. private _currentSceneUrl;
  47620. private _db;
  47621. private _enableSceneOffline;
  47622. private _enableTexturesOffline;
  47623. private _manifestVersionFound;
  47624. private _mustUpdateRessources;
  47625. private _hasReachedQuota;
  47626. private _isSupported;
  47627. private _idbFactory;
  47628. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  47629. private static IsUASupportingBlobStorage;
  47630. /**
  47631. * Gets a boolean indicating if Database storate is enabled (off by default)
  47632. */
  47633. static IDBStorageEnabled: boolean;
  47634. /**
  47635. * Gets a boolean indicating if scene must be saved in the database
  47636. */
  47637. readonly enableSceneOffline: boolean;
  47638. /**
  47639. * Gets a boolean indicating if textures must be saved in the database
  47640. */
  47641. readonly enableTexturesOffline: boolean;
  47642. /**
  47643. * Creates a new Database
  47644. * @param urlToScene defines the url to load the scene
  47645. * @param callbackManifestChecked defines the callback to use when manifest is checked
  47646. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  47647. */
  47648. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  47649. private static _ParseURL;
  47650. private static _ReturnFullUrlLocation;
  47651. private _checkManifestFile;
  47652. /**
  47653. * Open the database and make it available
  47654. * @param successCallback defines the callback to call on success
  47655. * @param errorCallback defines the callback to call on error
  47656. */
  47657. open(successCallback: () => void, errorCallback: () => void): void;
  47658. /**
  47659. * Loads an image from the database
  47660. * @param url defines the url to load from
  47661. * @param image defines the target DOM image
  47662. */
  47663. loadImage(url: string, image: HTMLImageElement): void;
  47664. private _loadImageFromDBAsync;
  47665. private _saveImageIntoDBAsync;
  47666. private _checkVersionFromDB;
  47667. private _loadVersionFromDBAsync;
  47668. private _saveVersionIntoDBAsync;
  47669. /**
  47670. * Loads a file from database
  47671. * @param url defines the URL to load from
  47672. * @param sceneLoaded defines a callback to call on success
  47673. * @param progressCallBack defines a callback to call when progress changed
  47674. * @param errorCallback defines a callback to call on error
  47675. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  47676. */
  47677. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  47678. private _loadFileAsync;
  47679. private _saveFileAsync;
  47680. /**
  47681. * Validates if xhr data is correct
  47682. * @param xhr defines the request to validate
  47683. * @param dataType defines the expected data type
  47684. * @returns true if data is correct
  47685. */
  47686. private static _ValidateXHRData;
  47687. }
  47688. }
  47689. declare module BABYLON {
  47690. /** @hidden */
  47691. export var gpuUpdateParticlesPixelShader: {
  47692. name: string;
  47693. shader: string;
  47694. };
  47695. }
  47696. declare module BABYLON {
  47697. /** @hidden */
  47698. export var gpuUpdateParticlesVertexShader: {
  47699. name: string;
  47700. shader: string;
  47701. };
  47702. }
  47703. declare module BABYLON {
  47704. /** @hidden */
  47705. export var clipPlaneFragmentDeclaration2: {
  47706. name: string;
  47707. shader: string;
  47708. };
  47709. }
  47710. declare module BABYLON {
  47711. /** @hidden */
  47712. export var gpuRenderParticlesPixelShader: {
  47713. name: string;
  47714. shader: string;
  47715. };
  47716. }
  47717. declare module BABYLON {
  47718. /** @hidden */
  47719. export var clipPlaneVertexDeclaration2: {
  47720. name: string;
  47721. shader: string;
  47722. };
  47723. }
  47724. declare module BABYLON {
  47725. /** @hidden */
  47726. export var gpuRenderParticlesVertexShader: {
  47727. name: string;
  47728. shader: string;
  47729. };
  47730. }
  47731. declare module BABYLON {
  47732. /**
  47733. * This represents a GPU particle system in Babylon
  47734. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  47735. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  47736. */
  47737. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  47738. /**
  47739. * The layer mask we are rendering the particles through.
  47740. */
  47741. layerMask: number;
  47742. private _capacity;
  47743. private _activeCount;
  47744. private _currentActiveCount;
  47745. private _accumulatedCount;
  47746. private _renderEffect;
  47747. private _updateEffect;
  47748. private _buffer0;
  47749. private _buffer1;
  47750. private _spriteBuffer;
  47751. private _updateVAO;
  47752. private _renderVAO;
  47753. private _targetIndex;
  47754. private _sourceBuffer;
  47755. private _targetBuffer;
  47756. private _engine;
  47757. private _currentRenderId;
  47758. private _started;
  47759. private _stopped;
  47760. private _timeDelta;
  47761. private _randomTexture;
  47762. private _randomTexture2;
  47763. private _attributesStrideSize;
  47764. private _updateEffectOptions;
  47765. private _randomTextureSize;
  47766. private _actualFrame;
  47767. private readonly _rawTextureWidth;
  47768. /**
  47769. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  47770. */
  47771. static readonly IsSupported: boolean;
  47772. /**
  47773. * An event triggered when the system is disposed.
  47774. */
  47775. onDisposeObservable: Observable<GPUParticleSystem>;
  47776. /**
  47777. * Gets the maximum number of particles active at the same time.
  47778. * @returns The max number of active particles.
  47779. */
  47780. getCapacity(): number;
  47781. /**
  47782. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  47783. * to override the particles.
  47784. */
  47785. forceDepthWrite: boolean;
  47786. /**
  47787. * Gets or set the number of active particles
  47788. */
  47789. activeParticleCount: number;
  47790. private _preWarmDone;
  47791. /**
  47792. * Is this system ready to be used/rendered
  47793. * @return true if the system is ready
  47794. */
  47795. isReady(): boolean;
  47796. /**
  47797. * Gets if the system has been started. (Note: this will still be true after stop is called)
  47798. * @returns True if it has been started, otherwise false.
  47799. */
  47800. isStarted(): boolean;
  47801. /**
  47802. * Starts the particle system and begins to emit
  47803. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  47804. */
  47805. start(delay?: number): void;
  47806. /**
  47807. * Stops the particle system.
  47808. */
  47809. stop(): void;
  47810. /**
  47811. * Remove all active particles
  47812. */
  47813. reset(): void;
  47814. /**
  47815. * Returns the string "GPUParticleSystem"
  47816. * @returns a string containing the class name
  47817. */
  47818. getClassName(): string;
  47819. private _colorGradientsTexture;
  47820. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  47821. /**
  47822. * Adds a new color gradient
  47823. * @param gradient defines the gradient to use (between 0 and 1)
  47824. * @param color1 defines the color to affect to the specified gradient
  47825. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  47826. * @returns the current particle system
  47827. */
  47828. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  47829. /**
  47830. * Remove a specific color gradient
  47831. * @param gradient defines the gradient to remove
  47832. * @returns the current particle system
  47833. */
  47834. removeColorGradient(gradient: number): GPUParticleSystem;
  47835. private _angularSpeedGradientsTexture;
  47836. private _sizeGradientsTexture;
  47837. private _velocityGradientsTexture;
  47838. private _limitVelocityGradientsTexture;
  47839. private _dragGradientsTexture;
  47840. private _addFactorGradient;
  47841. /**
  47842. * Adds a new size gradient
  47843. * @param gradient defines the gradient to use (between 0 and 1)
  47844. * @param factor defines the size factor to affect to the specified gradient
  47845. * @returns the current particle system
  47846. */
  47847. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  47848. /**
  47849. * Remove a specific size gradient
  47850. * @param gradient defines the gradient to remove
  47851. * @returns the current particle system
  47852. */
  47853. removeSizeGradient(gradient: number): GPUParticleSystem;
  47854. /**
  47855. * Adds a new angular speed gradient
  47856. * @param gradient defines the gradient to use (between 0 and 1)
  47857. * @param factor defines the angular speed to affect to the specified gradient
  47858. * @returns the current particle system
  47859. */
  47860. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  47861. /**
  47862. * Remove a specific angular speed gradient
  47863. * @param gradient defines the gradient to remove
  47864. * @returns the current particle system
  47865. */
  47866. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  47867. /**
  47868. * Adds a new velocity gradient
  47869. * @param gradient defines the gradient to use (between 0 and 1)
  47870. * @param factor defines the velocity to affect to the specified gradient
  47871. * @returns the current particle system
  47872. */
  47873. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  47874. /**
  47875. * Remove a specific velocity gradient
  47876. * @param gradient defines the gradient to remove
  47877. * @returns the current particle system
  47878. */
  47879. removeVelocityGradient(gradient: number): GPUParticleSystem;
  47880. /**
  47881. * Adds a new limit velocity gradient
  47882. * @param gradient defines the gradient to use (between 0 and 1)
  47883. * @param factor defines the limit velocity value to affect to the specified gradient
  47884. * @returns the current particle system
  47885. */
  47886. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  47887. /**
  47888. * Remove a specific limit velocity gradient
  47889. * @param gradient defines the gradient to remove
  47890. * @returns the current particle system
  47891. */
  47892. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  47893. /**
  47894. * Adds a new drag gradient
  47895. * @param gradient defines the gradient to use (between 0 and 1)
  47896. * @param factor defines the drag value to affect to the specified gradient
  47897. * @returns the current particle system
  47898. */
  47899. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  47900. /**
  47901. * Remove a specific drag gradient
  47902. * @param gradient defines the gradient to remove
  47903. * @returns the current particle system
  47904. */
  47905. removeDragGradient(gradient: number): GPUParticleSystem;
  47906. /**
  47907. * Not supported by GPUParticleSystem
  47908. * @param gradient defines the gradient to use (between 0 and 1)
  47909. * @param factor defines the emit rate value to affect to the specified gradient
  47910. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  47911. * @returns the current particle system
  47912. */
  47913. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  47914. /**
  47915. * Not supported by GPUParticleSystem
  47916. * @param gradient defines the gradient to remove
  47917. * @returns the current particle system
  47918. */
  47919. removeEmitRateGradient(gradient: number): IParticleSystem;
  47920. /**
  47921. * Not supported by GPUParticleSystem
  47922. * @param gradient defines the gradient to use (between 0 and 1)
  47923. * @param factor defines the start size value to affect to the specified gradient
  47924. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  47925. * @returns the current particle system
  47926. */
  47927. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  47928. /**
  47929. * Not supported by GPUParticleSystem
  47930. * @param gradient defines the gradient to remove
  47931. * @returns the current particle system
  47932. */
  47933. removeStartSizeGradient(gradient: number): IParticleSystem;
  47934. /**
  47935. * Not supported by GPUParticleSystem
  47936. * @param gradient defines the gradient to use (between 0 and 1)
  47937. * @param min defines the color remap minimal range
  47938. * @param max defines the color remap maximal range
  47939. * @returns the current particle system
  47940. */
  47941. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  47942. /**
  47943. * Not supported by GPUParticleSystem
  47944. * @param gradient defines the gradient to remove
  47945. * @returns the current particle system
  47946. */
  47947. removeColorRemapGradient(): IParticleSystem;
  47948. /**
  47949. * Not supported by GPUParticleSystem
  47950. * @param gradient defines the gradient to use (between 0 and 1)
  47951. * @param min defines the alpha remap minimal range
  47952. * @param max defines the alpha remap maximal range
  47953. * @returns the current particle system
  47954. */
  47955. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  47956. /**
  47957. * Not supported by GPUParticleSystem
  47958. * @param gradient defines the gradient to remove
  47959. * @returns the current particle system
  47960. */
  47961. removeAlphaRemapGradient(): IParticleSystem;
  47962. /**
  47963. * Not supported by GPUParticleSystem
  47964. * @param gradient defines the gradient to use (between 0 and 1)
  47965. * @param color defines the color to affect to the specified gradient
  47966. * @returns the current particle system
  47967. */
  47968. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  47969. /**
  47970. * Not supported by GPUParticleSystem
  47971. * @param gradient defines the gradient to remove
  47972. * @returns the current particle system
  47973. */
  47974. removeRampGradient(): IParticleSystem;
  47975. /**
  47976. * Not supported by GPUParticleSystem
  47977. * @returns the list of ramp gradients
  47978. */
  47979. getRampGradients(): Nullable<Array<Color3Gradient>>;
  47980. /**
  47981. * Not supported by GPUParticleSystem
  47982. * Gets or sets a boolean indicating that ramp gradients must be used
  47983. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  47984. */
  47985. useRampGradients: boolean;
  47986. /**
  47987. * Not supported by GPUParticleSystem
  47988. * @param gradient defines the gradient to use (between 0 and 1)
  47989. * @param factor defines the life time factor to affect to the specified gradient
  47990. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  47991. * @returns the current particle system
  47992. */
  47993. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  47994. /**
  47995. * Not supported by GPUParticleSystem
  47996. * @param gradient defines the gradient to remove
  47997. * @returns the current particle system
  47998. */
  47999. removeLifeTimeGradient(gradient: number): IParticleSystem;
  48000. /**
  48001. * Instantiates a GPU particle system.
  48002. * 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.
  48003. * @param name The name of the particle system
  48004. * @param options The options used to create the system
  48005. * @param scene The scene the particle system belongs to
  48006. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  48007. */
  48008. constructor(name: string, options: Partial<{
  48009. capacity: number;
  48010. randomTextureSize: number;
  48011. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  48012. protected _reset(): void;
  48013. private _createUpdateVAO;
  48014. private _createRenderVAO;
  48015. private _initialize;
  48016. /** @hidden */
  48017. _recreateUpdateEffect(): void;
  48018. /** @hidden */
  48019. _recreateRenderEffect(): void;
  48020. /**
  48021. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  48022. * @param preWarm defines if we are in the pre-warmimg phase
  48023. */
  48024. animate(preWarm?: boolean): void;
  48025. private _createFactorGradientTexture;
  48026. private _createSizeGradientTexture;
  48027. private _createAngularSpeedGradientTexture;
  48028. private _createVelocityGradientTexture;
  48029. private _createLimitVelocityGradientTexture;
  48030. private _createDragGradientTexture;
  48031. private _createColorGradientTexture;
  48032. /**
  48033. * Renders the particle system in its current state
  48034. * @param preWarm defines if the system should only update the particles but not render them
  48035. * @returns the current number of particles
  48036. */
  48037. render(preWarm?: boolean): number;
  48038. /**
  48039. * Rebuilds the particle system
  48040. */
  48041. rebuild(): void;
  48042. private _releaseBuffers;
  48043. private _releaseVAOs;
  48044. /**
  48045. * Disposes the particle system and free the associated resources
  48046. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  48047. */
  48048. dispose(disposeTexture?: boolean): void;
  48049. /**
  48050. * Clones the particle system.
  48051. * @param name The name of the cloned object
  48052. * @param newEmitter The new emitter to use
  48053. * @returns the cloned particle system
  48054. */
  48055. clone(name: string, newEmitter: any): GPUParticleSystem;
  48056. /**
  48057. * Serializes the particle system to a JSON object.
  48058. * @returns the JSON object
  48059. */
  48060. serialize(): any;
  48061. /**
  48062. * Parses a JSON object to create a GPU particle system.
  48063. * @param parsedParticleSystem The JSON object to parse
  48064. * @param scene The scene to create the particle system in
  48065. * @param rootUrl The root url to use to load external dependencies like texture
  48066. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  48067. * @returns the parsed GPU particle system
  48068. */
  48069. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  48070. }
  48071. }
  48072. declare module BABYLON {
  48073. /**
  48074. * Represents a set of particle systems working together to create a specific effect
  48075. */
  48076. export class ParticleSystemSet implements IDisposable {
  48077. private _emitterCreationOptions;
  48078. private _emitterNode;
  48079. /**
  48080. * Gets the particle system list
  48081. */
  48082. systems: IParticleSystem[];
  48083. /**
  48084. * Gets the emitter node used with this set
  48085. */
  48086. readonly emitterNode: Nullable<TransformNode>;
  48087. /**
  48088. * Creates a new emitter mesh as a sphere
  48089. * @param options defines the options used to create the sphere
  48090. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  48091. * @param scene defines the hosting scene
  48092. */
  48093. setEmitterAsSphere(options: {
  48094. diameter: number;
  48095. segments: number;
  48096. color: Color3;
  48097. }, renderingGroupId: number, scene: Scene): void;
  48098. /**
  48099. * Starts all particle systems of the set
  48100. * @param emitter defines an optional mesh to use as emitter for the particle systems
  48101. */
  48102. start(emitter?: AbstractMesh): void;
  48103. /**
  48104. * Release all associated resources
  48105. */
  48106. dispose(): void;
  48107. /**
  48108. * Serialize the set into a JSON compatible object
  48109. * @returns a JSON compatible representation of the set
  48110. */
  48111. serialize(): any;
  48112. /**
  48113. * Parse a new ParticleSystemSet from a serialized source
  48114. * @param data defines a JSON compatible representation of the set
  48115. * @param scene defines the hosting scene
  48116. * @param gpu defines if we want GPU particles or CPU particles
  48117. * @returns a new ParticleSystemSet
  48118. */
  48119. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  48120. }
  48121. }
  48122. declare module BABYLON {
  48123. /**
  48124. * This class is made for on one-liner static method to help creating particle system set.
  48125. */
  48126. export class ParticleHelper {
  48127. /**
  48128. * Gets or sets base Assets URL
  48129. */
  48130. static BaseAssetsUrl: string;
  48131. /**
  48132. * Create a default particle system that you can tweak
  48133. * @param emitter defines the emitter to use
  48134. * @param capacity defines the system capacity (default is 500 particles)
  48135. * @param scene defines the hosting scene
  48136. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  48137. * @returns the new Particle system
  48138. */
  48139. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  48140. /**
  48141. * This is the main static method (one-liner) of this helper to create different particle systems
  48142. * @param type This string represents the type to the particle system to create
  48143. * @param scene The scene where the particle system should live
  48144. * @param gpu If the system will use gpu
  48145. * @returns the ParticleSystemSet created
  48146. */
  48147. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  48148. /**
  48149. * Static function used to export a particle system to a ParticleSystemSet variable.
  48150. * Please note that the emitter shape is not exported
  48151. * @param systems defines the particle systems to export
  48152. * @returns the created particle system set
  48153. */
  48154. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  48155. }
  48156. }
  48157. declare module BABYLON {
  48158. interface Engine {
  48159. /**
  48160. * Create an effect to use with particle systems.
  48161. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  48162. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  48163. * @param uniformsNames defines a list of attribute names
  48164. * @param samplers defines an array of string used to represent textures
  48165. * @param defines defines the string containing the defines to use to compile the shaders
  48166. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  48167. * @param onCompiled defines a function to call when the effect creation is successful
  48168. * @param onError defines a function to call when the effect creation has failed
  48169. * @returns the new Effect
  48170. */
  48171. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  48172. }
  48173. interface Mesh {
  48174. /**
  48175. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  48176. * @returns an array of IParticleSystem
  48177. */
  48178. getEmittedParticleSystems(): IParticleSystem[];
  48179. /**
  48180. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  48181. * @returns an array of IParticleSystem
  48182. */
  48183. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  48184. }
  48185. /**
  48186. * @hidden
  48187. */
  48188. export var _IDoNeedToBeInTheBuild: number;
  48189. }
  48190. declare module BABYLON {
  48191. interface Scene {
  48192. /** @hidden (Backing field) */
  48193. _physicsEngine: Nullable<IPhysicsEngine>;
  48194. /**
  48195. * Gets the current physics engine
  48196. * @returns a IPhysicsEngine or null if none attached
  48197. */
  48198. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  48199. /**
  48200. * Enables physics to the current scene
  48201. * @param gravity defines the scene's gravity for the physics engine
  48202. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  48203. * @return a boolean indicating if the physics engine was initialized
  48204. */
  48205. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  48206. /**
  48207. * Disables and disposes the physics engine associated with the scene
  48208. */
  48209. disablePhysicsEngine(): void;
  48210. /**
  48211. * Gets a boolean indicating if there is an active physics engine
  48212. * @returns a boolean indicating if there is an active physics engine
  48213. */
  48214. isPhysicsEnabled(): boolean;
  48215. /**
  48216. * Deletes a physics compound impostor
  48217. * @param compound defines the compound to delete
  48218. */
  48219. deleteCompoundImpostor(compound: any): void;
  48220. /**
  48221. * An event triggered when physic simulation is about to be run
  48222. */
  48223. onBeforePhysicsObservable: Observable<Scene>;
  48224. /**
  48225. * An event triggered when physic simulation has been done
  48226. */
  48227. onAfterPhysicsObservable: Observable<Scene>;
  48228. }
  48229. interface AbstractMesh {
  48230. /** @hidden */
  48231. _physicsImpostor: Nullable<PhysicsImpostor>;
  48232. /**
  48233. * Gets or sets impostor used for physic simulation
  48234. * @see http://doc.babylonjs.com/features/physics_engine
  48235. */
  48236. physicsImpostor: Nullable<PhysicsImpostor>;
  48237. /**
  48238. * Gets the current physics impostor
  48239. * @see http://doc.babylonjs.com/features/physics_engine
  48240. * @returns a physics impostor or null
  48241. */
  48242. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  48243. /** Apply a physic impulse to the mesh
  48244. * @param force defines the force to apply
  48245. * @param contactPoint defines where to apply the force
  48246. * @returns the current mesh
  48247. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48248. */
  48249. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  48250. /**
  48251. * Creates a physic joint between two meshes
  48252. * @param otherMesh defines the other mesh to use
  48253. * @param pivot1 defines the pivot to use on this mesh
  48254. * @param pivot2 defines the pivot to use on the other mesh
  48255. * @param options defines additional options (can be plugin dependent)
  48256. * @returns the current mesh
  48257. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  48258. */
  48259. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  48260. /** @hidden */
  48261. _disposePhysicsObserver: Nullable<Observer<Node>>;
  48262. }
  48263. /**
  48264. * Defines the physics engine scene component responsible to manage a physics engine
  48265. */
  48266. export class PhysicsEngineSceneComponent implements ISceneComponent {
  48267. /**
  48268. * The component name helpful to identify the component in the list of scene components.
  48269. */
  48270. readonly name: string;
  48271. /**
  48272. * The scene the component belongs to.
  48273. */
  48274. scene: Scene;
  48275. /**
  48276. * Creates a new instance of the component for the given scene
  48277. * @param scene Defines the scene to register the component in
  48278. */
  48279. constructor(scene: Scene);
  48280. /**
  48281. * Registers the component in a given scene
  48282. */
  48283. register(): void;
  48284. /**
  48285. * Rebuilds the elements related to this component in case of
  48286. * context lost for instance.
  48287. */
  48288. rebuild(): void;
  48289. /**
  48290. * Disposes the component and the associated ressources
  48291. */
  48292. dispose(): void;
  48293. }
  48294. }
  48295. declare module BABYLON {
  48296. /**
  48297. * A helper for physics simulations
  48298. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48299. */
  48300. export class PhysicsHelper {
  48301. private _scene;
  48302. private _physicsEngine;
  48303. /**
  48304. * Initializes the Physics helper
  48305. * @param scene Babylon.js scene
  48306. */
  48307. constructor(scene: Scene);
  48308. /**
  48309. * Applies a radial explosion impulse
  48310. * @param origin the origin of the explosion
  48311. * @param radius the explosion radius
  48312. * @param strength the explosion strength
  48313. * @param falloff possible options: Constant & Linear. Defaults to Constant
  48314. * @returns A physics radial explosion event, or null
  48315. */
  48316. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  48317. /**
  48318. * Applies a radial explosion force
  48319. * @param origin the origin of the explosion
  48320. * @param radius the explosion radius
  48321. * @param strength the explosion strength
  48322. * @param falloff possible options: Constant & Linear. Defaults to Constant
  48323. * @returns A physics radial explosion event, or null
  48324. */
  48325. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  48326. /**
  48327. * Creates a gravitational field
  48328. * @param origin the origin of the explosion
  48329. * @param radius the explosion radius
  48330. * @param strength the explosion strength
  48331. * @param falloff possible options: Constant & Linear. Defaults to Constant
  48332. * @returns A physics gravitational field event, or null
  48333. */
  48334. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  48335. /**
  48336. * Creates a physics updraft event
  48337. * @param origin the origin of the updraft
  48338. * @param radius the radius of the updraft
  48339. * @param strength the strength of the updraft
  48340. * @param height the height of the updraft
  48341. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  48342. * @returns A physics updraft event, or null
  48343. */
  48344. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  48345. /**
  48346. * Creates a physics vortex event
  48347. * @param origin the of the vortex
  48348. * @param radius the radius of the vortex
  48349. * @param strength the strength of the vortex
  48350. * @param height the height of the vortex
  48351. * @returns a Physics vortex event, or null
  48352. * A physics vortex event or null
  48353. */
  48354. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  48355. }
  48356. /**
  48357. * Represents a physics radial explosion event
  48358. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48359. */
  48360. export class PhysicsRadialExplosionEvent {
  48361. private _scene;
  48362. private _sphere;
  48363. private _sphereOptions;
  48364. private _rays;
  48365. private _dataFetched;
  48366. /**
  48367. * Initializes a radial explosioin event
  48368. * @param scene BabylonJS scene
  48369. */
  48370. constructor(scene: Scene);
  48371. /**
  48372. * Returns the data related to the radial explosion event (sphere & rays).
  48373. * @returns The radial explosion event data
  48374. */
  48375. getData(): PhysicsRadialExplosionEventData;
  48376. /**
  48377. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  48378. * @param impostor A physics imposter
  48379. * @param origin the origin of the explosion
  48380. * @param radius the explosion radius
  48381. * @param strength the explosion strength
  48382. * @param falloff possible options: Constant & Linear
  48383. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  48384. */
  48385. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  48386. /**
  48387. * Disposes the sphere.
  48388. * @param force Specifies if the sphere should be disposed by force
  48389. */
  48390. dispose(force?: boolean): void;
  48391. /*** Helpers ***/
  48392. private _prepareSphere;
  48393. private _intersectsWithSphere;
  48394. }
  48395. /**
  48396. * Represents a gravitational field event
  48397. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48398. */
  48399. export class PhysicsGravitationalFieldEvent {
  48400. private _physicsHelper;
  48401. private _scene;
  48402. private _origin;
  48403. private _radius;
  48404. private _strength;
  48405. private _falloff;
  48406. private _tickCallback;
  48407. private _sphere;
  48408. private _dataFetched;
  48409. /**
  48410. * Initializes the physics gravitational field event
  48411. * @param physicsHelper A physics helper
  48412. * @param scene BabylonJS scene
  48413. * @param origin The origin position of the gravitational field event
  48414. * @param radius The radius of the gravitational field event
  48415. * @param strength The strength of the gravitational field event
  48416. * @param falloff The falloff for the gravitational field event
  48417. */
  48418. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  48419. /**
  48420. * Returns the data related to the gravitational field event (sphere).
  48421. * @returns A gravitational field event
  48422. */
  48423. getData(): PhysicsGravitationalFieldEventData;
  48424. /**
  48425. * Enables the gravitational field.
  48426. */
  48427. enable(): void;
  48428. /**
  48429. * Disables the gravitational field.
  48430. */
  48431. disable(): void;
  48432. /**
  48433. * Disposes the sphere.
  48434. * @param force The force to dispose from the gravitational field event
  48435. */
  48436. dispose(force?: boolean): void;
  48437. private _tick;
  48438. }
  48439. /**
  48440. * Represents a physics updraft event
  48441. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48442. */
  48443. export class PhysicsUpdraftEvent {
  48444. private _scene;
  48445. private _origin;
  48446. private _radius;
  48447. private _strength;
  48448. private _height;
  48449. private _updraftMode;
  48450. private _physicsEngine;
  48451. private _originTop;
  48452. private _originDirection;
  48453. private _tickCallback;
  48454. private _cylinder;
  48455. private _cylinderPosition;
  48456. private _dataFetched;
  48457. /**
  48458. * Initializes the physics updraft event
  48459. * @param _scene BabylonJS scene
  48460. * @param _origin The origin position of the updraft
  48461. * @param _radius The radius of the updraft
  48462. * @param _strength The strength of the updraft
  48463. * @param _height The height of the updraft
  48464. * @param _updraftMode The mode of the updraft
  48465. */
  48466. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  48467. /**
  48468. * Returns the data related to the updraft event (cylinder).
  48469. * @returns A physics updraft event
  48470. */
  48471. getData(): PhysicsUpdraftEventData;
  48472. /**
  48473. * Enables the updraft.
  48474. */
  48475. enable(): void;
  48476. /**
  48477. * Disables the cortex.
  48478. */
  48479. disable(): void;
  48480. /**
  48481. * Disposes the sphere.
  48482. * @param force Specifies if the updraft should be disposed by force
  48483. */
  48484. dispose(force?: boolean): void;
  48485. private getImpostorForceAndContactPoint;
  48486. private _tick;
  48487. /*** Helpers ***/
  48488. private _prepareCylinder;
  48489. private _intersectsWithCylinder;
  48490. }
  48491. /**
  48492. * Represents a physics vortex event
  48493. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48494. */
  48495. export class PhysicsVortexEvent {
  48496. private _scene;
  48497. private _origin;
  48498. private _radius;
  48499. private _strength;
  48500. private _height;
  48501. private _physicsEngine;
  48502. private _originTop;
  48503. private _centripetalForceThreshold;
  48504. private _updraftMultiplier;
  48505. private _tickCallback;
  48506. private _cylinder;
  48507. private _cylinderPosition;
  48508. private _dataFetched;
  48509. /**
  48510. * Initializes the physics vortex event
  48511. * @param _scene The BabylonJS scene
  48512. * @param _origin The origin position of the vortex
  48513. * @param _radius The radius of the vortex
  48514. * @param _strength The strength of the vortex
  48515. * @param _height The height of the vortex
  48516. */
  48517. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  48518. /**
  48519. * Returns the data related to the vortex event (cylinder).
  48520. * @returns The physics vortex event data
  48521. */
  48522. getData(): PhysicsVortexEventData;
  48523. /**
  48524. * Enables the vortex.
  48525. */
  48526. enable(): void;
  48527. /**
  48528. * Disables the cortex.
  48529. */
  48530. disable(): void;
  48531. /**
  48532. * Disposes the sphere.
  48533. * @param force
  48534. */
  48535. dispose(force?: boolean): void;
  48536. private getImpostorForceAndContactPoint;
  48537. private _tick;
  48538. /*** Helpers ***/
  48539. private _prepareCylinder;
  48540. private _intersectsWithCylinder;
  48541. }
  48542. /**
  48543. * The strenght of the force in correspondence to the distance of the affected object
  48544. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48545. */
  48546. export enum PhysicsRadialImpulseFalloff {
  48547. /** Defines that impulse is constant in strength across it's whole radius */
  48548. Constant = 0,
  48549. /** DEfines that impulse gets weaker if it's further from the origin */
  48550. Linear = 1
  48551. }
  48552. /**
  48553. * The strength of the force in correspondence to the distance of the affected object
  48554. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48555. */
  48556. export enum PhysicsUpdraftMode {
  48557. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  48558. Center = 0,
  48559. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  48560. Perpendicular = 1
  48561. }
  48562. /**
  48563. * Interface for a physics force and contact point
  48564. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48565. */
  48566. export interface PhysicsForceAndContactPoint {
  48567. /**
  48568. * The force applied at the contact point
  48569. */
  48570. force: Vector3;
  48571. /**
  48572. * The contact point
  48573. */
  48574. contactPoint: Vector3;
  48575. }
  48576. /**
  48577. * Interface for radial explosion event data
  48578. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48579. */
  48580. export interface PhysicsRadialExplosionEventData {
  48581. /**
  48582. * A sphere used for the radial explosion event
  48583. */
  48584. sphere: Mesh;
  48585. /**
  48586. * An array of rays for the radial explosion event
  48587. */
  48588. rays: Array<Ray>;
  48589. }
  48590. /**
  48591. * Interface for gravitational field event data
  48592. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48593. */
  48594. export interface PhysicsGravitationalFieldEventData {
  48595. /**
  48596. * A sphere mesh used for the gravitational field event
  48597. */
  48598. sphere: Mesh;
  48599. }
  48600. /**
  48601. * Interface for updraft event data
  48602. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48603. */
  48604. export interface PhysicsUpdraftEventData {
  48605. /**
  48606. * A cylinder used for the updraft event
  48607. */
  48608. cylinder: Mesh;
  48609. }
  48610. /**
  48611. * Interface for vortex event data
  48612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48613. */
  48614. export interface PhysicsVortexEventData {
  48615. /**
  48616. * A cylinder used for the vortex event
  48617. */
  48618. cylinder: Mesh;
  48619. }
  48620. }
  48621. declare module BABYLON {
  48622. /**
  48623. * AmmoJS Physics plugin
  48624. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48625. * @see https://github.com/kripken/ammo.js/
  48626. */
  48627. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48628. private _useDeltaForWorldStep;
  48629. /**
  48630. * Reference to the Ammo library
  48631. */
  48632. bjsAMMO: any;
  48633. /**
  48634. * Created ammoJS world which physics bodies are added to
  48635. */
  48636. world: any;
  48637. /**
  48638. * Name of the plugin
  48639. */
  48640. name: string;
  48641. private _timeStep;
  48642. private _fixedTimeStep;
  48643. private _maxSteps;
  48644. private _tmpQuaternion;
  48645. private _tmpAmmoTransform;
  48646. private _tmpAmmoQuaternion;
  48647. private _tmpAmmoConcreteContactResultCallback;
  48648. private _collisionConfiguration;
  48649. private _dispatcher;
  48650. private _overlappingPairCache;
  48651. private _solver;
  48652. private _tmpAmmoVectorA;
  48653. private _tmpAmmoVectorB;
  48654. private _tmpAmmoVectorC;
  48655. private _tmpContactCallbackResult;
  48656. private static readonly DISABLE_COLLISION_FLAG;
  48657. private static readonly KINEMATIC_FLAG;
  48658. private static readonly DISABLE_DEACTIVATION_FLAG;
  48659. /**
  48660. * Initializes the ammoJS plugin
  48661. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48662. * @param ammoInjection can be used to inject your own ammo reference
  48663. */
  48664. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  48665. /**
  48666. * Sets the gravity of the physics world (m/(s^2))
  48667. * @param gravity Gravity to set
  48668. */
  48669. setGravity(gravity: Vector3): void;
  48670. /**
  48671. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48672. * @param timeStep timestep to use in seconds
  48673. */
  48674. setTimeStep(timeStep: number): void;
  48675. /**
  48676. * 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)
  48677. * @param fixedTimeStep fixedTimeStep to use in seconds
  48678. */
  48679. setFixedTimeStep(fixedTimeStep: number): void;
  48680. /**
  48681. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48682. * @param maxSteps the maximum number of steps by the physics engine per frame
  48683. */
  48684. setMaxSteps(maxSteps: number): void;
  48685. /**
  48686. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48687. * @returns the current timestep in seconds
  48688. */
  48689. getTimeStep(): number;
  48690. private _isImpostorInContact;
  48691. private _isImpostorPairInContact;
  48692. private _stepSimulation;
  48693. /**
  48694. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48695. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48696. * After the step the babylon meshes are set to the position of the physics imposters
  48697. * @param delta amount of time to step forward
  48698. * @param impostors array of imposters to update before/after the step
  48699. */
  48700. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48701. private _tmpVector;
  48702. private _tmpMatrix;
  48703. /**
  48704. * Applies an implulse on the imposter
  48705. * @param impostor imposter to apply impulse
  48706. * @param force amount of force to be applied to the imposter
  48707. * @param contactPoint the location to apply the impulse on the imposter
  48708. */
  48709. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48710. /**
  48711. * Applies a force on the imposter
  48712. * @param impostor imposter to apply force
  48713. * @param force amount of force to be applied to the imposter
  48714. * @param contactPoint the location to apply the force on the imposter
  48715. */
  48716. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48717. /**
  48718. * Creates a physics body using the plugin
  48719. * @param impostor the imposter to create the physics body on
  48720. */
  48721. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48722. /**
  48723. * Removes the physics body from the imposter and disposes of the body's memory
  48724. * @param impostor imposter to remove the physics body from
  48725. */
  48726. removePhysicsBody(impostor: PhysicsImpostor): void;
  48727. /**
  48728. * Generates a joint
  48729. * @param impostorJoint the imposter joint to create the joint with
  48730. */
  48731. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48732. /**
  48733. * Removes a joint
  48734. * @param impostorJoint the imposter joint to remove the joint from
  48735. */
  48736. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48737. private _addMeshVerts;
  48738. private _createShape;
  48739. /**
  48740. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48741. * @param impostor imposter containing the physics body and babylon object
  48742. */
  48743. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48744. /**
  48745. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48746. * @param impostor imposter containing the physics body and babylon object
  48747. * @param newPosition new position
  48748. * @param newRotation new rotation
  48749. */
  48750. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48751. /**
  48752. * If this plugin is supported
  48753. * @returns true if its supported
  48754. */
  48755. isSupported(): boolean;
  48756. /**
  48757. * Sets the linear velocity of the physics body
  48758. * @param impostor imposter to set the velocity on
  48759. * @param velocity velocity to set
  48760. */
  48761. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48762. /**
  48763. * Sets the angular velocity of the physics body
  48764. * @param impostor imposter to set the velocity on
  48765. * @param velocity velocity to set
  48766. */
  48767. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48768. /**
  48769. * gets the linear velocity
  48770. * @param impostor imposter to get linear velocity from
  48771. * @returns linear velocity
  48772. */
  48773. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48774. /**
  48775. * gets the angular velocity
  48776. * @param impostor imposter to get angular velocity from
  48777. * @returns angular velocity
  48778. */
  48779. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48780. /**
  48781. * Sets the mass of physics body
  48782. * @param impostor imposter to set the mass on
  48783. * @param mass mass to set
  48784. */
  48785. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48786. /**
  48787. * Gets the mass of the physics body
  48788. * @param impostor imposter to get the mass from
  48789. * @returns mass
  48790. */
  48791. getBodyMass(impostor: PhysicsImpostor): number;
  48792. /**
  48793. * Gets friction of the impostor
  48794. * @param impostor impostor to get friction from
  48795. * @returns friction value
  48796. */
  48797. getBodyFriction(impostor: PhysicsImpostor): number;
  48798. /**
  48799. * Sets friction of the impostor
  48800. * @param impostor impostor to set friction on
  48801. * @param friction friction value
  48802. */
  48803. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48804. /**
  48805. * Gets restitution of the impostor
  48806. * @param impostor impostor to get restitution from
  48807. * @returns restitution value
  48808. */
  48809. getBodyRestitution(impostor: PhysicsImpostor): number;
  48810. /**
  48811. * Sets resitution of the impostor
  48812. * @param impostor impostor to set resitution on
  48813. * @param restitution resitution value
  48814. */
  48815. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48816. /**
  48817. * Sleeps the physics body and stops it from being active
  48818. * @param impostor impostor to sleep
  48819. */
  48820. sleepBody(impostor: PhysicsImpostor): void;
  48821. /**
  48822. * Activates the physics body
  48823. * @param impostor impostor to activate
  48824. */
  48825. wakeUpBody(impostor: PhysicsImpostor): void;
  48826. /**
  48827. * Updates the distance parameters of the joint
  48828. * @param joint joint to update
  48829. * @param maxDistance maximum distance of the joint
  48830. * @param minDistance minimum distance of the joint
  48831. */
  48832. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48833. /**
  48834. * Sets a motor on the joint
  48835. * @param joint joint to set motor on
  48836. * @param speed speed of the motor
  48837. * @param maxForce maximum force of the motor
  48838. * @param motorIndex index of the motor
  48839. */
  48840. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48841. /**
  48842. * Sets the motors limit
  48843. * @param joint joint to set limit on
  48844. * @param upperLimit upper limit
  48845. * @param lowerLimit lower limit
  48846. */
  48847. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48848. /**
  48849. * Syncs the position and rotation of a mesh with the impostor
  48850. * @param mesh mesh to sync
  48851. * @param impostor impostor to update the mesh with
  48852. */
  48853. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48854. /**
  48855. * Gets the radius of the impostor
  48856. * @param impostor impostor to get radius from
  48857. * @returns the radius
  48858. */
  48859. getRadius(impostor: PhysicsImpostor): number;
  48860. /**
  48861. * Gets the box size of the impostor
  48862. * @param impostor impostor to get box size from
  48863. * @param result the resulting box size
  48864. */
  48865. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48866. /**
  48867. * Disposes of the impostor
  48868. */
  48869. dispose(): void;
  48870. }
  48871. }
  48872. declare module BABYLON {
  48873. /** @hidden */
  48874. export var blackAndWhitePixelShader: {
  48875. name: string;
  48876. shader: string;
  48877. };
  48878. }
  48879. declare module BABYLON {
  48880. /**
  48881. * Post process used to render in black and white
  48882. */
  48883. export class BlackAndWhitePostProcess extends PostProcess {
  48884. /**
  48885. * Linear about to convert he result to black and white (default: 1)
  48886. */
  48887. degree: number;
  48888. /**
  48889. * Creates a black and white post process
  48890. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  48891. * @param name The name of the effect.
  48892. * @param options The required width/height ratio to downsize to before computing the render pass.
  48893. * @param camera The camera to apply the render pass to.
  48894. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  48895. * @param engine The engine which the post process will be applied. (default: current engine)
  48896. * @param reusable If the post process can be reused on the same frame. (default: false)
  48897. */
  48898. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  48899. }
  48900. }
  48901. declare module BABYLON {
  48902. /**
  48903. * This represents a set of one or more post processes in Babylon.
  48904. * A post process can be used to apply a shader to a texture after it is rendered.
  48905. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48906. */
  48907. export class PostProcessRenderEffect {
  48908. private _postProcesses;
  48909. private _getPostProcesses;
  48910. private _singleInstance;
  48911. private _cameras;
  48912. private _indicesForCamera;
  48913. /**
  48914. * Name of the effect
  48915. * @hidden
  48916. */
  48917. _name: string;
  48918. /**
  48919. * Instantiates a post process render effect.
  48920. * A post process can be used to apply a shader to a texture after it is rendered.
  48921. * @param engine The engine the effect is tied to
  48922. * @param name The name of the effect
  48923. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  48924. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  48925. */
  48926. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  48927. /**
  48928. * Checks if all the post processes in the effect are supported.
  48929. */
  48930. readonly isSupported: boolean;
  48931. /**
  48932. * Updates the current state of the effect
  48933. * @hidden
  48934. */
  48935. _update(): void;
  48936. /**
  48937. * Attaches the effect on cameras
  48938. * @param cameras The camera to attach to.
  48939. * @hidden
  48940. */
  48941. _attachCameras(cameras: Camera): void;
  48942. /**
  48943. * Attaches the effect on cameras
  48944. * @param cameras The camera to attach to.
  48945. * @hidden
  48946. */
  48947. _attachCameras(cameras: Camera[]): void;
  48948. /**
  48949. * Detatches the effect on cameras
  48950. * @param cameras The camera to detatch from.
  48951. * @hidden
  48952. */
  48953. _detachCameras(cameras: Camera): void;
  48954. /**
  48955. * Detatches the effect on cameras
  48956. * @param cameras The camera to detatch from.
  48957. * @hidden
  48958. */
  48959. _detachCameras(cameras: Camera[]): void;
  48960. /**
  48961. * Enables the effect on given cameras
  48962. * @param cameras The camera to enable.
  48963. * @hidden
  48964. */
  48965. _enable(cameras: Camera): void;
  48966. /**
  48967. * Enables the effect on given cameras
  48968. * @param cameras The camera to enable.
  48969. * @hidden
  48970. */
  48971. _enable(cameras: Nullable<Camera[]>): void;
  48972. /**
  48973. * Disables the effect on the given cameras
  48974. * @param cameras The camera to disable.
  48975. * @hidden
  48976. */
  48977. _disable(cameras: Camera): void;
  48978. /**
  48979. * Disables the effect on the given cameras
  48980. * @param cameras The camera to disable.
  48981. * @hidden
  48982. */
  48983. _disable(cameras: Nullable<Camera[]>): void;
  48984. /**
  48985. * Gets a list of the post processes contained in the effect.
  48986. * @param camera The camera to get the post processes on.
  48987. * @returns The list of the post processes in the effect.
  48988. */
  48989. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  48990. }
  48991. }
  48992. declare module BABYLON {
  48993. /** @hidden */
  48994. export var extractHighlightsPixelShader: {
  48995. name: string;
  48996. shader: string;
  48997. };
  48998. }
  48999. declare module BABYLON {
  49000. /**
  49001. * 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.
  49002. */
  49003. export class ExtractHighlightsPostProcess extends PostProcess {
  49004. /**
  49005. * The luminance threshold, pixels below this value will be set to black.
  49006. */
  49007. threshold: number;
  49008. /** @hidden */
  49009. _exposure: number;
  49010. /**
  49011. * Post process which has the input texture to be used when performing highlight extraction
  49012. * @hidden
  49013. */
  49014. _inputPostProcess: Nullable<PostProcess>;
  49015. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49016. }
  49017. }
  49018. declare module BABYLON {
  49019. /** @hidden */
  49020. export var bloomMergePixelShader: {
  49021. name: string;
  49022. shader: string;
  49023. };
  49024. }
  49025. declare module BABYLON {
  49026. /**
  49027. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  49028. */
  49029. export class BloomMergePostProcess extends PostProcess {
  49030. /** Weight of the bloom to be added to the original input. */
  49031. weight: number;
  49032. /**
  49033. * Creates a new instance of @see BloomMergePostProcess
  49034. * @param name The name of the effect.
  49035. * @param originalFromInput Post process which's input will be used for the merge.
  49036. * @param blurred Blurred highlights post process which's output will be used.
  49037. * @param weight Weight of the bloom to be added to the original input.
  49038. * @param options The required width/height ratio to downsize to before computing the render pass.
  49039. * @param camera The camera to apply the render pass to.
  49040. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49041. * @param engine The engine which the post process will be applied. (default: current engine)
  49042. * @param reusable If the post process can be reused on the same frame. (default: false)
  49043. * @param textureType Type of textures used when performing the post process. (default: 0)
  49044. * @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)
  49045. */
  49046. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  49047. /** Weight of the bloom to be added to the original input. */
  49048. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49049. }
  49050. }
  49051. declare module BABYLON {
  49052. /**
  49053. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  49054. */
  49055. export class BloomEffect extends PostProcessRenderEffect {
  49056. private bloomScale;
  49057. /**
  49058. * @hidden Internal
  49059. */
  49060. _effects: Array<PostProcess>;
  49061. /**
  49062. * @hidden Internal
  49063. */
  49064. _downscale: ExtractHighlightsPostProcess;
  49065. private _blurX;
  49066. private _blurY;
  49067. private _merge;
  49068. /**
  49069. * The luminance threshold to find bright areas of the image to bloom.
  49070. */
  49071. threshold: number;
  49072. /**
  49073. * The strength of the bloom.
  49074. */
  49075. weight: number;
  49076. /**
  49077. * Specifies the size of the bloom blur kernel, relative to the final output size
  49078. */
  49079. kernel: number;
  49080. /**
  49081. * Creates a new instance of @see BloomEffect
  49082. * @param scene The scene the effect belongs to.
  49083. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  49084. * @param bloomKernel The size of the kernel to be used when applying the blur.
  49085. * @param bloomWeight The the strength of bloom.
  49086. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  49087. * @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)
  49088. */
  49089. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  49090. /**
  49091. * Disposes each of the internal effects for a given camera.
  49092. * @param camera The camera to dispose the effect on.
  49093. */
  49094. disposeEffects(camera: Camera): void;
  49095. /**
  49096. * @hidden Internal
  49097. */
  49098. _updateEffects(): void;
  49099. /**
  49100. * Internal
  49101. * @returns if all the contained post processes are ready.
  49102. * @hidden
  49103. */
  49104. _isReady(): boolean;
  49105. }
  49106. }
  49107. declare module BABYLON {
  49108. /** @hidden */
  49109. export var chromaticAberrationPixelShader: {
  49110. name: string;
  49111. shader: string;
  49112. };
  49113. }
  49114. declare module BABYLON {
  49115. /**
  49116. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  49117. */
  49118. export class ChromaticAberrationPostProcess extends PostProcess {
  49119. /**
  49120. * The amount of seperation of rgb channels (default: 30)
  49121. */
  49122. aberrationAmount: number;
  49123. /**
  49124. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  49125. */
  49126. radialIntensity: number;
  49127. /**
  49128. * 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))
  49129. */
  49130. direction: Vector2;
  49131. /**
  49132. * 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))
  49133. */
  49134. centerPosition: Vector2;
  49135. /**
  49136. * Creates a new instance ChromaticAberrationPostProcess
  49137. * @param name The name of the effect.
  49138. * @param screenWidth The width of the screen to apply the effect on.
  49139. * @param screenHeight The height of the screen to apply the effect on.
  49140. * @param options The required width/height ratio to downsize to before computing the render pass.
  49141. * @param camera The camera to apply the render pass to.
  49142. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49143. * @param engine The engine which the post process will be applied. (default: current engine)
  49144. * @param reusable If the post process can be reused on the same frame. (default: false)
  49145. * @param textureType Type of textures used when performing the post process. (default: 0)
  49146. * @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)
  49147. */
  49148. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49149. }
  49150. }
  49151. declare module BABYLON {
  49152. /** @hidden */
  49153. export var circleOfConfusionPixelShader: {
  49154. name: string;
  49155. shader: string;
  49156. };
  49157. }
  49158. declare module BABYLON {
  49159. /**
  49160. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  49161. */
  49162. export class CircleOfConfusionPostProcess extends PostProcess {
  49163. /**
  49164. * 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.
  49165. */
  49166. lensSize: number;
  49167. /**
  49168. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  49169. */
  49170. fStop: number;
  49171. /**
  49172. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  49173. */
  49174. focusDistance: number;
  49175. /**
  49176. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  49177. */
  49178. focalLength: number;
  49179. private _depthTexture;
  49180. /**
  49181. * Creates a new instance CircleOfConfusionPostProcess
  49182. * @param name The name of the effect.
  49183. * @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.
  49184. * @param options The required width/height ratio to downsize to before computing the render pass.
  49185. * @param camera The camera to apply the render pass to.
  49186. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49187. * @param engine The engine which the post process will be applied. (default: current engine)
  49188. * @param reusable If the post process can be reused on the same frame. (default: false)
  49189. * @param textureType Type of textures used when performing the post process. (default: 0)
  49190. * @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)
  49191. */
  49192. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49193. /**
  49194. * 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.
  49195. */
  49196. depthTexture: RenderTargetTexture;
  49197. }
  49198. }
  49199. declare module BABYLON {
  49200. /** @hidden */
  49201. export var colorCorrectionPixelShader: {
  49202. name: string;
  49203. shader: string;
  49204. };
  49205. }
  49206. declare module BABYLON {
  49207. /**
  49208. *
  49209. * This post-process allows the modification of rendered colors by using
  49210. * a 'look-up table' (LUT). This effect is also called Color Grading.
  49211. *
  49212. * The object needs to be provided an url to a texture containing the color
  49213. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  49214. * Use an image editing software to tweak the LUT to match your needs.
  49215. *
  49216. * For an example of a color LUT, see here:
  49217. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  49218. * For explanations on color grading, see here:
  49219. * @see http://udn.epicgames.com/Three/ColorGrading.html
  49220. *
  49221. */
  49222. export class ColorCorrectionPostProcess extends PostProcess {
  49223. private _colorTableTexture;
  49224. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49225. }
  49226. }
  49227. declare module BABYLON {
  49228. /** @hidden */
  49229. export var convolutionPixelShader: {
  49230. name: string;
  49231. shader: string;
  49232. };
  49233. }
  49234. declare module BABYLON {
  49235. /**
  49236. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  49237. * input texture to perform effects such as edge detection or sharpening
  49238. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  49239. */
  49240. export class ConvolutionPostProcess extends PostProcess {
  49241. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  49242. kernel: number[];
  49243. /**
  49244. * Creates a new instance ConvolutionPostProcess
  49245. * @param name The name of the effect.
  49246. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  49247. * @param options The required width/height ratio to downsize to before computing the render pass.
  49248. * @param camera The camera to apply the render pass to.
  49249. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49250. * @param engine The engine which the post process will be applied. (default: current engine)
  49251. * @param reusable If the post process can be reused on the same frame. (default: false)
  49252. * @param textureType Type of textures used when performing the post process. (default: 0)
  49253. */
  49254. constructor(name: string,
  49255. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  49256. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  49257. /**
  49258. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49259. */
  49260. static EdgeDetect0Kernel: number[];
  49261. /**
  49262. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49263. */
  49264. static EdgeDetect1Kernel: number[];
  49265. /**
  49266. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49267. */
  49268. static EdgeDetect2Kernel: number[];
  49269. /**
  49270. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49271. */
  49272. static SharpenKernel: number[];
  49273. /**
  49274. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49275. */
  49276. static EmbossKernel: number[];
  49277. /**
  49278. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49279. */
  49280. static GaussianKernel: number[];
  49281. }
  49282. }
  49283. declare module BABYLON {
  49284. /**
  49285. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  49286. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  49287. * based on samples that have a large difference in distance than the center pixel.
  49288. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  49289. */
  49290. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  49291. direction: Vector2;
  49292. /**
  49293. * Creates a new instance CircleOfConfusionPostProcess
  49294. * @param name The name of the effect.
  49295. * @param scene The scene the effect belongs to.
  49296. * @param direction The direction the blur should be applied.
  49297. * @param kernel The size of the kernel used to blur.
  49298. * @param options The required width/height ratio to downsize to before computing the render pass.
  49299. * @param camera The camera to apply the render pass to.
  49300. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  49301. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  49302. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49303. * @param engine The engine which the post process will be applied. (default: current engine)
  49304. * @param reusable If the post process can be reused on the same frame. (default: false)
  49305. * @param textureType Type of textures used when performing the post process. (default: 0)
  49306. * @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)
  49307. */
  49308. 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);
  49309. }
  49310. }
  49311. declare module BABYLON {
  49312. /** @hidden */
  49313. export var depthOfFieldMergePixelShader: {
  49314. name: string;
  49315. shader: string;
  49316. };
  49317. }
  49318. declare module BABYLON {
  49319. /**
  49320. * Options to be set when merging outputs from the default pipeline.
  49321. */
  49322. export class DepthOfFieldMergePostProcessOptions {
  49323. /**
  49324. * The original image to merge on top of
  49325. */
  49326. originalFromInput: PostProcess;
  49327. /**
  49328. * Parameters to perform the merge of the depth of field effect
  49329. */
  49330. depthOfField?: {
  49331. circleOfConfusion: PostProcess;
  49332. blurSteps: Array<PostProcess>;
  49333. };
  49334. /**
  49335. * Parameters to perform the merge of bloom effect
  49336. */
  49337. bloom?: {
  49338. blurred: PostProcess;
  49339. weight: number;
  49340. };
  49341. }
  49342. /**
  49343. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  49344. */
  49345. export class DepthOfFieldMergePostProcess extends PostProcess {
  49346. private blurSteps;
  49347. /**
  49348. * Creates a new instance of DepthOfFieldMergePostProcess
  49349. * @param name The name of the effect.
  49350. * @param originalFromInput Post process which's input will be used for the merge.
  49351. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  49352. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  49353. * @param options The required width/height ratio to downsize to before computing the render pass.
  49354. * @param camera The camera to apply the render pass to.
  49355. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49356. * @param engine The engine which the post process will be applied. (default: current engine)
  49357. * @param reusable If the post process can be reused on the same frame. (default: false)
  49358. * @param textureType Type of textures used when performing the post process. (default: 0)
  49359. * @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)
  49360. */
  49361. 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);
  49362. /**
  49363. * Updates the effect with the current post process compile time values and recompiles the shader.
  49364. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  49365. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  49366. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  49367. * @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
  49368. * @param onCompiled Called when the shader has been compiled.
  49369. * @param onError Called if there is an error when compiling a shader.
  49370. */
  49371. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  49372. }
  49373. }
  49374. declare module BABYLON {
  49375. /**
  49376. * Specifies the level of max blur that should be applied when using the depth of field effect
  49377. */
  49378. export enum DepthOfFieldEffectBlurLevel {
  49379. /**
  49380. * Subtle blur
  49381. */
  49382. Low = 0,
  49383. /**
  49384. * Medium blur
  49385. */
  49386. Medium = 1,
  49387. /**
  49388. * Large blur
  49389. */
  49390. High = 2
  49391. }
  49392. /**
  49393. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  49394. */
  49395. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  49396. private _circleOfConfusion;
  49397. /**
  49398. * @hidden Internal, blurs from high to low
  49399. */
  49400. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  49401. private _depthOfFieldBlurY;
  49402. private _dofMerge;
  49403. /**
  49404. * @hidden Internal post processes in depth of field effect
  49405. */
  49406. _effects: Array<PostProcess>;
  49407. /**
  49408. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  49409. */
  49410. focalLength: number;
  49411. /**
  49412. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  49413. */
  49414. fStop: number;
  49415. /**
  49416. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  49417. */
  49418. focusDistance: number;
  49419. /**
  49420. * 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.
  49421. */
  49422. lensSize: number;
  49423. /**
  49424. * Creates a new instance DepthOfFieldEffect
  49425. * @param scene The scene the effect belongs to.
  49426. * @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.
  49427. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  49428. * @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)
  49429. */
  49430. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  49431. /**
  49432. * 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.
  49433. */
  49434. depthTexture: RenderTargetTexture;
  49435. /**
  49436. * Disposes each of the internal effects for a given camera.
  49437. * @param camera The camera to dispose the effect on.
  49438. */
  49439. disposeEffects(camera: Camera): void;
  49440. /**
  49441. * @hidden Internal
  49442. */
  49443. _updateEffects(): void;
  49444. /**
  49445. * Internal
  49446. * @returns if all the contained post processes are ready.
  49447. * @hidden
  49448. */
  49449. _isReady(): boolean;
  49450. }
  49451. }
  49452. declare module BABYLON {
  49453. /** @hidden */
  49454. export var displayPassPixelShader: {
  49455. name: string;
  49456. shader: string;
  49457. };
  49458. }
  49459. declare module BABYLON {
  49460. /**
  49461. * DisplayPassPostProcess which produces an output the same as it's input
  49462. */
  49463. export class DisplayPassPostProcess extends PostProcess {
  49464. /**
  49465. * Creates the DisplayPassPostProcess
  49466. * @param name The name of the effect.
  49467. * @param options The required width/height ratio to downsize to before computing the render pass.
  49468. * @param camera The camera to apply the render pass to.
  49469. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49470. * @param engine The engine which the post process will be applied. (default: current engine)
  49471. * @param reusable If the post process can be reused on the same frame. (default: false)
  49472. */
  49473. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49474. }
  49475. }
  49476. declare module BABYLON {
  49477. /** @hidden */
  49478. export var filterPixelShader: {
  49479. name: string;
  49480. shader: string;
  49481. };
  49482. }
  49483. declare module BABYLON {
  49484. /**
  49485. * Applies a kernel filter to the image
  49486. */
  49487. export class FilterPostProcess extends PostProcess {
  49488. /** The matrix to be applied to the image */
  49489. kernelMatrix: Matrix;
  49490. /**
  49491. *
  49492. * @param name The name of the effect.
  49493. * @param kernelMatrix The matrix to be applied to the image
  49494. * @param options The required width/height ratio to downsize to before computing the render pass.
  49495. * @param camera The camera to apply the render pass to.
  49496. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49497. * @param engine The engine which the post process will be applied. (default: current engine)
  49498. * @param reusable If the post process can be reused on the same frame. (default: false)
  49499. */
  49500. constructor(name: string,
  49501. /** The matrix to be applied to the image */
  49502. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49503. }
  49504. }
  49505. declare module BABYLON {
  49506. /** @hidden */
  49507. export var fxaaPixelShader: {
  49508. name: string;
  49509. shader: string;
  49510. };
  49511. }
  49512. declare module BABYLON {
  49513. /** @hidden */
  49514. export var fxaaVertexShader: {
  49515. name: string;
  49516. shader: string;
  49517. };
  49518. }
  49519. declare module BABYLON {
  49520. /**
  49521. * Fxaa post process
  49522. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  49523. */
  49524. export class FxaaPostProcess extends PostProcess {
  49525. /** @hidden */
  49526. texelWidth: number;
  49527. /** @hidden */
  49528. texelHeight: number;
  49529. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  49530. private _getDefines;
  49531. }
  49532. }
  49533. declare module BABYLON {
  49534. /** @hidden */
  49535. export var grainPixelShader: {
  49536. name: string;
  49537. shader: string;
  49538. };
  49539. }
  49540. declare module BABYLON {
  49541. /**
  49542. * The GrainPostProcess adds noise to the image at mid luminance levels
  49543. */
  49544. export class GrainPostProcess extends PostProcess {
  49545. /**
  49546. * The intensity of the grain added (default: 30)
  49547. */
  49548. intensity: number;
  49549. /**
  49550. * If the grain should be randomized on every frame
  49551. */
  49552. animated: boolean;
  49553. /**
  49554. * Creates a new instance of @see GrainPostProcess
  49555. * @param name The name of the effect.
  49556. * @param options The required width/height ratio to downsize to before computing the render pass.
  49557. * @param camera The camera to apply the render pass to.
  49558. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49559. * @param engine The engine which the post process will be applied. (default: current engine)
  49560. * @param reusable If the post process can be reused on the same frame. (default: false)
  49561. * @param textureType Type of textures used when performing the post process. (default: 0)
  49562. * @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)
  49563. */
  49564. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49565. }
  49566. }
  49567. declare module BABYLON {
  49568. /** @hidden */
  49569. export var highlightsPixelShader: {
  49570. name: string;
  49571. shader: string;
  49572. };
  49573. }
  49574. declare module BABYLON {
  49575. /**
  49576. * Extracts highlights from the image
  49577. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  49578. */
  49579. export class HighlightsPostProcess extends PostProcess {
  49580. /**
  49581. * Extracts highlights from the image
  49582. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  49583. * @param name The name of the effect.
  49584. * @param options The required width/height ratio to downsize to before computing the render pass.
  49585. * @param camera The camera to apply the render pass to.
  49586. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49587. * @param engine The engine which the post process will be applied. (default: current engine)
  49588. * @param reusable If the post process can be reused on the same frame. (default: false)
  49589. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  49590. */
  49591. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  49592. }
  49593. }
  49594. declare module BABYLON {
  49595. /** @hidden */
  49596. export var mrtFragmentDeclaration: {
  49597. name: string;
  49598. shader: string;
  49599. };
  49600. }
  49601. declare module BABYLON {
  49602. /** @hidden */
  49603. export var geometryPixelShader: {
  49604. name: string;
  49605. shader: string;
  49606. };
  49607. }
  49608. declare module BABYLON {
  49609. /** @hidden */
  49610. export var geometryVertexShader: {
  49611. name: string;
  49612. shader: string;
  49613. };
  49614. }
  49615. declare module BABYLON {
  49616. /**
  49617. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  49618. */
  49619. export class GeometryBufferRenderer {
  49620. /**
  49621. * Constant used to retrieve the position texture index in the G-Buffer textures array
  49622. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  49623. */
  49624. static readonly POSITION_TEXTURE_TYPE: number;
  49625. /**
  49626. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  49627. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  49628. */
  49629. static readonly VELOCITY_TEXTURE_TYPE: number;
  49630. /**
  49631. * Dictionary used to store the previous transformation matrices of each rendered mesh
  49632. * in order to compute objects velocities when enableVelocity is set to "true"
  49633. * @hidden
  49634. */
  49635. _previousTransformationMatrices: {
  49636. [index: number]: Matrix;
  49637. };
  49638. private _scene;
  49639. private _multiRenderTarget;
  49640. private _ratio;
  49641. private _enablePosition;
  49642. private _enableVelocity;
  49643. private _positionIndex;
  49644. private _velocityIndex;
  49645. protected _effect: Effect;
  49646. protected _cachedDefines: string;
  49647. /**
  49648. * Set the render list (meshes to be rendered) used in the G buffer.
  49649. */
  49650. renderList: Mesh[];
  49651. /**
  49652. * Gets wether or not G buffer are supported by the running hardware.
  49653. * This requires draw buffer supports
  49654. */
  49655. readonly isSupported: boolean;
  49656. /**
  49657. * Returns the index of the given texture type in the G-Buffer textures array
  49658. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  49659. * @returns the index of the given texture type in the G-Buffer textures array
  49660. */
  49661. getTextureIndex(textureType: number): number;
  49662. /**
  49663. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  49664. */
  49665. /**
  49666. * Sets whether or not objects positions are enabled for the G buffer.
  49667. */
  49668. enablePosition: boolean;
  49669. /**
  49670. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  49671. */
  49672. /**
  49673. * Sets wether or not objects velocities are enabled for the G buffer.
  49674. */
  49675. enableVelocity: boolean;
  49676. /**
  49677. * Gets the scene associated with the buffer.
  49678. */
  49679. readonly scene: Scene;
  49680. /**
  49681. * Gets the ratio used by the buffer during its creation.
  49682. * How big is the buffer related to the main canvas.
  49683. */
  49684. readonly ratio: number;
  49685. /** @hidden */
  49686. static _SceneComponentInitialization: (scene: Scene) => void;
  49687. /**
  49688. * Creates a new G Buffer for the scene
  49689. * @param scene The scene the buffer belongs to
  49690. * @param ratio How big is the buffer related to the main canvas.
  49691. */
  49692. constructor(scene: Scene, ratio?: number);
  49693. /**
  49694. * Checks wether everything is ready to render a submesh to the G buffer.
  49695. * @param subMesh the submesh to check readiness for
  49696. * @param useInstances is the mesh drawn using instance or not
  49697. * @returns true if ready otherwise false
  49698. */
  49699. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49700. /**
  49701. * Gets the current underlying G Buffer.
  49702. * @returns the buffer
  49703. */
  49704. getGBuffer(): MultiRenderTarget;
  49705. /**
  49706. * Gets the number of samples used to render the buffer (anti aliasing).
  49707. */
  49708. /**
  49709. * Sets the number of samples used to render the buffer (anti aliasing).
  49710. */
  49711. samples: number;
  49712. /**
  49713. * Disposes the renderer and frees up associated resources.
  49714. */
  49715. dispose(): void;
  49716. protected _createRenderTargets(): void;
  49717. }
  49718. }
  49719. declare module BABYLON {
  49720. /** @hidden */
  49721. export var motionBlurPixelShader: {
  49722. name: string;
  49723. shader: string;
  49724. };
  49725. }
  49726. declare module BABYLON {
  49727. /**
  49728. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  49729. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  49730. * As an example, all you have to do is to create the post-process:
  49731. * var mb = new BABYLON.MotionBlurPostProcess(
  49732. * 'mb', // The name of the effect.
  49733. * scene, // The scene containing the objects to blur according to their velocity.
  49734. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  49735. * camera // The camera to apply the render pass to.
  49736. * );
  49737. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  49738. */
  49739. export class MotionBlurPostProcess extends PostProcess {
  49740. /**
  49741. * Defines how much the image is blurred by the movement. Default value is equal to 1
  49742. */
  49743. motionStrength: number;
  49744. /**
  49745. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  49746. */
  49747. /**
  49748. * Sets the number of iterations to be used for motion blur quality
  49749. */
  49750. motionBlurSamples: number;
  49751. private _motionBlurSamples;
  49752. private _geometryBufferRenderer;
  49753. /**
  49754. * Creates a new instance MotionBlurPostProcess
  49755. * @param name The name of the effect.
  49756. * @param scene The scene containing the objects to blur according to their velocity.
  49757. * @param options The required width/height ratio to downsize to before computing the render pass.
  49758. * @param camera The camera to apply the render pass to.
  49759. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49760. * @param engine The engine which the post process will be applied. (default: current engine)
  49761. * @param reusable If the post process can be reused on the same frame. (default: false)
  49762. * @param textureType Type of textures used when performing the post process. (default: 0)
  49763. * @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)
  49764. */
  49765. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49766. /**
  49767. * Disposes the post process.
  49768. * @param camera The camera to dispose the post process on.
  49769. */
  49770. dispose(camera?: Camera): void;
  49771. }
  49772. }
  49773. declare module BABYLON {
  49774. /** @hidden */
  49775. export var refractionPixelShader: {
  49776. name: string;
  49777. shader: string;
  49778. };
  49779. }
  49780. declare module BABYLON {
  49781. /**
  49782. * Post process which applies a refractin texture
  49783. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  49784. */
  49785. export class RefractionPostProcess extends PostProcess {
  49786. /** the base color of the refraction (used to taint the rendering) */
  49787. color: Color3;
  49788. /** simulated refraction depth */
  49789. depth: number;
  49790. /** the coefficient of the base color (0 to remove base color tainting) */
  49791. colorLevel: number;
  49792. private _refTexture;
  49793. private _ownRefractionTexture;
  49794. /**
  49795. * Gets or sets the refraction texture
  49796. * Please note that you are responsible for disposing the texture if you set it manually
  49797. */
  49798. refractionTexture: Texture;
  49799. /**
  49800. * Initializes the RefractionPostProcess
  49801. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  49802. * @param name The name of the effect.
  49803. * @param refractionTextureUrl Url of the refraction texture to use
  49804. * @param color the base color of the refraction (used to taint the rendering)
  49805. * @param depth simulated refraction depth
  49806. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  49807. * @param camera The camera to apply the render pass to.
  49808. * @param options The required width/height ratio to downsize to before computing the render pass.
  49809. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49810. * @param engine The engine which the post process will be applied. (default: current engine)
  49811. * @param reusable If the post process can be reused on the same frame. (default: false)
  49812. */
  49813. constructor(name: string, refractionTextureUrl: string,
  49814. /** the base color of the refraction (used to taint the rendering) */
  49815. color: Color3,
  49816. /** simulated refraction depth */
  49817. depth: number,
  49818. /** the coefficient of the base color (0 to remove base color tainting) */
  49819. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49820. /**
  49821. * Disposes of the post process
  49822. * @param camera Camera to dispose post process on
  49823. */
  49824. dispose(camera: Camera): void;
  49825. }
  49826. }
  49827. declare module BABYLON {
  49828. /** @hidden */
  49829. export var sharpenPixelShader: {
  49830. name: string;
  49831. shader: string;
  49832. };
  49833. }
  49834. declare module BABYLON {
  49835. /**
  49836. * The SharpenPostProcess applies a sharpen kernel to every pixel
  49837. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  49838. */
  49839. export class SharpenPostProcess extends PostProcess {
  49840. /**
  49841. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  49842. */
  49843. colorAmount: number;
  49844. /**
  49845. * How much sharpness should be applied (default: 0.3)
  49846. */
  49847. edgeAmount: number;
  49848. /**
  49849. * Creates a new instance ConvolutionPostProcess
  49850. * @param name The name of the effect.
  49851. * @param options The required width/height ratio to downsize to before computing the render pass.
  49852. * @param camera The camera to apply the render pass to.
  49853. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49854. * @param engine The engine which the post process will be applied. (default: current engine)
  49855. * @param reusable If the post process can be reused on the same frame. (default: false)
  49856. * @param textureType Type of textures used when performing the post process. (default: 0)
  49857. * @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)
  49858. */
  49859. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49860. }
  49861. }
  49862. declare module BABYLON {
  49863. /**
  49864. * PostProcessRenderPipeline
  49865. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49866. */
  49867. export class PostProcessRenderPipeline {
  49868. private engine;
  49869. private _renderEffects;
  49870. private _renderEffectsForIsolatedPass;
  49871. /**
  49872. * @hidden
  49873. */
  49874. protected _cameras: Camera[];
  49875. /** @hidden */
  49876. _name: string;
  49877. /**
  49878. * Initializes a PostProcessRenderPipeline
  49879. * @param engine engine to add the pipeline to
  49880. * @param name name of the pipeline
  49881. */
  49882. constructor(engine: Engine, name: string);
  49883. /**
  49884. * "PostProcessRenderPipeline"
  49885. * @returns "PostProcessRenderPipeline"
  49886. */
  49887. getClassName(): string;
  49888. /**
  49889. * If all the render effects in the pipeline are support
  49890. */
  49891. readonly isSupported: boolean;
  49892. /**
  49893. * Adds an effect to the pipeline
  49894. * @param renderEffect the effect to add
  49895. */
  49896. addEffect(renderEffect: PostProcessRenderEffect): void;
  49897. /** @hidden */
  49898. _rebuild(): void;
  49899. /** @hidden */
  49900. _enableEffect(renderEffectName: string, cameras: Camera): void;
  49901. /** @hidden */
  49902. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  49903. /** @hidden */
  49904. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49905. /** @hidden */
  49906. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49907. /** @hidden */
  49908. _attachCameras(cameras: Camera, unique: boolean): void;
  49909. /** @hidden */
  49910. _attachCameras(cameras: Camera[], unique: boolean): void;
  49911. /** @hidden */
  49912. _detachCameras(cameras: Camera): void;
  49913. /** @hidden */
  49914. _detachCameras(cameras: Nullable<Camera[]>): void;
  49915. /** @hidden */
  49916. _update(): void;
  49917. /** @hidden */
  49918. _reset(): void;
  49919. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  49920. /**
  49921. * Disposes of the pipeline
  49922. */
  49923. dispose(): void;
  49924. }
  49925. }
  49926. declare module BABYLON {
  49927. /**
  49928. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  49929. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49930. */
  49931. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  49932. private _scene;
  49933. private _camerasToBeAttached;
  49934. /**
  49935. * ID of the sharpen post process,
  49936. */
  49937. private readonly SharpenPostProcessId;
  49938. /**
  49939. * @ignore
  49940. * ID of the image processing post process;
  49941. */
  49942. readonly ImageProcessingPostProcessId: string;
  49943. /**
  49944. * @ignore
  49945. * ID of the Fast Approximate Anti-Aliasing post process;
  49946. */
  49947. readonly FxaaPostProcessId: string;
  49948. /**
  49949. * ID of the chromatic aberration post process,
  49950. */
  49951. private readonly ChromaticAberrationPostProcessId;
  49952. /**
  49953. * ID of the grain post process
  49954. */
  49955. private readonly GrainPostProcessId;
  49956. /**
  49957. * Sharpen post process which will apply a sharpen convolution to enhance edges
  49958. */
  49959. sharpen: SharpenPostProcess;
  49960. private _sharpenEffect;
  49961. private bloom;
  49962. /**
  49963. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  49964. */
  49965. depthOfField: DepthOfFieldEffect;
  49966. /**
  49967. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  49968. */
  49969. fxaa: FxaaPostProcess;
  49970. /**
  49971. * Image post processing pass used to perform operations such as tone mapping or color grading.
  49972. */
  49973. imageProcessing: ImageProcessingPostProcess;
  49974. /**
  49975. * Chromatic aberration post process which will shift rgb colors in the image
  49976. */
  49977. chromaticAberration: ChromaticAberrationPostProcess;
  49978. private _chromaticAberrationEffect;
  49979. /**
  49980. * Grain post process which add noise to the image
  49981. */
  49982. grain: GrainPostProcess;
  49983. private _grainEffect;
  49984. /**
  49985. * Glow post process which adds a glow to emmisive areas of the image
  49986. */
  49987. private _glowLayer;
  49988. /**
  49989. * Animations which can be used to tweak settings over a period of time
  49990. */
  49991. animations: Animation[];
  49992. private _imageProcessingConfigurationObserver;
  49993. private _sharpenEnabled;
  49994. private _bloomEnabled;
  49995. private _depthOfFieldEnabled;
  49996. private _depthOfFieldBlurLevel;
  49997. private _fxaaEnabled;
  49998. private _imageProcessingEnabled;
  49999. private _defaultPipelineTextureType;
  50000. private _bloomScale;
  50001. private _chromaticAberrationEnabled;
  50002. private _grainEnabled;
  50003. private _buildAllowed;
  50004. /**
  50005. * Enable or disable the sharpen process from the pipeline
  50006. */
  50007. sharpenEnabled: boolean;
  50008. private _resizeObserver;
  50009. private _hardwareScaleLevel;
  50010. private _bloomKernel;
  50011. /**
  50012. * Specifies the size of the bloom blur kernel, relative to the final output size
  50013. */
  50014. bloomKernel: number;
  50015. /**
  50016. * Specifies the weight of the bloom in the final rendering
  50017. */
  50018. private _bloomWeight;
  50019. /**
  50020. * Specifies the luma threshold for the area that will be blurred by the bloom
  50021. */
  50022. private _bloomThreshold;
  50023. private _hdr;
  50024. /**
  50025. * The strength of the bloom.
  50026. */
  50027. bloomWeight: number;
  50028. /**
  50029. * The strength of the bloom.
  50030. */
  50031. bloomThreshold: number;
  50032. /**
  50033. * The scale of the bloom, lower value will provide better performance.
  50034. */
  50035. bloomScale: number;
  50036. /**
  50037. * Enable or disable the bloom from the pipeline
  50038. */
  50039. bloomEnabled: boolean;
  50040. private _rebuildBloom;
  50041. /**
  50042. * If the depth of field is enabled.
  50043. */
  50044. depthOfFieldEnabled: boolean;
  50045. /**
  50046. * Blur level of the depth of field effect. (Higher blur will effect performance)
  50047. */
  50048. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  50049. /**
  50050. * If the anti aliasing is enabled.
  50051. */
  50052. fxaaEnabled: boolean;
  50053. private _samples;
  50054. /**
  50055. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50056. */
  50057. samples: number;
  50058. /**
  50059. * If image processing is enabled.
  50060. */
  50061. imageProcessingEnabled: boolean;
  50062. /**
  50063. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  50064. */
  50065. glowLayerEnabled: boolean;
  50066. /**
  50067. * Enable or disable the chromaticAberration process from the pipeline
  50068. */
  50069. chromaticAberrationEnabled: boolean;
  50070. /**
  50071. * Enable or disable the grain process from the pipeline
  50072. */
  50073. grainEnabled: boolean;
  50074. /**
  50075. * @constructor
  50076. * @param name - The rendering pipeline name (default: "")
  50077. * @param hdr - If high dynamic range textures should be used (default: true)
  50078. * @param scene - The scene linked to this pipeline (default: the last created scene)
  50079. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  50080. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  50081. */
  50082. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  50083. /**
  50084. * Force the compilation of the entire pipeline.
  50085. */
  50086. prepare(): void;
  50087. private _hasCleared;
  50088. private _prevPostProcess;
  50089. private _prevPrevPostProcess;
  50090. private _setAutoClearAndTextureSharing;
  50091. private _depthOfFieldSceneObserver;
  50092. private _buildPipeline;
  50093. private _disposePostProcesses;
  50094. /**
  50095. * Adds a camera to the pipeline
  50096. * @param camera the camera to be added
  50097. */
  50098. addCamera(camera: Camera): void;
  50099. /**
  50100. * Removes a camera from the pipeline
  50101. * @param camera the camera to remove
  50102. */
  50103. removeCamera(camera: Camera): void;
  50104. /**
  50105. * Dispose of the pipeline and stop all post processes
  50106. */
  50107. dispose(): void;
  50108. /**
  50109. * Serialize the rendering pipeline (Used when exporting)
  50110. * @returns the serialized object
  50111. */
  50112. serialize(): any;
  50113. /**
  50114. * Parse the serialized pipeline
  50115. * @param source Source pipeline.
  50116. * @param scene The scene to load the pipeline to.
  50117. * @param rootUrl The URL of the serialized pipeline.
  50118. * @returns An instantiated pipeline from the serialized object.
  50119. */
  50120. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  50121. }
  50122. }
  50123. declare module BABYLON {
  50124. /** @hidden */
  50125. export var lensHighlightsPixelShader: {
  50126. name: string;
  50127. shader: string;
  50128. };
  50129. }
  50130. declare module BABYLON {
  50131. /** @hidden */
  50132. export var depthOfFieldPixelShader: {
  50133. name: string;
  50134. shader: string;
  50135. };
  50136. }
  50137. declare module BABYLON {
  50138. /**
  50139. * BABYLON.JS Chromatic Aberration GLSL Shader
  50140. * Author: Olivier Guyot
  50141. * Separates very slightly R, G and B colors on the edges of the screen
  50142. * Inspired by Francois Tarlier & Martins Upitis
  50143. */
  50144. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  50145. /**
  50146. * @ignore
  50147. * The chromatic aberration PostProcess id in the pipeline
  50148. */
  50149. LensChromaticAberrationEffect: string;
  50150. /**
  50151. * @ignore
  50152. * The highlights enhancing PostProcess id in the pipeline
  50153. */
  50154. HighlightsEnhancingEffect: string;
  50155. /**
  50156. * @ignore
  50157. * The depth-of-field PostProcess id in the pipeline
  50158. */
  50159. LensDepthOfFieldEffect: string;
  50160. private _scene;
  50161. private _depthTexture;
  50162. private _grainTexture;
  50163. private _chromaticAberrationPostProcess;
  50164. private _highlightsPostProcess;
  50165. private _depthOfFieldPostProcess;
  50166. private _edgeBlur;
  50167. private _grainAmount;
  50168. private _chromaticAberration;
  50169. private _distortion;
  50170. private _highlightsGain;
  50171. private _highlightsThreshold;
  50172. private _dofDistance;
  50173. private _dofAperture;
  50174. private _dofDarken;
  50175. private _dofPentagon;
  50176. private _blurNoise;
  50177. /**
  50178. * @constructor
  50179. *
  50180. * Effect parameters are as follow:
  50181. * {
  50182. * chromatic_aberration: number; // from 0 to x (1 for realism)
  50183. * edge_blur: number; // from 0 to x (1 for realism)
  50184. * distortion: number; // from 0 to x (1 for realism)
  50185. * grain_amount: number; // from 0 to 1
  50186. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  50187. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  50188. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  50189. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  50190. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  50191. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  50192. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  50193. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  50194. * }
  50195. * Note: if an effect parameter is unset, effect is disabled
  50196. *
  50197. * @param name The rendering pipeline name
  50198. * @param parameters - An object containing all parameters (see above)
  50199. * @param scene The scene linked to this pipeline
  50200. * @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)
  50201. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50202. */
  50203. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  50204. /**
  50205. * Sets the amount of blur at the edges
  50206. * @param amount blur amount
  50207. */
  50208. setEdgeBlur(amount: number): void;
  50209. /**
  50210. * Sets edge blur to 0
  50211. */
  50212. disableEdgeBlur(): void;
  50213. /**
  50214. * Sets the amout of grain
  50215. * @param amount Amount of grain
  50216. */
  50217. setGrainAmount(amount: number): void;
  50218. /**
  50219. * Set grain amount to 0
  50220. */
  50221. disableGrain(): void;
  50222. /**
  50223. * Sets the chromatic aberration amount
  50224. * @param amount amount of chromatic aberration
  50225. */
  50226. setChromaticAberration(amount: number): void;
  50227. /**
  50228. * Sets chromatic aberration amount to 0
  50229. */
  50230. disableChromaticAberration(): void;
  50231. /**
  50232. * Sets the EdgeDistortion amount
  50233. * @param amount amount of EdgeDistortion
  50234. */
  50235. setEdgeDistortion(amount: number): void;
  50236. /**
  50237. * Sets edge distortion to 0
  50238. */
  50239. disableEdgeDistortion(): void;
  50240. /**
  50241. * Sets the FocusDistance amount
  50242. * @param amount amount of FocusDistance
  50243. */
  50244. setFocusDistance(amount: number): void;
  50245. /**
  50246. * Disables depth of field
  50247. */
  50248. disableDepthOfField(): void;
  50249. /**
  50250. * Sets the Aperture amount
  50251. * @param amount amount of Aperture
  50252. */
  50253. setAperture(amount: number): void;
  50254. /**
  50255. * Sets the DarkenOutOfFocus amount
  50256. * @param amount amount of DarkenOutOfFocus
  50257. */
  50258. setDarkenOutOfFocus(amount: number): void;
  50259. /**
  50260. * Creates a pentagon bokeh effect
  50261. */
  50262. enablePentagonBokeh(): void;
  50263. /**
  50264. * Disables the pentagon bokeh effect
  50265. */
  50266. disablePentagonBokeh(): void;
  50267. /**
  50268. * Enables noise blur
  50269. */
  50270. enableNoiseBlur(): void;
  50271. /**
  50272. * Disables noise blur
  50273. */
  50274. disableNoiseBlur(): void;
  50275. /**
  50276. * Sets the HighlightsGain amount
  50277. * @param amount amount of HighlightsGain
  50278. */
  50279. setHighlightsGain(amount: number): void;
  50280. /**
  50281. * Sets the HighlightsThreshold amount
  50282. * @param amount amount of HighlightsThreshold
  50283. */
  50284. setHighlightsThreshold(amount: number): void;
  50285. /**
  50286. * Disables highlights
  50287. */
  50288. disableHighlights(): void;
  50289. /**
  50290. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  50291. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  50292. */
  50293. dispose(disableDepthRender?: boolean): void;
  50294. private _createChromaticAberrationPostProcess;
  50295. private _createHighlightsPostProcess;
  50296. private _createDepthOfFieldPostProcess;
  50297. private _createGrainTexture;
  50298. }
  50299. }
  50300. declare module BABYLON {
  50301. /** @hidden */
  50302. export var ssao2PixelShader: {
  50303. name: string;
  50304. shader: string;
  50305. };
  50306. }
  50307. declare module BABYLON {
  50308. /** @hidden */
  50309. export var ssaoCombinePixelShader: {
  50310. name: string;
  50311. shader: string;
  50312. };
  50313. }
  50314. declare module BABYLON {
  50315. /**
  50316. * Render pipeline to produce ssao effect
  50317. */
  50318. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  50319. /**
  50320. * @ignore
  50321. * The PassPostProcess id in the pipeline that contains the original scene color
  50322. */
  50323. SSAOOriginalSceneColorEffect: string;
  50324. /**
  50325. * @ignore
  50326. * The SSAO PostProcess id in the pipeline
  50327. */
  50328. SSAORenderEffect: string;
  50329. /**
  50330. * @ignore
  50331. * The horizontal blur PostProcess id in the pipeline
  50332. */
  50333. SSAOBlurHRenderEffect: string;
  50334. /**
  50335. * @ignore
  50336. * The vertical blur PostProcess id in the pipeline
  50337. */
  50338. SSAOBlurVRenderEffect: string;
  50339. /**
  50340. * @ignore
  50341. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50342. */
  50343. SSAOCombineRenderEffect: string;
  50344. /**
  50345. * The output strength of the SSAO post-process. Default value is 1.0.
  50346. */
  50347. totalStrength: number;
  50348. /**
  50349. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50350. */
  50351. maxZ: number;
  50352. /**
  50353. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50354. */
  50355. minZAspect: number;
  50356. private _samples;
  50357. /**
  50358. * Number of samples used for the SSAO calculations. Default value is 8
  50359. */
  50360. samples: number;
  50361. private _textureSamples;
  50362. /**
  50363. * Number of samples to use for antialiasing
  50364. */
  50365. textureSamples: number;
  50366. /**
  50367. * Ratio object used for SSAO ratio and blur ratio
  50368. */
  50369. private _ratio;
  50370. /**
  50371. * Dynamically generated sphere sampler.
  50372. */
  50373. private _sampleSphere;
  50374. /**
  50375. * Blur filter offsets
  50376. */
  50377. private _samplerOffsets;
  50378. private _expensiveBlur;
  50379. /**
  50380. * If bilateral blur should be used
  50381. */
  50382. expensiveBlur: boolean;
  50383. /**
  50384. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50385. */
  50386. radius: number;
  50387. /**
  50388. * The base color of the SSAO post-process
  50389. * The final result is "base + ssao" between [0, 1]
  50390. */
  50391. base: number;
  50392. /**
  50393. * Support test.
  50394. */
  50395. static readonly IsSupported: boolean;
  50396. private _scene;
  50397. private _depthTexture;
  50398. private _normalTexture;
  50399. private _randomTexture;
  50400. private _originalColorPostProcess;
  50401. private _ssaoPostProcess;
  50402. private _blurHPostProcess;
  50403. private _blurVPostProcess;
  50404. private _ssaoCombinePostProcess;
  50405. private _firstUpdate;
  50406. /**
  50407. * @constructor
  50408. * @param name The rendering pipeline name
  50409. * @param scene The scene linked to this pipeline
  50410. * @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 }
  50411. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50412. */
  50413. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50414. /**
  50415. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50416. */
  50417. dispose(disableGeometryBufferRenderer?: boolean): void;
  50418. private _createBlurPostProcess;
  50419. /** @hidden */
  50420. _rebuild(): void;
  50421. private _bits;
  50422. private _radicalInverse_VdC;
  50423. private _hammersley;
  50424. private _hemisphereSample_uniform;
  50425. private _generateHemisphere;
  50426. private _createSSAOPostProcess;
  50427. private _createSSAOCombinePostProcess;
  50428. private _createRandomTexture;
  50429. /**
  50430. * Serialize the rendering pipeline (Used when exporting)
  50431. * @returns the serialized object
  50432. */
  50433. serialize(): any;
  50434. /**
  50435. * Parse the serialized pipeline
  50436. * @param source Source pipeline.
  50437. * @param scene The scene to load the pipeline to.
  50438. * @param rootUrl The URL of the serialized pipeline.
  50439. * @returns An instantiated pipeline from the serialized object.
  50440. */
  50441. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50442. }
  50443. }
  50444. declare module BABYLON {
  50445. /** @hidden */
  50446. export var ssaoPixelShader: {
  50447. name: string;
  50448. shader: string;
  50449. };
  50450. }
  50451. declare module BABYLON {
  50452. /**
  50453. * Render pipeline to produce ssao effect
  50454. */
  50455. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50456. /**
  50457. * @ignore
  50458. * The PassPostProcess id in the pipeline that contains the original scene color
  50459. */
  50460. SSAOOriginalSceneColorEffect: string;
  50461. /**
  50462. * @ignore
  50463. * The SSAO PostProcess id in the pipeline
  50464. */
  50465. SSAORenderEffect: string;
  50466. /**
  50467. * @ignore
  50468. * The horizontal blur PostProcess id in the pipeline
  50469. */
  50470. SSAOBlurHRenderEffect: string;
  50471. /**
  50472. * @ignore
  50473. * The vertical blur PostProcess id in the pipeline
  50474. */
  50475. SSAOBlurVRenderEffect: string;
  50476. /**
  50477. * @ignore
  50478. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50479. */
  50480. SSAOCombineRenderEffect: string;
  50481. /**
  50482. * The output strength of the SSAO post-process. Default value is 1.0.
  50483. */
  50484. totalStrength: number;
  50485. /**
  50486. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  50487. */
  50488. radius: number;
  50489. /**
  50490. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50491. * Must not be equal to fallOff and superior to fallOff.
  50492. * Default value is 0.975
  50493. */
  50494. area: number;
  50495. /**
  50496. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50497. * Must not be equal to area and inferior to area.
  50498. * Default value is 0.0
  50499. */
  50500. fallOff: number;
  50501. /**
  50502. * The base color of the SSAO post-process
  50503. * The final result is "base + ssao" between [0, 1]
  50504. */
  50505. base: number;
  50506. private _scene;
  50507. private _depthTexture;
  50508. private _randomTexture;
  50509. private _originalColorPostProcess;
  50510. private _ssaoPostProcess;
  50511. private _blurHPostProcess;
  50512. private _blurVPostProcess;
  50513. private _ssaoCombinePostProcess;
  50514. private _firstUpdate;
  50515. /**
  50516. * @constructor
  50517. * @param name - The rendering pipeline name
  50518. * @param scene - The scene linked to this pipeline
  50519. * @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 }
  50520. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  50521. */
  50522. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50523. /**
  50524. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50525. */
  50526. dispose(disableDepthRender?: boolean): void;
  50527. private _createBlurPostProcess;
  50528. /** @hidden */
  50529. _rebuild(): void;
  50530. private _createSSAOPostProcess;
  50531. private _createSSAOCombinePostProcess;
  50532. private _createRandomTexture;
  50533. }
  50534. }
  50535. declare module BABYLON {
  50536. /** @hidden */
  50537. export var standardPixelShader: {
  50538. name: string;
  50539. shader: string;
  50540. };
  50541. }
  50542. declare module BABYLON {
  50543. /**
  50544. * Standard rendering pipeline
  50545. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50546. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  50547. */
  50548. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50549. /**
  50550. * Public members
  50551. */
  50552. /**
  50553. * Post-process which contains the original scene color before the pipeline applies all the effects
  50554. */
  50555. originalPostProcess: Nullable<PostProcess>;
  50556. /**
  50557. * Post-process used to down scale an image x4
  50558. */
  50559. downSampleX4PostProcess: Nullable<PostProcess>;
  50560. /**
  50561. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  50562. */
  50563. brightPassPostProcess: Nullable<PostProcess>;
  50564. /**
  50565. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  50566. */
  50567. blurHPostProcesses: PostProcess[];
  50568. /**
  50569. * Post-process array storing all the vertical blur post-processes used by the pipeline
  50570. */
  50571. blurVPostProcesses: PostProcess[];
  50572. /**
  50573. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  50574. */
  50575. textureAdderPostProcess: Nullable<PostProcess>;
  50576. /**
  50577. * Post-process used to create volumetric lighting effect
  50578. */
  50579. volumetricLightPostProcess: Nullable<PostProcess>;
  50580. /**
  50581. * Post-process used to smooth the previous volumetric light post-process on the X axis
  50582. */
  50583. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  50584. /**
  50585. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  50586. */
  50587. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  50588. /**
  50589. * Post-process used to merge the volumetric light effect and the real scene color
  50590. */
  50591. volumetricLightMergePostProces: Nullable<PostProcess>;
  50592. /**
  50593. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  50594. */
  50595. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  50596. /**
  50597. * Base post-process used to calculate the average luminance of the final image for HDR
  50598. */
  50599. luminancePostProcess: Nullable<PostProcess>;
  50600. /**
  50601. * Post-processes used to create down sample post-processes in order to get
  50602. * the average luminance of the final image for HDR
  50603. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  50604. */
  50605. luminanceDownSamplePostProcesses: PostProcess[];
  50606. /**
  50607. * Post-process used to create a HDR effect (light adaptation)
  50608. */
  50609. hdrPostProcess: Nullable<PostProcess>;
  50610. /**
  50611. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  50612. */
  50613. textureAdderFinalPostProcess: Nullable<PostProcess>;
  50614. /**
  50615. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  50616. */
  50617. lensFlareFinalPostProcess: Nullable<PostProcess>;
  50618. /**
  50619. * Post-process used to merge the final HDR post-process and the real scene color
  50620. */
  50621. hdrFinalPostProcess: Nullable<PostProcess>;
  50622. /**
  50623. * Post-process used to create a lens flare effect
  50624. */
  50625. lensFlarePostProcess: Nullable<PostProcess>;
  50626. /**
  50627. * Post-process that merges the result of the lens flare post-process and the real scene color
  50628. */
  50629. lensFlareComposePostProcess: Nullable<PostProcess>;
  50630. /**
  50631. * Post-process used to create a motion blur effect
  50632. */
  50633. motionBlurPostProcess: Nullable<PostProcess>;
  50634. /**
  50635. * Post-process used to create a depth of field effect
  50636. */
  50637. depthOfFieldPostProcess: Nullable<PostProcess>;
  50638. /**
  50639. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50640. */
  50641. fxaaPostProcess: Nullable<FxaaPostProcess>;
  50642. /**
  50643. * Represents the brightness threshold in order to configure the illuminated surfaces
  50644. */
  50645. brightThreshold: number;
  50646. /**
  50647. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  50648. */
  50649. blurWidth: number;
  50650. /**
  50651. * Sets if the blur for highlighted surfaces must be only horizontal
  50652. */
  50653. horizontalBlur: boolean;
  50654. /**
  50655. * Sets the overall exposure used by the pipeline
  50656. */
  50657. exposure: number;
  50658. /**
  50659. * Texture used typically to simulate "dirty" on camera lens
  50660. */
  50661. lensTexture: Nullable<Texture>;
  50662. /**
  50663. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  50664. */
  50665. volumetricLightCoefficient: number;
  50666. /**
  50667. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  50668. */
  50669. volumetricLightPower: number;
  50670. /**
  50671. * Used the set the blur intensity to smooth the volumetric lights
  50672. */
  50673. volumetricLightBlurScale: number;
  50674. /**
  50675. * Light (spot or directional) used to generate the volumetric lights rays
  50676. * The source light must have a shadow generate so the pipeline can get its
  50677. * depth map
  50678. */
  50679. sourceLight: Nullable<SpotLight | DirectionalLight>;
  50680. /**
  50681. * For eye adaptation, represents the minimum luminance the eye can see
  50682. */
  50683. hdrMinimumLuminance: number;
  50684. /**
  50685. * For eye adaptation, represents the decrease luminance speed
  50686. */
  50687. hdrDecreaseRate: number;
  50688. /**
  50689. * For eye adaptation, represents the increase luminance speed
  50690. */
  50691. hdrIncreaseRate: number;
  50692. /**
  50693. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  50694. */
  50695. lensColorTexture: Nullable<Texture>;
  50696. /**
  50697. * The overall strengh for the lens flare effect
  50698. */
  50699. lensFlareStrength: number;
  50700. /**
  50701. * Dispersion coefficient for lens flare ghosts
  50702. */
  50703. lensFlareGhostDispersal: number;
  50704. /**
  50705. * Main lens flare halo width
  50706. */
  50707. lensFlareHaloWidth: number;
  50708. /**
  50709. * Based on the lens distortion effect, defines how much the lens flare result
  50710. * is distorted
  50711. */
  50712. lensFlareDistortionStrength: number;
  50713. /**
  50714. * Lens star texture must be used to simulate rays on the flares and is available
  50715. * in the documentation
  50716. */
  50717. lensStarTexture: Nullable<Texture>;
  50718. /**
  50719. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  50720. * flare effect by taking account of the dirt texture
  50721. */
  50722. lensFlareDirtTexture: Nullable<Texture>;
  50723. /**
  50724. * Represents the focal length for the depth of field effect
  50725. */
  50726. depthOfFieldDistance: number;
  50727. /**
  50728. * Represents the blur intensity for the blurred part of the depth of field effect
  50729. */
  50730. depthOfFieldBlurWidth: number;
  50731. /**
  50732. * For motion blur, defines how much the image is blurred by the movement
  50733. */
  50734. motionStrength: number;
  50735. /**
  50736. * List of animations for the pipeline (IAnimatable implementation)
  50737. */
  50738. animations: Animation[];
  50739. /**
  50740. * Private members
  50741. */
  50742. private _scene;
  50743. private _currentDepthOfFieldSource;
  50744. private _basePostProcess;
  50745. private _hdrCurrentLuminance;
  50746. private _floatTextureType;
  50747. private _ratio;
  50748. private _bloomEnabled;
  50749. private _depthOfFieldEnabled;
  50750. private _vlsEnabled;
  50751. private _lensFlareEnabled;
  50752. private _hdrEnabled;
  50753. private _motionBlurEnabled;
  50754. private _fxaaEnabled;
  50755. private _motionBlurSamples;
  50756. private _volumetricLightStepsCount;
  50757. private _samples;
  50758. /**
  50759. * @ignore
  50760. * Specifies if the bloom pipeline is enabled
  50761. */
  50762. BloomEnabled: boolean;
  50763. /**
  50764. * @ignore
  50765. * Specifies if the depth of field pipeline is enabed
  50766. */
  50767. DepthOfFieldEnabled: boolean;
  50768. /**
  50769. * @ignore
  50770. * Specifies if the lens flare pipeline is enabed
  50771. */
  50772. LensFlareEnabled: boolean;
  50773. /**
  50774. * @ignore
  50775. * Specifies if the HDR pipeline is enabled
  50776. */
  50777. HDREnabled: boolean;
  50778. /**
  50779. * @ignore
  50780. * Specifies if the volumetric lights scattering effect is enabled
  50781. */
  50782. VLSEnabled: boolean;
  50783. /**
  50784. * @ignore
  50785. * Specifies if the motion blur effect is enabled
  50786. */
  50787. MotionBlurEnabled: boolean;
  50788. /**
  50789. * Specifies if anti-aliasing is enabled
  50790. */
  50791. fxaaEnabled: boolean;
  50792. /**
  50793. * Specifies the number of steps used to calculate the volumetric lights
  50794. * Typically in interval [50, 200]
  50795. */
  50796. volumetricLightStepsCount: number;
  50797. /**
  50798. * Specifies the number of samples used for the motion blur effect
  50799. * Typically in interval [16, 64]
  50800. */
  50801. motionBlurSamples: number;
  50802. /**
  50803. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50804. */
  50805. samples: number;
  50806. /**
  50807. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50808. * @constructor
  50809. * @param name The rendering pipeline name
  50810. * @param scene The scene linked to this pipeline
  50811. * @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)
  50812. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  50813. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50814. */
  50815. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  50816. private _buildPipeline;
  50817. private _createDownSampleX4PostProcess;
  50818. private _createBrightPassPostProcess;
  50819. private _createBlurPostProcesses;
  50820. private _createTextureAdderPostProcess;
  50821. private _createVolumetricLightPostProcess;
  50822. private _createLuminancePostProcesses;
  50823. private _createHdrPostProcess;
  50824. private _createLensFlarePostProcess;
  50825. private _createDepthOfFieldPostProcess;
  50826. private _createMotionBlurPostProcess;
  50827. private _getDepthTexture;
  50828. private _disposePostProcesses;
  50829. /**
  50830. * Dispose of the pipeline and stop all post processes
  50831. */
  50832. dispose(): void;
  50833. /**
  50834. * Serialize the rendering pipeline (Used when exporting)
  50835. * @returns the serialized object
  50836. */
  50837. serialize(): any;
  50838. /**
  50839. * Parse the serialized pipeline
  50840. * @param source Source pipeline.
  50841. * @param scene The scene to load the pipeline to.
  50842. * @param rootUrl The URL of the serialized pipeline.
  50843. * @returns An instantiated pipeline from the serialized object.
  50844. */
  50845. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  50846. /**
  50847. * Luminance steps
  50848. */
  50849. static LuminanceSteps: number;
  50850. }
  50851. }
  50852. declare module BABYLON {
  50853. /**
  50854. * PostProcessRenderPipelineManager class
  50855. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  50856. */
  50857. export class PostProcessRenderPipelineManager {
  50858. private _renderPipelines;
  50859. /**
  50860. * Initializes a PostProcessRenderPipelineManager
  50861. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  50862. */
  50863. constructor();
  50864. /**
  50865. * Adds a pipeline to the manager
  50866. * @param renderPipeline The pipeline to add
  50867. */
  50868. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  50869. /**
  50870. * Attaches a camera to the pipeline
  50871. * @param renderPipelineName The name of the pipeline to attach to
  50872. * @param cameras the camera to attach
  50873. * @param unique if the camera can be attached multiple times to the pipeline
  50874. */
  50875. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  50876. /**
  50877. * Detaches a camera from the pipeline
  50878. * @param renderPipelineName The name of the pipeline to detach from
  50879. * @param cameras the camera to detach
  50880. */
  50881. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  50882. /**
  50883. * Enables an effect by name on a pipeline
  50884. * @param renderPipelineName the name of the pipeline to enable the effect in
  50885. * @param renderEffectName the name of the effect to enable
  50886. * @param cameras the cameras that the effect should be enabled on
  50887. */
  50888. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  50889. /**
  50890. * Disables an effect by name on a pipeline
  50891. * @param renderPipelineName the name of the pipeline to disable the effect in
  50892. * @param renderEffectName the name of the effect to disable
  50893. * @param cameras the cameras that the effect should be disabled on
  50894. */
  50895. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  50896. /**
  50897. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  50898. */
  50899. update(): void;
  50900. /** @hidden */
  50901. _rebuild(): void;
  50902. /**
  50903. * Disposes of the manager and pipelines
  50904. */
  50905. dispose(): void;
  50906. }
  50907. }
  50908. declare module BABYLON {
  50909. interface Scene {
  50910. /** @hidden (Backing field) */
  50911. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  50912. /**
  50913. * Gets the postprocess render pipeline manager
  50914. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  50915. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  50916. */
  50917. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  50918. }
  50919. /**
  50920. * Defines the Render Pipeline scene component responsible to rendering pipelines
  50921. */
  50922. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  50923. /**
  50924. * The component name helpfull to identify the component in the list of scene components.
  50925. */
  50926. readonly name: string;
  50927. /**
  50928. * The scene the component belongs to.
  50929. */
  50930. scene: Scene;
  50931. /**
  50932. * Creates a new instance of the component for the given scene
  50933. * @param scene Defines the scene to register the component in
  50934. */
  50935. constructor(scene: Scene);
  50936. /**
  50937. * Registers the component in a given scene
  50938. */
  50939. register(): void;
  50940. /**
  50941. * Rebuilds the elements related to this component in case of
  50942. * context lost for instance.
  50943. */
  50944. rebuild(): void;
  50945. /**
  50946. * Disposes the component and the associated ressources
  50947. */
  50948. dispose(): void;
  50949. private _gatherRenderTargets;
  50950. }
  50951. }
  50952. declare module BABYLON {
  50953. /** @hidden */
  50954. export var tonemapPixelShader: {
  50955. name: string;
  50956. shader: string;
  50957. };
  50958. }
  50959. declare module BABYLON {
  50960. /** Defines operator used for tonemapping */
  50961. export enum TonemappingOperator {
  50962. /** Hable */
  50963. Hable = 0,
  50964. /** Reinhard */
  50965. Reinhard = 1,
  50966. /** HejiDawson */
  50967. HejiDawson = 2,
  50968. /** Photographic */
  50969. Photographic = 3
  50970. }
  50971. /**
  50972. * Defines a post process to apply tone mapping
  50973. */
  50974. export class TonemapPostProcess extends PostProcess {
  50975. private _operator;
  50976. /** Defines the required exposure adjustement */
  50977. exposureAdjustment: number;
  50978. /**
  50979. * Creates a new TonemapPostProcess
  50980. * @param name defines the name of the postprocess
  50981. * @param _operator defines the operator to use
  50982. * @param exposureAdjustment defines the required exposure adjustement
  50983. * @param camera defines the camera to use (can be null)
  50984. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  50985. * @param engine defines the hosting engine (can be ignore if camera is set)
  50986. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50987. */
  50988. constructor(name: string, _operator: TonemappingOperator,
  50989. /** Defines the required exposure adjustement */
  50990. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  50991. }
  50992. }
  50993. declare module BABYLON {
  50994. /** @hidden */
  50995. export var depthVertexShader: {
  50996. name: string;
  50997. shader: string;
  50998. };
  50999. }
  51000. declare module BABYLON {
  51001. /** @hidden */
  51002. export var volumetricLightScatteringPixelShader: {
  51003. name: string;
  51004. shader: string;
  51005. };
  51006. }
  51007. declare module BABYLON {
  51008. /** @hidden */
  51009. export var volumetricLightScatteringPassPixelShader: {
  51010. name: string;
  51011. shader: string;
  51012. };
  51013. }
  51014. declare module BABYLON {
  51015. /**
  51016. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  51017. */
  51018. export class VolumetricLightScatteringPostProcess extends PostProcess {
  51019. private _volumetricLightScatteringPass;
  51020. private _volumetricLightScatteringRTT;
  51021. private _viewPort;
  51022. private _screenCoordinates;
  51023. private _cachedDefines;
  51024. /**
  51025. * If not undefined, the mesh position is computed from the attached node position
  51026. */
  51027. attachedNode: {
  51028. position: Vector3;
  51029. };
  51030. /**
  51031. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  51032. */
  51033. customMeshPosition: Vector3;
  51034. /**
  51035. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  51036. */
  51037. useCustomMeshPosition: boolean;
  51038. /**
  51039. * If the post-process should inverse the light scattering direction
  51040. */
  51041. invert: boolean;
  51042. /**
  51043. * The internal mesh used by the post-process
  51044. */
  51045. mesh: Mesh;
  51046. /**
  51047. * @hidden
  51048. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  51049. */
  51050. useDiffuseColor: boolean;
  51051. /**
  51052. * Array containing the excluded meshes not rendered in the internal pass
  51053. */
  51054. excludedMeshes: AbstractMesh[];
  51055. /**
  51056. * Controls the overall intensity of the post-process
  51057. */
  51058. exposure: number;
  51059. /**
  51060. * Dissipates each sample's contribution in range [0, 1]
  51061. */
  51062. decay: number;
  51063. /**
  51064. * Controls the overall intensity of each sample
  51065. */
  51066. weight: number;
  51067. /**
  51068. * Controls the density of each sample
  51069. */
  51070. density: number;
  51071. /**
  51072. * @constructor
  51073. * @param name The post-process name
  51074. * @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)
  51075. * @param camera The camera that the post-process will be attached to
  51076. * @param mesh The mesh used to create the light scattering
  51077. * @param samples The post-process quality, default 100
  51078. * @param samplingModeThe post-process filtering mode
  51079. * @param engine The babylon engine
  51080. * @param reusable If the post-process is reusable
  51081. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  51082. */
  51083. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  51084. /**
  51085. * Returns the string "VolumetricLightScatteringPostProcess"
  51086. * @returns "VolumetricLightScatteringPostProcess"
  51087. */
  51088. getClassName(): string;
  51089. private _isReady;
  51090. /**
  51091. * Sets the new light position for light scattering effect
  51092. * @param position The new custom light position
  51093. */
  51094. setCustomMeshPosition(position: Vector3): void;
  51095. /**
  51096. * Returns the light position for light scattering effect
  51097. * @return Vector3 The custom light position
  51098. */
  51099. getCustomMeshPosition(): Vector3;
  51100. /**
  51101. * Disposes the internal assets and detaches the post-process from the camera
  51102. */
  51103. dispose(camera: Camera): void;
  51104. /**
  51105. * Returns the render target texture used by the post-process
  51106. * @return the render target texture used by the post-process
  51107. */
  51108. getPass(): RenderTargetTexture;
  51109. private _meshExcluded;
  51110. private _createPass;
  51111. private _updateMeshScreenCoordinates;
  51112. /**
  51113. * Creates a default mesh for the Volumeric Light Scattering post-process
  51114. * @param name The mesh name
  51115. * @param scene The scene where to create the mesh
  51116. * @return the default mesh
  51117. */
  51118. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  51119. }
  51120. }
  51121. declare module BABYLON {
  51122. interface Scene {
  51123. /** @hidden (Backing field) */
  51124. _boundingBoxRenderer: BoundingBoxRenderer;
  51125. /** @hidden (Backing field) */
  51126. _forceShowBoundingBoxes: boolean;
  51127. /**
  51128. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  51129. */
  51130. forceShowBoundingBoxes: boolean;
  51131. /**
  51132. * Gets the bounding box renderer associated with the scene
  51133. * @returns a BoundingBoxRenderer
  51134. */
  51135. getBoundingBoxRenderer(): BoundingBoxRenderer;
  51136. }
  51137. interface AbstractMesh {
  51138. /** @hidden (Backing field) */
  51139. _showBoundingBox: boolean;
  51140. /**
  51141. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  51142. */
  51143. showBoundingBox: boolean;
  51144. }
  51145. /**
  51146. * Component responsible of rendering the bounding box of the meshes in a scene.
  51147. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  51148. */
  51149. export class BoundingBoxRenderer implements ISceneComponent {
  51150. /**
  51151. * The component name helpfull to identify the component in the list of scene components.
  51152. */
  51153. readonly name: string;
  51154. /**
  51155. * The scene the component belongs to.
  51156. */
  51157. scene: Scene;
  51158. /**
  51159. * Color of the bounding box lines placed in front of an object
  51160. */
  51161. frontColor: Color3;
  51162. /**
  51163. * Color of the bounding box lines placed behind an object
  51164. */
  51165. backColor: Color3;
  51166. /**
  51167. * Defines if the renderer should show the back lines or not
  51168. */
  51169. showBackLines: boolean;
  51170. /**
  51171. * @hidden
  51172. */
  51173. renderList: SmartArray<BoundingBox>;
  51174. private _colorShader;
  51175. private _vertexBuffers;
  51176. private _indexBuffer;
  51177. /**
  51178. * Instantiates a new bounding box renderer in a scene.
  51179. * @param scene the scene the renderer renders in
  51180. */
  51181. constructor(scene: Scene);
  51182. /**
  51183. * Registers the component in a given scene
  51184. */
  51185. register(): void;
  51186. private _evaluateSubMesh;
  51187. private _activeMesh;
  51188. private _prepareRessources;
  51189. private _createIndexBuffer;
  51190. /**
  51191. * Rebuilds the elements related to this component in case of
  51192. * context lost for instance.
  51193. */
  51194. rebuild(): void;
  51195. /**
  51196. * @hidden
  51197. */
  51198. reset(): void;
  51199. /**
  51200. * Render the bounding boxes of a specific rendering group
  51201. * @param renderingGroupId defines the rendering group to render
  51202. */
  51203. render(renderingGroupId: number): void;
  51204. /**
  51205. * In case of occlusion queries, we can render the occlusion bounding box through this method
  51206. * @param mesh Define the mesh to render the occlusion bounding box for
  51207. */
  51208. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  51209. /**
  51210. * Dispose and release the resources attached to this renderer.
  51211. */
  51212. dispose(): void;
  51213. }
  51214. }
  51215. declare module BABYLON {
  51216. /** @hidden */
  51217. export var depthPixelShader: {
  51218. name: string;
  51219. shader: string;
  51220. };
  51221. }
  51222. declare module BABYLON {
  51223. /**
  51224. * This represents a depth renderer in Babylon.
  51225. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  51226. */
  51227. export class DepthRenderer {
  51228. private _scene;
  51229. private _depthMap;
  51230. private _effect;
  51231. private _cachedDefines;
  51232. private _camera;
  51233. /**
  51234. * Specifiess that the depth renderer will only be used within
  51235. * the camera it is created for.
  51236. * This can help forcing its rendering during the camera processing.
  51237. */
  51238. useOnlyInActiveCamera: boolean;
  51239. /** @hidden */
  51240. static _SceneComponentInitialization: (scene: Scene) => void;
  51241. /**
  51242. * Instantiates a depth renderer
  51243. * @param scene The scene the renderer belongs to
  51244. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  51245. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  51246. */
  51247. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  51248. /**
  51249. * Creates the depth rendering effect and checks if the effect is ready.
  51250. * @param subMesh The submesh to be used to render the depth map of
  51251. * @param useInstances If multiple world instances should be used
  51252. * @returns if the depth renderer is ready to render the depth map
  51253. */
  51254. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51255. /**
  51256. * Gets the texture which the depth map will be written to.
  51257. * @returns The depth map texture
  51258. */
  51259. getDepthMap(): RenderTargetTexture;
  51260. /**
  51261. * Disposes of the depth renderer.
  51262. */
  51263. dispose(): void;
  51264. }
  51265. }
  51266. declare module BABYLON {
  51267. interface Scene {
  51268. /** @hidden (Backing field) */
  51269. _depthRenderer: {
  51270. [id: string]: DepthRenderer;
  51271. };
  51272. /**
  51273. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  51274. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  51275. * @returns the created depth renderer
  51276. */
  51277. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  51278. /**
  51279. * Disables a depth renderer for a given camera
  51280. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  51281. */
  51282. disableDepthRenderer(camera?: Nullable<Camera>): void;
  51283. }
  51284. /**
  51285. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  51286. * in several rendering techniques.
  51287. */
  51288. export class DepthRendererSceneComponent implements ISceneComponent {
  51289. /**
  51290. * The component name helpfull to identify the component in the list of scene components.
  51291. */
  51292. readonly name: string;
  51293. /**
  51294. * The scene the component belongs to.
  51295. */
  51296. scene: Scene;
  51297. /**
  51298. * Creates a new instance of the component for the given scene
  51299. * @param scene Defines the scene to register the component in
  51300. */
  51301. constructor(scene: Scene);
  51302. /**
  51303. * Registers the component in a given scene
  51304. */
  51305. register(): void;
  51306. /**
  51307. * Rebuilds the elements related to this component in case of
  51308. * context lost for instance.
  51309. */
  51310. rebuild(): void;
  51311. /**
  51312. * Disposes the component and the associated ressources
  51313. */
  51314. dispose(): void;
  51315. private _gatherRenderTargets;
  51316. private _gatherActiveCameraRenderTargets;
  51317. }
  51318. }
  51319. declare module BABYLON {
  51320. interface Scene {
  51321. /** @hidden (Backing field) */
  51322. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  51323. /**
  51324. * Gets or Sets the current geometry buffer associated to the scene.
  51325. */
  51326. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  51327. /**
  51328. * Enables a GeometryBufferRender and associates it with the scene
  51329. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  51330. * @returns the GeometryBufferRenderer
  51331. */
  51332. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  51333. /**
  51334. * Disables the GeometryBufferRender associated with the scene
  51335. */
  51336. disableGeometryBufferRenderer(): void;
  51337. }
  51338. /**
  51339. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  51340. * in several rendering techniques.
  51341. */
  51342. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  51343. /**
  51344. * The component name helpful to identify the component in the list of scene components.
  51345. */
  51346. readonly name: string;
  51347. /**
  51348. * The scene the component belongs to.
  51349. */
  51350. scene: Scene;
  51351. /**
  51352. * Creates a new instance of the component for the given scene
  51353. * @param scene Defines the scene to register the component in
  51354. */
  51355. constructor(scene: Scene);
  51356. /**
  51357. * Registers the component in a given scene
  51358. */
  51359. register(): void;
  51360. /**
  51361. * Rebuilds the elements related to this component in case of
  51362. * context lost for instance.
  51363. */
  51364. rebuild(): void;
  51365. /**
  51366. * Disposes the component and the associated ressources
  51367. */
  51368. dispose(): void;
  51369. private _gatherRenderTargets;
  51370. }
  51371. }
  51372. declare module BABYLON {
  51373. /** @hidden */
  51374. export var outlinePixelShader: {
  51375. name: string;
  51376. shader: string;
  51377. };
  51378. }
  51379. declare module BABYLON {
  51380. /** @hidden */
  51381. export var outlineVertexShader: {
  51382. name: string;
  51383. shader: string;
  51384. };
  51385. }
  51386. declare module BABYLON {
  51387. interface Scene {
  51388. /** @hidden */
  51389. _outlineRenderer: OutlineRenderer;
  51390. /**
  51391. * Gets the outline renderer associated with the scene
  51392. * @returns a OutlineRenderer
  51393. */
  51394. getOutlineRenderer(): OutlineRenderer;
  51395. }
  51396. interface AbstractMesh {
  51397. /** @hidden (Backing field) */
  51398. _renderOutline: boolean;
  51399. /**
  51400. * Gets or sets a boolean indicating if the outline must be rendered as well
  51401. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  51402. */
  51403. renderOutline: boolean;
  51404. /** @hidden (Backing field) */
  51405. _renderOverlay: boolean;
  51406. /**
  51407. * Gets or sets a boolean indicating if the overlay must be rendered as well
  51408. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  51409. */
  51410. renderOverlay: boolean;
  51411. }
  51412. /**
  51413. * This class is responsible to draw bothe outline/overlay of meshes.
  51414. * It should not be used directly but through the available method on mesh.
  51415. */
  51416. export class OutlineRenderer implements ISceneComponent {
  51417. /**
  51418. * The name of the component. Each component must have a unique name.
  51419. */
  51420. name: string;
  51421. /**
  51422. * The scene the component belongs to.
  51423. */
  51424. scene: Scene;
  51425. /**
  51426. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  51427. */
  51428. zOffset: number;
  51429. private _engine;
  51430. private _effect;
  51431. private _cachedDefines;
  51432. private _savedDepthWrite;
  51433. /**
  51434. * Instantiates a new outline renderer. (There could be only one per scene).
  51435. * @param scene Defines the scene it belongs to
  51436. */
  51437. constructor(scene: Scene);
  51438. /**
  51439. * Register the component to one instance of a scene.
  51440. */
  51441. register(): void;
  51442. /**
  51443. * Rebuilds the elements related to this component in case of
  51444. * context lost for instance.
  51445. */
  51446. rebuild(): void;
  51447. /**
  51448. * Disposes the component and the associated ressources.
  51449. */
  51450. dispose(): void;
  51451. /**
  51452. * Renders the outline in the canvas.
  51453. * @param subMesh Defines the sumesh to render
  51454. * @param batch Defines the batch of meshes in case of instances
  51455. * @param useOverlay Defines if the rendering is for the overlay or the outline
  51456. */
  51457. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  51458. /**
  51459. * Returns whether or not the outline renderer is ready for a given submesh.
  51460. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  51461. * @param subMesh Defines the submesh to check readyness for
  51462. * @param useInstances Defines wheter wee are trying to render instances or not
  51463. * @returns true if ready otherwise false
  51464. */
  51465. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51466. private _beforeRenderingMesh;
  51467. private _afterRenderingMesh;
  51468. }
  51469. }
  51470. declare module BABYLON {
  51471. /**
  51472. * Defines the list of states available for a task inside a AssetsManager
  51473. */
  51474. export enum AssetTaskState {
  51475. /**
  51476. * Initialization
  51477. */
  51478. INIT = 0,
  51479. /**
  51480. * Running
  51481. */
  51482. RUNNING = 1,
  51483. /**
  51484. * Done
  51485. */
  51486. DONE = 2,
  51487. /**
  51488. * Error
  51489. */
  51490. ERROR = 3
  51491. }
  51492. /**
  51493. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  51494. */
  51495. export abstract class AbstractAssetTask {
  51496. /**
  51497. * Task name
  51498. */ name: string;
  51499. /**
  51500. * Callback called when the task is successful
  51501. */
  51502. onSuccess: (task: any) => void;
  51503. /**
  51504. * Callback called when the task is not successful
  51505. */
  51506. onError: (task: any, message?: string, exception?: any) => void;
  51507. /**
  51508. * Creates a new AssetsManager
  51509. * @param name defines the name of the task
  51510. */
  51511. constructor(
  51512. /**
  51513. * Task name
  51514. */ name: string);
  51515. private _isCompleted;
  51516. private _taskState;
  51517. private _errorObject;
  51518. /**
  51519. * Get if the task is completed
  51520. */
  51521. readonly isCompleted: boolean;
  51522. /**
  51523. * Gets the current state of the task
  51524. */
  51525. readonly taskState: AssetTaskState;
  51526. /**
  51527. * Gets the current error object (if task is in error)
  51528. */
  51529. readonly errorObject: {
  51530. message?: string;
  51531. exception?: any;
  51532. };
  51533. /**
  51534. * Internal only
  51535. * @hidden
  51536. */
  51537. _setErrorObject(message?: string, exception?: any): void;
  51538. /**
  51539. * Execute the current task
  51540. * @param scene defines the scene where you want your assets to be loaded
  51541. * @param onSuccess is a callback called when the task is successfully executed
  51542. * @param onError is a callback called if an error occurs
  51543. */
  51544. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51545. /**
  51546. * Execute the current task
  51547. * @param scene defines the scene where you want your assets to be loaded
  51548. * @param onSuccess is a callback called when the task is successfully executed
  51549. * @param onError is a callback called if an error occurs
  51550. */
  51551. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51552. /**
  51553. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  51554. * This can be used with failed tasks that have the reason for failure fixed.
  51555. */
  51556. reset(): void;
  51557. private onErrorCallback;
  51558. private onDoneCallback;
  51559. }
  51560. /**
  51561. * Define the interface used by progress events raised during assets loading
  51562. */
  51563. export interface IAssetsProgressEvent {
  51564. /**
  51565. * Defines the number of remaining tasks to process
  51566. */
  51567. remainingCount: number;
  51568. /**
  51569. * Defines the total number of tasks
  51570. */
  51571. totalCount: number;
  51572. /**
  51573. * Defines the task that was just processed
  51574. */
  51575. task: AbstractAssetTask;
  51576. }
  51577. /**
  51578. * Class used to share progress information about assets loading
  51579. */
  51580. export class AssetsProgressEvent implements IAssetsProgressEvent {
  51581. /**
  51582. * Defines the number of remaining tasks to process
  51583. */
  51584. remainingCount: number;
  51585. /**
  51586. * Defines the total number of tasks
  51587. */
  51588. totalCount: number;
  51589. /**
  51590. * Defines the task that was just processed
  51591. */
  51592. task: AbstractAssetTask;
  51593. /**
  51594. * Creates a AssetsProgressEvent
  51595. * @param remainingCount defines the number of remaining tasks to process
  51596. * @param totalCount defines the total number of tasks
  51597. * @param task defines the task that was just processed
  51598. */
  51599. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  51600. }
  51601. /**
  51602. * Define a task used by AssetsManager to load meshes
  51603. */
  51604. export class MeshAssetTask extends AbstractAssetTask {
  51605. /**
  51606. * Defines the name of the task
  51607. */
  51608. name: string;
  51609. /**
  51610. * Defines the list of mesh's names you want to load
  51611. */
  51612. meshesNames: any;
  51613. /**
  51614. * Defines the root url to use as a base to load your meshes and associated resources
  51615. */
  51616. rootUrl: string;
  51617. /**
  51618. * Defines the filename of the scene to load from
  51619. */
  51620. sceneFilename: string;
  51621. /**
  51622. * Gets the list of loaded meshes
  51623. */
  51624. loadedMeshes: Array<AbstractMesh>;
  51625. /**
  51626. * Gets the list of loaded particle systems
  51627. */
  51628. loadedParticleSystems: Array<IParticleSystem>;
  51629. /**
  51630. * Gets the list of loaded skeletons
  51631. */
  51632. loadedSkeletons: Array<Skeleton>;
  51633. /**
  51634. * Gets the list of loaded animation groups
  51635. */
  51636. loadedAnimationGroups: Array<AnimationGroup>;
  51637. /**
  51638. * Callback called when the task is successful
  51639. */
  51640. onSuccess: (task: MeshAssetTask) => void;
  51641. /**
  51642. * Callback called when the task is successful
  51643. */
  51644. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  51645. /**
  51646. * Creates a new MeshAssetTask
  51647. * @param name defines the name of the task
  51648. * @param meshesNames defines the list of mesh's names you want to load
  51649. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  51650. * @param sceneFilename defines the filename of the scene to load from
  51651. */
  51652. constructor(
  51653. /**
  51654. * Defines the name of the task
  51655. */
  51656. name: string,
  51657. /**
  51658. * Defines the list of mesh's names you want to load
  51659. */
  51660. meshesNames: any,
  51661. /**
  51662. * Defines the root url to use as a base to load your meshes and associated resources
  51663. */
  51664. rootUrl: string,
  51665. /**
  51666. * Defines the filename of the scene to load from
  51667. */
  51668. sceneFilename: string);
  51669. /**
  51670. * Execute the current task
  51671. * @param scene defines the scene where you want your assets to be loaded
  51672. * @param onSuccess is a callback called when the task is successfully executed
  51673. * @param onError is a callback called if an error occurs
  51674. */
  51675. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51676. }
  51677. /**
  51678. * Define a task used by AssetsManager to load text content
  51679. */
  51680. export class TextFileAssetTask extends AbstractAssetTask {
  51681. /**
  51682. * Defines the name of the task
  51683. */
  51684. name: string;
  51685. /**
  51686. * Defines the location of the file to load
  51687. */
  51688. url: string;
  51689. /**
  51690. * Gets the loaded text string
  51691. */
  51692. text: string;
  51693. /**
  51694. * Callback called when the task is successful
  51695. */
  51696. onSuccess: (task: TextFileAssetTask) => void;
  51697. /**
  51698. * Callback called when the task is successful
  51699. */
  51700. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  51701. /**
  51702. * Creates a new TextFileAssetTask object
  51703. * @param name defines the name of the task
  51704. * @param url defines the location of the file to load
  51705. */
  51706. constructor(
  51707. /**
  51708. * Defines the name of the task
  51709. */
  51710. name: string,
  51711. /**
  51712. * Defines the location of the file to load
  51713. */
  51714. url: string);
  51715. /**
  51716. * Execute the current task
  51717. * @param scene defines the scene where you want your assets to be loaded
  51718. * @param onSuccess is a callback called when the task is successfully executed
  51719. * @param onError is a callback called if an error occurs
  51720. */
  51721. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51722. }
  51723. /**
  51724. * Define a task used by AssetsManager to load binary data
  51725. */
  51726. export class BinaryFileAssetTask extends AbstractAssetTask {
  51727. /**
  51728. * Defines the name of the task
  51729. */
  51730. name: string;
  51731. /**
  51732. * Defines the location of the file to load
  51733. */
  51734. url: string;
  51735. /**
  51736. * Gets the lodaded data (as an array buffer)
  51737. */
  51738. data: ArrayBuffer;
  51739. /**
  51740. * Callback called when the task is successful
  51741. */
  51742. onSuccess: (task: BinaryFileAssetTask) => void;
  51743. /**
  51744. * Callback called when the task is successful
  51745. */
  51746. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  51747. /**
  51748. * Creates a new BinaryFileAssetTask object
  51749. * @param name defines the name of the new task
  51750. * @param url defines the location of the file to load
  51751. */
  51752. constructor(
  51753. /**
  51754. * Defines the name of the task
  51755. */
  51756. name: string,
  51757. /**
  51758. * Defines the location of the file to load
  51759. */
  51760. url: string);
  51761. /**
  51762. * Execute the current task
  51763. * @param scene defines the scene where you want your assets to be loaded
  51764. * @param onSuccess is a callback called when the task is successfully executed
  51765. * @param onError is a callback called if an error occurs
  51766. */
  51767. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51768. }
  51769. /**
  51770. * Define a task used by AssetsManager to load images
  51771. */
  51772. export class ImageAssetTask extends AbstractAssetTask {
  51773. /**
  51774. * Defines the name of the task
  51775. */
  51776. name: string;
  51777. /**
  51778. * Defines the location of the image to load
  51779. */
  51780. url: string;
  51781. /**
  51782. * Gets the loaded images
  51783. */
  51784. image: HTMLImageElement;
  51785. /**
  51786. * Callback called when the task is successful
  51787. */
  51788. onSuccess: (task: ImageAssetTask) => void;
  51789. /**
  51790. * Callback called when the task is successful
  51791. */
  51792. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  51793. /**
  51794. * Creates a new ImageAssetTask
  51795. * @param name defines the name of the task
  51796. * @param url defines the location of the image to load
  51797. */
  51798. constructor(
  51799. /**
  51800. * Defines the name of the task
  51801. */
  51802. name: string,
  51803. /**
  51804. * Defines the location of the image to load
  51805. */
  51806. url: string);
  51807. /**
  51808. * Execute the current task
  51809. * @param scene defines the scene where you want your assets to be loaded
  51810. * @param onSuccess is a callback called when the task is successfully executed
  51811. * @param onError is a callback called if an error occurs
  51812. */
  51813. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51814. }
  51815. /**
  51816. * Defines the interface used by texture loading tasks
  51817. */
  51818. export interface ITextureAssetTask<TEX extends BaseTexture> {
  51819. /**
  51820. * Gets the loaded texture
  51821. */
  51822. texture: TEX;
  51823. }
  51824. /**
  51825. * Define a task used by AssetsManager to load 2D textures
  51826. */
  51827. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  51828. /**
  51829. * Defines the name of the task
  51830. */
  51831. name: string;
  51832. /**
  51833. * Defines the location of the file to load
  51834. */
  51835. url: string;
  51836. /**
  51837. * Defines if mipmap should not be generated (default is false)
  51838. */
  51839. noMipmap?: boolean | undefined;
  51840. /**
  51841. * Defines if texture must be inverted on Y axis (default is false)
  51842. */
  51843. invertY?: boolean | undefined;
  51844. /**
  51845. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51846. */
  51847. samplingMode: number;
  51848. /**
  51849. * Gets the loaded texture
  51850. */
  51851. texture: Texture;
  51852. /**
  51853. * Callback called when the task is successful
  51854. */
  51855. onSuccess: (task: TextureAssetTask) => void;
  51856. /**
  51857. * Callback called when the task is successful
  51858. */
  51859. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  51860. /**
  51861. * Creates a new TextureAssetTask object
  51862. * @param name defines the name of the task
  51863. * @param url defines the location of the file to load
  51864. * @param noMipmap defines if mipmap should not be generated (default is false)
  51865. * @param invertY defines if texture must be inverted on Y axis (default is false)
  51866. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51867. */
  51868. constructor(
  51869. /**
  51870. * Defines the name of the task
  51871. */
  51872. name: string,
  51873. /**
  51874. * Defines the location of the file to load
  51875. */
  51876. url: string,
  51877. /**
  51878. * Defines if mipmap should not be generated (default is false)
  51879. */
  51880. noMipmap?: boolean | undefined,
  51881. /**
  51882. * Defines if texture must be inverted on Y axis (default is false)
  51883. */
  51884. invertY?: boolean | undefined,
  51885. /**
  51886. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51887. */
  51888. samplingMode?: number);
  51889. /**
  51890. * Execute the current task
  51891. * @param scene defines the scene where you want your assets to be loaded
  51892. * @param onSuccess is a callback called when the task is successfully executed
  51893. * @param onError is a callback called if an error occurs
  51894. */
  51895. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51896. }
  51897. /**
  51898. * Define a task used by AssetsManager to load cube textures
  51899. */
  51900. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  51901. /**
  51902. * Defines the name of the task
  51903. */
  51904. name: string;
  51905. /**
  51906. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  51907. */
  51908. url: string;
  51909. /**
  51910. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  51911. */
  51912. extensions?: string[] | undefined;
  51913. /**
  51914. * Defines if mipmaps should not be generated (default is false)
  51915. */
  51916. noMipmap?: boolean | undefined;
  51917. /**
  51918. * Defines the explicit list of files (undefined by default)
  51919. */
  51920. files?: string[] | undefined;
  51921. /**
  51922. * Gets the loaded texture
  51923. */
  51924. texture: CubeTexture;
  51925. /**
  51926. * Callback called when the task is successful
  51927. */
  51928. onSuccess: (task: CubeTextureAssetTask) => void;
  51929. /**
  51930. * Callback called when the task is successful
  51931. */
  51932. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  51933. /**
  51934. * Creates a new CubeTextureAssetTask
  51935. * @param name defines the name of the task
  51936. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  51937. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  51938. * @param noMipmap defines if mipmaps should not be generated (default is false)
  51939. * @param files defines the explicit list of files (undefined by default)
  51940. */
  51941. constructor(
  51942. /**
  51943. * Defines the name of the task
  51944. */
  51945. name: string,
  51946. /**
  51947. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  51948. */
  51949. url: string,
  51950. /**
  51951. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  51952. */
  51953. extensions?: string[] | undefined,
  51954. /**
  51955. * Defines if mipmaps should not be generated (default is false)
  51956. */
  51957. noMipmap?: boolean | undefined,
  51958. /**
  51959. * Defines the explicit list of files (undefined by default)
  51960. */
  51961. files?: string[] | undefined);
  51962. /**
  51963. * Execute the current task
  51964. * @param scene defines the scene where you want your assets to be loaded
  51965. * @param onSuccess is a callback called when the task is successfully executed
  51966. * @param onError is a callback called if an error occurs
  51967. */
  51968. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51969. }
  51970. /**
  51971. * Define a task used by AssetsManager to load HDR cube textures
  51972. */
  51973. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  51974. /**
  51975. * Defines the name of the task
  51976. */
  51977. name: string;
  51978. /**
  51979. * Defines the location of the file to load
  51980. */
  51981. url: string;
  51982. /**
  51983. * Defines the desired size (the more it increases the longer the generation will be)
  51984. */
  51985. size: number;
  51986. /**
  51987. * Defines if mipmaps should not be generated (default is false)
  51988. */
  51989. noMipmap: boolean;
  51990. /**
  51991. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  51992. */
  51993. generateHarmonics: boolean;
  51994. /**
  51995. * 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)
  51996. */
  51997. gammaSpace: boolean;
  51998. /**
  51999. * Internal Use Only
  52000. */
  52001. reserved: boolean;
  52002. /**
  52003. * Gets the loaded texture
  52004. */
  52005. texture: HDRCubeTexture;
  52006. /**
  52007. * Callback called when the task is successful
  52008. */
  52009. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  52010. /**
  52011. * Callback called when the task is successful
  52012. */
  52013. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  52014. /**
  52015. * Creates a new HDRCubeTextureAssetTask object
  52016. * @param name defines the name of the task
  52017. * @param url defines the location of the file to load
  52018. * @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.
  52019. * @param noMipmap defines if mipmaps should not be generated (default is false)
  52020. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  52021. * @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)
  52022. * @param reserved Internal use only
  52023. */
  52024. constructor(
  52025. /**
  52026. * Defines the name of the task
  52027. */
  52028. name: string,
  52029. /**
  52030. * Defines the location of the file to load
  52031. */
  52032. url: string,
  52033. /**
  52034. * Defines the desired size (the more it increases the longer the generation will be)
  52035. */
  52036. size: number,
  52037. /**
  52038. * Defines if mipmaps should not be generated (default is false)
  52039. */
  52040. noMipmap?: boolean,
  52041. /**
  52042. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  52043. */
  52044. generateHarmonics?: boolean,
  52045. /**
  52046. * 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)
  52047. */
  52048. gammaSpace?: boolean,
  52049. /**
  52050. * Internal Use Only
  52051. */
  52052. reserved?: boolean);
  52053. /**
  52054. * Execute the current task
  52055. * @param scene defines the scene where you want your assets to be loaded
  52056. * @param onSuccess is a callback called when the task is successfully executed
  52057. * @param onError is a callback called if an error occurs
  52058. */
  52059. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52060. }
  52061. /**
  52062. * This class can be used to easily import assets into a scene
  52063. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  52064. */
  52065. export class AssetsManager {
  52066. private _scene;
  52067. private _isLoading;
  52068. protected _tasks: AbstractAssetTask[];
  52069. protected _waitingTasksCount: number;
  52070. protected _totalTasksCount: number;
  52071. /**
  52072. * Callback called when all tasks are processed
  52073. */
  52074. onFinish: (tasks: AbstractAssetTask[]) => void;
  52075. /**
  52076. * Callback called when a task is successful
  52077. */
  52078. onTaskSuccess: (task: AbstractAssetTask) => void;
  52079. /**
  52080. * Callback called when a task had an error
  52081. */
  52082. onTaskError: (task: AbstractAssetTask) => void;
  52083. /**
  52084. * Callback called when a task is done (whatever the result is)
  52085. */
  52086. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  52087. /**
  52088. * Observable called when all tasks are processed
  52089. */
  52090. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  52091. /**
  52092. * Observable called when a task had an error
  52093. */
  52094. onTaskErrorObservable: Observable<AbstractAssetTask>;
  52095. /**
  52096. * Observable called when a task is successful
  52097. */
  52098. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  52099. /**
  52100. * Observable called when a task is done (whatever the result is)
  52101. */
  52102. onProgressObservable: Observable<IAssetsProgressEvent>;
  52103. /**
  52104. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  52105. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  52106. */
  52107. useDefaultLoadingScreen: boolean;
  52108. /**
  52109. * Creates a new AssetsManager
  52110. * @param scene defines the scene to work on
  52111. */
  52112. constructor(scene: Scene);
  52113. /**
  52114. * Add a MeshAssetTask to the list of active tasks
  52115. * @param taskName defines the name of the new task
  52116. * @param meshesNames defines the name of meshes to load
  52117. * @param rootUrl defines the root url to use to locate files
  52118. * @param sceneFilename defines the filename of the scene file
  52119. * @returns a new MeshAssetTask object
  52120. */
  52121. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  52122. /**
  52123. * Add a TextFileAssetTask to the list of active tasks
  52124. * @param taskName defines the name of the new task
  52125. * @param url defines the url of the file to load
  52126. * @returns a new TextFileAssetTask object
  52127. */
  52128. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  52129. /**
  52130. * Add a BinaryFileAssetTask to the list of active tasks
  52131. * @param taskName defines the name of the new task
  52132. * @param url defines the url of the file to load
  52133. * @returns a new BinaryFileAssetTask object
  52134. */
  52135. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  52136. /**
  52137. * Add a ImageAssetTask to the list of active tasks
  52138. * @param taskName defines the name of the new task
  52139. * @param url defines the url of the file to load
  52140. * @returns a new ImageAssetTask object
  52141. */
  52142. addImageTask(taskName: string, url: string): ImageAssetTask;
  52143. /**
  52144. * Add a TextureAssetTask to the list of active tasks
  52145. * @param taskName defines the name of the new task
  52146. * @param url defines the url of the file to load
  52147. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  52148. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  52149. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52150. * @returns a new TextureAssetTask object
  52151. */
  52152. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  52153. /**
  52154. * Add a CubeTextureAssetTask to the list of active tasks
  52155. * @param taskName defines the name of the new task
  52156. * @param url defines the url of the file to load
  52157. * @param extensions defines the extension to use to load the cube map (can be null)
  52158. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  52159. * @param files defines the list of files to load (can be null)
  52160. * @returns a new CubeTextureAssetTask object
  52161. */
  52162. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  52163. /**
  52164. *
  52165. * Add a HDRCubeTextureAssetTask to the list of active tasks
  52166. * @param taskName defines the name of the new task
  52167. * @param url defines the url of the file to load
  52168. * @param size defines the size you want for the cubemap (can be null)
  52169. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  52170. * @param generateHarmonics defines if you want to automatically generate (true by default)
  52171. * @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)
  52172. * @param reserved Internal use only
  52173. * @returns a new HDRCubeTextureAssetTask object
  52174. */
  52175. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  52176. /**
  52177. * Remove a task from the assets manager.
  52178. * @param task the task to remove
  52179. */
  52180. removeTask(task: AbstractAssetTask): void;
  52181. private _decreaseWaitingTasksCount;
  52182. private _runTask;
  52183. /**
  52184. * Reset the AssetsManager and remove all tasks
  52185. * @return the current instance of the AssetsManager
  52186. */
  52187. reset(): AssetsManager;
  52188. /**
  52189. * Start the loading process
  52190. * @return the current instance of the AssetsManager
  52191. */
  52192. load(): AssetsManager;
  52193. }
  52194. }
  52195. declare module BABYLON {
  52196. /**
  52197. * Wrapper class for promise with external resolve and reject.
  52198. */
  52199. export class Deferred<T> {
  52200. /**
  52201. * The promise associated with this deferred object.
  52202. */
  52203. readonly promise: Promise<T>;
  52204. private _resolve;
  52205. private _reject;
  52206. /**
  52207. * The resolve method of the promise associated with this deferred object.
  52208. */
  52209. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  52210. /**
  52211. * The reject method of the promise associated with this deferred object.
  52212. */
  52213. readonly reject: (reason?: any) => void;
  52214. /**
  52215. * Constructor for this deferred object.
  52216. */
  52217. constructor();
  52218. }
  52219. }
  52220. declare module BABYLON {
  52221. /**
  52222. * Class used to help managing file picking and drag'n'drop
  52223. */
  52224. export class FilesInput {
  52225. /**
  52226. * List of files ready to be loaded
  52227. */
  52228. static readonly FilesToLoad: {
  52229. [key: string]: File;
  52230. };
  52231. /**
  52232. * Callback called when a file is processed
  52233. */
  52234. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  52235. private _engine;
  52236. private _currentScene;
  52237. private _sceneLoadedCallback;
  52238. private _progressCallback;
  52239. private _additionalRenderLoopLogicCallback;
  52240. private _textureLoadingCallback;
  52241. private _startingProcessingFilesCallback;
  52242. private _onReloadCallback;
  52243. private _errorCallback;
  52244. private _elementToMonitor;
  52245. private _sceneFileToLoad;
  52246. private _filesToLoad;
  52247. /**
  52248. * Creates a new FilesInput
  52249. * @param engine defines the rendering engine
  52250. * @param scene defines the hosting scene
  52251. * @param sceneLoadedCallback callback called when scene is loaded
  52252. * @param progressCallback callback called to track progress
  52253. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  52254. * @param textureLoadingCallback callback called when a texture is loading
  52255. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  52256. * @param onReloadCallback callback called when a reload is requested
  52257. * @param errorCallback callback call if an error occurs
  52258. */
  52259. 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);
  52260. private _dragEnterHandler;
  52261. private _dragOverHandler;
  52262. private _dropHandler;
  52263. /**
  52264. * Calls this function to listen to drag'n'drop events on a specific DOM element
  52265. * @param elementToMonitor defines the DOM element to track
  52266. */
  52267. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  52268. /**
  52269. * Release all associated resources
  52270. */
  52271. dispose(): void;
  52272. private renderFunction;
  52273. private drag;
  52274. private drop;
  52275. private _traverseFolder;
  52276. private _processFiles;
  52277. /**
  52278. * Load files from a drop event
  52279. * @param event defines the drop event to use as source
  52280. */
  52281. loadFiles(event: any): void;
  52282. private _processReload;
  52283. /**
  52284. * Reload the current scene from the loaded files
  52285. */
  52286. reload(): void;
  52287. }
  52288. }
  52289. declare module BABYLON {
  52290. /**
  52291. * Defines the root class used to create scene optimization to use with SceneOptimizer
  52292. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52293. */
  52294. export class SceneOptimization {
  52295. /**
  52296. * Defines the priority of this optimization (0 by default which means first in the list)
  52297. */
  52298. priority: number;
  52299. /**
  52300. * Gets a string describing the action executed by the current optimization
  52301. * @returns description string
  52302. */
  52303. getDescription(): string;
  52304. /**
  52305. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52306. * @param scene defines the current scene where to apply this optimization
  52307. * @param optimizer defines the current optimizer
  52308. * @returns true if everything that can be done was applied
  52309. */
  52310. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52311. /**
  52312. * Creates the SceneOptimization object
  52313. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52314. * @param desc defines the description associated with the optimization
  52315. */
  52316. constructor(
  52317. /**
  52318. * Defines the priority of this optimization (0 by default which means first in the list)
  52319. */
  52320. priority?: number);
  52321. }
  52322. /**
  52323. * Defines an optimization used to reduce the size of render target textures
  52324. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52325. */
  52326. export class TextureOptimization extends SceneOptimization {
  52327. /**
  52328. * Defines the priority of this optimization (0 by default which means first in the list)
  52329. */
  52330. priority: number;
  52331. /**
  52332. * 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
  52333. */
  52334. maximumSize: number;
  52335. /**
  52336. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  52337. */
  52338. step: number;
  52339. /**
  52340. * Gets a string describing the action executed by the current optimization
  52341. * @returns description string
  52342. */
  52343. getDescription(): string;
  52344. /**
  52345. * Creates the TextureOptimization object
  52346. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52347. * @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
  52348. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  52349. */
  52350. constructor(
  52351. /**
  52352. * Defines the priority of this optimization (0 by default which means first in the list)
  52353. */
  52354. priority?: number,
  52355. /**
  52356. * 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
  52357. */
  52358. maximumSize?: number,
  52359. /**
  52360. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  52361. */
  52362. step?: number);
  52363. /**
  52364. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52365. * @param scene defines the current scene where to apply this optimization
  52366. * @param optimizer defines the current optimizer
  52367. * @returns true if everything that can be done was applied
  52368. */
  52369. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52370. }
  52371. /**
  52372. * Defines an optimization used to increase or decrease the rendering resolution
  52373. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52374. */
  52375. export class HardwareScalingOptimization extends SceneOptimization {
  52376. /**
  52377. * Defines the priority of this optimization (0 by default which means first in the list)
  52378. */
  52379. priority: number;
  52380. /**
  52381. * Defines the maximum scale to use (2 by default)
  52382. */
  52383. maximumScale: number;
  52384. /**
  52385. * Defines the step to use between two passes (0.5 by default)
  52386. */
  52387. step: number;
  52388. private _currentScale;
  52389. private _directionOffset;
  52390. /**
  52391. * Gets a string describing the action executed by the current optimization
  52392. * @return description string
  52393. */
  52394. getDescription(): string;
  52395. /**
  52396. * Creates the HardwareScalingOptimization object
  52397. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52398. * @param maximumScale defines the maximum scale to use (2 by default)
  52399. * @param step defines the step to use between two passes (0.5 by default)
  52400. */
  52401. constructor(
  52402. /**
  52403. * Defines the priority of this optimization (0 by default which means first in the list)
  52404. */
  52405. priority?: number,
  52406. /**
  52407. * Defines the maximum scale to use (2 by default)
  52408. */
  52409. maximumScale?: number,
  52410. /**
  52411. * Defines the step to use between two passes (0.5 by default)
  52412. */
  52413. step?: number);
  52414. /**
  52415. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52416. * @param scene defines the current scene where to apply this optimization
  52417. * @param optimizer defines the current optimizer
  52418. * @returns true if everything that can be done was applied
  52419. */
  52420. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52421. }
  52422. /**
  52423. * Defines an optimization used to remove shadows
  52424. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52425. */
  52426. export class ShadowsOptimization extends SceneOptimization {
  52427. /**
  52428. * Gets a string describing the action executed by the current optimization
  52429. * @return description string
  52430. */
  52431. getDescription(): string;
  52432. /**
  52433. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52434. * @param scene defines the current scene where to apply this optimization
  52435. * @param optimizer defines the current optimizer
  52436. * @returns true if everything that can be done was applied
  52437. */
  52438. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52439. }
  52440. /**
  52441. * Defines an optimization used to turn post-processes off
  52442. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52443. */
  52444. export class PostProcessesOptimization extends SceneOptimization {
  52445. /**
  52446. * Gets a string describing the action executed by the current optimization
  52447. * @return description string
  52448. */
  52449. getDescription(): string;
  52450. /**
  52451. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52452. * @param scene defines the current scene where to apply this optimization
  52453. * @param optimizer defines the current optimizer
  52454. * @returns true if everything that can be done was applied
  52455. */
  52456. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52457. }
  52458. /**
  52459. * Defines an optimization used to turn lens flares off
  52460. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52461. */
  52462. export class LensFlaresOptimization extends SceneOptimization {
  52463. /**
  52464. * Gets a string describing the action executed by the current optimization
  52465. * @return description string
  52466. */
  52467. getDescription(): string;
  52468. /**
  52469. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52470. * @param scene defines the current scene where to apply this optimization
  52471. * @param optimizer defines the current optimizer
  52472. * @returns true if everything that can be done was applied
  52473. */
  52474. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52475. }
  52476. /**
  52477. * Defines an optimization based on user defined callback.
  52478. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52479. */
  52480. export class CustomOptimization extends SceneOptimization {
  52481. /**
  52482. * Callback called to apply the custom optimization.
  52483. */
  52484. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  52485. /**
  52486. * Callback called to get custom description
  52487. */
  52488. onGetDescription: () => string;
  52489. /**
  52490. * Gets a string describing the action executed by the current optimization
  52491. * @returns description string
  52492. */
  52493. getDescription(): string;
  52494. /**
  52495. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52496. * @param scene defines the current scene where to apply this optimization
  52497. * @param optimizer defines the current optimizer
  52498. * @returns true if everything that can be done was applied
  52499. */
  52500. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52501. }
  52502. /**
  52503. * Defines an optimization used to turn particles off
  52504. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52505. */
  52506. export class ParticlesOptimization extends SceneOptimization {
  52507. /**
  52508. * Gets a string describing the action executed by the current optimization
  52509. * @return description string
  52510. */
  52511. getDescription(): string;
  52512. /**
  52513. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52514. * @param scene defines the current scene where to apply this optimization
  52515. * @param optimizer defines the current optimizer
  52516. * @returns true if everything that can be done was applied
  52517. */
  52518. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52519. }
  52520. /**
  52521. * Defines an optimization used to turn render targets off
  52522. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52523. */
  52524. export class RenderTargetsOptimization extends SceneOptimization {
  52525. /**
  52526. * Gets a string describing the action executed by the current optimization
  52527. * @return description string
  52528. */
  52529. getDescription(): string;
  52530. /**
  52531. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52532. * @param scene defines the current scene where to apply this optimization
  52533. * @param optimizer defines the current optimizer
  52534. * @returns true if everything that can be done was applied
  52535. */
  52536. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52537. }
  52538. /**
  52539. * Defines an optimization used to merge meshes with compatible materials
  52540. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52541. */
  52542. export class MergeMeshesOptimization extends SceneOptimization {
  52543. private static _UpdateSelectionTree;
  52544. /**
  52545. * Gets or sets a boolean which defines if optimization octree has to be updated
  52546. */
  52547. /**
  52548. * Gets or sets a boolean which defines if optimization octree has to be updated
  52549. */
  52550. static UpdateSelectionTree: boolean;
  52551. /**
  52552. * Gets a string describing the action executed by the current optimization
  52553. * @return description string
  52554. */
  52555. getDescription(): string;
  52556. private _canBeMerged;
  52557. /**
  52558. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52559. * @param scene defines the current scene where to apply this optimization
  52560. * @param optimizer defines the current optimizer
  52561. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  52562. * @returns true if everything that can be done was applied
  52563. */
  52564. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  52565. }
  52566. /**
  52567. * Defines a list of options used by SceneOptimizer
  52568. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52569. */
  52570. export class SceneOptimizerOptions {
  52571. /**
  52572. * Defines the target frame rate to reach (60 by default)
  52573. */
  52574. targetFrameRate: number;
  52575. /**
  52576. * Defines the interval between two checkes (2000ms by default)
  52577. */
  52578. trackerDuration: number;
  52579. /**
  52580. * Gets the list of optimizations to apply
  52581. */
  52582. optimizations: SceneOptimization[];
  52583. /**
  52584. * Creates a new list of options used by SceneOptimizer
  52585. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  52586. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  52587. */
  52588. constructor(
  52589. /**
  52590. * Defines the target frame rate to reach (60 by default)
  52591. */
  52592. targetFrameRate?: number,
  52593. /**
  52594. * Defines the interval between two checkes (2000ms by default)
  52595. */
  52596. trackerDuration?: number);
  52597. /**
  52598. * Add a new optimization
  52599. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  52600. * @returns the current SceneOptimizerOptions
  52601. */
  52602. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  52603. /**
  52604. * Add a new custom optimization
  52605. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  52606. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  52607. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52608. * @returns the current SceneOptimizerOptions
  52609. */
  52610. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  52611. /**
  52612. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  52613. * @param targetFrameRate defines the target frame rate (60 by default)
  52614. * @returns a SceneOptimizerOptions object
  52615. */
  52616. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  52617. /**
  52618. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  52619. * @param targetFrameRate defines the target frame rate (60 by default)
  52620. * @returns a SceneOptimizerOptions object
  52621. */
  52622. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  52623. /**
  52624. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  52625. * @param targetFrameRate defines the target frame rate (60 by default)
  52626. * @returns a SceneOptimizerOptions object
  52627. */
  52628. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  52629. }
  52630. /**
  52631. * Class used to run optimizations in order to reach a target frame rate
  52632. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52633. */
  52634. export class SceneOptimizer implements IDisposable {
  52635. private _isRunning;
  52636. private _options;
  52637. private _scene;
  52638. private _currentPriorityLevel;
  52639. private _targetFrameRate;
  52640. private _trackerDuration;
  52641. private _currentFrameRate;
  52642. private _sceneDisposeObserver;
  52643. private _improvementMode;
  52644. /**
  52645. * Defines an observable called when the optimizer reaches the target frame rate
  52646. */
  52647. onSuccessObservable: Observable<SceneOptimizer>;
  52648. /**
  52649. * Defines an observable called when the optimizer enables an optimization
  52650. */
  52651. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  52652. /**
  52653. * Defines an observable called when the optimizer is not able to reach the target frame rate
  52654. */
  52655. onFailureObservable: Observable<SceneOptimizer>;
  52656. /**
  52657. * Gets a boolean indicating if the optimizer is in improvement mode
  52658. */
  52659. readonly isInImprovementMode: boolean;
  52660. /**
  52661. * Gets the current priority level (0 at start)
  52662. */
  52663. readonly currentPriorityLevel: number;
  52664. /**
  52665. * Gets the current frame rate checked by the SceneOptimizer
  52666. */
  52667. readonly currentFrameRate: number;
  52668. /**
  52669. * Gets or sets the current target frame rate (60 by default)
  52670. */
  52671. /**
  52672. * Gets or sets the current target frame rate (60 by default)
  52673. */
  52674. targetFrameRate: number;
  52675. /**
  52676. * Gets or sets the current interval between two checks (every 2000ms by default)
  52677. */
  52678. /**
  52679. * Gets or sets the current interval between two checks (every 2000ms by default)
  52680. */
  52681. trackerDuration: number;
  52682. /**
  52683. * Gets the list of active optimizations
  52684. */
  52685. readonly optimizations: SceneOptimization[];
  52686. /**
  52687. * Creates a new SceneOptimizer
  52688. * @param scene defines the scene to work on
  52689. * @param options defines the options to use with the SceneOptimizer
  52690. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  52691. * @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)
  52692. */
  52693. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  52694. /**
  52695. * Stops the current optimizer
  52696. */
  52697. stop(): void;
  52698. /**
  52699. * Reset the optimizer to initial step (current priority level = 0)
  52700. */
  52701. reset(): void;
  52702. /**
  52703. * Start the optimizer. By default it will try to reach a specific framerate
  52704. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  52705. */
  52706. start(): void;
  52707. private _checkCurrentState;
  52708. /**
  52709. * Release all resources
  52710. */
  52711. dispose(): void;
  52712. /**
  52713. * Helper function to create a SceneOptimizer with one single line of code
  52714. * @param scene defines the scene to work on
  52715. * @param options defines the options to use with the SceneOptimizer
  52716. * @param onSuccess defines a callback to call on success
  52717. * @param onFailure defines a callback to call on failure
  52718. * @returns the new SceneOptimizer object
  52719. */
  52720. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  52721. }
  52722. }
  52723. declare module BABYLON {
  52724. /**
  52725. * Class used to serialize a scene into a string
  52726. */
  52727. export class SceneSerializer {
  52728. /**
  52729. * Clear cache used by a previous serialization
  52730. */
  52731. static ClearCache(): void;
  52732. /**
  52733. * Serialize a scene into a JSON compatible object
  52734. * @param scene defines the scene to serialize
  52735. * @returns a JSON compatible object
  52736. */
  52737. static Serialize(scene: Scene): any;
  52738. /**
  52739. * Serialize a mesh into a JSON compatible object
  52740. * @param toSerialize defines the mesh to serialize
  52741. * @param withParents defines if parents must be serialized as well
  52742. * @param withChildren defines if children must be serialized as well
  52743. * @returns a JSON compatible object
  52744. */
  52745. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  52746. }
  52747. }
  52748. declare module BABYLON {
  52749. /**
  52750. * This represents the different options avilable for the video capture.
  52751. */
  52752. export interface VideoRecorderOptions {
  52753. /** Defines the mime type of the video */
  52754. mimeType: string;
  52755. /** Defines the video the video should be recorded at */
  52756. fps: number;
  52757. /** Defines the chunk size for the recording data */
  52758. recordChunckSize: number;
  52759. }
  52760. /**
  52761. * This can helps recording videos from BabylonJS.
  52762. * This is based on the available WebRTC functionalities of the browser.
  52763. *
  52764. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  52765. */
  52766. export class VideoRecorder {
  52767. private static readonly _defaultOptions;
  52768. /**
  52769. * Returns wehther or not the VideoRecorder is available in your browser.
  52770. * @param engine Defines the Babylon Engine to check the support for
  52771. * @returns true if supported otherwise false
  52772. */
  52773. static IsSupported(engine: Engine): boolean;
  52774. private readonly _options;
  52775. private _canvas;
  52776. private _mediaRecorder;
  52777. private _recordedChunks;
  52778. private _fileName;
  52779. private _resolve;
  52780. private _reject;
  52781. /**
  52782. * True wether a recording is already in progress.
  52783. */
  52784. readonly isRecording: boolean;
  52785. /**
  52786. * Create a new VideoCapture object which can help converting what you see in Babylon to
  52787. * a video file.
  52788. * @param engine Defines the BabylonJS Engine you wish to record
  52789. * @param options Defines options that can be used to customized the capture
  52790. */
  52791. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  52792. /**
  52793. * Stops the current recording before the default capture timeout passed in the startRecording
  52794. * functions.
  52795. */
  52796. stopRecording(): void;
  52797. /**
  52798. * Starts recording the canvas for a max duration specified in parameters.
  52799. * @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.
  52800. * @param maxDuration Defines the maximum recording time in seconds.
  52801. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  52802. * @return a promise callback at the end of the recording with the video data in Blob.
  52803. */
  52804. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  52805. /**
  52806. * Releases internal resources used during the recording.
  52807. */
  52808. dispose(): void;
  52809. private _handleDataAvailable;
  52810. private _handleError;
  52811. private _handleStop;
  52812. }
  52813. }
  52814. declare module BABYLON {
  52815. /**
  52816. * Helper class to push actions to a pool of workers.
  52817. */
  52818. export class WorkerPool implements IDisposable {
  52819. private _workerInfos;
  52820. private _pendingActions;
  52821. /**
  52822. * Constructor
  52823. * @param workers Array of workers to use for actions
  52824. */
  52825. constructor(workers: Array<Worker>);
  52826. /**
  52827. * Terminates all workers and clears any pending actions.
  52828. */
  52829. dispose(): void;
  52830. /**
  52831. * Pushes an action to the worker pool. If all the workers are active, the action will be
  52832. * pended until a worker has completed its action.
  52833. * @param action The action to perform. Call onComplete when the action is complete.
  52834. */
  52835. push(action: (worker: Worker, onComplete: () => void) => void): void;
  52836. private _execute;
  52837. }
  52838. }
  52839. declare module BABYLON {
  52840. /**
  52841. * Class containing a set of static utilities functions for screenshots
  52842. */
  52843. export class ScreenshotTools {
  52844. /**
  52845. * Captures a screenshot of the current rendering
  52846. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  52847. * @param engine defines the rendering engine
  52848. * @param camera defines the source camera
  52849. * @param size This parameter can be set to a single number or to an object with the
  52850. * following (optional) properties: precision, width, height. If a single number is passed,
  52851. * it will be used for both width and height. If an object is passed, the screenshot size
  52852. * will be derived from the parameters. The precision property is a multiplier allowing
  52853. * rendering at a higher or lower resolution
  52854. * @param successCallback defines the callback receives a single parameter which contains the
  52855. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  52856. * src parameter of an <img> to display it
  52857. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  52858. * Check your browser for supported MIME types
  52859. */
  52860. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  52861. /**
  52862. * Generates an image screenshot from the specified camera.
  52863. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  52864. * @param engine The engine to use for rendering
  52865. * @param camera The camera to use for rendering
  52866. * @param size This parameter can be set to a single number or to an object with the
  52867. * following (optional) properties: precision, width, height. If a single number is passed,
  52868. * it will be used for both width and height. If an object is passed, the screenshot size
  52869. * will be derived from the parameters. The precision property is a multiplier allowing
  52870. * rendering at a higher or lower resolution
  52871. * @param successCallback The callback receives a single parameter which contains the
  52872. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  52873. * src parameter of an <img> to display it
  52874. * @param mimeType The MIME type of the screenshot image (default: image/png).
  52875. * Check your browser for supported MIME types
  52876. * @param samples Texture samples (default: 1)
  52877. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  52878. * @param fileName A name for for the downloaded file.
  52879. */
  52880. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  52881. }
  52882. }
  52883. declare module BABYLON {
  52884. /** @hidden */
  52885. export var blurPixelShader: {
  52886. name: string;
  52887. shader: string;
  52888. };
  52889. }
  52890. declare module BABYLON {
  52891. /** @hidden */
  52892. export var bones300Declaration: {
  52893. name: string;
  52894. shader: string;
  52895. };
  52896. }
  52897. declare module BABYLON {
  52898. /** @hidden */
  52899. export var instances300Declaration: {
  52900. name: string;
  52901. shader: string;
  52902. };
  52903. }
  52904. declare module BABYLON {
  52905. /** @hidden */
  52906. export var pointCloudVertexDeclaration: {
  52907. name: string;
  52908. shader: string;
  52909. };
  52910. }
  52911. // Mixins
  52912. interface Window {
  52913. mozIndexedDB: IDBFactory;
  52914. webkitIndexedDB: IDBFactory;
  52915. msIndexedDB: IDBFactory;
  52916. webkitURL: typeof URL;
  52917. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  52918. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  52919. WebGLRenderingContext: WebGLRenderingContext;
  52920. MSGesture: MSGesture;
  52921. CANNON: any;
  52922. AudioContext: AudioContext;
  52923. webkitAudioContext: AudioContext;
  52924. PointerEvent: any;
  52925. Math: Math;
  52926. Uint8Array: Uint8ArrayConstructor;
  52927. Float32Array: Float32ArrayConstructor;
  52928. mozURL: typeof URL;
  52929. msURL: typeof URL;
  52930. VRFrameData: any; // WebVR, from specs 1.1
  52931. DracoDecoderModule: any;
  52932. setImmediate(handler: (...args: any[]) => void): number;
  52933. }
  52934. interface Document {
  52935. mozCancelFullScreen(): void;
  52936. msCancelFullScreen(): void;
  52937. webkitCancelFullScreen(): void;
  52938. requestPointerLock(): void;
  52939. exitPointerLock(): void;
  52940. mozFullScreen: boolean;
  52941. msIsFullScreen: boolean;
  52942. readonly webkitIsFullScreen: boolean;
  52943. readonly pointerLockElement: Element;
  52944. mozPointerLockElement: HTMLElement;
  52945. msPointerLockElement: HTMLElement;
  52946. webkitPointerLockElement: HTMLElement;
  52947. }
  52948. interface HTMLCanvasElement {
  52949. requestPointerLock(): void;
  52950. msRequestPointerLock?(): void;
  52951. mozRequestPointerLock?(): void;
  52952. webkitRequestPointerLock?(): void;
  52953. /** Track wether a record is in progress */
  52954. isRecording: boolean;
  52955. /** Capture Stream method defined by some browsers */
  52956. captureStream(fps?: number): MediaStream;
  52957. }
  52958. interface CanvasRenderingContext2D {
  52959. msImageSmoothingEnabled: boolean;
  52960. }
  52961. interface MouseEvent {
  52962. mozMovementX: number;
  52963. mozMovementY: number;
  52964. webkitMovementX: number;
  52965. webkitMovementY: number;
  52966. msMovementX: number;
  52967. msMovementY: number;
  52968. }
  52969. interface Navigator {
  52970. mozGetVRDevices: (any: any) => any;
  52971. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  52972. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  52973. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  52974. webkitGetGamepads(): Gamepad[];
  52975. msGetGamepads(): Gamepad[];
  52976. webkitGamepads(): Gamepad[];
  52977. }
  52978. interface HTMLVideoElement {
  52979. mozSrcObject: any;
  52980. }
  52981. interface Math {
  52982. fround(x: number): number;
  52983. imul(a: number, b: number): number;
  52984. }
  52985. interface WebGLProgram {
  52986. context?: WebGLRenderingContext;
  52987. vertexShader?: WebGLShader;
  52988. fragmentShader?: WebGLShader;
  52989. isParallelCompiled: boolean;
  52990. onCompiled?: () => void;
  52991. }
  52992. interface WebGLRenderingContext {
  52993. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  52994. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  52995. vertexAttribDivisor(index: number, divisor: number): void;
  52996. createVertexArray(): any;
  52997. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  52998. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  52999. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  53000. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  53001. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  53002. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  53003. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  53004. // Queries
  53005. createQuery(): WebGLQuery;
  53006. deleteQuery(query: WebGLQuery): void;
  53007. beginQuery(target: number, query: WebGLQuery): void;
  53008. endQuery(target: number): void;
  53009. getQueryParameter(query: WebGLQuery, pname: number): any;
  53010. getQuery(target: number, pname: number): any;
  53011. MAX_SAMPLES: number;
  53012. RGBA8: number;
  53013. READ_FRAMEBUFFER: number;
  53014. DRAW_FRAMEBUFFER: number;
  53015. UNIFORM_BUFFER: number;
  53016. HALF_FLOAT_OES: number;
  53017. RGBA16F: number;
  53018. RGBA32F: number;
  53019. R32F: number;
  53020. RG32F: number;
  53021. RGB32F: number;
  53022. R16F: number;
  53023. RG16F: number;
  53024. RGB16F: number;
  53025. RED: number;
  53026. RG: number;
  53027. R8: number;
  53028. RG8: number;
  53029. UNSIGNED_INT_24_8: number;
  53030. DEPTH24_STENCIL8: number;
  53031. /* Multiple Render Targets */
  53032. drawBuffers(buffers: number[]): void;
  53033. readBuffer(src: number): void;
  53034. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  53035. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  53036. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  53037. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  53038. // Occlusion Query
  53039. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  53040. ANY_SAMPLES_PASSED: number;
  53041. QUERY_RESULT_AVAILABLE: number;
  53042. QUERY_RESULT: number;
  53043. }
  53044. interface WebGLBuffer {
  53045. references: number;
  53046. capacity: number;
  53047. is32Bits: boolean;
  53048. }
  53049. interface WebGLProgram {
  53050. transformFeedback?: WebGLTransformFeedback | null;
  53051. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  53052. }
  53053. interface EXT_disjoint_timer_query {
  53054. QUERY_COUNTER_BITS_EXT: number;
  53055. TIME_ELAPSED_EXT: number;
  53056. TIMESTAMP_EXT: number;
  53057. GPU_DISJOINT_EXT: number;
  53058. QUERY_RESULT_EXT: number;
  53059. QUERY_RESULT_AVAILABLE_EXT: number;
  53060. queryCounterEXT(query: WebGLQuery, target: number): void;
  53061. createQueryEXT(): WebGLQuery;
  53062. beginQueryEXT(target: number, query: WebGLQuery): void;
  53063. endQueryEXT(target: number): void;
  53064. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  53065. deleteQueryEXT(query: WebGLQuery): void;
  53066. }
  53067. interface WebGLUniformLocation {
  53068. _currentState: any;
  53069. }
  53070. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  53071. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  53072. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  53073. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  53074. interface WebGLRenderingContext {
  53075. readonly RASTERIZER_DISCARD: number;
  53076. readonly DEPTH_COMPONENT24: number;
  53077. readonly TEXTURE_3D: number;
  53078. readonly TEXTURE_2D_ARRAY: number;
  53079. readonly TEXTURE_COMPARE_FUNC: number;
  53080. readonly TEXTURE_COMPARE_MODE: number;
  53081. readonly COMPARE_REF_TO_TEXTURE: number;
  53082. readonly TEXTURE_WRAP_R: number;
  53083. readonly HALF_FLOAT: number;
  53084. readonly RGB8: number;
  53085. readonly RED_INTEGER: number;
  53086. readonly RG_INTEGER: number;
  53087. readonly RGB_INTEGER: number;
  53088. readonly RGBA_INTEGER: number;
  53089. readonly R8_SNORM: number;
  53090. readonly RG8_SNORM: number;
  53091. readonly RGB8_SNORM: number;
  53092. readonly RGBA8_SNORM: number;
  53093. readonly R8I: number;
  53094. readonly RG8I: number;
  53095. readonly RGB8I: number;
  53096. readonly RGBA8I: number;
  53097. readonly R8UI: number;
  53098. readonly RG8UI: number;
  53099. readonly RGB8UI: number;
  53100. readonly RGBA8UI: number;
  53101. readonly R16I: number;
  53102. readonly RG16I: number;
  53103. readonly RGB16I: number;
  53104. readonly RGBA16I: number;
  53105. readonly R16UI: number;
  53106. readonly RG16UI: number;
  53107. readonly RGB16UI: number;
  53108. readonly RGBA16UI: number;
  53109. readonly R32I: number;
  53110. readonly RG32I: number;
  53111. readonly RGB32I: number;
  53112. readonly RGBA32I: number;
  53113. readonly R32UI: number;
  53114. readonly RG32UI: number;
  53115. readonly RGB32UI: number;
  53116. readonly RGBA32UI: number;
  53117. readonly RGB10_A2UI: number;
  53118. readonly R11F_G11F_B10F: number;
  53119. readonly RGB9_E5: number;
  53120. readonly RGB10_A2: number;
  53121. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  53122. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  53123. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  53124. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  53125. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  53126. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  53127. 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;
  53128. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  53129. readonly TRANSFORM_FEEDBACK: number;
  53130. readonly INTERLEAVED_ATTRIBS: number;
  53131. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  53132. createTransformFeedback(): WebGLTransformFeedback;
  53133. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  53134. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  53135. beginTransformFeedback(primitiveMode: number): void;
  53136. endTransformFeedback(): void;
  53137. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  53138. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  53139. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  53140. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  53141. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  53142. }
  53143. interface ImageBitmap {
  53144. readonly width: number;
  53145. readonly height: number;
  53146. close(): void;
  53147. }
  53148. interface WebGLQuery extends WebGLObject {
  53149. }
  53150. declare var WebGLQuery: {
  53151. prototype: WebGLQuery;
  53152. new(): WebGLQuery;
  53153. };
  53154. interface WebGLSampler extends WebGLObject {
  53155. }
  53156. declare var WebGLSampler: {
  53157. prototype: WebGLSampler;
  53158. new(): WebGLSampler;
  53159. };
  53160. interface WebGLSync extends WebGLObject {
  53161. }
  53162. declare var WebGLSync: {
  53163. prototype: WebGLSync;
  53164. new(): WebGLSync;
  53165. };
  53166. interface WebGLTransformFeedback extends WebGLObject {
  53167. }
  53168. declare var WebGLTransformFeedback: {
  53169. prototype: WebGLTransformFeedback;
  53170. new(): WebGLTransformFeedback;
  53171. };
  53172. interface WebGLVertexArrayObject extends WebGLObject {
  53173. }
  53174. declare var WebGLVertexArrayObject: {
  53175. prototype: WebGLVertexArrayObject;
  53176. new(): WebGLVertexArrayObject;
  53177. };
  53178. // Type definitions for WebVR API
  53179. // Project: https://w3c.github.io/webvr/
  53180. // Definitions by: six a <https://github.com/lostfictions>
  53181. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  53182. interface VRDisplay extends EventTarget {
  53183. /**
  53184. * Dictionary of capabilities describing the VRDisplay.
  53185. */
  53186. readonly capabilities: VRDisplayCapabilities;
  53187. /**
  53188. * z-depth defining the far plane of the eye view frustum
  53189. * enables mapping of values in the render target depth
  53190. * attachment to scene coordinates. Initially set to 10000.0.
  53191. */
  53192. depthFar: number;
  53193. /**
  53194. * z-depth defining the near plane of the eye view frustum
  53195. * enables mapping of values in the render target depth
  53196. * attachment to scene coordinates. Initially set to 0.01.
  53197. */
  53198. depthNear: number;
  53199. /**
  53200. * An identifier for this distinct VRDisplay. Used as an
  53201. * association point in the Gamepad API.
  53202. */
  53203. readonly displayId: number;
  53204. /**
  53205. * A display name, a user-readable name identifying it.
  53206. */
  53207. readonly displayName: string;
  53208. readonly isConnected: boolean;
  53209. readonly isPresenting: boolean;
  53210. /**
  53211. * If this VRDisplay supports room-scale experiences, the optional
  53212. * stage attribute contains details on the room-scale parameters.
  53213. */
  53214. readonly stageParameters: VRStageParameters | null;
  53215. /**
  53216. * Passing the value returned by `requestAnimationFrame` to
  53217. * `cancelAnimationFrame` will unregister the callback.
  53218. * @param handle Define the hanle of the request to cancel
  53219. */
  53220. cancelAnimationFrame(handle: number): void;
  53221. /**
  53222. * Stops presenting to the VRDisplay.
  53223. * @returns a promise to know when it stopped
  53224. */
  53225. exitPresent(): Promise<void>;
  53226. /**
  53227. * Return the current VREyeParameters for the given eye.
  53228. * @param whichEye Define the eye we want the parameter for
  53229. * @returns the eye parameters
  53230. */
  53231. getEyeParameters(whichEye: string): VREyeParameters;
  53232. /**
  53233. * Populates the passed VRFrameData with the information required to render
  53234. * the current frame.
  53235. * @param frameData Define the data structure to populate
  53236. * @returns true if ok otherwise false
  53237. */
  53238. getFrameData(frameData: VRFrameData): boolean;
  53239. /**
  53240. * Get the layers currently being presented.
  53241. * @returns the list of VR layers
  53242. */
  53243. getLayers(): VRLayer[];
  53244. /**
  53245. * Return a VRPose containing the future predicted pose of the VRDisplay
  53246. * when the current frame will be presented. The value returned will not
  53247. * change until JavaScript has returned control to the browser.
  53248. *
  53249. * The VRPose will contain the position, orientation, velocity,
  53250. * and acceleration of each of these properties.
  53251. * @returns the pose object
  53252. */
  53253. getPose(): VRPose;
  53254. /**
  53255. * Return the current instantaneous pose of the VRDisplay, with no
  53256. * prediction applied.
  53257. * @returns the current instantaneous pose
  53258. */
  53259. getImmediatePose(): VRPose;
  53260. /**
  53261. * The callback passed to `requestAnimationFrame` will be called
  53262. * any time a new frame should be rendered. When the VRDisplay is
  53263. * presenting the callback will be called at the native refresh
  53264. * rate of the HMD. When not presenting this function acts
  53265. * identically to how window.requestAnimationFrame acts. Content should
  53266. * make no assumptions of frame rate or vsync behavior as the HMD runs
  53267. * asynchronously from other displays and at differing refresh rates.
  53268. * @param callback Define the eaction to run next frame
  53269. * @returns the request handle it
  53270. */
  53271. requestAnimationFrame(callback: FrameRequestCallback): number;
  53272. /**
  53273. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  53274. * Repeat calls while already presenting will update the VRLayers being displayed.
  53275. * @param layers Define the list of layer to present
  53276. * @returns a promise to know when the request has been fulfilled
  53277. */
  53278. requestPresent(layers: VRLayer[]): Promise<void>;
  53279. /**
  53280. * Reset the pose for this display, treating its current position and
  53281. * orientation as the "origin/zero" values. VRPose.position,
  53282. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  53283. * updated when calling resetPose(). This should be called in only
  53284. * sitting-space experiences.
  53285. */
  53286. resetPose(): void;
  53287. /**
  53288. * The VRLayer provided to the VRDisplay will be captured and presented
  53289. * in the HMD. Calling this function has the same effect on the source
  53290. * canvas as any other operation that uses its source image, and canvases
  53291. * created without preserveDrawingBuffer set to true will be cleared.
  53292. * @param pose Define the pose to submit
  53293. */
  53294. submitFrame(pose?: VRPose): void;
  53295. }
  53296. declare var VRDisplay: {
  53297. prototype: VRDisplay;
  53298. new(): VRDisplay;
  53299. };
  53300. interface VRLayer {
  53301. leftBounds?: number[] | Float32Array | null;
  53302. rightBounds?: number[] | Float32Array | null;
  53303. source?: HTMLCanvasElement | null;
  53304. }
  53305. interface VRDisplayCapabilities {
  53306. readonly canPresent: boolean;
  53307. readonly hasExternalDisplay: boolean;
  53308. readonly hasOrientation: boolean;
  53309. readonly hasPosition: boolean;
  53310. readonly maxLayers: number;
  53311. }
  53312. interface VREyeParameters {
  53313. /** @deprecated */
  53314. readonly fieldOfView: VRFieldOfView;
  53315. readonly offset: Float32Array;
  53316. readonly renderHeight: number;
  53317. readonly renderWidth: number;
  53318. }
  53319. interface VRFieldOfView {
  53320. readonly downDegrees: number;
  53321. readonly leftDegrees: number;
  53322. readonly rightDegrees: number;
  53323. readonly upDegrees: number;
  53324. }
  53325. interface VRFrameData {
  53326. readonly leftProjectionMatrix: Float32Array;
  53327. readonly leftViewMatrix: Float32Array;
  53328. readonly pose: VRPose;
  53329. readonly rightProjectionMatrix: Float32Array;
  53330. readonly rightViewMatrix: Float32Array;
  53331. readonly timestamp: number;
  53332. }
  53333. interface VRPose {
  53334. readonly angularAcceleration: Float32Array | null;
  53335. readonly angularVelocity: Float32Array | null;
  53336. readonly linearAcceleration: Float32Array | null;
  53337. readonly linearVelocity: Float32Array | null;
  53338. readonly orientation: Float32Array | null;
  53339. readonly position: Float32Array | null;
  53340. readonly timestamp: number;
  53341. }
  53342. interface VRStageParameters {
  53343. sittingToStandingTransform?: Float32Array;
  53344. sizeX?: number;
  53345. sizeY?: number;
  53346. }
  53347. interface Navigator {
  53348. getVRDisplays(): Promise<VRDisplay[]>;
  53349. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  53350. }
  53351. interface Window {
  53352. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  53353. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  53354. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  53355. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  53356. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  53357. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  53358. }
  53359. interface Gamepad {
  53360. readonly displayId: number;
  53361. }
  53362. interface XRDevice {
  53363. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  53364. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  53365. }
  53366. interface XRSession {
  53367. getInputSources(): Array<any>;
  53368. baseLayer: XRWebGLLayer;
  53369. requestFrameOfReference(type: string): Promise<void>;
  53370. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  53371. end(): Promise<void>;
  53372. requestAnimationFrame: Function;
  53373. addEventListener: Function;
  53374. }
  53375. interface XRSessionCreationOptions {
  53376. outputContext?: WebGLRenderingContext | null;
  53377. immersive?: boolean;
  53378. environmentIntegration?: boolean;
  53379. }
  53380. interface XRLayer {
  53381. getViewport: Function;
  53382. framebufferWidth: number;
  53383. framebufferHeight: number;
  53384. }
  53385. interface XRView {
  53386. projectionMatrix: Float32Array;
  53387. }
  53388. interface XRFrame {
  53389. getDevicePose: Function;
  53390. getInputPose: Function;
  53391. views: Array<XRView>;
  53392. baseLayer: XRLayer;
  53393. }
  53394. interface XRFrameOfReference {
  53395. }
  53396. interface XRWebGLLayer extends XRLayer {
  53397. framebuffer: WebGLFramebuffer;
  53398. }
  53399. declare var XRWebGLLayer: {
  53400. prototype: XRWebGLLayer;
  53401. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  53402. };